瀏覽代碼

Adding BCL style exception factories.

Bart De Smet 7 年之前
父節點
當前提交
cfd11d1c62
共有 70 個文件被更改,包括 1005 次插入989 次删除
  1. 14 0
      Ix.NET/Source/System.Linq.Async/System/Error.cs
  2. 2 2
      Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs
  3. 4 4
      Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs
  4. 30 30
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs
  5. 8 8
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs
  6. 10 10
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs
  7. 2 2
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs
  8. 100 100
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs
  9. 10 10
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt
  10. 5 5
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.cs
  11. 1 1
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Cast.cs
  12. 2 2
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs
  13. 6 6
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs
  14. 10 10
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs
  15. 4 4
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs
  16. 2 2
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs
  17. 3 3
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs
  18. 5 5
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs
  19. 5 3
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs
  20. 5 5
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs
  21. 13 13
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs
  22. 10 10
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs
  23. 20 20
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs
  24. 56 56
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs
  25. 22 22
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs
  26. 1 1
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Grouping.cs
  27. 5 5
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs
  28. 22 22
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs
  29. 13 13
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs
  30. 10 10
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs
  31. 10 10
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs
  32. 3 3
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Generic.cs
  33. 15 15
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Primitive.cs
  34. 10 10
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs
  35. 3 3
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Generic.cs
  36. 15 15
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Primitive.cs
  37. 10 10
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs
  38. 152 152
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs
  39. 10 10
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt
  40. 1 1
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs
  41. 40 40
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs
  42. 2 2
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs
  43. 1 1
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs
  44. 1 1
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs
  45. 8 8
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs
  46. 20 20
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs
  47. 10 10
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs
  48. 18 18
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs
  49. 14 14
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs
  50. 1 1
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Skip.cs
  51. 1 1
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs
  52. 8 8
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs
  53. 100 100
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs
  54. 10 10
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt
  55. 1 1
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Take.cs
  56. 1 1
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs
  57. 8 8
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs
  58. 2 2
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToArray.cs
  59. 3 3
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs
  60. 48 48
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs
  61. 1 1
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToEnumerable.cs
  62. 6 6
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs
  63. 2 2
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs
  64. 48 48
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs
  65. 1 1
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToObservable.cs
  66. 5 5
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs
  67. 8 8
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs
  68. 6 6
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs
  69. 1 1
      Ix.NET/Source/System.Linq.Async/System/Strings.cs
  70. 1 1
      Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs

+ 14 - 0
Ix.NET/Source/System.Linq.Async/System/Error.cs

@@ -0,0 +1,14 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the Apache 2.0 License.
+// See the LICENSE file in the project root for more information. 
+
+namespace System
+{
+    internal static class Error
+    {
+        public static Exception ArgumentNull(string paramName) => new ArgumentNullException(paramName);
+        public static Exception ArgumentOutOfRange(string paramName) => new ArgumentOutOfRangeException(paramName);
+        public static Exception NoElements() => new InvalidOperationException(Strings.NO_ELEMENTS);
+        public static Exception MoreThanOneElement() => new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT);
+    }
+}

+ 2 - 2
Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs

@@ -12,7 +12,7 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> AsAsyncEnumerable<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return source.Select(x => x);
         }
@@ -20,7 +20,7 @@ namespace System.Linq
         private static IAsyncEnumerable<TValue> Throw<TValue>(Exception exception)
         {
             if (exception == null)
-                throw new ArgumentNullException(nameof(exception));
+                throw Error.ArgumentNull(nameof(exception));
 
 #if NO_TASK_FROMEXCEPTION
             var tcs = new TaskCompletionSource<bool>();

+ 4 - 4
Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs

@@ -25,7 +25,7 @@ namespace System.Collections.Generic
         public static IAsyncEnumerator<T> Create<T>(Func<ValueTask<bool>> moveNext, Func<T> current, Func<ValueTask> dispose)
         {
             if (moveNext == null)
-                throw new ArgumentNullException(nameof(moveNext));
+                throw Error.ArgumentNull(nameof(moveNext));
 
             // Note: Many methods pass null in for the second two params. We're assuming
             // That the caller is responsible and knows what they're doing
@@ -45,7 +45,7 @@ namespace System.Collections.Generic
         public static ValueTask<bool> MoveNextAsync<T>(this IAsyncEnumerator<T> source, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             cancellationToken.ThrowIfCancellationRequested();
 
@@ -63,7 +63,7 @@ namespace System.Collections.Generic
         public static IAsyncEnumerator<T> WithCancellation<T>(this IAsyncEnumerator<T> source, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return new AnonymousAsyncIterator<T>(
                 moveNext: () =>
@@ -85,7 +85,7 @@ namespace System.Collections.Generic
         public static IAsyncEnumerable<T> AsEnumerable<T>(this IAsyncEnumerator<T> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return AsyncEnumerable.CreateEnumerable<T>(_ => source);
         }

+ 30 - 30
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs

@@ -13,9 +13,9 @@ namespace System.Linq
         public static Task<TSource> Aggregate<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, TSource, TSource> accumulator)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (accumulator == null)
-                throw new ArgumentNullException(nameof(accumulator));
+                throw Error.ArgumentNull(nameof(accumulator));
 
             return AggregateCore(source, accumulator, CancellationToken.None);
         }
@@ -23,9 +23,9 @@ namespace System.Linq
         public static Task<TSource> Aggregate<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, TSource, TSource> accumulator, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (accumulator == null)
-                throw new ArgumentNullException(nameof(accumulator));
+                throw Error.ArgumentNull(nameof(accumulator));
 
             return AggregateCore(source, accumulator, cancellationToken);
         }
@@ -33,9 +33,9 @@ namespace System.Linq
         public static Task<TSource> Aggregate<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, TSource, Task<TSource>> accumulator)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (accumulator == null)
-                throw new ArgumentNullException(nameof(accumulator));
+                throw Error.ArgumentNull(nameof(accumulator));
 
             return AggregateCore(source, accumulator, CancellationToken.None);
         }
@@ -43,9 +43,9 @@ namespace System.Linq
         public static Task<TSource> Aggregate<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, TSource, Task<TSource>> accumulator, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (accumulator == null)
-                throw new ArgumentNullException(nameof(accumulator));
+                throw Error.ArgumentNull(nameof(accumulator));
 
             return AggregateCore(source, accumulator, cancellationToken);
         }
@@ -53,9 +53,9 @@ namespace System.Linq
         public static Task<TAccumulate> Aggregate<TSource, TAccumulate>(this IAsyncEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> accumulator)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (accumulator == null)
-                throw new ArgumentNullException(nameof(accumulator));
+                throw Error.ArgumentNull(nameof(accumulator));
 
             return AggregateCore(source, seed, accumulator, x => x, CancellationToken.None);
         }
@@ -63,9 +63,9 @@ namespace System.Linq
         public static Task<TAccumulate> Aggregate<TSource, TAccumulate>(this IAsyncEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> accumulator, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (accumulator == null)
-                throw new ArgumentNullException(nameof(accumulator));
+                throw Error.ArgumentNull(nameof(accumulator));
 
             return AggregateCore(source, seed, accumulator, x => x, cancellationToken);
         }
@@ -73,9 +73,9 @@ namespace System.Linq
         public static Task<TAccumulate> Aggregate<TSource, TAccumulate>(this IAsyncEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, Task<TAccumulate>> accumulator)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (accumulator == null)
-                throw new ArgumentNullException(nameof(accumulator));
+                throw Error.ArgumentNull(nameof(accumulator));
 
             return AggregateCore(source, seed, accumulator, CancellationToken.None);
         }
@@ -83,9 +83,9 @@ namespace System.Linq
         public static Task<TAccumulate> Aggregate<TSource, TAccumulate>(this IAsyncEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, Task<TAccumulate>> accumulator, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (accumulator == null)
-                throw new ArgumentNullException(nameof(accumulator));
+                throw Error.ArgumentNull(nameof(accumulator));
 
             return AggregateCore(source, seed, accumulator, cancellationToken);
         }
@@ -93,11 +93,11 @@ namespace System.Linq
         public static Task<TResult> Aggregate<TSource, TAccumulate, TResult>(this IAsyncEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> accumulator, Func<TAccumulate, TResult> resultSelector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (accumulator == null)
-                throw new ArgumentNullException(nameof(accumulator));
+                throw Error.ArgumentNull(nameof(accumulator));
             if (resultSelector == null)
-                throw new ArgumentNullException(nameof(resultSelector));
+                throw Error.ArgumentNull(nameof(resultSelector));
 
             return AggregateCore(source, seed, accumulator, resultSelector, CancellationToken.None);
         }
@@ -105,11 +105,11 @@ namespace System.Linq
         public static Task<TResult> Aggregate<TSource, TAccumulate, TResult>(this IAsyncEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> accumulator, Func<TAccumulate, TResult> resultSelector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (accumulator == null)
-                throw new ArgumentNullException(nameof(accumulator));
+                throw Error.ArgumentNull(nameof(accumulator));
             if (resultSelector == null)
-                throw new ArgumentNullException(nameof(resultSelector));
+                throw Error.ArgumentNull(nameof(resultSelector));
 
             return AggregateCore(source, seed, accumulator, resultSelector, cancellationToken);
         }
@@ -117,11 +117,11 @@ namespace System.Linq
         public static Task<TResult> Aggregate<TSource, TAccumulate, TResult>(this IAsyncEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, Task<TAccumulate>> accumulator, Func<TAccumulate, Task<TResult>> resultSelector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (accumulator == null)
-                throw new ArgumentNullException(nameof(accumulator));
+                throw Error.ArgumentNull(nameof(accumulator));
             if (resultSelector == null)
-                throw new ArgumentNullException(nameof(resultSelector));
+                throw Error.ArgumentNull(nameof(resultSelector));
 
             return AggregateCore(source, seed, accumulator, resultSelector, CancellationToken.None);
         }
@@ -129,11 +129,11 @@ namespace System.Linq
         public static Task<TResult> Aggregate<TSource, TAccumulate, TResult>(this IAsyncEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, Task<TAccumulate>> accumulator, Func<TAccumulate, Task<TResult>> resultSelector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (accumulator == null)
-                throw new ArgumentNullException(nameof(accumulator));
+                throw Error.ArgumentNull(nameof(accumulator));
             if (resultSelector == null)
-                throw new ArgumentNullException(nameof(resultSelector));
+                throw Error.ArgumentNull(nameof(resultSelector));
 
             return AggregateCore(source, seed, accumulator, resultSelector, cancellationToken);
         }
@@ -180,7 +180,7 @@ namespace System.Linq
             }
 
             if (first)
-                throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                throw Error.NoElements();
 
             return acc;
         }
@@ -248,7 +248,7 @@ namespace System.Linq
             }
 
             if (first)
-                throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                throw Error.NoElements();
 
             return acc;
         }

+ 8 - 8
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs

@@ -13,9 +13,9 @@ namespace System.Linq
         public static Task<bool> All<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return AllCore(source, predicate, CancellationToken.None);
         }
@@ -23,9 +23,9 @@ namespace System.Linq
         public static Task<bool> All<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return AllCore(source, predicate, CancellationToken.None);
         }
@@ -33,9 +33,9 @@ namespace System.Linq
         public static Task<bool> All<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return AllCore(source, predicate, cancellationToken);
         }
@@ -43,9 +43,9 @@ namespace System.Linq
         public static Task<bool> All<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return AllCore(source, predicate, cancellationToken);
         }

+ 10 - 10
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs

@@ -13,9 +13,9 @@ namespace System.Linq
         public static Task<bool> Any<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return AnyCore(source, predicate, CancellationToken.None);
         }
@@ -23,9 +23,9 @@ namespace System.Linq
         public static Task<bool> Any<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return AnyCore(source, predicate, CancellationToken.None);
         }
@@ -33,7 +33,7 @@ namespace System.Linq
         public static Task<bool> Any<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return AnyCore(source, CancellationToken.None);
         }
@@ -41,9 +41,9 @@ namespace System.Linq
         public static Task<bool> Any<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return AnyCore(source, predicate, cancellationToken);
         }
@@ -51,9 +51,9 @@ namespace System.Linq
         public static Task<bool> Any<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return AnyCore(source, predicate, cancellationToken);
         }
@@ -61,7 +61,7 @@ namespace System.Linq
         public static Task<bool> Any<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return AnyCore(source, cancellationToken);
         }

+ 2 - 2
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs

@@ -14,7 +14,7 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Append<TSource>(this IAsyncEnumerable<TSource> source, TSource element)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             if (source is AppendPrependAsyncIterator<TSource> appendable)
             {
@@ -27,7 +27,7 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Prepend<TSource>(this IAsyncEnumerable<TSource> source, TSource element)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             if (source is AppendPrependAsyncIterator<TSource> appendable)
             {

+ 100 - 100
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs

@@ -13,7 +13,7 @@ namespace System.Linq
         public static Task<double> Average(this IAsyncEnumerable<int> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return AverageCore(source, CancellationToken.None);
         }
@@ -21,7 +21,7 @@ namespace System.Linq
         public static Task<double> Average(this IAsyncEnumerable<int> source, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return AverageCore(source, cancellationToken);
         }
@@ -29,9 +29,9 @@ namespace System.Linq
         public static Task<double> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(CancellationToken.None);
         }
@@ -39,9 +39,9 @@ namespace System.Linq
         public static Task<double> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(cancellationToken);
         }
@@ -49,9 +49,9 @@ namespace System.Linq
         public static Task<double> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<int>> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(CancellationToken.None);
         }
@@ -59,9 +59,9 @@ namespace System.Linq
         public static Task<double> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<int>> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(cancellationToken);
         }
@@ -69,7 +69,7 @@ namespace System.Linq
         public static Task<double> Average(this IAsyncEnumerable<long> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return AverageCore(source, CancellationToken.None);
         }
@@ -77,7 +77,7 @@ namespace System.Linq
         public static Task<double> Average(this IAsyncEnumerable<long> source, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return AverageCore(source, cancellationToken);
         }
@@ -85,9 +85,9 @@ namespace System.Linq
         public static Task<double> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(CancellationToken.None);
         }
@@ -95,9 +95,9 @@ namespace System.Linq
         public static Task<double> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(cancellationToken);
         }
@@ -105,9 +105,9 @@ namespace System.Linq
         public static Task<double> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<long>> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(CancellationToken.None);
         }
@@ -115,9 +115,9 @@ namespace System.Linq
         public static Task<double> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<long>> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(cancellationToken);
         }
@@ -125,7 +125,7 @@ namespace System.Linq
         public static Task<float> Average(this IAsyncEnumerable<float> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return AverageCore(source, CancellationToken.None);
         }
@@ -133,7 +133,7 @@ namespace System.Linq
         public static Task<float> Average(this IAsyncEnumerable<float> source, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return AverageCore(source, cancellationToken);
         }
@@ -141,9 +141,9 @@ namespace System.Linq
         public static Task<float> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(CancellationToken.None);
         }
@@ -151,9 +151,9 @@ namespace System.Linq
         public static Task<float> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(cancellationToken);
         }
@@ -161,9 +161,9 @@ namespace System.Linq
         public static Task<float> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<float>> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(CancellationToken.None);
         }
