Explorar el Código

Cleaning up Ix-Async.

Bart De Smet hace 8 años
padre
commit
25888d7f63

+ 0 - 2
Ix.NET/Source/System.Interactive.Async/System/Linq/AsyncEnumerableEx.cs

@@ -17,8 +17,6 @@ namespace System.Linq
                 {
                     var tcs = new TaskCompletionSource<bool>();
 
-                    var stop = new Action(() => tcs.TrySetCanceled());
-
                     return await moveNext(tcs).ConfigureAwait(false);
                 },
                 current,

+ 1 - 0
Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs

@@ -109,6 +109,7 @@ namespace System.Linq
 
                                     continue; // loop
                                 }
+
                                 stopped = true;
                                 await enumerator.DisposeAsync().ConfigureAwait(false);
                                 enumerator = null;

+ 4 - 4
Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs

@@ -38,7 +38,7 @@ namespace System.Linq
             if (sources == null)
                 throw new ArgumentNullException(nameof(sources));
 
-            return sources.Catch_();
+            return CatchCore(sources);
         }
 
         public static IAsyncEnumerable<TSource> Catch<TSource>(params IAsyncEnumerable<TSource>[] sources)
@@ -46,7 +46,7 @@ namespace System.Linq
             if (sources == null)
                 throw new ArgumentNullException(nameof(sources));
 
-            return sources.Catch_();
+            return CatchCore(sources);
         }
 
         public static IAsyncEnumerable<TSource> Catch<TSource>(this IAsyncEnumerable<TSource> first, IAsyncEnumerable<TSource> second)
@@ -56,10 +56,10 @@ namespace System.Linq
             if (second == null)
                 throw new ArgumentNullException(nameof(second));
 
-            return new[] { first, second }.Catch_();
+            return CatchCore(new[] { first, second });
         }
 
-        private static IAsyncEnumerable<TSource> Catch_<TSource>(this IEnumerable<IAsyncEnumerable<TSource>> sources)
+        private static IAsyncEnumerable<TSource> CatchCore<TSource>(IEnumerable<IAsyncEnumerable<TSource>> sources)
         {
             return new CatchAsyncIterator<TSource>(sources);
         }

+ 13 - 3
Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs

@@ -18,7 +18,7 @@ namespace System.Linq
             if (keySelector == null)
                 throw new ArgumentNullException(nameof(keySelector));
 
-            return source.Distinct(keySelector, EqualityComparer<TKey>.Default);
+            return DistinctCore(source, keySelector, EqualityComparer<TKey>.Default);
         }
 
         public static IAsyncEnumerable<TSource> Distinct<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
@@ -30,7 +30,7 @@ namespace System.Linq
             if (comparer == null)
                 throw new ArgumentNullException(nameof(comparer));
 
-            return new DistinctAsyncIterator<TSource, TKey>(source, keySelector, comparer);
+            return DistinctCore(source, keySelector, comparer);
         }
 
         public static IAsyncEnumerable<TSource> Distinct<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector)
@@ -40,7 +40,7 @@ namespace System.Linq
             if (keySelector == null)
                 throw new ArgumentNullException(nameof(keySelector));
 
-            return source.Distinct(keySelector, EqualityComparer<TKey>.Default);
+            return DistinctCore(source, keySelector, EqualityComparer<TKey>.Default);
         }
 
         public static IAsyncEnumerable<TSource> Distinct<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector, IEqualityComparer<TKey> comparer)
@@ -52,6 +52,16 @@ namespace System.Linq
             if (comparer == null)
                 throw new ArgumentNullException(nameof(comparer));
 
+            return DistinctCore(source, keySelector, comparer);
+        }
+
+        private static IAsyncEnumerable<TSource> DistinctCore<TSource, TKey>(IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
+        {
+            return new DistinctAsyncIterator<TSource, TKey>(source, keySelector, comparer);
+        }
+
+        private static IAsyncEnumerable<TSource> DistinctCore<TSource, TKey>(IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector, IEqualityComparer<TKey> comparer)
+        {
             return new DistinctAsyncIteratorWithTask<TSource, TKey>(source, keySelector, comparer);
         }
 

+ 13 - 9
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 @@ namespace System.Linq
             if (source == null)
                 throw new ArgumentNullException(nameof(source));
 
-            return source.DistinctUntilChanged(EqualityComparer<TSource>.Default);
+            return DistinctUntilChangedCore(source, EqualityComparer<TSource>.Default);
         }
 
         public static IAsyncEnumerable<TSource> DistinctUntilChanged<TSource>(this IAsyncEnumerable<TSource> source, IEqualityComparer<TSource> comparer)
