瀏覽代碼

Generating Min and Max.

Bart De Smet 8 年之前
父節點
當前提交
807fdf34d8

+ 0 - 387
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 @@ namespace System.Linq
             return Max_(source, comparer, cancellationToken);
         }
 
-        public static Task<int> Max(this IAsyncEnumerable<int> source)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return Max(source, CancellationToken.None);
-        }
-
-        public static Task<long> Max(this IAsyncEnumerable<long> source)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return Max(source, CancellationToken.None);
-        }
-
-        public static Task<double> Max(this IAsyncEnumerable<double> source)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return Max(source, CancellationToken.None);
-        }
-
-        public static Task<float> Max(this IAsyncEnumerable<float> source)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return Max(source, CancellationToken.None);
-        }
-
-
-        public static Task<int> Max(this IAsyncEnumerable<int> source, CancellationToken cancellationToken)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return source.Aggregate(Math.Max, cancellationToken);
-        }
-
-        public static Task<long> Max(this IAsyncEnumerable<long> source, CancellationToken cancellationToken)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return source.Aggregate(Math.Max, cancellationToken);
-        }
-
-        public static Task<double> Max(this IAsyncEnumerable<double> source, CancellationToken cancellationToken)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return source.Aggregate(Math.Max, cancellationToken);
-        }
-
-        public static Task<float> Max(this IAsyncEnumerable<float> source, CancellationToken cancellationToken)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return source.Aggregate(Math.Max, cancellationToken);
-        }
-
-        public static Task<decimal> Max(this IAsyncEnumerable<decimal> source, CancellationToken cancellationToken)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return source.Aggregate(Math.Max, cancellationToken);
-        }
-
-        public static Task<int?> Max(this IAsyncEnumerable<int?> source, CancellationToken cancellationToken)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return source.Aggregate(default(int?), NullableMax, cancellationToken);
-        }
-
-        public static Task<long?> Max(this IAsyncEnumerable<long?> source, CancellationToken cancellationToken)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return source.Aggregate(default(long?), NullableMax, cancellationToken);
-        }
-
-        public static Task<double?> Max(this IAsyncEnumerable<double?> source, CancellationToken cancellationToken)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return source.Aggregate(default(double?), NullableMax, cancellationToken);
-        }
-
-        public static Task<float?> Max(this IAsyncEnumerable<float?> source, CancellationToken cancellationToken)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return source.Aggregate(default(float?), NullableMax, cancellationToken);
-        }
-
-        public static Task<decimal?> Max(this IAsyncEnumerable<decimal?> source, CancellationToken cancellationToken)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return source.Aggregate(default(decimal?), NullableMax, cancellationToken);
-        }
-
         public static Task<TSource> Max<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
         {
             if (source == null)
@@ -144,116 +29,6 @@ namespace System.Linq
             return source.Aggregate((x, y) => comparer.Compare(x, y) >= 0 ? x : y, cancellationToken);
         }
 
-        public static Task<int> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int> 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<long> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long> 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<double> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double> 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<float> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float> 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<decimal> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal> 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<int?> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int?> 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<long?> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long?> 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<double?> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double?> 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<float?> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float?> 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<decimal?> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal?> 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<TResult> Max<TSource, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, TResult> selector, CancellationToken cancellationToken)
         {
             if (source == null)
@@ -265,55 +40,6 @@ namespace System.Linq
                          .Max(cancellationToken);
         }
 
-
-        public static Task<decimal> Max(this IAsyncEnumerable<decimal> source)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return Max(source, CancellationToken.None);
-        }
-
-        public static Task<int?> Max(this IAsyncEnumerable<int?> source)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return Max(source, CancellationToken.None);
-        }
-
-        public static Task<long?> Max(this IAsyncEnumerable<long?> source)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return Max(source, CancellationToken.None);
-        }
-
-        public static Task<double?> Max(this IAsyncEnumerable<double?> source)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return Max(source, CancellationToken.None);
-        }
-
-        public static Task<float?> Max(this IAsyncEnumerable<float?> source)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return Max(source, CancellationToken.None);
-        }
-
-        public static Task<decimal?> Max(this IAsyncEnumerable<decimal?> source)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return Max(source, CancellationToken.None);
-        }
-
         public static Task<TSource> Max<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