@@ -171,9 +171,9 @@ namespace System.Linq
         public static Task<float> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<float>> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(cancellationToken);
         }
@@ -181,7 +181,7 @@ namespace System.Linq
         public static Task<double> Average(this IAsyncEnumerable<double> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return AverageCore(source, CancellationToken.None);
         }
@@ -189,7 +189,7 @@ namespace System.Linq
         public static Task<double> Average(this IAsyncEnumerable<double> source, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return AverageCore(source, cancellationToken);
         }
@@ -197,9 +197,9 @@ namespace System.Linq
         public static Task<double> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(CancellationToken.None);
         }
@@ -207,9 +207,9 @@ namespace System.Linq
         public static Task<double> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(cancellationToken);
         }
@@ -217,9 +217,9 @@ namespace System.Linq
         public static Task<double> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<double>> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(CancellationToken.None);
         }
@@ -227,9 +227,9 @@ namespace System.Linq
         public static Task<double> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<double>> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(cancellationToken);
         }
@@ -237,7 +237,7 @@ namespace System.Linq
         public static Task<decimal> Average(this IAsyncEnumerable<decimal> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return AverageCore(source, CancellationToken.None);
         }
@@ -245,7 +245,7 @@ namespace System.Linq
         public static Task<decimal> Average(this IAsyncEnumerable<decimal> source, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return AverageCore(source, cancellationToken);
         }
@@ -253,9 +253,9 @@ namespace System.Linq
         public static Task<decimal> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(CancellationToken.None);
         }
@@ -263,9 +263,9 @@ namespace System.Linq
         public static Task<decimal> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(cancellationToken);
         }
@@ -273,9 +273,9 @@ namespace System.Linq
         public static Task<decimal> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<decimal>> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(CancellationToken.None);
         }
@@ -283,9 +283,9 @@ namespace System.Linq
         public static Task<decimal> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<decimal>> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(cancellationToken);
         }
@@ -293,7 +293,7 @@ namespace System.Linq
         public static Task<double?> Average(this IAsyncEnumerable<int?> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return AverageCore(source, CancellationToken.None);
         }
@@ -301,7 +301,7 @@ namespace System.Linq
         public static Task<double?> Average(this IAsyncEnumerable<int?> source, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return AverageCore(source, cancellationToken);
         }
@@ -309,9 +309,9 @@ namespace System.Linq
         public static Task<double?> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int?> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(CancellationToken.None);
         }
@@ -319,9 +319,9 @@ namespace System.Linq
         public static Task<double?> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int?> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(cancellationToken);
         }
@@ -329,9 +329,9 @@ namespace System.Linq
         public static Task<double?> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<int?>> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(CancellationToken.None);
         }
@@ -339,9 +339,9 @@ namespace System.Linq
         public static Task<double?> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<int?>> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(cancellationToken);
         }
@@ -349,7 +349,7 @@ namespace System.Linq
         public static Task<double?> Average(this IAsyncEnumerable<long?> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return AverageCore(source, CancellationToken.None);
         }
@@ -357,7 +357,7 @@ namespace System.Linq
         public static Task<double?> Average(this IAsyncEnumerable<long?> source, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return AverageCore(source, cancellationToken);
         }
@@ -365,9 +365,9 @@ namespace System.Linq
         public static Task<double?> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long?> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(CancellationToken.None);
         }
@@ -375,9 +375,9 @@ namespace System.Linq
         public static Task<double?> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long?> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(cancellationToken);
         }
@@ -385,9 +385,9 @@ namespace System.Linq
         public static Task<double?> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<long?>> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(CancellationToken.None);
         }
@@ -395,9 +395,9 @@ namespace System.Linq
         public static Task<double?> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<long?>> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(cancellationToken);
         }
@@ -405,7 +405,7 @@ namespace System.Linq
         public static Task<float?> Average(this IAsyncEnumerable<float?> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return AverageCore(source, CancellationToken.None);
         }
@@ -413,7 +413,7 @@ namespace System.Linq
         public static Task<float?> Average(this IAsyncEnumerable<float?> source, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return AverageCore(source, cancellationToken);
         }
@@ -421,9 +421,9 @@ namespace System.Linq
         public static Task<float?> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float?> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(CancellationToken.None);
         }
@@ -431,9 +431,9 @@ namespace System.Linq
         public static Task<float?> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float?> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(cancellationToken);
         }
@@ -441,9 +441,9 @@ namespace System.Linq
         public static Task<float?> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<float?>> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(CancellationToken.None);
         }
@@ -451,9 +451,9 @@ namespace System.Linq
         public static Task<float?> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<float?>> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(cancellationToken);
         }
@@ -461,7 +461,7 @@ namespace System.Linq
         public static Task<double?> Average(this IAsyncEnumerable<double?> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return AverageCore(source, CancellationToken.None);
         }
@@ -469,7 +469,7 @@ namespace System.Linq
         public static Task<double?> Average(this IAsyncEnumerable<double?> source, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return AverageCore(source, cancellationToken);
         }
@@ -477,9 +477,9 @@ namespace System.Linq
         public static Task<double?> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double?> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(CancellationToken.None);
         }
@@ -487,9 +487,9 @@ namespace System.Linq
         public static Task<double?> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double?> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(cancellationToken);
         }
@@ -497,9 +497,9 @@ namespace System.Linq
         public static Task<double?> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<double?>> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(CancellationToken.None);
         }
@@ -507,9 +507,9 @@ namespace System.Linq
         public static Task<double?> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<double?>> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(cancellationToken);
         }
@@ -517,7 +517,7 @@ namespace System.Linq
         public static Task<decimal?> Average(this IAsyncEnumerable<decimal?> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return AverageCore(source, CancellationToken.None);
         }
@@ -525,7 +525,7 @@ namespace System.Linq
         public static Task<decimal?> Average(this IAsyncEnumerable<decimal?> source, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return AverageCore(source, cancellationToken);
         }
@@ -533,9 +533,9 @@ namespace System.Linq
         public static Task<decimal?> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal?> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(CancellationToken.None);
         }
@@ -543,9 +543,9 @@ namespace System.Linq
         public static Task<decimal?> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal?> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(cancellationToken);
         }
@@ -553,9 +553,9 @@ namespace System.Linq
         public static Task<decimal?> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<decimal?>> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(CancellationToken.None);
         }
@@ -563,9 +563,9 @@ namespace System.Linq
         public static Task<decimal?> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<decimal?>> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(cancellationToken);
         }

+ 10 - 10
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt

@@ -38,7 +38,7 @@ foreach (var o in os)
         public static Task<<#=o.res#>> Average(this IAsyncEnumerable<<#=o.type#>> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return AverageCore(source, CancellationToken.None);
         }
@@ -46,7 +46,7 @@ foreach (var o in os)
         public static Task<<#=o.res#>> Average(this IAsyncEnumerable<<#=o.type#>> source, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return AverageCore(source, cancellationToken);
         }
@@ -54,9 +54,9 @@ foreach (var o in os)
         public static Task<<#=o.res#>> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, <#=o.type#>> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(CancellationToken.None);
         }
@@ -64,9 +64,9 @@ foreach (var o in os)
         public static Task<<#=o.res#>> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, <#=o.type#>> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(cancellationToken);
         }
@@ -74,9 +74,9 @@ foreach (var o in os)
         public static Task<<#=o.res#>> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<<#=o.type#>>> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(CancellationToken.None);
         }
@@ -84,9 +84,9 @@ foreach (var o in os)
         public static Task<<#=o.res#>> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<<#=o.type#>>> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return source.Select(selector).Average(cancellationToken);
         }

+ 5 - 5
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.cs

@@ -18,7 +18,7 @@ namespace System.Linq
             {
                 if (!await e.MoveNextAsync().ConfigureAwait(false))
                 {
-                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    throw Error.NoElements();
                 }
 
                 long sum = e.Current;
@@ -86,7 +86,7 @@ namespace System.Linq
             {
                 if (!await e.MoveNextAsync().ConfigureAwait(false))
                 {
-                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    throw Error.NoElements();
                 }
 
                 var sum = e.Current;
@@ -154,7 +154,7 @@ namespace System.Linq
             {
                 if (!await e.MoveNextAsync().ConfigureAwait(false))
                 {
-                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    throw Error.NoElements();
                 }
 
                 var sum = e.Current;
@@ -222,7 +222,7 @@ namespace System.Linq
             {
                 if (!await e.MoveNextAsync().ConfigureAwait(false))
                 {
-                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    throw Error.NoElements();
                 }
 
                 double sum = e.Current;
@@ -287,7 +287,7 @@ namespace System.Linq
             {
                 if (!await e.MoveNextAsync().ConfigureAwait(false))
                 {
-                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    throw Error.NoElements();
                 }
 
                 var sum = e.Current;

+ 1 - 1
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Cast.cs

@@ -11,7 +11,7 @@ namespace System.Linq
         public static IAsyncEnumerable<TResult> Cast<TResult>(this IAsyncEnumerable<object> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             // Check to see if it already is and short-circuit
             if (source is IAsyncEnumerable<TResult> typedSource)

+ 2 - 2
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs

@@ -14,9 +14,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Concat<TSource>(this IAsyncEnumerable<TSource> first, IAsyncEnumerable<TSource> second)
         {
             if (first == null)
-                throw new ArgumentNullException(nameof(first));
+                throw Error.ArgumentNull(nameof(first));
             if (second == null)
-                throw new ArgumentNullException(nameof(second));
+                throw Error.ArgumentNull(nameof(second));
 
             return first is ConcatAsyncIterator<TSource> concatFirst ?
                        concatFirst.Concat(second) :

+ 6 - 6
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs

@@ -13,7 +13,7 @@ namespace System.Linq
         public static Task<bool> Contains<TSource>(this IAsyncEnumerable<TSource> source, TSource value)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return ContainsCore(source, value, CancellationToken.None);
         }
@@ -21,7 +21,7 @@ namespace System.Linq
         public static Task<bool> Contains<TSource>(this IAsyncEnumerable<TSource> source, TSource value, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return ContainsCore(source, value, cancellationToken);
         }
@@ -29,9 +29,9 @@ namespace System.Linq
         public static Task<bool> Contains<TSource>(this IAsyncEnumerable<TSource> source, TSource value, IEqualityComparer<TSource> comparer)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return ContainsCore(source, value, comparer, CancellationToken.None);
         }
@@ -39,9 +39,9 @@ namespace System.Linq
         public static Task<bool> Contains<TSource>(this IAsyncEnumerable<TSource> source, TSource value, IEqualityComparer<TSource> comparer, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return ContainsCore(source, value, comparer, cancellationToken);
         }

+ 10 - 10
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs

@@ -14,7 +14,7 @@ namespace System.Linq
         public static Task<int> Count<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return CountCore(source, CancellationToken.None);
         }
@@ -22,7 +22,7 @@ namespace System.Linq
         public static Task<int> Count<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return CountCore(source, cancellationToken);
         }
@@ -30,9 +30,9 @@ namespace System.Linq
         public static Task<int> Count<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return CountCore(source, predicate, CancellationToken.None);
         }
@@ -40,9 +40,9 @@ namespace System.Linq
         public static Task<int> Count<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return CountCore(source, predicate, cancellationToken);
         }
@@ -50,9 +50,9 @@ namespace System.Linq
         public static Task<int> Count<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return CountCore(source, predicate, CancellationToken.None);
         }
@@ -60,9 +60,9 @@ namespace System.Linq
         public static Task<int> Count<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return CountCore(source, predicate, cancellationToken);
         }

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

@@ -14,7 +14,7 @@ namespace System.Linq
         public static IAsyncEnumerable<T> CreateEnumerable<T>(Func<IAsyncEnumerator<T>> getEnumerator)
         {
             if (getEnumerator == null)
-                throw new ArgumentNullException(nameof(getEnumerator));
+                throw Error.ArgumentNull(nameof(getEnumerator));
 
             return new AnonymousAsyncEnumerable<T>(_ => getEnumerator());
         }
@@ -22,7 +22,7 @@ namespace System.Linq
         public static IAsyncEnumerable<T> CreateEnumerable<T>(Func<CancellationToken, IAsyncEnumerator<T>> getEnumerator)
         {
             if (getEnumerator == null)
-                throw new ArgumentNullException(nameof(getEnumerator));
+                throw Error.ArgumentNull(nameof(getEnumerator));
 
             return new AnonymousAsyncEnumerable<T>(getEnumerator);
         }
@@ -30,7 +30,7 @@ namespace System.Linq
         public static IAsyncEnumerable<T> CreateEnumerable<T>(Func<Task<IAsyncEnumerator<T>>> getEnumerator)
         {
             if (getEnumerator == null)
-                throw new ArgumentNullException(nameof(getEnumerator));
+                throw Error.ArgumentNull(nameof(getEnumerator));
 
             return new AnonymousAsyncEnumerableWithTask<T>(_ => getEnumerator());
         }
@@ -38,7 +38,7 @@ namespace System.Linq
         public static IAsyncEnumerable<T> CreateEnumerable<T>(Func<CancellationToken, Task<IAsyncEnumerator<T>>> getEnumerator)
         {
             if (getEnumerator == null)
-                throw new ArgumentNullException(nameof(getEnumerator));
+                throw Error.ArgumentNull(nameof(getEnumerator));
 
             return new AnonymousAsyncEnumerableWithTask<T>(getEnumerator);
         }

+ 2 - 2
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs

@@ -16,7 +16,7 @@ namespace System.Linq
         {
             if (source == null)
             {
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             }
 
             return new DefaultIfEmptyAsyncIterator<TSource>(source, defaultValue);
@@ -26,7 +26,7 @@ namespace System.Linq
         {
             if (source == null)
             {
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             }
 
             return DefaultIfEmpty(source, default);

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

@@ -14,7 +14,7 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Distinct<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return source.Distinct(EqualityComparer<TSource>.Default);
         }
@@ -22,9 +22,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Distinct<TSource>(this IAsyncEnumerable<TSource> source, IEqualityComparer<TSource> comparer)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return new DistinctAsyncIterator<TSource>(source, comparer);
         }

+ 5 - 5
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs

@@ -13,7 +13,7 @@ namespace System.Linq
         public static Task<TSource> ElementAt<TSource>(this IAsyncEnumerable<TSource> source, int index)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return ElementAtCore(source, index, CancellationToken.None);
         }
@@ -21,9 +21,9 @@ namespace System.Linq
         public static Task<TSource> ElementAt<TSource>(this IAsyncEnumerable<TSource> source, int index, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (index < 0)
-                throw new ArgumentOutOfRangeException(nameof(index));
+                throw Error.ArgumentOutOfRange(nameof(index));
 
             return ElementAtCore(source, index, cancellationToken);
         }
@@ -47,7 +47,7 @@ namespace System.Linq
                 }
                 else
                 {
-                    throw new ArgumentOutOfRangeException(nameof(index));
+                    throw Error.ArgumentOutOfRange(nameof(index));
                 }
             }
             else
@@ -72,7 +72,7 @@ namespace System.Linq
                 }
             }
 