@@ -26,7 +25,7 @@ namespace System.Linq
             if (comparer == null)
                 throw new ArgumentNullException(nameof(comparer));
 
-            return new DistinctUntilChangedAsyncIterator<TSource>(source, comparer);
+            return DistinctUntilChangedCore(source, comparer);
         }
 
         public static IAsyncEnumerable<TSource> DistinctUntilChanged<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector)
@@ -36,7 +35,7 @@ namespace System.Linq
             if (keySelector == null)
                 throw new ArgumentNullException(nameof(keySelector));
 
-            return source.DistinctUntilChanged_(keySelector, EqualityComparer<TKey>.Default);
+            return DistinctUntilChangedCore(source, keySelector, EqualityComparer<TKey>.Default);
         }
 
         public static IAsyncEnumerable<TSource> DistinctUntilChanged<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
@@ -48,7 +47,7 @@ namespace System.Linq
             if (comparer == null)
                 throw new ArgumentNullException(nameof(comparer));
 
-            return source.DistinctUntilChanged_(keySelector, comparer);
+            return DistinctUntilChangedCore(source, keySelector, comparer);
         }
 
         public static IAsyncEnumerable<TSource> DistinctUntilChanged<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector)
@@ -58,7 +57,7 @@ namespace System.Linq
             if (keySelector == null)
                 throw new ArgumentNullException(nameof(keySelector));
 
-            return source.DistinctUntilChanged_(keySelector, EqualityComparer<TKey>.Default);
+            return DistinctUntilChangedCore(source, keySelector, EqualityComparer<TKey>.Default);
         }
 
         public static IAsyncEnumerable<TSource> DistinctUntilChanged<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector, IEqualityComparer<TKey> comparer)
@@ -70,15 +69,20 @@ namespace System.Linq
             if (comparer == null)
                 throw new ArgumentNullException(nameof(comparer));
 
-            return source.DistinctUntilChanged_(keySelector, comparer);
+            return DistinctUntilChangedCore(source, keySelector, comparer);
+        }
+
+        private static IAsyncEnumerable<TSource> DistinctUntilChangedCore<TSource>(IAsyncEnumerable<TSource> source, IEqualityComparer<TSource> comparer)
+        {
+            return new DistinctUntilChangedAsyncIterator<TSource>(source, comparer);
         }
 
-        private static IAsyncEnumerable<TSource> DistinctUntilChanged_<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
+        private static IAsyncEnumerable<TSource> DistinctUntilChangedCore<TSource, TKey>(IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
         {
             return new DistinctUntilChangedAsyncIterator<TSource, TKey>(source, keySelector, comparer);
         }
 
-        private static IAsyncEnumerable<TSource> DistinctUntilChanged_<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector, IEqualityComparer<TKey> comparer)
+        private static IAsyncEnumerable<TSource> DistinctUntilChangedCore<TSource, TKey>(IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector, IEqualityComparer<TKey> comparer)
         {
             return new DistinctUntilChangedAsyncIteratorWithTask<TSource, TKey>(source, keySelector, comparer);
         }

+ 11 - 11
Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs

@@ -17,7 +17,7 @@ namespace System.Linq
             if (onNext == null)
                 throw new ArgumentNullException(nameof(onNext));
 
-            return DoHelper(source, onNext, null, null);
+            return DoCore(source, onNext: onNext, onError: null, onCompleted: null);
         }
 
         public static IAsyncEnumerable<TSource> Do<TSource>(this IAsyncEnumerable<TSource> source, Action<TSource> onNext, Action onCompleted)
@@ -29,7 +29,7 @@ namespace System.Linq
             if (onCompleted == null)
                 throw new ArgumentNullException(nameof(onCompleted));
 
-            return DoHelper(source, onNext, null, onCompleted);
+            return DoCore(source, onNext: onNext, onError: null, onCompleted: onCompleted);
         }
 
         public static IAsyncEnumerable<TSource> Do<TSource>(this IAsyncEnumerable<TSource> source, Action<TSource> onNext, Action<Exception> onError)
