Browse Source

Share some code and streamline exceptions.

Bart De Smet 7 years ago
parent
commit
07a9483ed7
30 changed files with 159 additions and 252 deletions
  1. 6 0
      Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj
  2. 4 4
      Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs
  3. 5 5
      Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs
  4. 8 8
      Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs
  5. 3 3
      Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs
  6. 2 2
      Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs
  7. 9 9
      Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs
  8. 11 11
      Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs
  9. 26 26
      Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs
  10. 4 4
      Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs
  11. 4 4
      Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs
  12. 3 3
      Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs
  13. 1 1
      Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs
  14. 2 2
      Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs
  15. 3 3
      Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs
  16. 16 16
      Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs
  17. 3 3
      Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs
  18. 3 3
      Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs
  19. 18 18
      Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs
  20. 4 4
      Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/OnErrorResumeNext.cs
  21. 3 3
      Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs
  22. 3 3
      Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Retry.cs
  23. 8 8
      Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs
  24. 2 2
      Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/SelectMany.cs
  25. 1 1
      Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/StartWith.cs
  26. 1 1
      Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs
  27. 2 2
      Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs
  28. 4 4
      Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs
  29. 0 86
      Ix.NET/Source/System.Interactive.Async/System/Linq/Set.cs
  30. 0 13
      Ix.NET/Source/System.Interactive.Async/System/Linq/Strings.cs

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

@@ -7,6 +7,12 @@
     <PackageTags>Ix;Interactive;Extensions;Enumerable;Asynchronous</PackageTags>
   </PropertyGroup>
 
+  <ItemGroup>
+    <Compile Include="..\System.Linq.Async\System\Error.cs" Link="System\Error.cs" />
+    <Compile Include="..\System.Linq.Async\System\Linq\Set.cs" Link="System\Linq\Set.cs" />
+    <Compile Include="..\System.Linq.Async\System\Strings.cs" Link="System\Strings.cs" />
+  </ItemGroup>
+
   <ItemGroup>
     <EmbeddedResource Include="Properties\System.Interactive.Async.rd.xml" />
   </ItemGroup>

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

@@ -14,9 +14,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Amb<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 new AmbAsyncIterator<TSource>(first, second);
         }
@@ -24,7 +24,7 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Amb<TSource>(params IAsyncEnumerable<TSource>[] sources)
         {
             if (sources == null)
-                throw new ArgumentNullException(nameof(sources));
+                throw Error.ArgumentNull(nameof(sources));
 
             return new AmbAsyncIteratorN<TSource>(sources);
         }
@@ -32,7 +32,7 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Amb<TSource>(this IEnumerable<IAsyncEnumerable<TSource>> sources)
         {
             if (sources == null)
-                throw new ArgumentNullException(nameof(sources));
+                throw Error.ArgumentNull(nameof(sources));
 
             return new AmbAsyncIteratorN<TSource>(sources.ToArray());
         }

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

@@ -14,9 +14,9 @@ namespace System.Linq
         public static IAsyncEnumerable<IList<TSource>> Buffer<TSource>(this IAsyncEnumerable<TSource> source, int count)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (count <= 0)
-                throw new ArgumentOutOfRangeException(nameof(count));
+                throw Error.ArgumentOutOfRange(nameof(count));
 
             return new BufferAsyncIterator<TSource>(source, count, count);
         }
@@ -24,11 +24,11 @@ namespace System.Linq
         public static IAsyncEnumerable<IList<TSource>> Buffer<TSource>(this IAsyncEnumerable<TSource> source, int count, int skip)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (count <= 0)
-                throw new ArgumentOutOfRangeException(nameof(count));
+                throw Error.ArgumentOutOfRange(nameof(count));
             if (skip <= 0)
-                throw new ArgumentOutOfRangeException(nameof(skip));
+                throw Error.ArgumentOutOfRange(nameof(skip));
 
             return new BufferAsyncIterator<TSource>(source, count, skip);
         }

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

@@ -16,9 +16,9 @@ namespace System.Linq
             where TException : Exception
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (handler == null)
-                throw new ArgumentNullException(nameof(handler));
+                throw Error.ArgumentNull(nameof(handler));
 
             return new CatchAsyncIterator<TSource, TException>(source, handler);
         }