-            throw new ArgumentOutOfRangeException(nameof(index));
+            throw Error.ArgumentOutOfRange(nameof(index));
         }
     }
 }

+ 5 - 3
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs

@@ -13,7 +13,9 @@ namespace System.Linq
         public static Task<TSource> ElementAtOrDefault<TSource>(this IAsyncEnumerable<TSource> source, int index)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
+            if (index < 0)
+                throw Error.ArgumentOutOfRange(nameof(index));
 
             return ElementAtOrDefaultCore(source, index, CancellationToken.None);
         }
@@ -21,9 +23,9 @@ namespace System.Linq
         public static Task<TSource> ElementAtOrDefault<TSource>(this IAsyncEnumerable<TSource> source, int index, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (index < 0)
-                throw new ArgumentOutOfRangeException(nameof(index));
+                throw Error.ArgumentOutOfRange(nameof(index));
 
             return ElementAtOrDefaultCore(source, index, cancellationToken);
         }

+ 5 - 5
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs

@@ -14,9 +14,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Except<TSource>(this IAsyncEnumerable<TSource> first, IAsyncEnumerable<TSource> second)
         {
             if (first == null)
-                throw new ArgumentNullException(nameof(first));
+                throw Error.ArgumentNull(nameof(first));
             if (second == null)
-                throw new ArgumentNullException(nameof(second));
+                throw Error.ArgumentNull(nameof(second));
 
             return first.Except(second, EqualityComparer<TSource>.Default);
         }
@@ -24,11 +24,11 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Except<TSource>(this IAsyncEnumerable<TSource> first, IAsyncEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
         {
             if (first == null)
-                throw new ArgumentNullException(nameof(first));
+                throw Error.ArgumentNull(nameof(first));
             if (second == null)
-                throw new ArgumentNullException(nameof(second));
+                throw Error.ArgumentNull(nameof(second));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return new ExceptAsyncIterator<TSource>(first, second, comparer);
         }

+ 13 - 13
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs

@@ -13,7 +13,7 @@ namespace System.Linq
         public static Task<TSource> First<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return FirstCore(source, CancellationToken.None);
         }
@@ -21,7 +21,7 @@ namespace System.Linq
         public static Task<TSource> First<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return FirstCore(source, cancellationToken);
         }
@@ -29,9 +29,9 @@ namespace System.Linq
         public static Task<TSource> First<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return FirstCore(source, predicate, CancellationToken.None);
         }
@@ -39,9 +39,9 @@ namespace System.Linq
         public static Task<TSource> First<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return FirstCore(source, predicate, cancellationToken);
         }
@@ -49,9 +49,9 @@ namespace System.Linq
         public static Task<TSource> First<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return FirstCore(source, predicate, CancellationToken.None);
         }
@@ -59,9 +59,9 @@ namespace System.Linq
         public static Task<TSource> First<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return FirstCore(source, predicate, cancellationToken);
         }
@@ -70,21 +70,21 @@ namespace System.Linq
         {
             var first = await TryGetFirst(source, cancellationToken).ConfigureAwait(false);
 
-            return first.HasValue ? first.Value : throw new InvalidOperationException(Strings.NO_ELEMENTS);
+            return first.HasValue ? first.Value : throw Error.NoElements();
         }
 
         private static async Task<TSource> FirstCore<TSource>(IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate, CancellationToken cancellationToken)
         {
             var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false);
 
-            return first.HasValue ? first.Value : throw new InvalidOperationException(Strings.NO_ELEMENTS);
+            return first.HasValue ? first.Value : throw Error.NoElements();
         }
 
         private static async Task<TSource> FirstCore<TSource>(IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate, CancellationToken cancellationToken)
         {
             var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false);
 
-            return first.HasValue ? first.Value : throw new InvalidOperationException(Strings.NO_ELEMENTS);
+            return first.HasValue ? first.Value : throw Error.NoElements();
         }
     }
 }

+ 10 - 10
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs

@@ -13,7 +13,7 @@ namespace System.Linq
         public static Task<TSource> FirstOrDefault<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return FirstOrDefaultCore(source, CancellationToken.None);
         }
@@ -21,7 +21,7 @@ namespace System.Linq
         public static Task<TSource> FirstOrDefault<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return FirstOrDefaultCore(source, cancellationToken);
         }
@@ -29,9 +29,9 @@ namespace System.Linq
         public static Task<TSource> FirstOrDefault<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return FirstOrDefaultCore(source, predicate, CancellationToken.None);
         }
@@ -39,9 +39,9 @@ namespace System.Linq
         public static Task<TSource> FirstOrDefault<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return FirstOrDefaultCore(source, predicate, cancellationToken);
         }
@@ -49,9 +49,9 @@ namespace System.Linq
         public static Task<TSource> FirstOrDefault<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return FirstOrDefaultCore(source, predicate, CancellationToken.None);
         }
@@ -59,9 +59,9 @@ namespace System.Linq
         public static Task<TSource> FirstOrDefault<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return FirstOrDefaultCore(source, predicate, cancellationToken);
         }

+ 20 - 20
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs

@@ -13,9 +13,9 @@ namespace System.Linq
         public static Task ForEachAsync<TSource>(this IAsyncEnumerable<TSource> source, Action<TSource> action)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (action == null)
-                throw new ArgumentNullException(nameof(action));
+                throw Error.ArgumentNull(nameof(action));
 
             return ForEachAsyncCore(source, action, CancellationToken.None);
         }
@@ -23,9 +23,9 @@ namespace System.Linq
         public static Task ForEachAsync<TSource>(this IAsyncEnumerable<TSource> source, Action<TSource> action, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (action == null)
-                throw new ArgumentNullException(nameof(action));
+                throw Error.ArgumentNull(nameof(action));
 
             return ForEachAsyncCore(source, action, cancellationToken);
         }
@@ -33,9 +33,9 @@ namespace System.Linq
         public static Task ForEachAsync<TSource>(this IAsyncEnumerable<TSource> source, Action<TSource, int> action)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (action == null)
-                throw new ArgumentNullException(nameof(action));
+                throw Error.ArgumentNull(nameof(action));
 
             return ForEachAsyncCore(source, action, CancellationToken.None);
         }
@@ -43,9 +43,9 @@ namespace System.Linq
         public static Task ForEachAsync<TSource>(this IAsyncEnumerable<TSource> source, Action<TSource, int> action, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (action == null)
-                throw new ArgumentNullException(nameof(action));
+                throw Error.ArgumentNull(nameof(action));
 
             return ForEachAsyncCore(source, action, cancellationToken);
         }
@@ -53,9 +53,9 @@ namespace System.Linq
         public static Task ForEachAsync<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task> action)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (action == null)
-                throw new ArgumentNullException(nameof(action));
+                throw Error.ArgumentNull(nameof(action));
 
             return ForEachAsyncCore(source, (x, ct) => action(x), CancellationToken.None);
         }
@@ -63,9 +63,9 @@ namespace System.Linq
         public static Task ForEachAsync<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task> action, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (action == null)
-                throw new ArgumentNullException(nameof(action));
+                throw Error.ArgumentNull(nameof(action));
 
             return ForEachAsyncCore(source, (x, ct) => action(x), cancellationToken);
         }
@@ -73,9 +73,9 @@ namespace System.Linq
         public static Task ForEachAsync<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, Task> action, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (action == null)
-                throw new ArgumentNullException(nameof(action));
+                throw Error.ArgumentNull(nameof(action));
 
             return ForEachAsyncCore(source, action, cancellationToken);
         }
@@ -83,9 +83,9 @@ namespace System.Linq
         public static Task ForEachAsync<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int, Task> action)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (action == null)
-                throw new ArgumentNullException(nameof(action));
+                throw Error.ArgumentNull(nameof(action));
 
             return ForEachAsyncCore(source, (x, i, ct) => action(x, i), CancellationToken.None);
         }
@@ -93,9 +93,9 @@ namespace System.Linq
         public static Task ForEachAsync<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int, Task> action, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (action == null)
-                throw new ArgumentNullException(nameof(action));
+                throw Error.ArgumentNull(nameof(action));
 
             return ForEachAsyncCore(source, (x, i, ct) => action(x, i), cancellationToken);
         }
@@ -103,9 +103,9 @@ namespace System.Linq
         public static Task ForEachAsync<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int, CancellationToken, Task> action, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (action == null)
-                throw new ArgumentNullException(nameof(action));
+                throw Error.ArgumentNull(nameof(action));
 
             return ForEachAsyncCore(source, action, cancellationToken);
         }

+ 56 - 56
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs

@@ -14,9 +14,9 @@ namespace System.Linq
         public static IAsyncEnumerable<IAsyncGrouping<TKey, TSource>> GroupBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
 
             return new GroupedAsyncEnumerable<TSource, TKey>(source, keySelector, EqualityComparer<TKey>.Default);
         }
@@ -24,11 +24,11 @@ namespace System.Linq
         public static IAsyncEnumerable<IAsyncGrouping<TKey, TSource>> GroupBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return new GroupedAsyncEnumerable<TSource, TKey>(source, keySelector, comparer);
         }
@@ -36,9 +36,9 @@ namespace System.Linq
         public static IAsyncEnumerable<IAsyncGrouping<TKey, TSource>> GroupBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
 
             return new GroupedAsyncEnumerableWithTask<TSource, TKey>(source, keySelector, EqualityComparer<TKey>.Default);
         }
@@ -46,11 +46,11 @@ namespace System.Linq
         public static IAsyncEnumerable<IAsyncGrouping<TKey, TSource>> GroupBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector, IEqualityComparer<TKey> comparer)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return new GroupedAsyncEnumerableWithTask<TSource, TKey>(source, keySelector, comparer);
         }
@@ -58,11 +58,11 @@ namespace System.Linq
         public static IAsyncEnumerable<IAsyncGrouping<TKey, TElement>> GroupBy<TSource, TKey, TElement>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (elementSelector == null)
-                throw new ArgumentNullException(nameof(elementSelector));
+                throw Error.ArgumentNull(nameof(elementSelector));
 
             return source.GroupBy(keySelector, elementSelector, EqualityComparer<TKey>.Default);
         }
@@ -70,13 +70,13 @@ namespace System.Linq
         public static IAsyncEnumerable<IAsyncGrouping<TKey, TElement>> GroupBy<TSource, TKey, TElement>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (elementSelector == null)
-                throw new ArgumentNullException(nameof(elementSelector));
+                throw Error.ArgumentNull(nameof(elementSelector));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return new GroupedAsyncEnumerable<TSource, TKey, TElement>(source, keySelector, elementSelector, comparer);
         }
@@ -84,11 +84,11 @@ namespace System.Linq
         public static IAsyncEnumerable<IAsyncGrouping<TKey, TElement>> GroupBy<TSource, TKey, TElement>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector, Func<TSource, Task<TElement>> elementSelector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (elementSelector == null)
-                throw new ArgumentNullException(nameof(elementSelector));
+                throw Error.ArgumentNull(nameof(elementSelector));
 
             return source.GroupBy(keySelector, elementSelector, EqualityComparer<TKey>.Default);
         }
@@ -96,13 +96,13 @@ namespace System.Linq
         public static IAsyncEnumerable<IAsyncGrouping<TKey, TElement>> GroupBy<TSource, TKey, TElement>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector, Func<TSource, Task<TElement>> elementSelector, IEqualityComparer<TKey> comparer)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (elementSelector == null)
-                throw new ArgumentNullException(nameof(elementSelector));
+                throw Error.ArgumentNull(nameof(elementSelector));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return new GroupedAsyncEnumerableWithTask<TSource, TKey, TElement>(source, keySelector, elementSelector, comparer);
         }
@@ -110,11 +110,11 @@ namespace System.Linq
         public static IAsyncEnumerable<TResult> GroupBy<TSource, TKey, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TKey, IAsyncEnumerable<TSource>, TResult> resultSelector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (resultSelector == null)
-                throw new ArgumentNullException(nameof(resultSelector));
+                throw Error.ArgumentNull(nameof(resultSelector));
 
             return GroupBy(source, keySelector, resultSelector, EqualityComparer<TKey>.Default);
         }
@@ -122,13 +122,13 @@ namespace System.Linq
         public static IAsyncEnumerable<TResult> GroupBy<TSource, TKey, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TKey, IAsyncEnumerable<TSource>, TResult> resultSelector, IEqualityComparer<TKey> comparer)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (resultSelector == null)
-                throw new ArgumentNullException(nameof(resultSelector));
+                throw Error.ArgumentNull(nameof(resultSelector));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return new GroupedResultAsyncEnumerable<TSource, TKey, TResult>(source, keySelector, resultSelector, comparer);
         }
@@ -136,11 +136,11 @@ namespace System.Linq
         public static IAsyncEnumerable<TResult> GroupBy<TSource, TKey, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector, Func<TKey, IAsyncEnumerable<TSource>, Task<TResult>> resultSelector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (resultSelector == null)
-                throw new ArgumentNullException(nameof(resultSelector));
+                throw Error.ArgumentNull(nameof(resultSelector));
 
             return GroupBy(source, keySelector, resultSelector, EqualityComparer<TKey>.Default);
         }
@@ -148,13 +148,13 @@ namespace System.Linq
         public static IAsyncEnumerable<TResult> GroupBy<TSource, TKey, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector, Func<TKey, IAsyncEnumerable<TSource>, Task<TResult>> resultSelector, IEqualityComparer<TKey> comparer)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (resultSelector == null)
-                throw new ArgumentNullException(nameof(resultSelector));
+                throw Error.ArgumentNull(nameof(resultSelector));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return new GroupedResultAsyncEnumerableWithTask<TSource, TKey, TResult>(source, keySelector, resultSelector, comparer);
         }
@@ -162,13 +162,13 @@ namespace System.Linq
         public static IAsyncEnumerable<TResult> GroupBy<TSource, TKey, TElement, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, Func<TKey, IAsyncEnumerable<TElement>, TResult> resultSelector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (elementSelector == null)
-                throw new ArgumentNullException(nameof(elementSelector));
+                throw Error.ArgumentNull(nameof(elementSelector));
             if (resultSelector == null)
-                throw new ArgumentNullException(nameof(resultSelector));
+                throw Error.ArgumentNull(nameof(resultSelector));
 
             return source.GroupBy(keySelector, elementSelector, EqualityComparer<TKey>.Default).Select(g => resultSelector(g.Key, g));
         }
@@ -176,15 +176,15 @@ namespace System.Linq
         public static IAsyncEnumerable<TResult> GroupBy<TSource, TKey, TElement, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, Func<TKey, IAsyncEnumerable<TElement>, TResult> resultSelector, IEqualityComparer<TKey> comparer)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (elementSelector == null)
-                throw new ArgumentNullException(nameof(elementSelector));
+                throw Error.ArgumentNull(nameof(elementSelector));
             if (resultSelector == null)
-                throw new ArgumentNullException(nameof(resultSelector));
+                throw Error.ArgumentNull(nameof(resultSelector));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return source.GroupBy(keySelector, elementSelector, comparer).Select(g => resultSelector(g.Key, g));
         }