@@ -41,7 +41,7 @@ namespace System.Linq
             if (onError == null)
                 throw new ArgumentNullException(nameof(onError));
 
-            return DoHelper(source, onNext, onError, null);
+            return DoCore(source, onNext: onNext, onError: onError, onCompleted: null);
         }
 
         public static IAsyncEnumerable<TSource> Do<TSource>(this IAsyncEnumerable<TSource> source, Action<TSource> onNext, Action<Exception> onError, Action onCompleted)
@@ -55,7 +55,7 @@ namespace System.Linq
             if (onCompleted == null)
                 throw new ArgumentNullException(nameof(onCompleted));
 
-            return DoHelper(source, onNext, onError, onCompleted);
+            return DoCore(source, onNext, onError, onCompleted);
         }
 
         public static IAsyncEnumerable<TSource> Do<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task> onNext)
@@ -65,7 +65,7 @@ namespace System.Linq
             if (onNext == null)
                 throw new ArgumentNullException(nameof(onNext));
 
-            return DoHelper(source, onNext, null, null);
+            return DoCore(source, onNext: onNext, onError: null, onCompleted: null);
         }
 
         public static IAsyncEnumerable<TSource> Do<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task> onNext, Func<Task> onCompleted)
@@ -77,7 +77,7 @@ namespace System.Linq
             if (onCompleted == null)
                 throw new ArgumentNullException(nameof(onCompleted));
 
-            return DoHelper(source, onNext, null, onCompleted);
+            return DoCore(source, onNext: onNext, onError: null, onCompleted: onCompleted);
         }
 
         public static IAsyncEnumerable<TSource> Do<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task> onNext, Func<Exception, Task> onError)
@@ -89,7 +89,7 @@ namespace System.Linq
             if (onError == null)
                 throw new ArgumentNullException(nameof(onError));
 
-            return DoHelper(source, onNext, onError, null);
+            return DoCore(source, onNext: onNext, onError: onError, onCompleted: null);
         }
 
         public static IAsyncEnumerable<TSource> Do<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task> onNext, Func<Exception, Task> onError, Func<Task> onCompleted)
@@ -103,7 +103,7 @@ namespace System.Linq
             if (onCompleted == null)
                 throw new ArgumentNullException(nameof(onCompleted));
 
-            return DoHelper(source, onNext, onError, onCompleted);
+            return DoCore(source, onNext, onError, onCompleted);
         }
 
         public static IAsyncEnumerable<TSource> Do<TSource>(this IAsyncEnumerable<TSource> source, IObserver<TSource> observer)
@@ -113,15 +113,15 @@ namespace System.Linq
             if (observer == null)
                 throw new ArgumentNullException(nameof(observer));
 
-            return DoHelper(source, new Action<TSource>(observer.OnNext), new Action<Exception>(observer.OnError), new Action(observer.OnCompleted));
+            return DoCore(source, new Action<TSource>(observer.OnNext), new Action<Exception>(observer.OnError), new Action(observer.OnCompleted));
         }
 
-        private static IAsyncEnumerable<TSource> DoHelper<TSource>(this IAsyncEnumerable<TSource> source, Action<TSource> onNext, Action<Exception> onError, Action onCompleted)
+        private static IAsyncEnumerable<TSource> DoCore<TSource>(IAsyncEnumerable<TSource> source, Action<TSource> onNext, Action<Exception> onError, Action onCompleted)
         {
             return new DoAsyncIterator<TSource>(source, onNext, onError, onCompleted);
         }
 
-        private static IAsyncEnumerable<TSource> DoHelper<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task> onNext, Func<Exception, Task> onError, Func<Task> onCompleted)
+        private static IAsyncEnumerable<TSource> DoCore<TSource>(IAsyncEnumerable<TSource> source, Func<TSource, Task> onNext, Func<Exception, Task> onError, Func<Task> onCompleted)
         {
             return new DoAsyncIteratorWithTask<TSource>(source, onNext, onError, onCompleted);
         }

+ 0 - 1
Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs

@@ -58,7 +58,6 @@ namespace System.Linq
                     case AsyncIteratorState.Iterating:
                         while (await enumerator.MoveNextAsync().ConfigureAwait(false))
                         {
-                            // Do nothing, we're ignoring these elements
                         }
 
                         break; // case

+ 3 - 3
Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs

@@ -15,7 +15,7 @@ namespace System.Linq
             if (source == null)
                 throw new ArgumentNullException(nameof(source));
 