@@ -27,9 +27,9 @@ namespace System.Linq
             where TException : Exception
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (handler == null)
-                throw new ArgumentNullException(nameof(handler));
+                throw Error.ArgumentNull(nameof(handler));
 
             return new CatchAsyncIteratorWithTask<TSource, TException>(source, handler);
         }
@@ -37,7 +37,7 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Catch<TSource>(this IEnumerable<IAsyncEnumerable<TSource>> sources)
         {
             if (sources == null)
-                throw new ArgumentNullException(nameof(sources));
+                throw Error.ArgumentNull(nameof(sources));
 
             return CatchCore(sources);
         }
@@ -45,7 +45,7 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Catch<TSource>(params IAsyncEnumerable<TSource>[] sources)
         {
             if (sources == null)
-                throw new ArgumentNullException(nameof(sources));
+                throw Error.ArgumentNull(nameof(sources));
 
             return CatchCore(sources);
         }
@@ -53,9 +53,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Catch<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 CatchCore(new[] { first, second });
         }

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

@@ -14,7 +14,7 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Concat<TSource>(this IAsyncEnumerable<IAsyncEnumerable<TSource>> sources)
         {
             if (sources == null)
-                throw new ArgumentNullException(nameof(sources));
+                throw Error.ArgumentNull(nameof(sources));
 
             return new ConcatAsyncEnumerableAsyncIterator<TSource>(sources);
         }
@@ -22,7 +22,7 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Concat<TSource>(this IEnumerable<IAsyncEnumerable<TSource>> sources)
         {
             if (sources == null)
-                throw new ArgumentNullException(nameof(sources));
+                throw Error.ArgumentNull(nameof(sources));
 
             return ConcatCore(sources);
         }
@@ -30,7 +30,7 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Concat<TSource>(params IAsyncEnumerable<TSource>[] sources)
         {
             if (sources == null)
-                throw new ArgumentNullException(nameof(sources));
+                throw Error.ArgumentNull(nameof(sources));
 
             return ConcatCore(sources);
         }

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

@@ -15,7 +15,7 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Defer<TSource>(Func<IAsyncEnumerable<TSource>> factory)
         {
             if (factory == null)
-                throw new ArgumentNullException(nameof(factory));
+                throw Error.ArgumentNull(nameof(factory));
 
             return CreateEnumerable(ct => factory().GetAsyncEnumerator(ct));
         }
@@ -23,7 +23,7 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Defer<TSource>(Func<Task<IAsyncEnumerable<TSource>>> factory)
         {
             if (factory == null)
-                throw new ArgumentNullException(nameof(factory));
+                throw Error.ArgumentNull(nameof(factory));
 
             return new AnonymousAsyncEnumerableWithTask<TSource>(async ct => (await factory().ConfigureAwait(false)).GetAsyncEnumerator(ct));
         }

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

@@ -14,9 +14,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Distinct<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 DistinctCore(source, keySelector, comparer: null);
         }
@@ -24,9 +24,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Distinct<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));
 
             return DistinctCore(source, keySelector, comparer);
         }
@@ -34,9 +34,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Distinct<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 DistinctCore<TSource, TKey>(source, keySelector, comparer: null);
         }
@@ -44,11 +44,11 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Distinct<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 DistinctCore(source, keySelector, comparer);
         }

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

@@ -14,7 +14,7 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> DistinctUntilChanged<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return DistinctUntilChangedCore(source, comparer: null);
         }
@@ -22,7 +22,7 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> DistinctUntilChanged<TSource>(this IAsyncEnumerable<TSource> source, IEqualityComparer<TSource> comparer)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return DistinctUntilChangedCore(source, comparer);
         }
@@ -30,9 +30,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> DistinctUntilChanged<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 DistinctUntilChangedCore(source, keySelector, comparer: null);
         }
@@ -40,9 +40,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> DistinctUntilChanged<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));
 
             return DistinctUntilChangedCore(source, keySelector, comparer);
         }
@@ -50,9 +50,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> DistinctUntilChanged<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 DistinctUntilChangedCore<TSource, TKey>(source, keySelector, comparer: null);
         }
@@ -60,11 +60,11 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> DistinctUntilChanged<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 DistinctUntilChangedCore(source, keySelector, comparer);
         }

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