@@ -192,13 +192,13 @@ namespace System.Linq
         public static IAsyncEnumerable<TResult> GroupBy<TSource, TKey, TElement, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector, Func<TSource, Task<TElement>> elementSelector, Func<TKey, IAsyncEnumerable<TElement>, Task<TResult>> resultSelector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (elementSelector == null)
-                throw new ArgumentNullException(nameof(elementSelector));
+                throw Error.ArgumentNull(nameof(elementSelector));
             if (resultSelector == null)
-                throw new ArgumentNullException(nameof(resultSelector));
+                throw Error.ArgumentNull(nameof(resultSelector));
 
             return source.GroupBy(keySelector, elementSelector, EqualityComparer<TKey>.Default).Select(g => resultSelector(g.Key, g));
         }
@@ -206,15 +206,15 @@ namespace System.Linq
         public static IAsyncEnumerable<TResult> GroupBy<TSource, TKey, TElement, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector, Func<TSource, Task<TElement>> elementSelector, Func<TKey, IAsyncEnumerable<TElement>, Task<TResult>> resultSelector, IEqualityComparer<TKey> comparer)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (elementSelector == null)
-                throw new ArgumentNullException(nameof(elementSelector));
+                throw Error.ArgumentNull(nameof(elementSelector));
             if (resultSelector == null)
-                throw new ArgumentNullException(nameof(resultSelector));
+                throw Error.ArgumentNull(nameof(resultSelector));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return source.GroupBy(keySelector, elementSelector, comparer).Select(g => resultSelector(g.Key, g));
         }

+ 22 - 22
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs

@@ -13,15 +13,15 @@ namespace System.Linq
         public static IAsyncEnumerable<TResult> GroupJoin<TOuter, TInner, TKey, TResult>(this IAsyncEnumerable<TOuter> outer, IAsyncEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, IAsyncEnumerable<TInner>, TResult> resultSelector)
         {
             if (outer == null)
-                throw new ArgumentNullException(nameof(outer));
+                throw Error.ArgumentNull(nameof(outer));
             if (inner == null)
-                throw new ArgumentNullException(nameof(inner));
+                throw Error.ArgumentNull(nameof(inner));
             if (outerKeySelector == null)
-                throw new ArgumentNullException(nameof(outerKeySelector));
+                throw Error.ArgumentNull(nameof(outerKeySelector));
             if (innerKeySelector == null)
-                throw new ArgumentNullException(nameof(innerKeySelector));
+                throw Error.ArgumentNull(nameof(innerKeySelector));
             if (resultSelector == null)
-                throw new ArgumentNullException(nameof(resultSelector));
+                throw Error.ArgumentNull(nameof(resultSelector));
 
             return outer.GroupJoin(inner, outerKeySelector, innerKeySelector, resultSelector, EqualityComparer<TKey>.Default);
         }
@@ -29,17 +29,17 @@ namespace System.Linq
         public static IAsyncEnumerable<TResult> GroupJoin<TOuter, TInner, TKey, TResult>(this IAsyncEnumerable<TOuter> outer, IAsyncEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, IAsyncEnumerable<TInner>, TResult> resultSelector, IEqualityComparer<TKey> comparer)
         {
             if (outer == null)
-                throw new ArgumentNullException(nameof(outer));
+                throw Error.ArgumentNull(nameof(outer));
             if (inner == null)
-                throw new ArgumentNullException(nameof(inner));
+                throw Error.ArgumentNull(nameof(inner));
             if (outerKeySelector == null)
-                throw new ArgumentNullException(nameof(outerKeySelector));
+                throw Error.ArgumentNull(nameof(outerKeySelector));
             if (innerKeySelector == null)
-                throw new ArgumentNullException(nameof(innerKeySelector));
+                throw Error.ArgumentNull(nameof(innerKeySelector));
             if (resultSelector == null)
-                throw new ArgumentNullException(nameof(resultSelector));
+                throw Error.ArgumentNull(nameof(resultSelector));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return new GroupJoinAsyncEnumerable<TOuter, TInner, TKey, TResult>(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer);
         }
@@ -47,15 +47,15 @@ namespace System.Linq
         public static IAsyncEnumerable<TResult> GroupJoin<TOuter, TInner, TKey, TResult>(this IAsyncEnumerable<TOuter> outer, IAsyncEnumerable<TInner> inner, Func<TOuter, Task<TKey>> outerKeySelector, Func<TInner, Task<TKey>> innerKeySelector, Func<TOuter, IAsyncEnumerable<TInner>, Task<TResult>> resultSelector)
         {
             if (outer == null)
-                throw new ArgumentNullException(nameof(outer));
+                throw Error.ArgumentNull(nameof(outer));
             if (inner == null)
-                throw new ArgumentNullException(nameof(inner));
+                throw Error.ArgumentNull(nameof(inner));
             if (outerKeySelector == null)
-                throw new ArgumentNullException(nameof(outerKeySelector));
+                throw Error.ArgumentNull(nameof(outerKeySelector));
             if (innerKeySelector == null)
-                throw new ArgumentNullException(nameof(innerKeySelector));
+                throw Error.ArgumentNull(nameof(innerKeySelector));
             if (resultSelector == null)
-                throw new ArgumentNullException(nameof(resultSelector));
+                throw Error.ArgumentNull(nameof(resultSelector));
 
             return outer.GroupJoin(inner, outerKeySelector, innerKeySelector, resultSelector, EqualityComparer<TKey>.Default);
         }
@@ -63,17 +63,17 @@ namespace System.Linq
         public static IAsyncEnumerable<TResult> GroupJoin<TOuter, TInner, TKey, TResult>(this IAsyncEnumerable<TOuter> outer, IAsyncEnumerable<TInner> inner, Func<TOuter, Task<TKey>> outerKeySelector, Func<TInner, Task<TKey>> innerKeySelector, Func<TOuter, IAsyncEnumerable<TInner>, Task<TResult>> resultSelector, IEqualityComparer<TKey> comparer)
         {
             if (outer == null)
-                throw new ArgumentNullException(nameof(outer));
+                throw Error.ArgumentNull(nameof(outer));
             if (inner == null)
-                throw new ArgumentNullException(nameof(inner));
+                throw Error.ArgumentNull(nameof(inner));
             if (outerKeySelector == null)
-                throw new ArgumentNullException(nameof(outerKeySelector));
+                throw Error.ArgumentNull(nameof(outerKeySelector));
             if (innerKeySelector == null)
-                throw new ArgumentNullException(nameof(innerKeySelector));
+                throw Error.ArgumentNull(nameof(innerKeySelector));
             if (resultSelector == null)
-                throw new ArgumentNullException(nameof(resultSelector));
+                throw Error.ArgumentNull(nameof(resultSelector));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return new GroupJoinAsyncEnumerableWithTask<TOuter, TInner, TKey, TResult>(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer);
         }

+ 1 - 1
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Grouping.cs

@@ -76,7 +76,7 @@ namespace System.Linq.Internal
             {
                 if (index < 0 || index >= _count)
                 {
-                    throw new ArgumentOutOfRangeException(nameof(index));
+                    throw Error.ArgumentOutOfRange(nameof(index));
                 }
 
                 return _elements[index];

+ 5 - 5
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs

@@ -14,9 +14,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Intersect<TSource>(this IAsyncEnumerable<TSource> first, IAsyncEnumerable<TSource> second)
         {
             if (first == null)
-                throw new ArgumentNullException(nameof(first));
+                throw Error.ArgumentNull(nameof(first));
             if (second == null)
-                throw new ArgumentNullException(nameof(second));
+                throw Error.ArgumentNull(nameof(second));
 
             return first.Intersect(second, EqualityComparer<TSource>.Default);
         }
@@ -24,11 +24,11 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Intersect<TSource>(this IAsyncEnumerable<TSource> first, IAsyncEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
         {
             if (first == null)
-                throw new ArgumentNullException(nameof(first));
+                throw Error.ArgumentNull(nameof(first));
             if (second == null)
-                throw new ArgumentNullException(nameof(second));
+                throw Error.ArgumentNull(nameof(second));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return new IntersectAsyncIterator<TSource>(first, second, comparer);
         }

+ 22 - 22
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs

@@ -14,15 +14,15 @@ namespace System.Linq
         public static IAsyncEnumerable<TResult> Join<TOuter, TInner, TKey, TResult>(this IAsyncEnumerable<TOuter> outer, IAsyncEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector)
         {
             if (outer == null)
-                throw new ArgumentNullException(nameof(outer));
+                throw Error.ArgumentNull(nameof(outer));
             if (inner == null)
-                throw new ArgumentNullException(nameof(inner));
+                throw Error.ArgumentNull(nameof(inner));
             if (outerKeySelector == null)
-                throw new ArgumentNullException(nameof(outerKeySelector));
+                throw Error.ArgumentNull(nameof(outerKeySelector));
             if (innerKeySelector == null)
-                throw new ArgumentNullException(nameof(innerKeySelector));
+                throw Error.ArgumentNull(nameof(innerKeySelector));
             if (resultSelector == null)
-                throw new ArgumentNullException(nameof(resultSelector));
+                throw Error.ArgumentNull(nameof(resultSelector));
 
             return new JoinAsyncIterator<TOuter, TInner, TKey, TResult>(outer, inner, outerKeySelector, innerKeySelector, resultSelector, EqualityComparer<TKey>.Default);
         }
@@ -30,17 +30,17 @@ namespace System.Linq
         public static IAsyncEnumerable<TResult> Join<TOuter, TInner, TKey, TResult>(this IAsyncEnumerable<TOuter> outer, IAsyncEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector, IEqualityComparer<TKey> comparer)
         {
             if (outer == null)
-                throw new ArgumentNullException(nameof(outer));
+                throw Error.ArgumentNull(nameof(outer));
             if (inner == null)
-                throw new ArgumentNullException(nameof(inner));
+                throw Error.ArgumentNull(nameof(inner));
             if (outerKeySelector == null)
-                throw new ArgumentNullException(nameof(outerKeySelector));
+                throw Error.ArgumentNull(nameof(outerKeySelector));
             if (innerKeySelector == null)
-                throw new ArgumentNullException(nameof(innerKeySelector));
+                throw Error.ArgumentNull(nameof(innerKeySelector));
             if (resultSelector == null)
-                throw new ArgumentNullException(nameof(resultSelector));
+                throw Error.ArgumentNull(nameof(resultSelector));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return new JoinAsyncIterator<TOuter, TInner, TKey, TResult>(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer);
         }
@@ -48,15 +48,15 @@ namespace System.Linq
         public static IAsyncEnumerable<TResult> Join<TOuter, TInner, TKey, TResult>(this IAsyncEnumerable<TOuter> outer, IAsyncEnumerable<TInner> inner, Func<TOuter, Task<TKey>> outerKeySelector, Func<TInner, Task<TKey>> innerKeySelector, Func<TOuter, TInner, Task<TResult>> resultSelector)
         {
             if (outer == null)
-                throw new ArgumentNullException(nameof(outer));
+                throw Error.ArgumentNull(nameof(outer));
             if (inner == null)
-                throw new ArgumentNullException(nameof(inner));
+                throw Error.ArgumentNull(nameof(inner));
             if (outerKeySelector == null)
-                throw new ArgumentNullException(nameof(outerKeySelector));
+                throw Error.ArgumentNull(nameof(outerKeySelector));
             if (innerKeySelector == null)
-                throw new ArgumentNullException(nameof(innerKeySelector));
+                throw Error.ArgumentNull(nameof(innerKeySelector));
             if (resultSelector == null)
-                throw new ArgumentNullException(nameof(resultSelector));
+                throw Error.ArgumentNull(nameof(resultSelector));
 
             return new JoinAsyncIteratorWithTask<TOuter, TInner, TKey, TResult>(outer, inner, outerKeySelector, innerKeySelector, resultSelector, EqualityComparer<TKey>.Default);
         }
@@ -64,17 +64,17 @@ namespace System.Linq
         public static IAsyncEnumerable<TResult> Join<TOuter, TInner, TKey, TResult>(this IAsyncEnumerable<TOuter> outer, IAsyncEnumerable<TInner> inner, Func<TOuter, Task<TKey>> outerKeySelector, Func<TInner, Task<TKey>> innerKeySelector, Func<TOuter, TInner, Task<TResult>> resultSelector, IEqualityComparer<TKey> comparer)
         {
             if (outer == null)
-                throw new ArgumentNullException(nameof(outer));
+                throw Error.ArgumentNull(nameof(outer));
             if (inner == null)
-                throw new ArgumentNullException(nameof(inner));
+                throw Error.ArgumentNull(nameof(inner));
             if (outerKeySelector == null)
-                throw new ArgumentNullException(nameof(outerKeySelector));
+                throw Error.ArgumentNull(nameof(outerKeySelector));
             if (innerKeySelector == null)
-                throw new ArgumentNullException(nameof(innerKeySelector));
+                throw Error.ArgumentNull(nameof(innerKeySelector));
             if (resultSelector == null)
-                throw new ArgumentNullException(nameof(resultSelector));
+                throw Error.ArgumentNull(nameof(resultSelector));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return new JoinAsyncIteratorWithTask<TOuter, TInner, TKey, TResult>(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer);
         }

+ 13 - 13
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs

@@ -13,7 +13,7 @@ namespace System.Linq
         public static Task<TSource> Last<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return LastCore(source, CancellationToken.None);
         }
@@ -21,7 +21,7 @@ namespace System.Linq
         public static Task<TSource> Last<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return LastCore(source, cancellationToken);
         }
@@ -29,9 +29,9 @@ namespace System.Linq
         public static Task<TSource> Last<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return LastCore(source, predicate, CancellationToken.None);
         }
@@ -39,9 +39,9 @@ namespace System.Linq
         public static Task<TSource> Last<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return LastCore(source, predicate, cancellationToken);
         }
@@ -49,9 +49,9 @@ namespace System.Linq
         public static Task<TSource> Last<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return LastCore(source, predicate, CancellationToken.None);
         }
@@ -59,9 +59,9 @@ namespace System.Linq
         public static Task<TSource> Last<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return LastCore(source, predicate, cancellationToken);
         }
@@ -70,21 +70,21 @@ namespace System.Linq
         {
             var last = await TryGetLast(source, cancellationToken).ConfigureAwait(false);
 
-            return last.HasValue ? last.Value : throw new InvalidOperationException(Strings.NO_ELEMENTS);
+            return last.HasValue ? last.Value : throw Error.NoElements();
         }
 
         private static async Task<TSource> LastCore<TSource>(IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate, CancellationToken cancellationToken)
         {
             var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false);
 
-            return last.HasValue ? last.Value : throw new InvalidOperationException(Strings.NO_ELEMENTS);
+            return last.HasValue ? last.Value : throw Error.NoElements();
         }
 
         private static async Task<TSource> LastCore<TSource>(IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate, CancellationToken cancellationToken)
         {
             var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false);
 
-            return last.HasValue ? last.Value : throw new InvalidOperationException(Strings.NO_ELEMENTS);
+            return last.HasValue ? last.Value : throw Error.NoElements();
         }
     }
 }

+ 10 - 10
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs

@@ -13,7 +13,7 @@ namespace System.Linq
         public static Task<TSource> LastOrDefault<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return LastOrDefaultCore(source, CancellationToken.None);
         }