@@ -322,106 +48,6 @@ namespace System.Linq
             return Max(source, CancellationToken.None);
         }
 
-        public static Task<int> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int> 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<long> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long> 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<double> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double> 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<float> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float> 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<decimal> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal> 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<int?> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int?> 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<long?> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long?> 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<double?> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double?> 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<float?> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float?> 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<decimal?> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal?> 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<TResult> Max<TSource, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, TResult> selector)
         {
             if (source == null)
@@ -432,7 +58,6 @@ namespace System.Linq
             return Max(source, selector, CancellationToken.None);
         }
 
-
         public static Task<TSource> Max<TSource>(this IAsyncEnumerable<TSource> source, IComparer<TSource> comparer)
         {
             if (source == null)
@@ -492,17 +117,5 @@ namespace System.Linq
             return (await MaxBy(source, x => x, comparer, cancellationToken)
                         .ConfigureAwait(false)).First();
         }
-
-        private static T? NullableMax<T>(T? x, T? y)
-            where T : struct, IComparable<T>
-        {
-            if (!x.HasValue)
-                return y;
-            if (!y.HasValue)
-                return x;
-            if (x.Value.CompareTo(y.Value) >= 0)
-                return x;
-            return y;
-        }
     }
 }

+ 0 - 388
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<decimal?> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal?> 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<TResult> Min<TSource, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, TResult> selector)
         {
             if (source == null)
@@ -42,87 +30,6 @@ namespace System.Linq
             return Min_(source, comparer, cancellationToken);
         }
 
-
-        public static Task<int> Min(this IAsyncEnumerable<int> source)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return Min(source, CancellationToken.None);
-        }
-
-        public static Task<long> Min(this IAsyncEnumerable<long> source)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return Min(source, CancellationToken.None);
-        }
-
-        public static Task<double> Min(this IAsyncEnumerable<double> source)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return Min(source, CancellationToken.None);
-        }
-
-        public static Task<float> Min(this IAsyncEnumerable<float> source)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return Min(source, CancellationToken.None);
-        }
-
-        public static Task<decimal> Min(this IAsyncEnumerable<decimal> source)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return Min(source, CancellationToken.None);
-        }
-
-        public static Task<int?> Min(this IAsyncEnumerable<int?> source)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return Min(source, CancellationToken.None);
-        }
-
-        public static Task<long?> Min(this IAsyncEnumerable<long?> source)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return Min(source, CancellationToken.None);
-        }
-
-        public static Task<double?> Min(this IAsyncEnumerable<double?> source)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return Min(source, CancellationToken.None);
-        }
-
-        public static Task<float?> Min(this IAsyncEnumerable<float?> source)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return Min(source, CancellationToken.None);
-        }
-
-        public static Task<decimal?> Min(this IAsyncEnumerable<decimal?> source)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return Min(source, CancellationToken.None);
-        }
-
         public static Task<TSource> Min<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
@@ -131,167 +38,6 @@ namespace System.Linq
             return Min(source, CancellationToken.None);
         }
 
-        public static Task<int> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int> 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<long> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long> 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<double> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double> 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<float> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float> 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<decimal> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal> 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<int?> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int?> 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<long?> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long?> 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<double?> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double?> 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<int> Min(this IAsyncEnumerable<int> source, CancellationToken cancellationToken)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return source.Aggregate(Math.Min, cancellationToken);
-        }
-
-        public static Task<long> Min(this IAsyncEnumerable<long> source, CancellationToken cancellationToken)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return source.Aggregate(Math.Min, cancellationToken);
-        }
-
-        public static Task<double> Min(this IAsyncEnumerable<double> source, CancellationToken cancellationToken)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return source.Aggregate(Math.Min, cancellationToken);
-        }
-
-        public static Task<float> Min(this IAsyncEnumerable<float> source, CancellationToken cancellationToken)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return source.Aggregate(Math.Min, cancellationToken);
-        }
-
-        public static Task<decimal> Min(this IAsyncEnumerable<decimal> source, CancellationToken cancellationToken)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return source.Aggregate(Math.Min, cancellationToken);
-        }
-
-        public static Task<int?> Min(this IAsyncEnumerable<int?> source, CancellationToken cancellationToken)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return source.Aggregate(default(int?), NullableMin, cancellationToken);
-        }
-
-        public static Task<long?> Min(this IAsyncEnumerable<long?> source, CancellationToken cancellationToken)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return source.Aggregate(default(long?), NullableMin, cancellationToken);
-        }
-
-        public static Task<double?> Min(this IAsyncEnumerable<double?> source, CancellationToken cancellationToken)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return source.Aggregate(default(double?), NullableMin, cancellationToken);
-        }
-
-        public static Task<float?> Min(this IAsyncEnumerable<float?> source, CancellationToken cancellationToken)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return source.Aggregate(default(float?), NullableMin, cancellationToken);
-        }
-
-        public static Task<decimal?> Min(this IAsyncEnumerable<decimal?> source, CancellationToken cancellationToken)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return source.Aggregate(default(decimal?), NullableMin, cancellationToken);
-        }
-
         public static Task<TSource> Min<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
         {
             if (source == null)
@@ -301,106 +47,6 @@ namespace System.Linq
             return source.Aggregate((x, y) => comparer.Compare(x, y) <= 0 ? x : y, cancellationToken);
         }
 