@@ -14,9 +14,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Do<TSource>(this IAsyncEnumerable<TSource> source, Action<TSource> onNext)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (onNext == null)
-                throw new ArgumentNullException(nameof(onNext));
+                throw Error.ArgumentNull(nameof(onNext));
 
             return DoCore(source, onNext: onNext, onError: null, onCompleted: null);
         }
@@ -24,11 +24,11 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Do<TSource>(this IAsyncEnumerable<TSource> source, Action<TSource> onNext, Action onCompleted)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (onNext == null)
-                throw new ArgumentNullException(nameof(onNext));
+                throw Error.ArgumentNull(nameof(onNext));
             if (onCompleted == null)
-                throw new ArgumentNullException(nameof(onCompleted));
+                throw Error.ArgumentNull(nameof(onCompleted));
 
             return DoCore(source, onNext: onNext, onError: null, onCompleted: onCompleted);
         }
@@ -36,11 +36,11 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Do<TSource>(this IAsyncEnumerable<TSource> source, Action<TSource> onNext, Action<Exception> onError)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (onNext == null)
-                throw new ArgumentNullException(nameof(onNext));
+                throw Error.ArgumentNull(nameof(onNext));
             if (onError == null)
-                throw new ArgumentNullException(nameof(onError));
+                throw Error.ArgumentNull(nameof(onError));
 
             return DoCore(source, onNext: onNext, onError: onError, onCompleted: null);
         }
@@ -48,13 +48,13 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Do<TSource>(this IAsyncEnumerable<TSource> source, Action<TSource> onNext, Action<Exception> onError, Action onCompleted)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (onNext == null)
-                throw new ArgumentNullException(nameof(onNext));
+                throw Error.ArgumentNull(nameof(onNext));
             if (onError == null)
-                throw new ArgumentNullException(nameof(onError));
+                throw Error.ArgumentNull(nameof(onError));
             if (onCompleted == null)
-                throw new ArgumentNullException(nameof(onCompleted));
+                throw Error.ArgumentNull(nameof(onCompleted));
 
             return DoCore(source, onNext, onError, onCompleted);
         }
@@ -62,9 +62,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Do<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task> onNext)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (onNext == null)
-                throw new ArgumentNullException(nameof(onNext));
+                throw Error.ArgumentNull(nameof(onNext));
 
             return DoCore(source, onNext: onNext, onError: null, onCompleted: null);
         }
@@ -72,11 +72,11 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Do<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task> onNext, Func<Task> onCompleted)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (onNext == null)
-                throw new ArgumentNullException(nameof(onNext));
+                throw Error.ArgumentNull(nameof(onNext));
             if (onCompleted == null)
-                throw new ArgumentNullException(nameof(onCompleted));
+                throw Error.ArgumentNull(nameof(onCompleted));
 
             return DoCore(source, onNext: onNext, onError: null, onCompleted: onCompleted);
         }
@@ -84,11 +84,11 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Do<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task> onNext, Func<Exception, Task> onError)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (onNext == null)
-                throw new ArgumentNullException(nameof(onNext));
+                throw Error.ArgumentNull(nameof(onNext));
             if (onError == null)
-                throw new ArgumentNullException(nameof(onError));
+                throw Error.ArgumentNull(nameof(onError));
 
             return DoCore(source, onNext: onNext, onError: onError, onCompleted: null);
         }
@@ -96,13 +96,13 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Do<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task> onNext, Func<Exception, Task> onError, Func<Task> onCompleted)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (onNext == null)
-                throw new ArgumentNullException(nameof(onNext));
+                throw Error.ArgumentNull(nameof(onNext));
             if (onError == null)
-                throw new ArgumentNullException(nameof(onError));
+                throw Error.ArgumentNull(nameof(onError));
             if (onCompleted == null)
-                throw new ArgumentNullException(nameof(onCompleted));
+                throw Error.ArgumentNull(nameof(onCompleted));
 
             return DoCore(source, onNext, onError, onCompleted);
         }
@@ -110,9 +110,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Do<TSource>(this IAsyncEnumerable<TSource> source, IObserver<TSource> observer)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (observer == null)
-                throw new ArgumentNullException(nameof(observer));
+                throw Error.ArgumentNull(nameof(observer));
 
             return DoCore(source, new Action<TSource>(observer.OnNext), new Action<Exception>(observer.OnError), new Action(observer.OnCompleted));
         }

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