@@ -21,7 +21,7 @@ namespace System.Linq
         public static Task<TSource> LastOrDefault<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return LastOrDefaultCore(source, cancellationToken);
         }
@@ -29,9 +29,9 @@ namespace System.Linq
         public static Task<TSource> LastOrDefault<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return LastOrDefaultCore(source, predicate, CancellationToken.None);
         }
@@ -39,9 +39,9 @@ namespace System.Linq
         public static Task<TSource> LastOrDefault<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return LastOrDefaultCore(source, predicate, cancellationToken);
         }
@@ -49,9 +49,9 @@ namespace System.Linq
         public static Task<TSource> LastOrDefault<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return LastOrDefaultCore(source, predicate, CancellationToken.None);
         }
@@ -59,9 +59,9 @@ namespace System.Linq
         public static Task<TSource> LastOrDefault<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return LastOrDefaultCore(source, predicate, cancellationToken);
         }

+ 10 - 10
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs

@@ -13,7 +13,7 @@ namespace System.Linq
         public static Task<long> LongCount<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return LongCountCore(source, CancellationToken.None);
         }
@@ -21,7 +21,7 @@ namespace System.Linq
         public static Task<long> LongCount<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return LongCountCore(source, cancellationToken);
         }
@@ -29,9 +29,9 @@ namespace System.Linq
         public static Task<long> LongCount<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return LongCountCore(source, predicate, CancellationToken.None);
         }
@@ -39,9 +39,9 @@ namespace System.Linq
         public static Task<long> LongCount<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return LongCountCore(source, predicate, cancellationToken);
         }
@@ -49,9 +49,9 @@ namespace System.Linq
         public static Task<long> LongCount<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return LongCountCore(source, predicate, CancellationToken.None);
         }
@@ -59,9 +59,9 @@ namespace System.Linq
         public static Task<long> LongCount<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return LongCountCore(source, predicate, cancellationToken);
         }

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

@@ -53,7 +53,7 @@ namespace System.Linq
                 {
                     if (!await e.MoveNextAsync().ConfigureAwait(false))
                     {
-                        throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                        throw Error.NoElements();
                     }
 
                     value = e.Current;
@@ -118,7 +118,7 @@ namespace System.Linq
                 {
                     if (!await e.MoveNextAsync().ConfigureAwait(false))
                     {
-                        throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                        throw Error.NoElements();
                     }
 
                     value = selector(e.Current);
@@ -183,7 +183,7 @@ namespace System.Linq
                 {
                     if (!await e.MoveNextAsync().ConfigureAwait(false))
                     {
-                        throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                        throw Error.NoElements();
                     }
 
                     value = await selector(e.Current).ConfigureAwait(false);

+ 15 - 15
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Primitive.cs

@@ -20,7 +20,7 @@ namespace System.Linq
             {
                 if (!await e.MoveNextAsync().ConfigureAwait(false))
                 {
-                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    throw Error.NoElements();
                 }
 
                 value = e.Current;
@@ -115,7 +115,7 @@ namespace System.Linq
             {
                 if (!await e.MoveNextAsync().ConfigureAwait(false))
                 {
-                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    throw Error.NoElements();
                 }
 
                 value = e.Current;
@@ -204,7 +204,7 @@ namespace System.Linq
             {
                 if (!await e.MoveNextAsync().ConfigureAwait(false))
                 {
-                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    throw Error.NoElements();
                 }
 
                 value = e.Current;
@@ -306,7 +306,7 @@ namespace System.Linq
             {
                 if (!await e.MoveNextAsync().ConfigureAwait(false))
                 {
-                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    throw Error.NoElements();
                 }
 
                 value = e.Current;
@@ -403,7 +403,7 @@ namespace System.Linq
             {
                 if (!await e.MoveNextAsync().ConfigureAwait(false))
                 {
-                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    throw Error.NoElements();
                 }
 
                 value = e.Current;
@@ -473,7 +473,7 @@ namespace System.Linq
             {
                 if (!await e.MoveNextAsync().ConfigureAwait(false))
                 {
-                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    throw Error.NoElements();
                 }
 
                 value = selector(e.Current);
@@ -568,7 +568,7 @@ namespace System.Linq
             {
                 if (!await e.MoveNextAsync().ConfigureAwait(false))
                 {
-                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    throw Error.NoElements();
                 }
 
                 value = selector(e.Current);
@@ -657,7 +657,7 @@ namespace System.Linq
             {
                 if (!await e.MoveNextAsync().ConfigureAwait(false))
                 {
-                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    throw Error.NoElements();
                 }
 
                 value = selector(e.Current);
@@ -754,7 +754,7 @@ namespace System.Linq
             {
                 if (!await e.MoveNextAsync().ConfigureAwait(false))
                 {
-                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    throw Error.NoElements();
                 }
 
                 value = selector(e.Current);
@@ -856,7 +856,7 @@ namespace System.Linq
             {
                 if (!await e.MoveNextAsync().ConfigureAwait(false))
                 {
-                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    throw Error.NoElements();
                 }
 
                 value = selector(e.Current);
@@ -926,7 +926,7 @@ namespace System.Linq
             {
                 if (!await e.MoveNextAsync().ConfigureAwait(false))
                 {
-                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    throw Error.NoElements();
                 }
 
                 value = await selector(e.Current).ConfigureAwait(false);
@@ -1021,7 +1021,7 @@ namespace System.Linq
             {
                 if (!await e.MoveNextAsync().ConfigureAwait(false))
                 {
-                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    throw Error.NoElements();
                 }
 
                 value = await selector(e.Current).ConfigureAwait(false);
@@ -1110,7 +1110,7 @@ namespace System.Linq
             {
                 if (!await e.MoveNextAsync().ConfigureAwait(false))
                 {
-                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    throw Error.NoElements();
                 }
 
                 value = await selector(e.Current).ConfigureAwait(false);
@@ -1207,7 +1207,7 @@ namespace System.Linq
             {
                 if (!await e.MoveNextAsync().ConfigureAwait(false))
                 {
-                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    throw Error.NoElements();
                 }
 
                 value = await selector(e.Current).ConfigureAwait(false);
@@ -1309,7 +1309,7 @@ namespace System.Linq
             {
                 if (!await e.MoveNextAsync().ConfigureAwait(false))
                 {
-                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    throw Error.NoElements();
                 }
 
                 value = await selector(e.Current).ConfigureAwait(false);

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

@@ -13,7 +13,7 @@ namespace System.Linq
         public static Task<TSource> Max<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return MaxCore(source, CancellationToken.None);
         }
@@ -21,7 +21,7 @@ namespace System.Linq
         public static Task<TSource> Max<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return MaxCore(source, cancellationToken);
         }
@@ -29,9 +29,9 @@ namespace System.Linq
         public static Task<TResult> Max<TSource, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, TResult> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return MaxCore(source, selector, CancellationToken.None);
         }
@@ -39,9 +39,9 @@ namespace System.Linq
         public static Task<TResult> Max<TSource, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, TResult> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return MaxCore(source, selector, cancellationToken);
         }
@@ -49,9 +49,9 @@ namespace System.Linq
         public static Task<TResult> Max<TSource, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TResult>> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return MaxCore(source, selector, CancellationToken.None);
         }
@@ -59,9 +59,9 @@ namespace System.Linq
         public static Task<TResult> Max<TSource, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TResult>> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return MaxCore(source, selector, cancellationToken);
         }

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

@@ -53,7 +53,7 @@ namespace System.Linq
                 {
                     if (!await e.MoveNextAsync().ConfigureAwait(false))
                     {
-                        throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                        throw Error.NoElements();
                     }
 
                     value = e.Current;
@@ -118,7 +118,7 @@ namespace System.Linq
                 {
                     if (!await e.MoveNextAsync().ConfigureAwait(false))
                     {
-                        throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                        throw Error.NoElements();
                     }
 
                     value = selector(e.Current);
@@ -183,7 +183,7 @@ namespace System.Linq
                 {
                     if (!await e.MoveNextAsync().ConfigureAwait(false))
                     {
-                        throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                        throw Error.NoElements();
                     }
 
                     value = await selector(e.Current).ConfigureAwait(false);

+ 15 - 15
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Primitive.cs

@@ -20,7 +20,7 @@ namespace System.Linq
             {
                 if (!await e.MoveNextAsync().ConfigureAwait(false))
                 {
-                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    throw Error.NoElements();
                 }
 
                 value = e.Current;
@@ -97,7 +97,7 @@ namespace System.Linq
             {
                 if (!await e.MoveNextAsync().ConfigureAwait(false))
                 {
-                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    throw Error.NoElements();
                 }
 
                 value = e.Current;
@@ -170,7 +170,7 @@ namespace System.Linq
             {
                 if (!await e.MoveNextAsync().ConfigureAwait(false))
                 {
-                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    throw Error.NoElements();
                 }
 
                 value = e.Current;
@@ -260,7 +260,7 @@ namespace System.Linq
             {
                 if (!await e.MoveNextAsync().ConfigureAwait(false))
                 {
-                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    throw Error.NoElements();
                 }
 
                 value = e.Current;
@@ -341,7 +341,7 @@ namespace System.Linq
             {
                 if (!await e.MoveNextAsync().ConfigureAwait(false))
                 {
-                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    throw Error.NoElements();
                 }
 
                 value = e.Current;
@@ -411,7 +411,7 @@ namespace System.Linq
             {
                 if (!await e.MoveNextAsync().ConfigureAwait(false))
                 {
-                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    throw Error.NoElements();
                 }
 
                 value = selector(e.Current);
@@ -488,7 +488,7 @@ namespace System.Linq
             {
                 if (!await e.MoveNextAsync().ConfigureAwait(false))
                 {
-                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    throw Error.NoElements();
                 }
 
                 value = selector(e.Current);
@@ -561,7 +561,7 @@ namespace System.Linq
             {
                 if (!await e.MoveNextAsync().ConfigureAwait(false))
                 {
-                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    throw Error.NoElements();
                 }
 
                 value = selector(e.Current);
@@ -651,7 +651,7 @@ namespace System.Linq
             {
                 if (!await e.MoveNextAsync().ConfigureAwait(false))
                 {
-                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    throw Error.NoElements();
                 }
 
                 value = selector(e.Current);
@@ -732,7 +732,7 @@ namespace System.Linq
             {
                 if (!await e.MoveNextAsync().ConfigureAwait(false))
                 {
-                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    throw Error.NoElements();
                 }
 
                 value = selector(e.Current);
@@ -802,7 +802,7 @@ namespace System.Linq
             {
                 if (!await e.MoveNextAsync().ConfigureAwait(false))
                 {
-                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    throw Error.NoElements();
                 }
 
                 value = await selector(e.Current).ConfigureAwait(false);
@@ -879,7 +879,7 @@ namespace System.Linq
             {
                 if (!await e.MoveNextAsync().ConfigureAwait(false))
                 {
-                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    throw Error.NoElements();
                 }
 
                 value = await selector(e.Current).ConfigureAwait(false);
@@ -952,7 +952,7 @@ namespace System.Linq
             {
                 if (!await e.MoveNextAsync().ConfigureAwait(false))
                 {
-                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    throw Error.NoElements();
                 }
 
                 value = await selector(e.Current).ConfigureAwait(false);
@@ -1042,7 +1042,7 @@ namespace System.Linq
             {
                 if (!await e.MoveNextAsync().ConfigureAwait(false))
                 {
-                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    throw Error.NoElements();
                 }
 
                 value = await selector(e.Current).ConfigureAwait(false);
@@ -1123,7 +1123,7 @@ namespace System.Linq
             {
                 if (!await e.MoveNextAsync().ConfigureAwait(false))
                 {
-                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    throw Error.NoElements();
                 }
 
                 value = await selector(e.Current).ConfigureAwait(false);

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

@@ -13,7 +13,7 @@ namespace System.Linq
         public static Task<TSource> Min<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return MinCore(source, CancellationToken.None);
         }
@@ -21,7 +21,7 @@ namespace System.Linq
         public static Task<TSource> Min<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return MinCore(source, cancellationToken);
         }
@@ -29,9 +29,9 @@ namespace System.Linq
         public static Task<TResult> Min<TSource, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, TResult> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return MinCore(source, selector, CancellationToken.None);
         }
@@ -39,9 +39,9 @@ namespace System.Linq
         public static Task<TResult> Min<TSource, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, TResult> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return MinCore(source, selector, cancellationToken);
         }
@@ -49,9 +49,9 @@ namespace System.Linq
         public static Task<TResult> Min<TSource, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TResult>> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return MinCore(source, selector, CancellationToken.None);
         }
@@ -59,9 +59,9 @@ namespace System.Linq
         public static Task<TResult> Min<TSource, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TResult>> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return MinCore(source, selector, cancellationToken);
         }

文件差異過大導致無法顯示
+ 152 - 152
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs


+ 10 - 10
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt

@@ -25,7 +25,7 @@ foreach (var m in new[] { "Max", "Min" })
         public static Task<<#=t#>> <#=m#>(this IAsyncEnumerable<<#=t#>> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return <#=m#>Core(source, CancellationToken.None);
         }
@@ -33,7 +33,7 @@ foreach (var m in new[] { "Max", "Min" })
         public static Task<<#=t#>> <#=m#>(this IAsyncEnumerable<<#=t#>> source, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return <#=m#>Core(source, cancellationToken);
         }
@@ -41,9 +41,9 @@ foreach (var m in new[] { "Max", "Min" })
         public static Task<<#=t#>> <#=m#><TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, <#=t#>> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return <#=m#>Core(source, selector, CancellationToken.None);
         }
@@ -51,9 +51,9 @@ foreach (var m in new[] { "Max", "Min" })
         public static Task<<#=t#>> <#=m#><TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, <#=t#>> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return <#=m#>Core(source, selector, cancellationToken);
         }
@@ -61,9 +61,9 @@ foreach (var m in new[] { "Max", "Min" })
         public static Task<<#=t#>> <#=m#><TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<<#=t#>>> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return <#=m#>Core(source, selector, CancellationToken.None);
         }
@@ -71,9 +71,9 @@ foreach (var m in new[] { "Max", "Min" })
         public static Task<<#=t#>> <#=m#><TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<<#=t#>>> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return <#=m#>Core(source, selector, cancellationToken);
         }

+ 1 - 1
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs

@@ -11,7 +11,7 @@ namespace System.Linq
         public static IAsyncEnumerable<TType> OfType<TType>(this IAsyncEnumerable<object> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return source.Where(x => x is TType).Cast<TType>();
         }

+ 40 - 40
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs

@@ -12,9 +12,9 @@ namespace System.Linq
         public static IOrderedAsyncEnumerable<TSource> OrderBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
 
             return source.OrderBy(keySelector, Comparer<TKey>.Default);
         }
@@ -22,9 +22,9 @@ namespace System.Linq
         public static IOrderedAsyncEnumerable<TSource> OrderBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
 
             return source.OrderBy(keySelector, Comparer<TKey>.Default);
         }
@@ -32,22 +32,22 @@ namespace System.Linq
         public static IOrderedAsyncEnumerable<TSource> OrderBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return new OrderedAsyncEnumerable<TSource, TKey>(source, keySelector, comparer, descending: false, parent: null);
         }
         public static IOrderedAsyncEnumerable<TSource> OrderBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector, IComparer<TKey> comparer)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return new OrderedAsyncEnumerableWithTask<TSource, TKey>(source, keySelector, comparer, descending: false, parent: null);
         }
@@ -55,9 +55,9 @@ namespace System.Linq
         public static IOrderedAsyncEnumerable<TSource> OrderByDescending<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
 
             return source.OrderByDescending(keySelector, Comparer<TKey>.Default);
         }
@@ -65,9 +65,9 @@ namespace System.Linq
         public static IOrderedAsyncEnumerable<TSource> OrderByDescending<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
 
             return source.OrderByDescending(keySelector, Comparer<TKey>.Default);
         }
@@ -75,11 +75,11 @@ namespace System.Linq
         public static IOrderedAsyncEnumerable<TSource> OrderByDescending<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return new OrderedAsyncEnumerable<TSource, TKey>(source, keySelector, comparer, descending: true, parent: null);
         }
@@ -87,11 +87,11 @@ namespace System.Linq
         public static IOrderedAsyncEnumerable<TSource> OrderByDescending<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector, IComparer<TKey> comparer)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return new OrderedAsyncEnumerableWithTask<TSource, TKey>(source, keySelector, comparer, descending: true, parent: null);
         }
@@ -99,9 +99,9 @@ namespace System.Linq
         public static IOrderedAsyncEnumerable<TSource> ThenBy<TSource, TKey>(this IOrderedAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
 
             return source.ThenBy(keySelector, Comparer<TKey>.Default);
         }
@@ -109,9 +109,9 @@ namespace System.Linq
         public static IOrderedAsyncEnumerable<TSource> ThenBy<TSource, TKey>(this IOrderedAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
 
             return source.ThenBy(keySelector, Comparer<TKey>.Default);
         }
@@ -119,11 +119,11 @@ namespace System.Linq
         public static IOrderedAsyncEnumerable<TSource> ThenBy<TSource, TKey>(this IOrderedAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return source.CreateOrderedEnumerable(keySelector, comparer, descending: false);
         }
@@ -131,11 +131,11 @@ namespace System.Linq
         public static IOrderedAsyncEnumerable<TSource> ThenBy<TSource, TKey>(this IOrderedAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector, IComparer<TKey> comparer)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return source.CreateOrderedEnumerable(keySelector, comparer, descending: false);
         }
@@ -143,9 +143,9 @@ namespace System.Linq
         public static IOrderedAsyncEnumerable<TSource> ThenByDescending<TSource, TKey>(this IOrderedAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
 
             return source.ThenByDescending(keySelector, Comparer<TKey>.Default);
         }
@@ -153,9 +153,9 @@ namespace System.Linq
         public static IOrderedAsyncEnumerable<TSource> ThenByDescending<TSource, TKey>(this IOrderedAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
 
             return source.ThenByDescending(keySelector, Comparer<TKey>.Default);
         }
@@ -163,11 +163,11 @@ namespace System.Linq
         public static IOrderedAsyncEnumerable<TSource> ThenByDescending<TSource, TKey>(this IOrderedAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return source.CreateOrderedEnumerable(keySelector, comparer, descending: true);
         }
@@ -175,11 +175,11 @@ namespace System.Linq
         public static IOrderedAsyncEnumerable<TSource> ThenByDescending<TSource, TKey>(this IOrderedAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector, IComparer<TKey> comparer)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return source.CreateOrderedEnumerable(keySelector, comparer, descending: true);
         }

+ 2 - 2
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs

@@ -14,11 +14,11 @@ namespace System.Linq
         public static IAsyncEnumerable<int> Range(int start, int count)
         {
             if (count < 0)
-                throw new ArgumentOutOfRangeException(nameof(count));
+                throw Error.ArgumentOutOfRange(nameof(count));
 
             var end = (long)start + count - 1L;
             if (count < 0 || end > int.MaxValue)
-                throw new ArgumentOutOfRangeException(nameof(count));
+                throw Error.ArgumentOutOfRange(nameof(count));
 
             if (count == 0)
                 return Empty<int>();

+ 1 - 1
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs

@@ -13,7 +13,7 @@ namespace System.Linq
         public static IAsyncEnumerable<TResult> Repeat<TResult>(TResult element, int count)
         {
             if (count < 0)
-                throw new ArgumentOutOfRangeException(nameof(count));
+                throw Error.ArgumentOutOfRange(nameof(count));
 
             return new RepeatAsyncIterator<TResult>(element, count);
         }

+ 1 - 1
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs

@@ -16,7 +16,7 @@ namespace System.Linq
         {
             if (source == null)
             {
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             }
 
             return new ReverseAsyncIterator<TSource>(source);

+ 8 - 8
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs

@@ -14,9 +14,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TResult> Select<TSource, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, TResult> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             if (source is AsyncIterator<TSource> iterator)
             {
@@ -34,9 +34,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TResult> Select<TSource, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, int, TResult> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return new SelectEnumerableWithIndexAsyncIterator<TSource, TResult>(source, selector);
         }
@@ -44,9 +44,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TResult> Select<TSource, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TResult>> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             if (source is AsyncIterator<TSource> iterator)
             {
@@ -64,9 +64,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TResult> Select<TSource, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, int, Task<TResult>> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return new SelectEnumerableWithIndexAsyncIteratorWithTask<TSource, TResult>(source, selector);
         }

+ 20 - 20
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs

@@ -14,9 +14,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TResult> SelectMany<TSource, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, IAsyncEnumerable<TResult>> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return new SelectManyAsyncIterator<TSource, TResult>(source, selector);
         }
@@ -24,9 +24,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TResult> SelectMany<TSource, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<IAsyncEnumerable<TResult>>> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return new SelectManyAsyncIteratorWithTask<TSource, TResult>(source, selector);
         }
@@ -34,9 +34,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TResult> SelectMany<TSource, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, int, IAsyncEnumerable<TResult>> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return new SelectManyWithIndexAsyncIterator<TSource, TResult>(source, selector);
         }
@@ -44,9 +44,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TResult> SelectMany<TSource, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, int, Task<IAsyncEnumerable<TResult>>> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return new SelectManyWithIndexAsyncIteratorWithTask<TSource, TResult>(source, selector);
         }
@@ -54,11 +54,11 @@ namespace System.Linq
         public static IAsyncEnumerable<TResult> SelectMany<TSource, TCollection, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, IAsyncEnumerable<TCollection>> selector, Func<TSource, TCollection, TResult> resultSelector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
             if (resultSelector == null)
-                throw new ArgumentNullException(nameof(resultSelector));
+                throw Error.ArgumentNull(nameof(resultSelector));
 
             return new SelectManyAsyncIterator<TSource, TCollection, TResult>(source, selector, resultSelector);
         }
@@ -66,11 +66,11 @@ namespace System.Linq
         public static IAsyncEnumerable<TResult> SelectMany<TSource, TCollection, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<IAsyncEnumerable<TCollection>>> selector, Func<TSource, TCollection, Task<TResult>> resultSelector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
             if (resultSelector == null)
-                throw new ArgumentNullException(nameof(resultSelector));
+                throw Error.ArgumentNull(nameof(resultSelector));
 
             return new SelectManyAsyncIteratorWithTask<TSource, TCollection, TResult>(source, selector, resultSelector);
         }
@@ -78,11 +78,11 @@ namespace System.Linq
         public static IAsyncEnumerable<TResult> SelectMany<TSource, TCollection, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, int, IAsyncEnumerable<TCollection>> selector, Func<TSource, TCollection, TResult> resultSelector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
             if (resultSelector == null)
-                throw new ArgumentNullException(nameof(resultSelector));
+                throw Error.ArgumentNull(nameof(resultSelector));
 
             return new SelectManyWithIndexAsyncIterator<TSource, TCollection, TResult>(source, selector, resultSelector);
         }
@@ -90,11 +90,11 @@ namespace System.Linq
         public static IAsyncEnumerable<TResult> SelectMany<TSource, TCollection, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, int, Task<IAsyncEnumerable<TCollection>>> selector, Func<TSource, TCollection, Task<TResult>> resultSelector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
             if (resultSelector == null)
-                throw new ArgumentNullException(nameof(resultSelector));
+                throw Error.ArgumentNull(nameof(resultSelector));
 
             return new SelectManyWithIndexAsyncIteratorWithTask<TSource, TCollection, TResult>(source, selector, resultSelector);
         }