-            return source.IsEmpty(CancellationToken.None);
+            return IsEmptyCore(source, CancellationToken.None);
         }
 
         public static Task<bool> IsEmpty<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
@@ -23,10 +23,10 @@ namespace System.Linq
             if (source == null)
                 throw new ArgumentNullException(nameof(source));
 
-            return IsEmpty_(source, cancellationToken);
+            return IsEmptyCore(source, cancellationToken);
         }
 
-        private static async Task<bool> IsEmpty_<TSource>(IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
+        private static async Task<bool> IsEmptyCore<TSource>(IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
         {
             return !await source.Any(cancellationToken).ConfigureAwait(false);
         }

+ 3 - 3
Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs

@@ -17,7 +17,7 @@ namespace System.Linq
             if (comparer == null)
                 throw new ArgumentNullException(nameof(comparer));
 
-            return source.Max(comparer, CancellationToken.None);
+            return MaxCore(source, comparer, CancellationToken.None);
         }
 
         public static Task<TSource> Max<TSource>(this IAsyncEnumerable<TSource> source, IComparer<TSource> comparer, CancellationToken cancellationToken)
@@ -27,10 +27,10 @@ namespace System.Linq
             if (comparer == null)
                 throw new ArgumentNullException(nameof(comparer));
 
-            return Max_(source, comparer, cancellationToken);
+            return MaxCore(source, comparer, cancellationToken);
         }
 
-        private static async Task<TSource> Max_<TSource>(IAsyncEnumerable<TSource> source, IComparer<TSource> comparer, CancellationToken cancellationToken)
+        private static async Task<TSource> MaxCore<TSource>(IAsyncEnumerable<TSource> source, IComparer<TSource> comparer, CancellationToken cancellationToken)
         {
             var e = source.GetAsyncEnumerator();
 

+ 17 - 7
Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs

@@ -17,7 +17,7 @@ namespace System.Linq
             if (keySelector == null)
                 throw new ArgumentNullException(nameof(keySelector));
 
-            return source.MaxBy(keySelector, CancellationToken.None);
+            return MaxByCore(source, keySelector, Comparer<TKey>.Default, CancellationToken.None);
         }
 
         public static Task<IList<TSource>> MaxBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, CancellationToken cancellationToken)
@@ -27,7 +27,7 @@ namespace System.Linq
             if (keySelector == null)
                 throw new ArgumentNullException(nameof(keySelector));
 
-            return MaxBy(source, keySelector, Comparer<TKey>.Default, cancellationToken);
+            return MaxByCore(source, keySelector, Comparer<TKey>.Default, cancellationToken);
         }
 
         public static Task<IList<TSource>> MaxBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
@@ -39,7 +39,7 @@ namespace System.Linq
             if (comparer == null)
                 throw new ArgumentNullException(nameof(comparer));
 
-            return source.MaxBy(keySelector, comparer, CancellationToken.None);
+            return MaxByCore(source, keySelector, comparer, CancellationToken.None);
         }
 
         public static Task<IList<TSource>> MaxBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer, CancellationToken cancellationToken)
@@ -51,7 +51,7 @@ namespace System.Linq
             if (comparer == null)
                 throw new ArgumentNullException(nameof(comparer));
 
-            return ExtremaBy(source, keySelector, (key, minValue) => comparer.Compare(key, minValue), cancellationToken);
+            return MaxByCore(source, keySelector, comparer, cancellationToken);
         }
 
         public static Task<IList<TSource>> MaxBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector)
@@ -61,7 +61,7 @@ namespace System.Linq
             if (keySelector == null)
                 throw new ArgumentNullException(nameof(keySelector));
 
-            return source.MaxBy(keySelector, CancellationToken.None);
+            return MaxByCore(source, keySelector, Comparer<TKey>.Default, CancellationToken.None);
         }
 
         public static Task<IList<TSource>> MaxBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector, CancellationToken cancellationToken)
@@ -71,7 +71,7 @@ namespace System.Linq
             if (keySelector == null)
                 throw new ArgumentNullException(nameof(keySelector));
 
-            return MaxBy(source, keySelector, Comparer<TKey>.Default, cancellationToken);
+            return MaxByCore(source, keySelector, Comparer<TKey>.Default, cancellationToken);
         }
 
         public static Task<IList<TSource>> MaxBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector, IComparer<TKey> comparer)