-        public static Task<int> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int> 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<long> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long> 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<double> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double> 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<float> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float> 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<decimal> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal> 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<int?> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int?> 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<long?> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long?> 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<double?> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double?> 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<float?> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float?> 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<TSource> Min<TSource>(this IAsyncEnumerable<TSource> source, IComparer<TSource> comparer)
         {
             if (source == null)
@@ -411,17 +57,6 @@ namespace System.Linq
             return source.Min(comparer, CancellationToken.None);
         }
 
-        public static Task<decimal?> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal?> 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<TResult> Min<TSource, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, TResult> selector, CancellationToken cancellationToken)
         {
             if (source == null)
@@ -433,17 +68,6 @@ namespace System.Linq
                          .Min(cancellationToken);
         }
 
-
-        public static Task<float?> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float?> 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<IList<TSource>> MinBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector)
         {
             if (source == null)
@@ -539,17 +163,5 @@ namespace System.Linq
             return (await MinBy(source, x => x, comparer, cancellationToken)
                         .ConfigureAwait(false)).First();
         }
-
-        private static T? NullableMin<T>(T? x, T? y)
-            where T : struct, IComparable<T>
-        {
-            if (!x.HasValue)
-                return y;
-            if (!y.HasValue)
-                return x;
-            if (x.Value.CompareTo(y.Value) <= 0)
-                return x;
-            return y;
-        }
     }
 }