+ 10 - 10
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs

@@ -14,17 +14,17 @@ namespace System.Linq
         {
             if (first == null)
             {
-                throw new ArgumentNullException(nameof(first));
+                throw Error.ArgumentNull(nameof(first));
             }
 
             if (second == null)
             {
-                throw new ArgumentNullException(nameof(second));
+                throw Error.ArgumentNull(nameof(second));
             }
 
             if (comparer == null)
             {
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
             }
 
             return SequenceEqual(first, second, comparer, CancellationToken.None);
@@ -34,12 +34,12 @@ namespace System.Linq
         {
             if (first == null)
             {
-                throw new ArgumentNullException(nameof(first));
+                throw Error.ArgumentNull(nameof(first));
             }
 
             if (second == null)
             {
-                throw new ArgumentNullException(nameof(second));
+                throw Error.ArgumentNull(nameof(second));
             }
 
             return SequenceEqual(first, second, CancellationToken.None);
@@ -50,17 +50,17 @@ namespace System.Linq
         {
             if (first == null)
             {
-                throw new ArgumentNullException(nameof(first));
+                throw Error.ArgumentNull(nameof(first));
             }
 
             if (second == null)
             {
-                throw new ArgumentNullException(nameof(second));
+                throw Error.ArgumentNull(nameof(second));
             }
 
             if (comparer == null)
             {
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
             }
 
             return SequenceEqualCore(first, second, comparer, cancellationToken);
@@ -70,12 +70,12 @@ namespace System.Linq
         {
             if (first == null)
             {
-                throw new ArgumentNullException(nameof(first));
+                throw Error.ArgumentNull(nameof(first));
             }
 
             if (second == null)
             {
-                throw new ArgumentNullException(nameof(second));
+                throw Error.ArgumentNull(nameof(second));
             }
 
             return first.SequenceEqual(second, EqualityComparer<TSource>.Default, cancellationToken);

+ 18 - 18
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs

@@ -13,7 +13,7 @@ namespace System.Linq
         public static Task<TSource> Single<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return SingleCore(source, CancellationToken.None);
         }
@@ -21,7 +21,7 @@ namespace System.Linq
         public static Task<TSource> Single<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return SingleCore(source, cancellationToken);
         }
@@ -29,9 +29,9 @@ namespace System.Linq
         public static Task<TSource> Single<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return SingleCore(source, predicate, CancellationToken.None);
         }
@@ -39,9 +39,9 @@ namespace System.Linq
         public static Task<TSource> Single<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return SingleCore(source, predicate, cancellationToken);
         }
@@ -49,9 +49,9 @@ namespace System.Linq
         public static Task<TSource> Single<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return SingleCore(source, predicate, CancellationToken.None);
         }
@@ -59,9 +59,9 @@ namespace System.Linq
         public static Task<TSource> Single<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return SingleCore(source, predicate, cancellationToken);
         }
@@ -72,11 +72,11 @@ namespace System.Linq
             {
                 switch (list.Count)
                 {
-                    case 0: throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    case 0: throw Error.NoElements();
                     case 1: return list[0];
                 }
 
-                throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT);
+                throw Error.MoreThanOneElement();
             }
 
             var e = source.GetAsyncEnumerator(cancellationToken);
@@ -85,13 +85,13 @@ namespace System.Linq
             {
                 if (!await e.MoveNextAsync().ConfigureAwait(false))
                 {
-                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    throw Error.NoElements();
                 }
 
                 var result = e.Current;
                 if (await e.MoveNextAsync().ConfigureAwait(false))
                 {
-                    throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT);
+                    throw Error.MoreThanOneElement();
                 }
 
                 return result;
@@ -118,7 +118,7 @@ namespace System.Linq
                         {
                             if (predicate(e.Current))
                             {
-                                throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT);
+                                throw Error.MoreThanOneElement();
                             }
                         }
 
@@ -126,7 +126,7 @@ namespace System.Linq
                     }
                 }
 
-                throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                throw Error.NoElements();
             }
             finally
             {
@@ -150,7 +150,7 @@ namespace System.Linq
                         {
                             if (await predicate(e.Current).ConfigureAwait(false))
                             {
-                                throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT);
+                                throw Error.MoreThanOneElement();
                             }
                         }
 
@@ -158,7 +158,7 @@ namespace System.Linq
                     }
                 }
 
-                throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                throw Error.NoElements();
             }
             finally
             {

+ 14 - 14
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs

@@ -13,7 +13,7 @@ namespace System.Linq
         public static Task<TSource> SingleOrDefault<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return SingleOrDefaultCore(source, CancellationToken.None);
         }
@@ -21,7 +21,7 @@ namespace System.Linq
         public static Task<TSource> SingleOrDefault<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return SingleOrDefaultCore(source, cancellationToken);
         }
@@ -29,9 +29,9 @@ namespace System.Linq
         public static Task<TSource> SingleOrDefault<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return SingleOrDefaultCore(source, predicate, CancellationToken.None);
         }
@@ -39,9 +39,9 @@ namespace System.Linq
         public static Task<TSource> SingleOrDefault<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return SingleOrDefaultCore(source, predicate, cancellationToken);
         }
@@ -49,9 +49,9 @@ namespace System.Linq
         public static Task<TSource> SingleOrDefault<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return SingleOrDefaultCore(source, predicate, CancellationToken.None);
         }
@@ -59,9 +59,9 @@ namespace System.Linq
         public static Task<TSource> SingleOrDefault<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return SingleOrDefaultCore(source, predicate, cancellationToken);
         }
@@ -76,7 +76,7 @@ namespace System.Linq
                     case 1: return list[0];
                 }
 
-                throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT);
+                throw Error.MoreThanOneElement();
             }
 
             var e = source.GetAsyncEnumerator(cancellationToken);
@@ -100,7 +100,7 @@ namespace System.Linq
                 await e.DisposeAsync().ConfigureAwait(false);
             }
 
-            throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT);
+            throw Error.MoreThanOneElement();
         }
 
         private static async Task<TSource> SingleOrDefaultCore<TSource>(IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate, CancellationToken cancellationToken)
@@ -119,7 +119,7 @@ namespace System.Linq
                         {
                             if (predicate(e.Current))
                             {
-                                throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT);
+                                throw Error.MoreThanOneElement();
                             }
                         }
 
@@ -151,7 +151,7 @@ namespace System.Linq
                         {
                             if (await predicate(e.Current).ConfigureAwait(false))
                             {
-                                throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT);
+                                throw Error.MoreThanOneElement();
                             }
                         }
 

+ 1 - 1
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Skip.cs