@@ -83,7 +83,7 @@ namespace System.Linq
             if (comparer == null)
                 throw new ArgumentNullException(nameof(comparer));
 
-            return source.MaxBy(keySelector, comparer, CancellationToken.None);
+            return MaxByCore(source, keySelector, comparer, CancellationToken.None);
         }
 
         public static Task<IList<TSource>> MaxBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector, IComparer<TKey> comparer, CancellationToken cancellationToken)
@@ -95,6 +95,16 @@ namespace System.Linq
             if (comparer == null)
                 throw new ArgumentNullException(nameof(comparer));
 
+            return MaxByCore(source, keySelector, comparer, cancellationToken);
+        }
+
+        private static Task<IList<TSource>> MaxByCore<TSource, TKey>(IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer, CancellationToken cancellationToken)
+        {
+            return ExtremaBy(source, keySelector, (key, minValue) => comparer.Compare(key, minValue), cancellationToken);
+        }
+
+        private static Task<IList<TSource>> MaxByCore<TSource, TKey>(IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector, IComparer<TKey> comparer, CancellationToken cancellationToken)
+        {
             return ExtremaBy(source, keySelector, (key, minValue) => comparer.Compare(key, minValue), cancellationToken);
         }
     }

+ 3 - 3
Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs

@@ -17,7 +17,7 @@ namespace System.Linq
             if (comparer == null)
                 throw new ArgumentNullException(nameof(comparer));
 
-            return source.Min(comparer, CancellationToken.None);
+            return MinCore(source, comparer, CancellationToken.None);
         }
 
         public static Task<TSource> Min<TSource>(this IAsyncEnumerable<TSource> source, IComparer<TSource> comparer, CancellationToken cancellationToken)
@@ -27,10 +27,10 @@ namespace System.Linq
             if (comparer == null)
                 throw new ArgumentNullException(nameof(comparer));
 
-            return Min_(source, comparer, cancellationToken);
+            return MinCore(source, comparer, cancellationToken);
         }
 
-        private static async Task<TSource> Min_<TSource>(IAsyncEnumerable<TSource> source, IComparer<TSource> comparer, CancellationToken cancellationToken)
+        private static async Task<TSource> MinCore<TSource>(IAsyncEnumerable<TSource> source, IComparer<TSource> comparer, CancellationToken cancellationToken)
         {
             var e = source.GetAsyncEnumerator();
 

+ 17 - 7
Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs

@@ -17,7 +17,7 @@ namespace System.Linq
             if (keySelector == null)
                 throw new ArgumentNullException(nameof(keySelector));
 
-            return source.MinBy(keySelector, CancellationToken.None);
+            return MinByCore(source, keySelector, Comparer<TKey>.Default, CancellationToken.None);
         }
 
         public static Task<IList<TSource>> MinBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, CancellationToken cancellationToken)
@@ -27,7 +27,7 @@ namespace System.Linq
             if (keySelector == null)
                 throw new ArgumentNullException(nameof(keySelector));
 
-            return MinBy(source, keySelector, Comparer<TKey>.Default, cancellationToken);
+            return MinByCore(source, keySelector, Comparer<TKey>.Default, cancellationToken);
         }
 
         public static Task<IList<TSource>> MinBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
@@ -39,7 +39,7 @@ namespace System.Linq
             if (comparer == null)
                 throw new ArgumentNullException(nameof(comparer));
 
-            return source.MinBy(keySelector, comparer, CancellationToken.None);
+            return MinByCore(source, keySelector, comparer, CancellationToken.None);
         }
 
         public static Task<IList<TSource>> MinBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer, CancellationToken cancellationToken)
@@ -51,7 +51,7 @@ namespace System.Linq
             if (comparer == null)
                 throw new ArgumentNullException(nameof(comparer));
 
-            return ExtremaBy(source, keySelector, (key, minValue) => -comparer.Compare(key, minValue), cancellationToken);
+            return MinByCore(source, keySelector, comparer, cancellationToken);
         }
 
         public static Task<IList<TSource>> MinBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector)
@@ -61,7 +61,7 @@ namespace System.Linq
             if (keySelector == null)
                 throw new ArgumentNullException(nameof(keySelector));
 
-            return source.MinBy(keySelector, CancellationToken.None);
+            return MinByCore(source, keySelector, Comparer<TKey>.Default, CancellationToken.None);
         }
 
         public static Task<IList<TSource>> MinBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector, CancellationToken cancellationToken)