@@ -14,9 +14,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Expand<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, IAsyncEnumerable<TSource>> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return new ExpandAsyncIterator<TSource>(source, selector);
         }
@@ -24,9 +24,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Expand<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<IAsyncEnumerable<TSource>>> selector)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (selector == null)
-                throw new ArgumentNullException(nameof(selector));
+                throw Error.ArgumentNull(nameof(selector));
 
             return new ExpandAsyncIteratorWithTask<TSource>(source, selector);
         }

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

@@ -14,9 +14,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Finally<TSource>(this IAsyncEnumerable<TSource> source, Action finallyAction)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (finallyAction == null)
-                throw new ArgumentNullException(nameof(finallyAction));
+                throw Error.ArgumentNull(nameof(finallyAction));
 
             return new FinallyAsyncIterator<TSource>(source, finallyAction);
         }
@@ -24,9 +24,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Finally<TSource>(this IAsyncEnumerable<TSource> source, Func<Task> finallyAction)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (finallyAction == null)
-                throw new ArgumentNullException(nameof(finallyAction));
+                throw Error.ArgumentNull(nameof(finallyAction));
 
             return new FinallyAsyncIteratorWithTask<TSource>(source, finallyAction);
         }

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

@@ -14,11 +14,11 @@ namespace System.Linq
         public static IAsyncEnumerable<TResult> Generate<TState, TResult>(TState initialState, Func<TState, bool> condition, Func<TState, TState> iterate, Func<TState, TResult> resultSelector)
         {
             if (condition == null)
-                throw new ArgumentNullException(nameof(condition));
+                throw Error.ArgumentNull(nameof(condition));
             if (iterate == null)
-                throw new ArgumentNullException(nameof(iterate));
+                throw Error.ArgumentNull(nameof(iterate));
             if (resultSelector == null)
-                throw new ArgumentNullException(nameof(resultSelector));
+                throw Error.ArgumentNull(nameof(resultSelector));
 
             return new GenerateAsyncIterator<TState, TResult>(initialState, condition, iterate, resultSelector);
         }

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

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

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

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

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

@@ -13,7 +13,7 @@ namespace System.Linq
         public static Task<TSource> Max<TSource>(this IAsyncEnumerable<TSource> source, IComparer<TSource> comparer)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return MaxCore(source, comparer, CancellationToken.None);
         }
@@ -21,7 +21,7 @@ namespace System.Linq
         public static Task<TSource> Max<TSource>(this IAsyncEnumerable<TSource> source, IComparer<TSource> comparer, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             
             return MaxCore(source, comparer, cancellationToken);
         }
@@ -38,7 +38,7 @@ namespace System.Linq
             try
             {
                 if (!await e.MoveNextAsync().ConfigureAwait(false))
-                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    throw Error.NoElements();
 
                 var max = e.Current;
 

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

@@ -13,9 +13,9 @@ namespace System.Linq
         public static Task<IList<TSource>> MaxBy<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 MaxByCore(source, keySelector, comparer: null, CancellationToken.None);
         }
@@ -23,9 +23,9 @@ namespace System.Linq
         public static Task<IList<TSource>> MaxBy<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 MaxByCore(source, keySelector, comparer: null, cancellationToken);
         }
@@ -33,9 +33,9 @@ namespace System.Linq
         public static Task<IList<TSource>> MaxBy<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));
 
             return MaxByCore(source, keySelector, comparer, CancellationToken.None);
         }
@@ -43,9 +43,9 @@ namespace System.Linq
         public static Task<IList<TSource>> MaxBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IComparer<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));
 
             return MaxByCore(source, keySelector, comparer, cancellationToken);
         }
@@ -53,9 +53,9 @@ namespace System.Linq
         public static Task<IList<TSource>> MaxBy<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 MaxByCore<TSource, TKey>(source, keySelector, comparer: null, CancellationToken.None);
         }
@@ -63,9 +63,9 @@ namespace System.Linq
         public static Task<IList<TSource>> MaxBy<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 MaxByCore<TSource, TKey>(source, keySelector, comparer: null, cancellationToken);
         }