@@ -11,7 +11,7 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Skip<TSource>(this IAsyncEnumerable<TSource> source, int count)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             if (count <= 0)
             {

+ 1 - 1
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs

@@ -14,7 +14,7 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> SkipLast<TSource>(this IAsyncEnumerable<TSource> source, int count)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             if (count <= 0)
             {

+ 8 - 8
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs

@@ -14,9 +14,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> SkipWhile<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return new SkipWhileAsyncIterator<TSource>(source, predicate);
         }
@@ -24,9 +24,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> SkipWhile<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int, bool> predicate)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return new SkipWhileWithIndexAsyncIterator<TSource>(source, predicate);
         }
@@ -34,9 +34,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> SkipWhile<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return new SkipWhileAsyncIteratorWithTask<TSource>(source, predicate);
         }
@@ -44,9 +44,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> SkipWhile<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int, Task<bool>> predicate)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return new SkipWhileWithIndexAsyncIteratorWithTask<TSource>(source, predicate);
         }

+ 100 - 100
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs

@@ -13,7 +13,7 @@ namespace System.Linq
         public static Task<int> Sum(this IAsyncEnumerable<int> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return SumCore(source, CancellationToken.None);
         }
@@ -21,7 +21,7 @@ namespace System.Linq
         public static Task<int> Sum(this IAsyncEnumerable<int> source, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return SumCore(source, cancellationToken);
         }
@@ -29,9 +29,9 @@ namespace System.Linq
         public static Task<int> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, CancellationToken.None);
         }
@@ -39,9 +39,9 @@ namespace System.Linq
         public static Task<int> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, cancellationToken);
         }
@@ -49,9 +49,9 @@ namespace System.Linq
         public static Task<int> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<int>> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, CancellationToken.None);
         }
@@ -59,9 +59,9 @@ namespace System.Linq
         public static Task<int> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<int>> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, cancellationToken);
         }
@@ -145,7 +145,7 @@ namespace System.Linq
         public static Task<long> Sum(this IAsyncEnumerable<long> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return SumCore(source, CancellationToken.None);
         }
@@ -153,7 +153,7 @@ namespace System.Linq
         public static Task<long> Sum(this IAsyncEnumerable<long> source, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return SumCore(source, cancellationToken);
         }
@@ -161,9 +161,9 @@ namespace System.Linq
         public static Task<long> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, CancellationToken.None);
         }
@@ -171,9 +171,9 @@ namespace System.Linq
         public static Task<long> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, cancellationToken);
         }
@@ -181,9 +181,9 @@ namespace System.Linq
         public static Task<long> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<long>> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, CancellationToken.None);
         }
@@ -191,9 +191,9 @@ namespace System.Linq
         public static Task<long> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<long>> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, cancellationToken);
         }
@@ -277,7 +277,7 @@ namespace System.Linq
         public static Task<float> Sum(this IAsyncEnumerable<float> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return SumCore(source, CancellationToken.None);
         }
@@ -285,7 +285,7 @@ namespace System.Linq
         public static Task<float> Sum(this IAsyncEnumerable<float> source, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return SumCore(source, cancellationToken);
         }
@@ -293,9 +293,9 @@ namespace System.Linq
         public static Task<float> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, CancellationToken.None);
         }
@@ -303,9 +303,9 @@ namespace System.Linq
         public static Task<float> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, cancellationToken);
         }
@@ -313,9 +313,9 @@ namespace System.Linq
         public static Task<float> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<float>> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, CancellationToken.None);
         }
@@ -323,9 +323,9 @@ namespace System.Linq
         public static Task<float> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<float>> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, cancellationToken);
         }
@@ -400,7 +400,7 @@ namespace System.Linq
         public static Task<double> Sum(this IAsyncEnumerable<double> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return SumCore(source, CancellationToken.None);
         }
@@ -408,7 +408,7 @@ namespace System.Linq
         public static Task<double> Sum(this IAsyncEnumerable<double> source, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return SumCore(source, cancellationToken);
         }
@@ -416,9 +416,9 @@ namespace System.Linq
         public static Task<double> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, CancellationToken.None);
         }
@@ -426,9 +426,9 @@ namespace System.Linq
         public static Task<double> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, cancellationToken);
         }
@@ -436,9 +436,9 @@ namespace System.Linq
         public static Task<double> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<double>> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, CancellationToken.None);
         }
@@ -446,9 +446,9 @@ namespace System.Linq
         public static Task<double> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<double>> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, cancellationToken);
         }
@@ -523,7 +523,7 @@ namespace System.Linq
         public static Task<decimal> Sum(this IAsyncEnumerable<decimal> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return SumCore(source, CancellationToken.None);
         }
@@ -531,7 +531,7 @@ namespace System.Linq
         public static Task<decimal> Sum(this IAsyncEnumerable<decimal> source, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return SumCore(source, cancellationToken);
         }
@@ -539,9 +539,9 @@ namespace System.Linq
         public static Task<decimal> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, CancellationToken.None);
         }
@@ -549,9 +549,9 @@ namespace System.Linq
         public static Task<decimal> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, cancellationToken);
         }
@@ -559,9 +559,9 @@ namespace System.Linq
         public static Task<decimal> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<decimal>> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, CancellationToken.None);
         }
@@ -569,9 +569,9 @@ namespace System.Linq
         public static Task<decimal> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<decimal>> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, cancellationToken);
         }
@@ -646,7 +646,7 @@ namespace System.Linq
         public static Task<int?> Sum(this IAsyncEnumerable<int?> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return SumCore(source, CancellationToken.None);
         }
@@ -654,7 +654,7 @@ namespace System.Linq
         public static Task<int?> Sum(this IAsyncEnumerable<int?> source, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return SumCore(source, cancellationToken);
         }
@@ -662,9 +662,9 @@ namespace System.Linq
         public static Task<int?> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int?> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, CancellationToken.None);
         }
@@ -672,9 +672,9 @@ namespace System.Linq
         public static Task<int?> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int?> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, cancellationToken);
         }
@@ -682,9 +682,9 @@ namespace System.Linq
         public static Task<int?> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<int?>> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, CancellationToken.None);
         }
@@ -692,9 +692,9 @@ namespace System.Linq
         public static Task<int?> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<int?>> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, cancellationToken);
         }
@@ -778,7 +778,7 @@ namespace System.Linq
         public static Task<long?> Sum(this IAsyncEnumerable<long?> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return SumCore(source, CancellationToken.None);
         }
@@ -786,7 +786,7 @@ namespace System.Linq
         public static Task<long?> Sum(this IAsyncEnumerable<long?> source, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return SumCore(source, cancellationToken);
         }
@@ -794,9 +794,9 @@ namespace System.Linq
         public static Task<long?> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long?> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, CancellationToken.None);
         }
@@ -804,9 +804,9 @@ namespace System.Linq
         public static Task<long?> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long?> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, cancellationToken);
         }
@@ -814,9 +814,9 @@ namespace System.Linq
         public static Task<long?> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<long?>> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, CancellationToken.None);
         }
@@ -824,9 +824,9 @@ namespace System.Linq
         public static Task<long?> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<long?>> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, cancellationToken);
         }
@@ -910,7 +910,7 @@ namespace System.Linq
         public static Task<float?> Sum(this IAsyncEnumerable<float?> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return SumCore(source, CancellationToken.None);
         }
@@ -918,7 +918,7 @@ namespace System.Linq
         public static Task<float?> Sum(this IAsyncEnumerable<float?> source, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return SumCore(source, cancellationToken);
         }
@@ -926,9 +926,9 @@ namespace System.Linq
         public static Task<float?> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float?> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, CancellationToken.None);
         }
@@ -936,9 +936,9 @@ namespace System.Linq
         public static Task<float?> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float?> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, cancellationToken);
         }
@@ -946,9 +946,9 @@ namespace System.Linq
         public static Task<float?> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<float?>> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, CancellationToken.None);
         }
@@ -956,9 +956,9 @@ namespace System.Linq
         public static Task<float?> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<float?>> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, cancellationToken);
         }
@@ -1033,7 +1033,7 @@ namespace System.Linq
         public static Task<double?> Sum(this IAsyncEnumerable<double?> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return SumCore(source, CancellationToken.None);
         }
@@ -1041,7 +1041,7 @@ namespace System.Linq
         public static Task<double?> Sum(this IAsyncEnumerable<double?> source, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return SumCore(source, cancellationToken);
         }
@@ -1049,9 +1049,9 @@ namespace System.Linq
         public static Task<double?> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double?> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, CancellationToken.None);
         }
@@ -1059,9 +1059,9 @@ namespace System.Linq
         public static Task<double?> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double?> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, cancellationToken);
         }
@@ -1069,9 +1069,9 @@ namespace System.Linq
         public static Task<double?> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<double?>> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, CancellationToken.None);
         }
@@ -1079,9 +1079,9 @@ namespace System.Linq
         public static Task<double?> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<double?>> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, cancellationToken);
         }
@@ -1156,7 +1156,7 @@ namespace System.Linq
         public static Task<decimal?> Sum(this IAsyncEnumerable<decimal?> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return SumCore(source, CancellationToken.None);
         }
@@ -1164,7 +1164,7 @@ namespace System.Linq
         public static Task<decimal?> Sum(this IAsyncEnumerable<decimal?> source, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return SumCore(source, cancellationToken);
         }
@@ -1172,9 +1172,9 @@ namespace System.Linq
         public static Task<decimal?> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal?> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, CancellationToken.None);
         }
@@ -1182,9 +1182,9 @@ namespace System.Linq
         public static Task<decimal?> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal?> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, cancellationToken);
         }
@@ -1192,9 +1192,9 @@ namespace System.Linq
         public static Task<decimal?> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<decimal?>> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, CancellationToken.None);
         }
@@ -1202,9 +1202,9 @@ namespace System.Linq
         public static Task<decimal?> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<decimal?>> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, cancellationToken);
         }

+ 10 - 10
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt

@@ -38,7 +38,7 @@ foreach (var o in os)
         public static Task<<#=o.type#>> Sum(this IAsyncEnumerable<<#=o.type#>> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return SumCore(source, CancellationToken.None);
         }
@@ -46,7 +46,7 @@ foreach (var o in os)
         public static Task<<#=o.type#>> Sum(this IAsyncEnumerable<<#=o.type#>> source, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return SumCore(source, cancellationToken);
         }
@@ -54,9 +54,9 @@ foreach (var o in os)
         public static Task<<#=o.type#>> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, <#=o.type#>> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, CancellationToken.None);
         }
@@ -64,9 +64,9 @@ foreach (var o in os)
         public static Task<<#=o.type#>> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, <#=o.type#>> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, cancellationToken);
         }
@@ -74,9 +74,9 @@ foreach (var o in os)
         public static Task<<#=o.type#>> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<<#=o.type#>>> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, CancellationToken.None);
         }
@@ -84,9 +84,9 @@ foreach (var o in os)
         public static Task<<#=o.type#>> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<<#=o.type#>>> selector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return SumCore(source, selector, cancellationToken);
         }

+ 1 - 1
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Take.cs

@@ -11,7 +11,7 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Take<TSource>(this IAsyncEnumerable<TSource> source, int count)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             if (count <= 0)
             {

+ 1 - 1
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs

@@ -14,7 +14,7 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> TakeLast<TSource>(this IAsyncEnumerable<TSource> source, int count)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             if (count <= 0)
             {

+ 8 - 8
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs

@@ -14,9 +14,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> TakeWhile<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return new TakeWhileAsyncIterator<TSource>(source, predicate);
         }
@@ -24,9 +24,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> TakeWhile<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int, bool> predicate)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return new TakeWhileWithIndexAsyncIterator<TSource>(source, predicate);
         }
@@ -34,9 +34,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> TakeWhile<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return new TakeWhileAsyncIteratorWithTask<TSource>(source, predicate);
         }
@@ -44,9 +44,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> TakeWhile<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int, Task<bool>> predicate)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return new TakeWhileWithIndexAsyncIteratorWithTask<TSource>(source, predicate);
         }

+ 2 - 2
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToArray.cs

@@ -13,7 +13,7 @@ namespace System.Linq
         public static Task<TSource[]> ToArray<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return ToArray(source, CancellationToken.None);
         }
@@ -21,7 +21,7 @@ namespace System.Linq
         public static Task<TSource[]> ToArray<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             if (source is IAsyncIListProvider<TSource> arrayProvider)
                 return arrayProvider.ToArrayAsync(cancellationToken);

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

@@ -15,7 +15,7 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> ToAsyncEnumerable<TSource>(this IEnumerable<TSource> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             // optimize these adapters for lists and collections
             if (source is IList<TSource> list)
@@ -30,7 +30,7 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> ToAsyncEnumerable<TSource>(this Task<TSource> task)
         {
             if (task == null)
-                throw new ArgumentNullException(nameof(task));
+                throw Error.ArgumentNull(nameof(task));
 
             return CreateEnumerable(
                 _ =>
@@ -56,7 +56,7 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> ToAsyncEnumerable<TSource>(this IObservable<TSource> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return CreateEnumerable(
                 ct =>

+ 48 - 48
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs

@@ -13,9 +13,9 @@ namespace System.Linq
         public static Task<Dictionary<TKey, TSource>> ToDictionary<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
 
             return ToDictionaryCore(source, keySelector, x => x, EqualityComparer<TKey>.Default, CancellationToken.None);
         }
@@ -23,9 +23,9 @@ namespace System.Linq
         public static Task<Dictionary<TKey, TSource>> ToDictionary<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
 
             return ToDictionaryCore(source, keySelector, x => x, EqualityComparer<TKey>.Default, cancellationToken);
         }
@@ -33,9 +33,9 @@ namespace System.Linq
         public static Task<Dictionary<TKey, TSource>> ToDictionary<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
 
             return ToDictionaryCore(source, keySelector, x => Task.FromResult(x), EqualityComparer<TKey>.Default, CancellationToken.None);
         }
@@ -43,9 +43,9 @@ namespace System.Linq
         public static Task<Dictionary<TKey, TSource>> ToDictionary<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
 
             return ToDictionaryCore(source, keySelector, x => Task.FromResult(x), EqualityComparer<TKey>.Default, cancellationToken);
         }
@@ -53,11 +53,11 @@ namespace System.Linq
         public static Task<Dictionary<TKey, TSource>> ToDictionary<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return ToDictionaryCore(source, keySelector, x => x, comparer, CancellationToken.None);
         }
@@ -65,11 +65,11 @@ namespace System.Linq
         public static Task<Dictionary<TKey, TSource>> ToDictionary<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return ToDictionaryCore(source, keySelector, x => x, comparer, cancellationToken);
         }
@@ -77,11 +77,11 @@ namespace System.Linq
         public static Task<Dictionary<TKey, TSource>> ToDictionary<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector, IEqualityComparer<TKey> comparer)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return ToDictionaryCore(source, keySelector, x => Task.FromResult(x), comparer, CancellationToken.None);
         }
@@ -89,11 +89,11 @@ namespace System.Linq
         public static Task<Dictionary<TKey, TSource>> ToDictionary<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return ToDictionaryCore(source, keySelector, x => Task.FromResult(x), comparer, cancellationToken);
         }
@@ -101,11 +101,11 @@ namespace System.Linq
         public static Task<Dictionary<TKey, TElement>> ToDictionary<TSource, TKey, TElement>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (elementSelector == null)