+ 757 - 0
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<int> Max(this IAsyncEnumerable<int> source)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            return source.Aggregate(Math.Max, CancellationToken.None);
+        }
+
+        public static Task<int> Max(this IAsyncEnumerable<int> source, CancellationToken cancellationToken)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            return source.Aggregate(Math.Max, cancellationToken);
+        }
+
+        public static Task<int> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int> 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<int> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int> 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<long> Max(this IAsyncEnumerable<long> source)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            return source.Aggregate(Math.Max, CancellationToken.None);
+        }
+
+        public static Task<long> Max(this IAsyncEnumerable<long> source, CancellationToken cancellationToken)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            return source.Aggregate(Math.Max, cancellationToken);
+        }
+
+        public static Task<long> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long> 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<long> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long> 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<float> Max(this IAsyncEnumerable<float> source)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            return source.Aggregate(Math.Max, CancellationToken.None);
+        }
+
+        public static Task<float> Max(this IAsyncEnumerable<float> source, CancellationToken cancellationToken)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            return source.Aggregate(Math.Max, cancellationToken);
+        }
+
+        public static Task<float> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float> 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<float> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float> 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<double> Max(this IAsyncEnumerable<double> source)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            return source.Aggregate(Math.Max, CancellationToken.None);
+        }
+
+        public static Task<double> Max(this IAsyncEnumerable<double> source, CancellationToken cancellationToken)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            return source.Aggregate(Math.Max, cancellationToken);
+        }
+
+        public static Task<double> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double> 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<double> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double> 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<decimal> Max(this IAsyncEnumerable<decimal> source)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            return source.Aggregate(Math.Max, CancellationToken.None);
+        }
+
+        public static Task<decimal> Max(this IAsyncEnumerable<decimal> source, CancellationToken cancellationToken)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            return source.Aggregate(Math.Max, cancellationToken);
+        }
+
+        public static Task<decimal> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal> 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<decimal> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal> 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<int?> Max(this IAsyncEnumerable<int?> source)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            return source.Aggregate(default(int?), NullableMax, CancellationToken.None);
+        }
+
+        public static Task<int?> Max(this IAsyncEnumerable<int?> source, CancellationToken cancellationToken)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            return source.Aggregate(default(int?), NullableMax, cancellationToken);
+        }
+
+        public static Task<int?> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int?> 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<int?> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int?> 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<long?> Max(this IAsyncEnumerable<long?> source)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            return source.Aggregate(default(long?), NullableMax, CancellationToken.None);
+        }
+
+        public static Task<long?> Max(this IAsyncEnumerable<long?> source, CancellationToken cancellationToken)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            return source.Aggregate(default(long?), NullableMax, cancellationToken);
+        }
+
+        public static Task<long?> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long?> 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<long?> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long?> 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<float?> Max(this IAsyncEnumerable<float?> source)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            return source.Aggregate(default(float?), NullableMax, CancellationToken.None);
+        }
+
+        public static Task<float?> Max(this IAsyncEnumerable<float?> source, CancellationToken cancellationToken)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            return source.Aggregate(default(float?), NullableMax, cancellationToken);
+        }
+
+        public static Task<float?> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float?> 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<float?> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float?> 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<double?> Max(this IAsyncEnumerable<double?> source)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            return source.Aggregate(default(double?), NullableMax, CancellationToken.None);
+        }
+
+        public static Task<double?> Max(this IAsyncEnumerable<double?> source, CancellationToken cancellationToken)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            return source.Aggregate(default(double?), NullableMax, cancellationToken);
+        }
+
+        public static Task<double?> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double?> 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<double?> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double?> 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<decimal?> Max(this IAsyncEnumerable<decimal?> source)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            return source.Aggregate(default(decimal?), NullableMax, CancellationToken.None);
+        }
+
+        public static Task<decimal?> Max(this IAsyncEnumerable<decimal?> source, CancellationToken cancellationToken)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            return source.Aggregate(default(decimal?), NullableMax, cancellationToken);
+        }
+
+        public static Task<decimal?> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal?> 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<decimal?> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal?> 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<int> Min(this IAsyncEnumerable<int> source)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            return source.Aggregate(Math.Min, CancellationToken.None);
+        }
+
+        public static Task<int> Min(this IAsyncEnumerable<int> source, CancellationToken cancellationToken)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            return source.Aggregate(Math.Min, cancellationToken);
+        }
+
+        public static Task<int> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int> 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<int> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int> 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<long> Min(this IAsyncEnumerable<long> source)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            return source.Aggregate(Math.Min, CancellationToken.None);
+        }
+
+        public static Task<long> Min(this IAsyncEnumerable<long> source, CancellationToken cancellationToken)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            return source.Aggregate(Math.Min, cancellationToken);
+        }
+
+        public static Task<long> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long> 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<long> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long> 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<float> Min(this IAsyncEnumerable<float> source)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            return source.Aggregate(Math.Min, CancellationToken.None);
+        }
+
+        public static Task<float> Min(this IAsyncEnumerable<float> source, CancellationToken cancellationToken)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            return source.Aggregate(Math.Min, cancellationToken);
+        }
+
+        public static Task<float> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float> 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<float> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float> 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<double> Min(this IAsyncEnumerable<double> source)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            return source.Aggregate(Math.Min, CancellationToken.None);
+        }
+
+        public static Task<double> Min(this IAsyncEnumerable<double> source, CancellationToken cancellationToken)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            return source.Aggregate(Math.Min, cancellationToken);
+        }
+
+        public static Task<double> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double> 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<double> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double> 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<decimal> Min(this IAsyncEnumerable<decimal> source)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            return source.Aggregate(Math.Min, CancellationToken.None);
+        }
+
+        public static Task<decimal> Min(this IAsyncEnumerable<decimal> source, CancellationToken cancellationToken)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            return source.Aggregate(Math.Min, cancellationToken);
+        }
+
+        public static Task<decimal> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal> 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<decimal> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal> 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<int?> Min(this IAsyncEnumerable<int?> source)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            return source.Aggregate(default(int?), NullableMin, CancellationToken.None);
+        }
+
+        public static Task<int?> Min(this IAsyncEnumerable<int?> source, CancellationToken cancellationToken)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            return source.Aggregate(default(int?), NullableMin, cancellationToken);
+        }
+
+        public static Task<int?> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int?> 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<int?> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int?> 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<long?> Min(this IAsyncEnumerable<long?> source)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            return source.Aggregate(default(long?), NullableMin, CancellationToken.None);
+        }
+
+        public static Task<long?> Min(this IAsyncEnumerable<long?> source, CancellationToken cancellationToken)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            return source.Aggregate(default(long?), NullableMin, cancellationToken);
+        }
+
+        public static Task<long?> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long?> 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<long?> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long?> 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<float?> Min(this IAsyncEnumerable<float?> source)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            return source.Aggregate(default(float?), NullableMin, CancellationToken.None);
+        }
+
+        public static Task<float?> Min(this IAsyncEnumerable<float?> source, CancellationToken cancellationToken)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            return source.Aggregate(default(float?), NullableMin, cancellationToken);
+        }
+
+        public static Task<float?> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float?> 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<float?> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float?> 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<double?> Min(this IAsyncEnumerable<double?> source)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            return source.Aggregate(default(double?), NullableMin, CancellationToken.None);
+        }
+
+        public static Task<double?> Min(this IAsyncEnumerable<double?> source, CancellationToken cancellationToken)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            return source.Aggregate(default(double?), NullableMin, cancellationToken);
+        }
+
+        public static Task<double?> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double?> 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<double?> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double?> 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<decimal?> Min(this IAsyncEnumerable<decimal?> source)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            return source.Aggregate(default(decimal?), NullableMin, CancellationToken.None);
+        }
+
+        public static Task<decimal?> Min(this IAsyncEnumerable<decimal?> source, CancellationToken cancellationToken)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+
+            return source.Aggregate(default(decimal?), NullableMin, cancellationToken);
+        }
+
+        public static Task<decimal?> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal?> 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<decimal?> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal?> 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>(T? x, T? y)
+            where T : struct, IComparable<T>
+        {
+            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>(T? x, T? y)
+            where T : struct, IComparable<T>
+        {
+            if (!x.HasValue)
+                return y;
+            if (!y.HasValue)
+                return x;
+            if (x.Value.CompareTo(y.Value) <= 0)
+                return x;
+            return y;
+        }
+    }
+}