@@ -71,7 +71,7 @@ namespace System.Linq
             if (keySelector == null)
                 throw new ArgumentNullException(nameof(keySelector));
 
-            return MinBy(source, keySelector, Comparer<TKey>.Default, cancellationToken);
+            return MinByCore(source, keySelector, Comparer<TKey>.Default, cancellationToken);
         }
 
         public static Task<IList<TSource>> MinBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector, IComparer<TKey> comparer)
@@ -83,7 +83,7 @@ namespace System.Linq
             if (comparer == null)
                 throw new ArgumentNullException(nameof(comparer));
 
-            return source.MinBy(keySelector, comparer, CancellationToken.None);
+            return MinByCore(source, keySelector, comparer, CancellationToken.None);
         }
 
         public static Task<IList<TSource>> MinBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector, IComparer<TKey> comparer, CancellationToken cancellationToken)
@@ -95,6 +95,16 @@ namespace System.Linq
             if (comparer == null)
                 throw new ArgumentNullException(nameof(comparer));
 
+            return MinByCore(source, keySelector, comparer, cancellationToken);
+        }
+
+        private static Task<IList<TSource>> MinByCore<TSource, TKey>(IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer, CancellationToken cancellationToken)
+        {
+            return ExtremaBy(source, keySelector, (key, minValue) => -comparer.Compare(key, minValue), cancellationToken);
+        }
+
+        private static Task<IList<TSource>> MinByCore<TSource, TKey>(IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector, IComparer<TKey> comparer, CancellationToken cancellationToken)
+        {
             return ExtremaBy(source, keySelector, (key, minValue) => -comparer.Compare(key, minValue), cancellationToken);
         }
 

+ 1 - 2
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 @@ namespace System.Linq
     {
         public static IAsyncEnumerable<TValue> Never<TValue>()
         {
-            return CreateEnumerable(() => CreateEnumerator<TValue>(tcs => tcs.Task, current: null, dispose: null));
+            return AsyncEnumerable.CreateEnumerable(() => CreateEnumerator<TValue>(tcs => tcs.Task, current: null, dispose: null));
         }
     }
 }

+ 4 - 4
Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/OnErrorResumeNext.cs

@@ -17,7 +17,7 @@ namespace System.Linq
             if (second == null)
                 throw new ArgumentNullException(nameof(second));
 
-            return OnErrorResumeNext_(new[] { first, second });
+            return OnErrorResumeNextCore(new[] { first, second });
         }
 
         public static IAsyncEnumerable<TSource> OnErrorResumeNext<TSource>(params IAsyncEnumerable<TSource>[] sources)
@@ -25,7 +25,7 @@ namespace System.Linq
             if (sources == null)
                 throw new ArgumentNullException(nameof(sources));
 
-            return OnErrorResumeNext_(sources);
+            return OnErrorResumeNextCore(sources);
         }
 
         public static IAsyncEnumerable<TSource> OnErrorResumeNext<TSource>(this IEnumerable<IAsyncEnumerable<TSource>> sources)
@@ -33,10 +33,10 @@ namespace System.Linq
             if (sources == null)
                 throw new ArgumentNullException(nameof(sources));
 
-            return OnErrorResumeNext_(sources);
+            return OnErrorResumeNextCore(sources);
         }
 
-        private static IAsyncEnumerable<TSource> OnErrorResumeNext_<TSource>(IEnumerable<IAsyncEnumerable<TSource>> sources)
+        private static IAsyncEnumerable<TSource> OnErrorResumeNextCore<TSource>(IEnumerable<IAsyncEnumerable<TSource>> sources)
         {
             return new OnErrorResumeNextAsyncIterator<TSource>(sources);
         }

+ 8 - 0
Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Retry.cs

@@ -29,15 +29,23 @@ namespace System.Linq
         private static IEnumerable<TSource> Repeat<TSource>(this IEnumerable<TSource> source)
         {
             while (true)
+            {
                 foreach (var item in source)
+                {
                     yield return item;
+                }
+            }
         }
 
         private static IEnumerable<TSource> Repeat<TSource>(this IEnumerable<TSource> source, int count)
         {
             for (var i = 0; i < count; i++)
+            {
                 foreach (var item in source)
+                {
                     yield return item;
+                }
+            }
         }
     }
 }