-                throw new ArgumentNullException(nameof(elementSelector));
+                throw Error.ArgumentNull(nameof(elementSelector));
 
             return ToDictionaryCore(source, keySelector, elementSelector, EqualityComparer<TKey>.Default, CancellationToken.None);
         }
@@ -113,11 +113,11 @@ namespace System.Linq
         public static Task<Dictionary<TKey, TElement>> ToDictionary<TSource, TKey, TElement>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (elementSelector == null)
-                throw new ArgumentNullException(nameof(elementSelector));
+                throw Error.ArgumentNull(nameof(elementSelector));
 
             return ToDictionaryCore(source, keySelector, elementSelector, EqualityComparer<TKey>.Default, cancellationToken);
         }
@@ -125,11 +125,11 @@ namespace System.Linq
         public static Task<Dictionary<TKey, TElement>> ToDictionary<TSource, TKey, TElement>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector, Func<TSource, Task<TElement>> elementSelector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (elementSelector == null)
-                throw new ArgumentNullException(nameof(elementSelector));
+                throw Error.ArgumentNull(nameof(elementSelector));
 
             return ToDictionaryCore(source, keySelector, elementSelector, EqualityComparer<TKey>.Default, CancellationToken.None);
         }
@@ -137,11 +137,11 @@ namespace System.Linq
         public static Task<Dictionary<TKey, TElement>> ToDictionary<TSource, TKey, TElement>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector, Func<TSource, Task<TElement>> elementSelector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (elementSelector == null)
-                throw new ArgumentNullException(nameof(elementSelector));
+                throw Error.ArgumentNull(nameof(elementSelector));
 
             return ToDictionaryCore(source, keySelector, elementSelector, EqualityComparer<TKey>.Default, cancellationToken);
         }
@@ -149,13 +149,13 @@ namespace System.Linq
         public static Task<Dictionary<TKey, TElement>> ToDictionary<TSource, TKey, TElement>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (elementSelector == null)
-                throw new ArgumentNullException(nameof(elementSelector));
+                throw Error.ArgumentNull(nameof(elementSelector));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return ToDictionaryCore(source, keySelector, elementSelector, comparer, CancellationToken.None);
         }
@@ -163,13 +163,13 @@ namespace System.Linq
         public static Task<Dictionary<TKey, TElement>> ToDictionary<TSource, TKey, TElement>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (elementSelector == null)
-                throw new ArgumentNullException(nameof(elementSelector));
+                throw Error.ArgumentNull(nameof(elementSelector));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return ToDictionaryCore(source, keySelector, elementSelector, comparer, cancellationToken);
         }
@@ -177,13 +177,13 @@ namespace System.Linq
         public static Task<Dictionary<TKey, TElement>> ToDictionary<TSource, TKey, TElement>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector, Func<TSource, Task<TElement>> elementSelector, IEqualityComparer<TKey> comparer)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (elementSelector == null)
-                throw new ArgumentNullException(nameof(elementSelector));
+                throw Error.ArgumentNull(nameof(elementSelector));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return ToDictionaryCore(source, keySelector, elementSelector, comparer, CancellationToken.None);
         }
@@ -191,13 +191,13 @@ namespace System.Linq
         public static Task<Dictionary<TKey, TElement>> ToDictionary<TSource, TKey, TElement>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector, Func<TSource, Task<TElement>> elementSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (elementSelector == null)
-                throw new ArgumentNullException(nameof(elementSelector));
+                throw Error.ArgumentNull(nameof(elementSelector));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return ToDictionaryCore(source, keySelector, elementSelector, comparer, cancellationToken);
         }

+ 1 - 1
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToEnumerable.cs

@@ -11,7 +11,7 @@ namespace System.Linq
         public static IEnumerable<TSource> ToEnumerable<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return ToEnumerableCore(source);
         }

+ 6 - 6
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs

@@ -13,7 +13,7 @@ namespace System.Linq
         public static Task<HashSet<TSource>> ToHashSet<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return ToHashSetCore(source, EqualityComparer<TSource>.Default, CancellationToken.None);
         }
@@ -21,7 +21,7 @@ namespace System.Linq
         public static Task<HashSet<TSource>> ToHashSet<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return ToHashSetCore(source, EqualityComparer<TSource>.Default, cancellationToken);
         }
@@ -29,9 +29,9 @@ namespace System.Linq
         public static Task<HashSet<TSource>> ToHashSet<TSource>(this IAsyncEnumerable<TSource> source, IEqualityComparer<TSource> comparer)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return ToHashSetCore(source, comparer, CancellationToken.None);
         }
@@ -39,9 +39,9 @@ namespace System.Linq
         public static Task<HashSet<TSource>> ToHashSet<TSource>(this IAsyncEnumerable<TSource> source, IEqualityComparer<TSource> comparer, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return ToHashSetCore(source, comparer, cancellationToken);
         }

+ 2 - 2
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs

@@ -13,7 +13,7 @@ namespace System.Linq
         public static Task<List<TSource>> ToList<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return ToListCore(source, CancellationToken.None);
         }
@@ -21,7 +21,7 @@ namespace System.Linq
         public static Task<List<TSource>> ToList<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return ToListCore(source, cancellationToken);
         }

+ 48 - 48
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs

@@ -15,9 +15,9 @@ namespace System.Linq
         public static Task<ILookup<TKey, TSource>> ToLookup<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
 
             return ToLookup(source, keySelector, CancellationToken.None);
         }
@@ -25,9 +25,9 @@ namespace System.Linq
         public static Task<ILookup<TKey, TSource>> ToLookup<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
 
             return source.ToLookup(keySelector, x => x, EqualityComparer<TKey>.Default, cancellationToken);
         }
@@ -35,9 +35,9 @@ namespace System.Linq
         public static Task<ILookup<TKey, TSource>> ToLookup<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
 
             return ToLookup(source, keySelector, CancellationToken.None);
         }
@@ -45,9 +45,9 @@ namespace System.Linq
         public static Task<ILookup<TKey, TSource>> ToLookup<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
 
             return source.ToLookup(keySelector, x => Task.FromResult(x), EqualityComparer<TKey>.Default, cancellationToken);
         }
@@ -55,11 +55,11 @@ namespace System.Linq
         public static Task<ILookup<TKey, TSource>> ToLookup<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return ToLookup(source, keySelector, comparer, CancellationToken.None);
         }
@@ -67,11 +67,11 @@ namespace System.Linq
         public static Task<ILookup<TKey, TSource>> ToLookup<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return source.ToLookup(keySelector, x => x, comparer, cancellationToken);
         }
@@ -79,11 +79,11 @@ namespace System.Linq
         public static Task<ILookup<TKey, TSource>> ToLookup<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector, IEqualityComparer<TKey> comparer)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return ToLookup(source, keySelector, comparer, CancellationToken.None);
         }
@@ -91,11 +91,11 @@ namespace System.Linq
         public static Task<ILookup<TKey, TSource>> ToLookup<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return source.ToLookup(keySelector, x => Task.FromResult(x), comparer, cancellationToken);
         }
@@ -103,11 +103,11 @@ namespace System.Linq
         public static Task<ILookup<TKey, TElement>> ToLookup<TSource, TKey, TElement>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (elementSelector == null)
-                throw new ArgumentNullException(nameof(elementSelector));
+                throw Error.ArgumentNull(nameof(elementSelector));
 
             return ToLookup(source, keySelector, elementSelector, CancellationToken.None);
         }
@@ -115,11 +115,11 @@ namespace System.Linq
         public static Task<ILookup<TKey, TElement>> ToLookup<TSource, TKey, TElement>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (elementSelector == null)
-                throw new ArgumentNullException(nameof(elementSelector));
+                throw Error.ArgumentNull(nameof(elementSelector));
 
             return source.ToLookup(keySelector, elementSelector, EqualityComparer<TKey>.Default, cancellationToken);
         }
@@ -127,11 +127,11 @@ namespace System.Linq
         public static Task<ILookup<TKey, TElement>> ToLookup<TSource, TKey, TElement>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector, Func<TSource, Task<TElement>> elementSelector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (elementSelector == null)
-                throw new ArgumentNullException(nameof(elementSelector));
+                throw Error.ArgumentNull(nameof(elementSelector));
 
             return ToLookup(source, keySelector, elementSelector, CancellationToken.None);
         }
@@ -139,11 +139,11 @@ namespace System.Linq
         public static Task<ILookup<TKey, TElement>> ToLookup<TSource, TKey, TElement>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector, Func<TSource, Task<TElement>> elementSelector, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (elementSelector == null)
-                throw new ArgumentNullException(nameof(elementSelector));
+                throw Error.ArgumentNull(nameof(elementSelector));
 
             return source.ToLookup(keySelector, elementSelector, EqualityComparer<TKey>.Default, cancellationToken);
         }
@@ -151,13 +151,13 @@ namespace System.Linq
         public static Task<ILookup<TKey, TElement>> ToLookup<TSource, TKey, TElement>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (elementSelector == null)
-                throw new ArgumentNullException(nameof(elementSelector));
+                throw Error.ArgumentNull(nameof(elementSelector));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return ToLookup(source, keySelector, elementSelector, comparer, CancellationToken.None);
         }
@@ -165,13 +165,13 @@ namespace System.Linq
         public static async Task<ILookup<TKey, TElement>> ToLookup<TSource, TKey, TElement>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (elementSelector == null)
-                throw new ArgumentNullException(nameof(elementSelector));
+                throw Error.ArgumentNull(nameof(elementSelector));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             var lookup = await Internal.Lookup<TKey, TElement>.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false);
 
@@ -181,13 +181,13 @@ namespace System.Linq
         public static Task<ILookup<TKey, TElement>> ToLookup<TSource, TKey, TElement>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector, Func<TSource, Task<TElement>> elementSelector, IEqualityComparer<TKey> comparer)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (elementSelector == null)
-                throw new ArgumentNullException(nameof(elementSelector));
+                throw Error.ArgumentNull(nameof(elementSelector));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return ToLookup(source, keySelector, elementSelector, comparer, CancellationToken.None);
         }
@@ -195,13 +195,13 @@ namespace System.Linq
         public static async Task<ILookup<TKey, TElement>> ToLookup<TSource, TKey, TElement>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector, Func<TSource, Task<TElement>> elementSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (keySelector == null)
-                throw new ArgumentNullException(nameof(keySelector));
+                throw Error.ArgumentNull(nameof(keySelector));
             if (elementSelector == null)
-                throw new ArgumentNullException(nameof(elementSelector));
+                throw Error.ArgumentNull(nameof(elementSelector));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             var lookup = await Internal.LookupWithTask<TKey, TElement>.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false);
 

+ 1 - 1
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToObservable.cs

@@ -11,7 +11,7 @@ namespace System.Linq
         public static IObservable<TSource> ToObservable<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return new ToObservableObservable<TSource>(source);
         }

+ 5 - 5
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs

@@ -14,9 +14,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Union<TSource>(this IAsyncEnumerable<TSource> first, IAsyncEnumerable<TSource> second)
         {
             if (first == null)
-                throw new ArgumentNullException(nameof(first));
+                throw Error.ArgumentNull(nameof(first));
             if (second == null)
-                throw new ArgumentNullException(nameof(second));
+                throw Error.ArgumentNull(nameof(second));
 
             return first.Union(second, EqualityComparer<TSource>.Default);
         }
@@ -24,11 +24,11 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Union<TSource>(this IAsyncEnumerable<TSource> first, IAsyncEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
         {
             if (first == null)
-                throw new ArgumentNullException(nameof(first));
+                throw Error.ArgumentNull(nameof(first));
             if (second == null)
-                throw new ArgumentNullException(nameof(second));
+                throw Error.ArgumentNull(nameof(second));
             if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
+                throw Error.ArgumentNull(nameof(comparer));
 
             return first is UnionAsyncIterator<TSource> union && AreEqualityComparersEqual(comparer, union._comparer) ? union.Union(second) : new UnionAsyncIterator2<TSource>(first, second, comparer);
         }

+ 8 - 8
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs

@@ -15,12 +15,12 @@ namespace System.Linq
         {
             if (source == null)
             {
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             }
 
             if (predicate == null)
             {
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
             }
 
             if (source is AsyncIterator<TSource> iterator)
@@ -36,12 +36,12 @@ namespace System.Linq
         {
             if (source == null)
             {
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             }
 
             if (predicate == null)
             {
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
             }
 
             return new WhereEnumerableWithIndexAsyncIterator<TSource>(source, predicate);
@@ -50,9 +50,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Where<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             if (source is AsyncIterator<TSource> iterator)
             {
@@ -66,9 +66,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Where<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int, Task<bool>> predicate)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (predicate == null)
-                throw new ArgumentNullException(nameof(predicate));
+                throw Error.ArgumentNull(nameof(predicate));
 
             return new WhereEnumerableWithIndexAsyncIteratorWithTask<TSource>(source, predicate);
         }

+ 6 - 6
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs

@@ -14,11 +14,11 @@ namespace System.Linq
         public static IAsyncEnumerable<TResult> Zip<TFirst, TSecond, TResult>(this IAsyncEnumerable<TFirst> first, IAsyncEnumerable<TSecond> second, Func<TFirst, TSecond, TResult> selector)
         {
             if (first == null)
-                throw new ArgumentNullException(nameof(first));
+                throw Error.ArgumentNull(nameof(first));
             if (second == null)
-                throw new ArgumentNullException(nameof(second));
+                throw Error.ArgumentNull(nameof(second));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return new ZipAsyncIterator<TFirst, TSecond, TResult>(first, second, selector);
         }
@@ -26,11 +26,11 @@ namespace System.Linq
         public static IAsyncEnumerable<TResult> Zip<TFirst, TSecond, TResult>(this IAsyncEnumerable<TFirst> first, IAsyncEnumerable<TSecond> second, Func<TFirst, TSecond, Task<TResult>> selector)
         {
             if (first == null)
-                throw new ArgumentNullException(nameof(first));
+                throw Error.ArgumentNull(nameof(first));
             if (second == null)
-                throw new ArgumentNullException(nameof(second));
+                throw Error.ArgumentNull(nameof(second));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return new ZipAsyncIteratorWithTask<TFirst, TSecond, TResult>(first, second, selector);
         }

+ 1 - 1
Ix.NET/Source/System.Linq.Async/System/Linq/Strings.cs → Ix.NET/Source/System.Linq.Async/System/Strings.cs

@@ -2,7 +2,7 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-namespace System.Linq
+namespace System
 {
     internal static class Strings
     {

+ 1 - 1
Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs

@@ -14,7 +14,7 @@ namespace System.Threading.Tasks
             public static ConfiguredAsyncEnumerable<T> ConfigureAwait<T>(this IAsyncEnumerable<T> enumerable, bool continueOnCapturedContext)
             {
                 if (enumerable == null)
-                    throw new ArgumentNullException(nameof(enumerable));
+                    throw Error.ArgumentNull(nameof(enumerable));
 
                 return new ConfiguredAsyncEnumerable<T>(enumerable, continueOnCapturedContext);
             }

部分文件因文件數量過多而無法顯示