@@ -73,9 +73,9 @@ namespace System.Linq
         public static Task<IList<TSource>> MaxBy<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));
 
             return MaxByCore(source, keySelector, comparer, CancellationToken.None);
         }
@@ -83,9 +83,9 @@ namespace System.Linq
         public static Task<IList<TSource>> MaxBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector, IComparer<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));
 
             return MaxByCore(source, keySelector, comparer, cancellationToken);
         }

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

@@ -14,7 +14,7 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Merge<TSource>(params IAsyncEnumerable<TSource>[] sources)
         {
             if (sources == null)
-                throw new ArgumentNullException(nameof(sources));
+                throw Error.ArgumentNull(nameof(sources));
 
             return new MergeAsyncIterator<TSource>(sources);
         }
@@ -22,7 +22,7 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Merge<TSource>(this IEnumerable<IAsyncEnumerable<TSource>> sources)
         {
             if (sources == null)
-                throw new ArgumentNullException(nameof(sources));
+                throw Error.ArgumentNull(nameof(sources));
 
             return sources.ToAsyncEnumerable().SelectMany(source => source);
         }
@@ -30,7 +30,7 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Merge<TSource>(this IAsyncEnumerable<IAsyncEnumerable<TSource>> sources)
         {
             if (sources == null)
-                throw new ArgumentNullException(nameof(sources));
+                throw Error.ArgumentNull(nameof(sources));
 
             return sources.SelectMany(source => source);
         }

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

@@ -13,7 +13,7 @@ namespace System.Linq
         public static Task<TSource> Min<TSource>(this IAsyncEnumerable<TSource> source, IComparer<TSource> comparer)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return MinCore(source, comparer, CancellationToken.None);
         }
@@ -21,7 +21,7 @@ namespace System.Linq
         public static Task<TSource> Min<TSource>(this IAsyncEnumerable<TSource> source, IComparer<TSource> comparer, CancellationToken cancellationToken)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return MinCore(source, comparer, cancellationToken);
         }
@@ -38,7 +38,7 @@ namespace System.Linq
             try
             {
                 if (!await e.MoveNextAsync().ConfigureAwait(false))
-                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    throw Error.NoElements();
 
                 var min = e.Current;
 

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

@@ -13,9 +13,9 @@ namespace System.Linq
         public static Task<IList<TSource>> MinBy<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 MinByCore(source, keySelector, comparer: null, CancellationToken.None);
         }
@@ -23,9 +23,9 @@ namespace System.Linq
         public static Task<IList<TSource>> MinBy<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 MinByCore(source, keySelector, comparer: null, cancellationToken);
         }
@@ -33,9 +33,9 @@ namespace System.Linq
         public static Task<IList<TSource>> MinBy<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));
 
             return MinByCore(source, keySelector, comparer, CancellationToken.None);
         }
@@ -43,9 +43,9 @@ namespace System.Linq
         public static Task<IList<TSource>> MinBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IComparer<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));
 
             return MinByCore(source, keySelector, comparer, cancellationToken);
         }
@@ -53,9 +53,9 @@ namespace System.Linq
         public static Task<IList<TSource>> MinBy<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 MinByCore<TSource, TKey>(source, keySelector, comparer: null, CancellationToken.None);
         }
@@ -63,9 +63,9 @@ namespace System.Linq
         public static Task<IList<TSource>> MinBy<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 MinByCore<TSource, TKey>(source, keySelector, comparer: null, cancellationToken);
         }
@@ -73,9 +73,9 @@ namespace System.Linq
         public static Task<IList<TSource>> MinBy<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));
 
             return MinByCore(source, keySelector, comparer, CancellationToken.None);
         }
@@ -83,9 +83,9 @@ namespace System.Linq
         public static Task<IList<TSource>> MinBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TKey>> keySelector, IComparer<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));
 
             return MinByCore(source, keySelector, comparer, cancellationToken);
         }