+ 130 - 0
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#><TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, <#=t#>> 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#><TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, <#=t#>> 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>(T? x, T? y)
+            where T : struct, IComparable<T>
+        {
+            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>(T? x, T? y)
+            where T : struct, IComparable<T>
+        {
+            if (!x.HasValue)
+                return y;
+            if (!y.HasValue)
+                return x;
+            if (x.Value.CompareTo(y.Value) <= 0)
+                return x;
+            return y;
+        }
+    }
+}

+ 14 - 0
Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj

@@ -12,6 +12,11 @@
   </ItemGroup>
 
   <ItemGroup>
+    <None Include="MinMax.Generated.cs">
+      <DesignTime>True</DesignTime>
+      <AutoGen>True</AutoGen>
+      <DependentUpon>MinMax.Generated.tt</DependentUpon>
+    </None>
     <None Include="Sum.Generated.cs">
       <DesignTime>True</DesignTime>
       <AutoGen>True</AutoGen>
@@ -20,6 +25,10 @@
   </ItemGroup>
 
   <ItemGroup>
+    <None Update="MinMax.Generated.tt">
+      <Generator>TextTemplatingFileGenerator</Generator>
+      <LastGenOutput>MinMax.Generated.cs</LastGenOutput>
+    </None>
     <None Update="Sum.Generated.tt">
       <Generator>TextTemplatingFileGenerator</Generator>
       <LastGenOutput>Sum.Generated.cs</LastGenOutput>
@@ -31,6 +40,11 @@
   </ItemGroup>
 
   <ItemGroup>
+    <Compile Update="MinMax.Generated.cs">
+      <DesignTime>True</DesignTime>
+      <AutoGen>True</AutoGen>
+      <DependentUpon>MinMax.Generated.tt</DependentUpon>
+    </Compile>
     <Compile Update="Sum.Generated.cs">
       <DesignTime>True</DesignTime>
       <AutoGen>True</AutoGen>