@@ -119,7 +119,7 @@ namespace System.Linq
             try
             {
                 if (!await e.MoveNextAsync().ConfigureAwait(false))
-                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    throw Error.NoElements();
 
                 var current = e.Current;
                 var resKey = keySelector(current);
@@ -159,7 +159,7 @@ namespace System.Linq
             try
             {
                 if (!await e.MoveNextAsync().ConfigureAwait(false))
-                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                    throw Error.NoElements();
 
                 var current = e.Current;
                 var resKey = await keySelector(current).ConfigureAwait(false);

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

@@ -14,9 +14,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> OnErrorResumeNext<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 OnErrorResumeNextCore(new[] { first, second });
         }
@@ -24,7 +24,7 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> OnErrorResumeNext<TSource>(params IAsyncEnumerable<TSource>[] sources)
         {
             if (sources == null)
-                throw new ArgumentNullException(nameof(sources));
+                throw Error.ArgumentNull(nameof(sources));
 
             return OnErrorResumeNextCore(sources);
         }
@@ -32,7 +32,7 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> OnErrorResumeNext<TSource>(this IEnumerable<IAsyncEnumerable<TSource>> sources)
         {
             if (sources == null)
-                throw new ArgumentNullException(nameof(sources));
+                throw Error.ArgumentNull(nameof(sources));
 
             return OnErrorResumeNextCore(sources);
         }

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

@@ -19,7 +19,7 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Repeat<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return new RepeatSequenceAsyncIterator<TSource>(source, -1);
         }
@@ -27,9 +27,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Repeat<TSource>(this IAsyncEnumerable<TSource> source, int count)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (count < 0)
-                throw new ArgumentOutOfRangeException(nameof(count));
+                throw Error.ArgumentOutOfRange(nameof(count));
 
             return new RepeatSequenceAsyncIterator<TSource>(source, count);
         }

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

@@ -11,7 +11,7 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Retry<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return new[] { source }.Repeat().Catch();
         }
@@ -19,9 +19,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Retry<TSource>(this IAsyncEnumerable<TSource> source, int retryCount)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (retryCount < 0)
-                throw new ArgumentOutOfRangeException(nameof(retryCount));
+                throw Error.ArgumentOutOfRange(nameof(retryCount));
 
             return new[] { source }.Repeat(retryCount).Catch();
         }

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

@@ -14,9 +14,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Scan<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 new ScanAsyncEnumerable<TSource>(source, accumulator);
         }
@@ -24,9 +24,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TAccumulate> Scan<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 new ScanAsyncEnumerable<TSource, TAccumulate>(source, seed, accumulator);
         }
@@ -34,9 +34,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Scan<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 new ScanAsyncEnumerableWithTask<TSource>(source, accumulator);
         }
@@ -44,9 +44,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TAccumulate> Scan<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 new ScanAsyncEnumerableWithTask<TSource, TAccumulate>(source, seed, accumulator);
         }

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

@@ -11,9 +11,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TOther> SelectMany<TSource, TOther>(this IAsyncEnumerable<TSource> source, IAsyncEnumerable<TOther> other)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
             if (other == null)
-                throw new ArgumentNullException(nameof(other));
+                throw Error.ArgumentNull(nameof(other));
 
             return source.SelectMany(_ => other);
         }

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

@@ -11,7 +11,7 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> StartWith<TSource>(this IAsyncEnumerable<TSource> source, params TSource[] values)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             return values.ToAsyncEnumerable().Concat(source);
         }

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

@@ -12,7 +12,7 @@ namespace System.Linq
         public 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>();

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

@@ -14,11 +14,11 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Timeout<TSource>(this IAsyncEnumerable<TSource> source, TimeSpan timeout)
         {
             if (source == null)
-                throw new ArgumentNullException(nameof(source));
+                throw Error.ArgumentNull(nameof(source));
 
             var num = (long)timeout.TotalMilliseconds;
             if (num < -1L || num > int.MaxValue)
-                throw new ArgumentOutOfRangeException(nameof(timeout));
+                throw Error.ArgumentOutOfRange(nameof(timeout));
 
             return new TimeoutAsyncIterator<TSource>(source, timeout);
         }

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

@@ -14,9 +14,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Using<TSource, TResource>(Func<TResource> resourceFactory, Func<TResource, IAsyncEnumerable<TSource>> enumerableFactory) where TResource : IDisposable
         {
             if (resourceFactory == null)
-                throw new ArgumentNullException(nameof(resourceFactory));
+                throw Error.ArgumentNull(nameof(resourceFactory));
             if (enumerableFactory == null)
-                throw new ArgumentNullException(nameof(enumerableFactory));
+                throw Error.ArgumentNull(nameof(enumerableFactory));
 
             return new UsingAsyncIterator<TSource, TResource>(resourceFactory, enumerableFactory);
         }
@@ -24,9 +24,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Using<TSource, TResource>(Func<Task<TResource>> resourceFactory, Func<TResource, Task<IAsyncEnumerable<TSource>>> enumerableFactory) where TResource : IDisposable
         {
             if (resourceFactory == null)
-                throw new ArgumentNullException(nameof(resourceFactory));
+                throw Error.ArgumentNull(nameof(resourceFactory));
             if (enumerableFactory == null)
-                throw new ArgumentNullException(nameof(enumerableFactory));
+                throw Error.ArgumentNull(nameof(enumerableFactory));
 
             return new UsingAsyncIteratorWithTask<TSource, TResource>(resourceFactory, enumerableFactory);
         }

+ 0 - 86
Ix.NET/Source/System.Interactive.Async/System/Linq/Set.cs

@@ -1,86 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the Apache 2.0 License.
-// See the LICENSE file in the project root for more information. 
-
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
-
-// from https://github.com/dotnet/corefx/blob/ec2685715b01d12f16b08d0dfa326649b12db8ec/src/System.Linq/src/System/Linq/Set.cs
-namespace System.Linq
-{
-    [ExcludeFromCodeCoverage]
-    internal sealed class Set<TElement>
-    {
-        private readonly IEqualityComparer<TElement> _comparer;
-        private int[] _buckets;
-
-        private Slot[] _slots;
-
-        public Set(IEqualityComparer<TElement> comparer)
-        {
-            _comparer = comparer ?? EqualityComparer<TElement>.Default;
-            _buckets = new int[7];
-            _slots = new Slot[7];
-        }
-
-        internal int Count { get; private set; }
-
-        // If value is not in set, add it and return true; otherwise return false
-        public bool Add(TElement value)
-        {
-            var hashCode = InternalGetHashCode(value);
-            for (var i = _buckets[hashCode%_buckets.Length] - 1; i >= 0; i = _slots[i]._next)
-            {
-                if (_slots[i]._hashCode == hashCode && _comparer.Equals(_slots[i]._value, value))
-                {
-                    return false;
-                }
-            }
-
-            if (Count == _slots.Length)
-            {
-                Resize();
-            }
-
-            var index = Count;
-            Count++;
-            var bucket = hashCode%_buckets.Length;
-            _slots[index]._hashCode = hashCode;
-            _slots[index]._value = value;
-            _slots[index]._next = _buckets[bucket] - 1;
-            _buckets[bucket] = index + 1;
-            return true;
-        }
-
-        internal int InternalGetHashCode(TElement value)
-        {
-            // Handle comparer implementations that throw when passed null
-            return (value == null) ? 0 : _comparer.GetHashCode(value) & 0x7FFFFFFF;
-        }
-
-        private void Resize()
-        {
-            var newSize = checked((Count*2) + 1);
-            var newBuckets = new int[newSize];
-            var newSlots = new Slot[newSize];
-            Array.Copy(_slots, 0, newSlots, 0, Count);
-            for (var i = 0; i < Count; i++)
-            {
-                var bucket = newSlots[i]._hashCode%newSize;
-                newSlots[i]._next = newBuckets[bucket] - 1;
-                newBuckets[bucket] = i + 1;
-            }
-
-            _buckets = newBuckets;
-            _slots = newSlots;
-        }
-
-        internal struct Slot
-        {
-            internal int _hashCode;
-            internal int _next;
-            internal TElement _value;
-        }
-    }
-}

+ 0 - 13
Ix.NET/Source/System.Interactive.Async/System/Linq/Strings.cs

@@ -1,13 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the Apache 2.0 License.
-// See the LICENSE file in the project root for more information. 
-
-namespace System.Linq
-{
-    internal static class Strings
-    {
-        public static string NO_ELEMENTS = "Source sequence doesn't contain any elements.";
-        public static string MORE_THAN_ONE_ELEMENT = "Source sequence contains more than one element.";
-        public static string NOT_SUPPORTED = "Specified method is not supported.";
-    }
-}