瀏覽代碼

Merge pull request #721 from dotnet/ix-formatting

Ix formatting
Daniel C. Weber 7 年之前
父節點
當前提交
5e77cabaac
共有 100 個文件被更改,包括 2432 次插入493 次删除
  1. 2 1
      Ix.NET/Source/Directory.build.props
  2. 1 2
      Ix.NET/Source/System.Interactive.Async.Providers/AsyncEnumerableQuery.cs
  3. 5 6
      Ix.NET/Source/System.Interactive.Async.Providers/AsyncEnumerableRewriter.cs
  4. 2 0
      Ix.NET/Source/System.Interactive.Async.Providers/AsyncQueryable.cs
  5. 0 2
      Ix.NET/Source/System.Interactive.Async.Providers/Properties/AssemblyInfo.cs
  6. 2 2
      Ix.NET/Source/System.Interactive.Async.Providers/Reflection.cs
  7. 26 26
      Ix.NET/Source/System.Interactive.Async.Tests/AppendPrependTests.cs
  8. 2 2
      Ix.NET/Source/System.Interactive.Async.Tests/AssertEx.cs
  9. 27 23
      Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs
  10. 14 15
      Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs
  11. 9 11
      Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Conversions.cs
  12. 11 12
      Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs
  13. 14 15
      Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs
  14. 39 17
      Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs
  15. 112 67
      Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs
  16. 1 5
      Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.cs
  17. 1 1
      Ix.NET/Source/System.Interactive.Async.Tests/TaskExtTests.cs
  18. 39 2
      Ix.NET/Source/System.Interactive.Async/Aggregate.cs
  19. 28 2
      Ix.NET/Source/System.Interactive.Async/AnyAll.cs
  20. 11 10
      Ix.NET/Source/System.Interactive.Async/AppendPrepend.cs
  21. 9 3
      Ix.NET/Source/System.Interactive.Async/AsyncEnumerable.cs
  22. 3 3
      Ix.NET/Source/System.Interactive.Async/AsyncEnumerator.cs
  23. 4 1
      Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs
  24. 152 12
      Ix.NET/Source/System.Interactive.Async/Average.cs
  25. 13 0
      Ix.NET/Source/System.Interactive.Async/Buffer.cs
  26. 4 3
      Ix.NET/Source/System.Interactive.Async/Cast.cs
  27. 16 2
      Ix.NET/Source/System.Interactive.Async/Catch.cs
  28. 15 7
      Ix.NET/Source/System.Interactive.Async/Concatenate.cs
  29. 14 2
      Ix.NET/Source/System.Interactive.Async/Contains.cs
  30. 28 2
      Ix.NET/Source/System.Interactive.Async/Count.cs
  31. 4 0
      Ix.NET/Source/System.Interactive.Async/Create.cs
  32. 6 2
      Ix.NET/Source/System.Interactive.Async/DefaultIfEmpty.cs
  33. 2 3
      Ix.NET/Source/System.Interactive.Async/Defer.cs
  34. 3 3
      Ix.NET/Source/System.Interactive.Async/Disposables.cs
  35. 42 2
      Ix.NET/Source/System.Interactive.Async/Distinct.cs
  36. 37 0
      Ix.NET/Source/System.Interactive.Async/Do.cs
  37. 15 3
      Ix.NET/Source/System.Interactive.Async/ElementAt.cs
  38. 14 1
      Ix.NET/Source/System.Interactive.Async/Except.cs
  39. 5 0
      Ix.NET/Source/System.Interactive.Async/Expand.cs
  40. 7 4
      Ix.NET/Source/System.Interactive.Async/Finally.cs
  41. 29 3
      Ix.NET/Source/System.Interactive.Async/First.cs
  42. 40 2
      Ix.NET/Source/System.Interactive.Async/ForEach.cs
  43. 9 1
      Ix.NET/Source/System.Interactive.Async/Generate.cs
  44. 32 4
      Ix.NET/Source/System.Interactive.Async/GroupJoin.cs
  45. 78 3
      Ix.NET/Source/System.Interactive.Async/Grouping.cs
  46. 0 4
      Ix.NET/Source/System.Interactive.Async/IAsyncEnumerable.cs
  47. 0 3
      Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs
  48. 0 3
      Ix.NET/Source/System.Interactive.Async/IAsyncGrouping.cs
  49. 2 4
      Ix.NET/Source/System.Interactive.Async/IIListProvider.cs
  50. 0 1
      Ix.NET/Source/System.Interactive.Async/IOrderedAsyncEnumerable.cs
  51. 2 0
      Ix.NET/Source/System.Interactive.Async/IgnoreElements.cs
  52. 13 0
      Ix.NET/Source/System.Interactive.Async/Intersect.cs
  53. 43 13
      Ix.NET/Source/System.Interactive.Async/Join.cs
  54. 32 3
      Ix.NET/Source/System.Interactive.Async/Last.cs
  55. 71 9
      Ix.NET/Source/System.Interactive.Async/Lookup.cs
  56. 199 2
      Ix.NET/Source/System.Interactive.Async/Max.cs
  57. 201 2
      Ix.NET/Source/System.Interactive.Async/Min.cs
  58. 12 5
      Ix.NET/Source/System.Interactive.Async/OnErrorResumeNext.cs
  59. 52 0
      Ix.NET/Source/System.Interactive.Async/OrderBy.cs
  60. 0 2
      Ix.NET/Source/System.Interactive.Async/Properties/AssemblyInfo.cs
  61. 2 3
      Ix.NET/Source/System.Interactive.Async/Range.cs
  62. 11 0
      Ix.NET/Source/System.Interactive.Async/Repeat.cs
  63. 17 5
      Ix.NET/Source/System.Interactive.Async/Retry.cs
  64. 2 0
      Ix.NET/Source/System.Interactive.Async/Reverse.cs
  65. 14 4
      Ix.NET/Source/System.Interactive.Async/Scan.cs
  66. 10 0
      Ix.NET/Source/System.Interactive.Async/Select.cs
  67. 33 2
      Ix.NET/Source/System.Interactive.Async/SelectMany.cs
  68. 26 2
      Ix.NET/Source/System.Interactive.Async/SequenceEqual.cs
  69. 6 9
      Ix.NET/Source/System.Interactive.Async/Set.cs
  70. 30 4
      Ix.NET/Source/System.Interactive.Async/Single.cs
  71. 14 0
      Ix.NET/Source/System.Interactive.Async/Skip.cs
  72. 2 3
      Ix.NET/Source/System.Interactive.Async/StartsWith.cs
  73. 140 2
      Ix.NET/Source/System.Interactive.Async/Sum.cs
  74. 14 0
      Ix.NET/Source/System.Interactive.Async/Take.cs
  75. 1 2
      Ix.NET/Source/System.Interactive.Async/TaskExt.cs
  76. 15 2
      Ix.NET/Source/System.Interactive.Async/ToAsyncEnumerable.cs
  77. 76 2
      Ix.NET/Source/System.Interactive.Async/ToCollection.cs
  78. 6 2
      Ix.NET/Source/System.Interactive.Async/ToObservable.cs
  79. 13 3
      Ix.NET/Source/System.Interactive.Async/Union.cs
  80. 6 1
      Ix.NET/Source/System.Interactive.Async/Using.cs
  81. 10 0
      Ix.NET/Source/System.Interactive.Async/Where.cs
  82. 8 0
      Ix.NET/Source/System.Interactive.Async/Zip.cs
  83. 0 2
      Ix.NET/Source/System.Interactive.Providers/Properties/AssemblyInfo.cs
  84. 288 42
      Ix.NET/Source/System.Interactive.Providers/QueryableEx.cs
  85. 1 1
      Ix.NET/Source/System.Interactive.Providers/Reflection.cs
  86. 2 2
      Ix.NET/Source/System.Interactive.Tests/AssertEx.cs
  87. 4 5
      Ix.NET/Source/System.Interactive.Tests/Tests.Aggregates.cs
  88. 8 7
      Ix.NET/Source/System.Interactive.Tests/Tests.Buffering.cs
  89. 11 9
      Ix.NET/Source/System.Interactive.Tests/Tests.Creation.cs
  90. 2 3
      Ix.NET/Source/System.Interactive.Tests/Tests.Exceptions.cs
  91. 0 1
      Ix.NET/Source/System.Interactive.Tests/Tests.Imperative.cs
  92. 1 2
      Ix.NET/Source/System.Interactive.Tests/Tests.Multiple.cs
  93. 18 5
      Ix.NET/Source/System.Interactive.Tests/Tests.Qbservable.cs
  94. 9 10
      Ix.NET/Source/System.Interactive.Tests/Tests.Single.cs
  95. 1 3
      Ix.NET/Source/System.Interactive.Tests/Tests.cs
  96. 22 4
      Ix.NET/Source/System.Interactive/Buffer.cs
  97. 16 3
      Ix.NET/Source/System.Interactive/Case.cs
  98. 25 4
      Ix.NET/Source/System.Interactive/Catch.cs
  99. 8 3
      Ix.NET/Source/System.Interactive/Concatenate.cs
  100. 6 3
      Ix.NET/Source/System.Interactive/Create.cs

+ 2 - 1
Ix.NET/Source/Directory.build.props

@@ -4,7 +4,7 @@
     <Product>$(AssemblyName) ($(TargetFramework))</Product>
     <Copyright>Copyright (c) .NET Foundation and Contributors.</Copyright>
     <MinClientVersion>2.12</MinClientVersion>
-    <GenerateDocumentationFile Condition=" '$(Configuration)' == 'Release' ">true</GenerateDocumentationFile>
+    <GenerateDocumentationFile>true</GenerateDocumentationFile>
     <Authors>.NET Foundation and Contributors</Authors>
     <PackageIconUrl>http://go.microsoft.com/fwlink/?LinkId=261274</PackageIconUrl>
     <PackageProjectUrl>http://go.microsoft.com/fwlink/?LinkId=261273</PackageProjectUrl>
@@ -18,6 +18,7 @@
     <DebugType>embedded</DebugType>
     <EmbedUntrackedSources>true</EmbedUntrackedSources>
     <PublishRepositoryUrl>true</PublishRepositoryUrl>
+    <LangVersion>latest</LangVersion>
   </PropertyGroup>
     
   <ItemGroup>

+ 1 - 2
Ix.NET/Source/System.Interactive.Async.Providers/AsyncEnumerableQuery.cs

@@ -161,8 +161,7 @@ namespace System.Linq
         /// <returns>String representation of the enumerable sequence.</returns>
         public override string ToString()
         {
-            var ce = _expression as ConstantExpression;
-            if (ce == null || ce.Value != this)
+            if (!(_expression is ConstantExpression ce) || ce.Value != this)
             {
                 return _expression.ToString();
             }

+ 5 - 6
Ix.NET/Source/System.Interactive.Async.Providers/AsyncEnumerableRewriter.cs

@@ -14,17 +14,16 @@ namespace System.Linq
     /// </summary>
     internal class AsyncEnumerableRewriter : ExpressionVisitor
     {
-        private static volatile ILookup<string, MethodInfo> Methods;
+        private static volatile ILookup<string, MethodInfo> _methods;
 
         protected override Expression VisitConstant(ConstantExpression node)
         {
-            var enumerableQuery = node.Value as AsyncEnumerableQuery;
 
             //
             // Not an expression representation obtained from the async enumerable query provider,
             // so just a plain constant that can be returned as-is.
             //
-            if (enumerableQuery == null)
+            if (!(node.Value is AsyncEnumerableQuery enumerableQuery))
             {
                 return node;
             }
@@ -394,15 +393,15 @@ namespace System.Linq
             //
             // Ensure the cached lookup table for AsyncEnumerable methods is initialized.
             //
-            if (Methods == null)
+            if (_methods == null)
             {
-                Methods = typeof(AsyncEnumerable).GetMethods(BindingFlags.Static | BindingFlags.Public).ToLookup(m => m.Name);
+                _methods = typeof(AsyncEnumerable).GetMethods(BindingFlags.Static | BindingFlags.Public).ToLookup(m => m.Name);
             }
 
             //
             // Find a match based on the method name and the argument types.
             //
-            var method = Methods[name].FirstOrDefault(m => ArgsMatch(m, args, typeArgs));
+            var method = _methods[name].FirstOrDefault(m => ArgsMatch(m, args, typeArgs));
             if (method == null)
             {
                 throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Could not find method with name '{0}' on type '{1}'.", name, typeof(Enumerable)));

+ 2 - 0
Ix.NET/Source/System.Interactive.Async.Providers/AsyncQueryable.cs

@@ -21,7 +21,9 @@ namespace System.Linq
         public static IAsyncQueryable<TElement> AsAsyncQueryable<TElement>(this IAsyncEnumerable<TElement> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             if (source is IAsyncQueryable<TElement> queryable)
             {

+ 0 - 2
Ix.NET/Source/System.Interactive.Async.Providers/Properties/AssemblyInfo.cs

@@ -1,8 +1,6 @@
 using System;
-using System.Reflection;
 using System.Resources;
 using System.Runtime.InteropServices;
-using System.Security;
 
 [assembly: NeutralResourcesLanguage("en-US")]
 

+ 2 - 2
Ix.NET/Source/System.Interactive.Async.Providers/Reflection.cs

@@ -19,7 +19,7 @@ namespace System.Reflection
 
 namespace System
 {
-    static class TypeExtensions
+    internal static class TypeExtensions
     {
         public static bool IsNestedPrivate(this Type t)
         {
@@ -86,7 +86,7 @@ namespace System
 #else
 namespace System
 {
-    static class TypeExtensions
+    internal static class TypeExtensions
     {
         public static bool IsNestedPrivate(this Type t)
         {

+ 26 - 26
Ix.NET/Source/System.Interactive.Async.Tests/AppendPrependTests.cs

@@ -23,7 +23,7 @@ namespace Tests
         [Fact]
         public void Append1()
         {
-            var xs = new[] {1, 2, 3}.ToAsyncEnumerable();
+            var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable();
 
             var res = xs.Append(4);
 
@@ -39,11 +39,11 @@ namespace Tests
         [Fact]
         public async Task Append2()
         {
-            var xs = new[] {1, 2, 3}.ToAsyncEnumerable();
+            var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable();
 
             var res = xs.Append(4);
 
-            var a = new[] {1, 2, 3, 4};
+            var a = new[] { 1, 2, 3, 4 };
 
             var arr = await res.ToArray();
             Assert.Equal(a, arr);
@@ -52,7 +52,7 @@ namespace Tests
         [Fact]
         public async Task Append3()
         {
-            var xs = new[] {1, 2, 3}.ToAsyncEnumerable();
+            var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable();
             var res = xs.Append(4);
             var a = new List<int>
             {
@@ -68,7 +68,7 @@ namespace Tests
         [Fact]
         public async Task Append4()
         {
-            var xs = new[] {1, 2, 3}.ToAsyncEnumerable();
+            var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable();
 
             var res = xs.Append(4);
             Assert.Equal(4, await res.Count());
@@ -82,7 +82,7 @@ namespace Tests
 
             var res = xs.Append(4);
 
-            var a = new[] {1, 2, 3, 4};
+            var a = new[] { 1, 2, 3, 4 };
 
             var arr = await res.ToArray();
             Assert.Equal(a, arr);
@@ -119,7 +119,7 @@ namespace Tests
         [Fact]
         public void AppendN1()
         {
-            var xs = new[] {1, 2, 3}.ToAsyncEnumerable();
+            var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable();
 
             var res = xs.Append(4)
                         .Append(5)
@@ -139,13 +139,13 @@ namespace Tests
         [Fact]
         public async Task AppendN2()
         {
-            var xs = new[] {1, 2, 3}.ToAsyncEnumerable();
+            var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable();
 
             var res = xs.Append(4)
                         .Append(5)
                         .Append(6);
 
-            var a = new[] {1, 2, 3, 4, 5, 6};
+            var a = new[] { 1, 2, 3, 4, 5, 6 };
 
             var arr = await res.ToArray();
             Assert.Equal(a, arr);
@@ -154,7 +154,7 @@ namespace Tests
         [Fact]
         public async Task AppendN3()
         {
-            var xs = new[] {1, 2, 3}.ToAsyncEnumerable();
+            var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable();
             var res = xs.Append(4)
                         .Append(5)
                         .Append(6);
@@ -184,7 +184,7 @@ namespace Tests
                         .Append(5)
                         .Append(6);
 
-            var a = new[] {1, 2, 3, 4, 5, 6};
+            var a = new[] { 1, 2, 3, 4, 5, 6 };
 
             var arr = await res.ToArray();
             Assert.Equal(a, arr);
@@ -228,7 +228,7 @@ namespace Tests
         [Fact]
         public async Task AppenN4()
         {
-            var xs = new[] {1, 2, 3}.ToAsyncEnumerable();
+            var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable();
 
             var res = xs.Append(4)
                         .Append(5)
@@ -239,7 +239,7 @@ namespace Tests
         [Fact]
         public void Prepend1()
         {
-            var xs = new[] {1, 2, 3}.ToAsyncEnumerable();
+            var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable();
 
             var res = xs.Prepend(4);
 
@@ -255,11 +255,11 @@ namespace Tests
         [Fact]
         public async Task Prepend2()
         {
-            var xs = new[] {1, 2, 3}.ToAsyncEnumerable();
+            var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable();
 
             var res = xs.Prepend(4);
 
-            var a = new[] {4, 1, 2, 3};
+            var a = new[] { 4, 1, 2, 3 };
 
             var arr = await res.ToArray();
             Assert.Equal(a, arr);
@@ -268,7 +268,7 @@ namespace Tests
         [Fact]
         public async Task Prepend3()
         {
-            var xs = new[] {1, 2, 3}.ToAsyncEnumerable();
+            var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable();
             var res = xs.Prepend(4);
             var a = new List<int>
             {
@@ -285,7 +285,7 @@ namespace Tests
         [Fact]
         public async Task Prepend4()
         {
-            var xs = new[] {1, 2, 3}.ToAsyncEnumerable();
+            var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable();
 
             var res = xs.Prepend(4);
             Assert.Equal(4, await res.Count());
@@ -300,7 +300,7 @@ namespace Tests
 
             var res = xs.Prepend(4);
 
-            var a = new[] {4, 1, 2, 3};
+            var a = new[] { 4, 1, 2, 3 };
 
             var arr = await res.ToArray();
             Assert.Equal(a, arr);
@@ -349,7 +349,7 @@ namespace Tests
         [Fact]
         public void PrependN1()
         {
-            var xs = new[] {1, 2, 3}.ToAsyncEnumerable();
+            var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable();
 
             var res = xs.Prepend(4)
                         .Prepend(5)
@@ -369,13 +369,13 @@ namespace Tests
         [Fact]
         public async Task PrependN2()
         {
-            var xs = new[] {1, 2, 3}.ToAsyncEnumerable();
+            var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable();
 
             var res = xs.Prepend(4)
                         .Prepend(5)
                         .Prepend(6);
 
-            var a = new[] {6, 5, 4, 1, 2, 3};
+            var a = new[] { 6, 5, 4, 1, 2, 3 };
 
             var arr = await res.ToArray();
             Assert.Equal(a, arr);
@@ -384,7 +384,7 @@ namespace Tests
         [Fact]
         public async Task PrependN3()
         {
-            var xs = new[] {1, 2, 3}.ToAsyncEnumerable();
+            var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable();
             var res = xs.Prepend(4)
                         .Prepend(5)
                         .Prepend(6);
@@ -406,7 +406,7 @@ namespace Tests
         [Fact]
         public async Task PrependN4()
         {
-            var xs = new[] {1, 2, 3}.ToAsyncEnumerable();
+            var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable();
 
             var res = xs.Prepend(4)
                         .Prepend(5)
@@ -424,7 +424,7 @@ namespace Tests
                         .Prepend(5)
                         .Prepend(6);
 
-            var a = new[] {6, 5, 4, 1, 2, 3};
+            var a = new[] { 6, 5, 4, 1, 2, 3 };
 
             var arr = await res.ToArray();
             Assert.Equal(a, arr);
@@ -480,7 +480,7 @@ namespace Tests
                         .Prepend(10);
 
             var e = res.GetEnumerator();
-            
+
 
             HasNext(e, 10);
             HasNext(e, 9);
@@ -615,7 +615,7 @@ namespace Tests
                         .Prepend(5);
 
             var e = res.GetEnumerator();
-            
+
             HasNext(e, 5);
             HasNext(e, 1);
             HasNext(e, 2);

+ 2 - 2
Ix.NET/Source/System.Interactive.Async.Tests/AssertEx.cs

@@ -1,8 +1,8 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
-using Xunit;
 using System;
+using Xunit;
 
 namespace Tests
 {
@@ -37,7 +37,7 @@ namespace Tests
         {
             try
             {
-                action();   
+                action();
             }
             catch (AggregateException ex)
             {

+ 27 - 23
Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs

@@ -3,12 +3,12 @@
 // See the LICENSE file in the project root for more information. 
 
 using System;
+using System.Collections;
 using System.Collections.Generic;
 using System.Linq;
-using Xunit;
-using System.Collections;
 using System.Threading;
 using System.Threading.Tasks;
+using Xunit;
 // ReSharper disable InvokeAsExtensionMethod
 // ReSharper disable InconsistentNaming
 // ReSharper disable RedundantTypeArgumentsOfMethod
@@ -366,7 +366,7 @@ namespace Tests
             Assert.False(ys.Result);
         }
 
-        class Eq : IEqualityComparer<int>
+        private class Eq : IEqualityComparer<int>
         {
             public bool Equals(int x, int y)
             {
@@ -1070,7 +1070,7 @@ namespace Tests
         [Fact]
         public async Task ToArray4()
         {
-            var xs = await AsyncEnumerable.Range(5,50).Take(10).ToArray();
+            var xs = await AsyncEnumerable.Range(5, 50).Take(10).ToArray();
             var ex = new[] { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 };
 
             Assert.True(ex.SequenceEqual(xs));
@@ -1083,7 +1083,7 @@ namespace Tests
             var xs = new HashSet<int>(res);
 
             var arr = await xs.ToAsyncEnumerable().ToArray();
-            
+
 
             Assert.True(res.SequenceEqual(arr));
         }
@@ -1298,7 +1298,9 @@ namespace Tests
             var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable();
             var res = xs.ToLookup(x => x % 2).Result;
             foreach (var g in res)
+            {
                 Assert.True(g.Key == 0 || g.Key == 1);
+            }
         }
 
         [Fact]
@@ -1308,7 +1310,9 @@ namespace Tests
             var res = xs.ToLookup(x => x % 2).Result;
 #pragma warning disable IDE0007 // Use implicit type
             foreach (IGrouping<int, int> g in (IEnumerable)res)
+            {
                 Assert.True(g.Key == 0 || g.Key == 1);
+            }
 #pragma warning restore IDE0007 // Use implicit type
         }
 
@@ -1383,7 +1387,7 @@ namespace Tests
             await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.Average(default(IAsyncEnumerable<decimal>), x => x, CancellationToken.None));
             await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.Average(default(IAsyncEnumerable<decimal?>), x => x, CancellationToken.None));
 
-            await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.Average(AsyncEnumerable.Empty<int>(), default(Func<int, int>), CancellationToken.None));
+            await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.Average(AsyncEnumerable.Empty<int>(), default, CancellationToken.None));
             await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.Average(AsyncEnumerable.Empty<int>(), default(Func<int, int?>), CancellationToken.None));
             await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.Average(AsyncEnumerable.Empty<int>(), default(Func<int, long>), CancellationToken.None));
             await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.Average(AsyncEnumerable.Empty<int>(), default(Func<int, long?>), CancellationToken.None));
@@ -1642,10 +1646,10 @@ namespace Tests
             await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.Min(default(IAsyncEnumerable<DateTime>), x => x, CancellationToken.None));
             await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.Min(AsyncEnumerable.Empty<DateTime>(), default(Func<DateTime, bool>), CancellationToken.None));
 
-            await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.Min(default(IAsyncEnumerable<DateTime>), Comparer<DateTime>.Default));
+            await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.Min(default, Comparer<DateTime>.Default));
             await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.Min(AsyncEnumerable.Empty<DateTime>(), default(IComparer<DateTime>)));
 
-            await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.Min(default(IAsyncEnumerable<DateTime>), Comparer<DateTime>.Default, CancellationToken.None));
+            await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.Min(default, Comparer<DateTime>.Default, CancellationToken.None));
             await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.Min(AsyncEnumerable.Empty<DateTime>(), default(IComparer<DateTime>), CancellationToken.None));
         }
 
@@ -1825,10 +1829,10 @@ namespace Tests
             await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.Max(default(IAsyncEnumerable<DateTime>), x => x, CancellationToken.None));
             await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.Max(AsyncEnumerable.Empty<DateTime>(), default(Func<DateTime, bool>), CancellationToken.None));
 
-            await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.Max(default(IAsyncEnumerable<DateTime>), Comparer<DateTime>.Default));
+            await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.Max(default, Comparer<DateTime>.Default));
             await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.Max(AsyncEnumerable.Empty<DateTime>(), default(IComparer<DateTime>)));
 
-            await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.Max(default(IAsyncEnumerable<DateTime>), Comparer<DateTime>.Default, CancellationToken.None));
+            await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.Max(default, Comparer<DateTime>.Default, CancellationToken.None));
             await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.Max(AsyncEnumerable.Empty<DateTime>(), default(IComparer<DateTime>), CancellationToken.None));
         }
 
@@ -1989,7 +1993,7 @@ namespace Tests
             await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.Sum(default(IAsyncEnumerable<decimal>), x => x, CancellationToken.None));
             await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.Sum(default(IAsyncEnumerable<decimal?>), x => x, CancellationToken.None));
 
-            await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty<int>(), default(Func<int, int>), CancellationToken.None));
+            await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty<int>(), default, CancellationToken.None));
             await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty<int>(), default(Func<int, int?>), CancellationToken.None));
             await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty<int>(), default(Func<int, long>), CancellationToken.None));
             await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty<int>(), default(Func<int, long?>), CancellationToken.None));
@@ -2098,15 +2102,15 @@ namespace Tests
             await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.MinBy(AsyncEnumerable.Return(42), default(Func<int, int>)));
 
             await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.MinBy(default(IAsyncEnumerable<int>), x => x, Comparer<int>.Default));
-            await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.MinBy(AsyncEnumerable.Return(42), default(Func<int, int>), Comparer<int>.Default));
+            await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.MinBy(AsyncEnumerable.Return(42), default, Comparer<int>.Default));
             await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.MinBy(AsyncEnumerable.Return(42), x => x, default(IComparer<int>)));
 
             await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.MinBy(default(IAsyncEnumerable<int>), x => x, CancellationToken.None));
             await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.MinBy(AsyncEnumerable.Return(42), default(Func<int, int>), CancellationToken.None));
 
             await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.MinBy(default(IAsyncEnumerable<int>), x => x, Comparer<int>.Default, CancellationToken.None));
-            await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.MinBy(AsyncEnumerable.Return(42), default(Func<int, int>), Comparer<int>.Default, CancellationToken.None));
-            await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.MinBy(AsyncEnumerable.Return(42), x => x, default(IComparer<int>), CancellationToken.None));
+            await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.MinBy(AsyncEnumerable.Return(42), default, Comparer<int>.Default, CancellationToken.None));
+            await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.MinBy(AsyncEnumerable.Return(42), x => x, default, CancellationToken.None));
         }
 
         [Fact]
@@ -2130,7 +2134,7 @@ namespace Tests
         public void MinBy3()
         {
             var ex = new Exception("Bang!");
-            var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MinBy(x => { if (x == 3) throw ex; return x; });
+            var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MinBy(x => { if (x == 3) { throw ex; } return x; });
 
             AssertThrows<Exception>(() => xs.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex);
         }
@@ -2139,7 +2143,7 @@ namespace Tests
         public void MinBy4()
         {
             var ex = new Exception("Bang!");
-            var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MinBy(x => { if (x == 4) throw ex; return x; });
+            var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MinBy(x => { if (x == 4) { throw ex; } return x; });
 
             AssertThrows<Exception>(() => xs.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex);
         }
@@ -2158,17 +2162,17 @@ namespace Tests
         {
             await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.MaxBy(default(IAsyncEnumerable<int>), x => x));
             await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.MaxBy(AsyncEnumerable.Return(42), default(Func<int, int>)));
-                                                                      
+
             await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.MaxBy(default(IAsyncEnumerable<int>), x => x, Comparer<int>.Default));
-            await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.MaxBy(AsyncEnumerable.Return(42), default(Func<int, int>), Comparer<int>.Default));
+            await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.MaxBy(AsyncEnumerable.Return(42), default, Comparer<int>.Default));
             await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.MaxBy(AsyncEnumerable.Return(42), x => x, default(IComparer<int>)));
-                                                                      
+
             await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.MaxBy(default(IAsyncEnumerable<int>), x => x, CancellationToken.None));
             await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.MaxBy(AsyncEnumerable.Return(42), default(Func<int, int>), CancellationToken.None));
 
             await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.MaxBy(default(IAsyncEnumerable<int>), x => x, Comparer<int>.Default, CancellationToken.None));
-            await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.MaxBy(AsyncEnumerable.Return(42), default(Func<int, int>), Comparer<int>.Default, CancellationToken.None));
-            await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.MaxBy(AsyncEnumerable.Return(42), x => x, default(IComparer<int>), CancellationToken.None));
+            await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.MaxBy(AsyncEnumerable.Return(42), default, Comparer<int>.Default, CancellationToken.None));
+            await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.MaxBy(AsyncEnumerable.Return(42), x => x, default, CancellationToken.None));
         }
 
         [Fact]
@@ -2192,7 +2196,7 @@ namespace Tests
         public void MaxBy3()
         {
             var ex = new Exception("Bang!");
-            var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MaxBy(x => { if (x == 3) throw ex; return x; });
+            var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MaxBy(x => { if (x == 3) { throw ex; } return x; });
 
             AssertThrows<Exception>(() => xs.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex);
         }
@@ -2201,7 +2205,7 @@ namespace Tests
         public void MaxBy4()
         {
             var ex = new Exception("Bang!");
-            var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MaxBy(x => { if (x == 4) throw ex; return x; });
+            var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MaxBy(x => { if (x == 4) { throw ex; } return x; });
 
             AssertThrows<Exception>(() => xs.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex);
         }

+ 14 - 15
Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs

@@ -3,14 +3,12 @@
 // See the LICENSE file in the project root for more information. 
 
 using System;
+using System.Collections;
 using System.Collections.Generic;
 using System.Linq;
-using System.Text;
-using Xunit;
-using System.Collections;
 using System.Threading;
 using System.Threading.Tasks;
-using System.Diagnostics;
+using Xunit;
 
 namespace Tests
 {
@@ -79,7 +77,7 @@ namespace Tests
         }
         */
 #if !NO_THREAD
-        static IEnumerable<int> Xs(Action a)
+        private static IEnumerable<int> Xs(Action a)
         {
             try
             {
@@ -137,7 +135,7 @@ namespace Tests
             }).ToAsyncEnumerable();
 
             var ex = new Exception("Bang!");
-            var ys = xs.Select(x => { if (x == 1) throw ex; return x; });
+            var ys = xs.Select(x => { if (x == 1) { throw ex; } return x; });
 
             var e = ys.GetEnumerator();
             await Assert.ThrowsAsync<Exception>(() => e.MoveNext());
@@ -234,7 +232,8 @@ namespace Tests
                 {
                     _iterationsBeforeDelay = iterationsBeforeDelay;
                 }
-                int _i = -1;
+
+                private int _i = -1;
                 public void Dispose()
                 {
                 }
@@ -243,12 +242,12 @@ namespace Tests
                 public bool MoveNextWasCalled { get; private set; }
 
                 public int Current => _i;
-                
+
                 public async Task<bool> MoveNext(CancellationToken cancellationToken)
                 {
                     LastToken = cancellationToken;
                     MoveNextWasCalled = true;
-                  
+
                     _i++;
                     if (Current >= _iterationsBeforeDelay)
                     {
@@ -285,7 +284,7 @@ namespace Tests
 
                 public void Reset()
                 {
-                  
+
                 }
 
                 object IEnumerator.Current => Current;
@@ -318,13 +317,13 @@ namespace Tests
 
 
             Task<bool> t = null;
-            var tMoveNext =Task.Run(
+            var tMoveNext = Task.Run(
                 () =>
                 {
                     // This call *will* block
                     t = e.MoveNext(cts.Token);
                 });
-         
+
 
             isRunningEvent.WaitOne();
             cts.Cancel();
@@ -345,7 +344,7 @@ namespace Tests
             evt.Set();
         }
 
-        static IEnumerable<int> Blocking(ManualResetEvent evt, ManualResetEvent blockingStarted)
+        private static IEnumerable<int> Blocking(ManualResetEvent evt, ManualResetEvent blockingStarted)
         {
             blockingStarted.Set();
             evt.WaitOne();
@@ -426,7 +425,7 @@ namespace Tests
         }
     }
 
-    static class MyExt
+    internal static class MyExt
     {
         public static IEnumerable<T> WithDispose<T>(this IEnumerable<T> source, Action a)
         {
@@ -446,7 +445,7 @@ namespace Tests
             });
         }
 
-        class Enumerator<T> : IEnumerator<T>
+        private class Enumerator<T> : IEnumerator<T>
         {
             private readonly Func<bool> _moveNext;
             private readonly Func<T> _current;

+ 9 - 11
Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Conversions.cs

@@ -4,12 +4,10 @@
 
 using System;
 using System.Collections.Generic;
-using System.Collections.ObjectModel;
 using System.Linq;
-using System.Text;
+using System.Threading;
 using System.Threading.Tasks;
 using Xunit;
-using System.Threading;
 
 namespace Tests
 {
@@ -171,11 +169,11 @@ namespace Tests
             var xs = set.ToAsyncEnumerable();
 
             var xc = xs as ICollection<int>;
-            
+
             Assert.NotNull(xc);
 
             Assert.False(xc.IsReadOnly);
-            
+
             xc.Add(5);
 
 
@@ -263,7 +261,7 @@ namespace Tests
             AssertThrows<Exception>(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).InnerExceptions.Single() is TaskCanceledException);
         }
 
-        class MyObservable<T> : IObservable<T>
+        private class MyObservable<T> : IObservable<T>
         {
             private readonly Func<IObserver<T>, IDisposable> _subscribe;
 
@@ -278,7 +276,7 @@ namespace Tests
             }
         }
 
-        class MyDisposable : IDisposable
+        private class MyDisposable : IDisposable
         {
             private readonly Action _dispose;
 
@@ -561,11 +559,11 @@ namespace Tests
             Assert.False(fail);
         }
 
-        class MyObserver<T> : IObserver<T>
+        private class MyObserver<T> : IObserver<T>
         {
-            readonly Action<T> _onNext;
-            readonly Action<Exception> _onError;
-            readonly Action _onCompleted;
+            private readonly Action<T> _onNext;
+            private readonly Action<Exception> _onError;
+            private readonly Action _onCompleted;
 
             public MyObserver(Action<T> onNext, Action<Exception> onError, Action onCompleted)
             {

+ 11 - 12
Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs

@@ -5,10 +5,9 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
-using System.Text;
-using Xunit;
-using System.Threading.Tasks;
 using System.Threading;
+using System.Threading.Tasks;
+using Xunit;
 
 namespace Tests
 {
@@ -19,15 +18,15 @@ namespace Tests
         public void Create_Null()
         {
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.CreateEnumerable<int>(null));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.CreateEnumerator<int>(null, () => 3, () => {}));
-       
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.CreateEnumerator<int>(null, () => 3, () => { }));
+
         }
 
         [Fact]
         public void Create_Iterator_Throws()
         {
-     
-           var iter = AsyncEnumerable.CreateEnumerator<int>(c => Task.FromResult(true), () => 3, () => { });
+
+            var iter = AsyncEnumerable.CreateEnumerator<int>(c => Task.FromResult(true), () => 3, () => { });
 
             var enu = (IAsyncEnumerable<int>)iter;
 
@@ -56,8 +55,8 @@ namespace Tests
         [Fact]
         public async Task Empty_Null()
         {
-           await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.IsEmpty<int>(null));
-           await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.IsEmpty<int>(null, CancellationToken.None));
+            await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.IsEmpty<int>(null));
+            await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.IsEmpty<int>(null, CancellationToken.None));
         }
 
         [Fact]
@@ -241,7 +240,7 @@ namespace Tests
         public void Generate3()
         {
             var ex = new Exception("Bang!");
-            var xs = AsyncEnumerable.Generate(0, x => true, x => x + 1, x => { if (x == 1) throw ex; return x * x; });
+            var xs = AsyncEnumerable.Generate(0, x => true, x => x + 1, x => { if (x == 1) { throw ex; } return x * x; });
 
             var e = xs.GetEnumerator();
             HasNext(e, 0);
@@ -338,7 +337,7 @@ namespace Tests
             Assert.Equal(0, i);
 
             AssertThrows<Exception>(() => xs.GetEnumerator(), ex_ => ex_ == ex);
-            
+
             Assert.Equal(1, d);
         }
 
@@ -474,7 +473,7 @@ namespace Tests
             Assert.Equal(1, dispose);
         }
 
-        class MyD : IDisposable
+        private class MyD : IDisposable
         {
             private readonly Action _dispose;
 

+ 14 - 15
Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs

@@ -5,10 +5,9 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
-using System.Text;
-using Xunit;
 using System.Threading;
 using System.Threading.Tasks;
+using Xunit;
 
 namespace Tests
 {
@@ -17,12 +16,12 @@ namespace Tests
         [Fact]
         public void Catch_Null()
         {
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Catch<int, Exception>(default(IAsyncEnumerable<int>), x => null));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Catch<int, Exception>(AsyncEnumerable.Return(42), default(Func<Exception, IAsyncEnumerable<int>>)));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Catch<int, Exception>(default, x => null));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Catch<int, Exception>(AsyncEnumerable.Return(42), default));
 
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Catch<int>(default(IAsyncEnumerable<int>), AsyncEnumerable.Return(42)));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Catch<int>(AsyncEnumerable.Return(42), default(IAsyncEnumerable<int>)));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Catch<int>(default(IAsyncEnumerable<int>[])));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Catch<int>(default, AsyncEnumerable.Return(42)));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Catch<int>(AsyncEnumerable.Return(42), default));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Catch<int>(default));
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Catch<int>(default(IEnumerable<IAsyncEnumerable<int>>)));
         }
 
@@ -128,7 +127,7 @@ namespace Tests
             var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw<int>(ex));
             var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable();
 
-            var res = xs.Catch<int, InvalidOperationException>(ex_ => { if (ex_.Message == "Bang!") throw ex2; return ys; });
+            var res = xs.Catch<int, InvalidOperationException>(ex_ => { if (ex_.Message == "Bang!") { throw ex2; } return ys; });
 
             var e = res.GetEnumerator();
             HasNext(e, 1);
@@ -429,14 +428,14 @@ namespace Tests
             await SequenceIdentity(xs);
             Assert.Equal(2, i);
         }
-    
 
-    [Fact]
+
+        [Fact]
         public void OnErrorResumeNext_Null()
         {
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.OnErrorResumeNext<int>(default(IAsyncEnumerable<int>), AsyncEnumerable.Return(42)));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.OnErrorResumeNext<int>(AsyncEnumerable.Return(42), default(IAsyncEnumerable<int>)));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.OnErrorResumeNext<int>(default(IAsyncEnumerable<int>[])));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.OnErrorResumeNext<int>(default, AsyncEnumerable.Return(42)));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.OnErrorResumeNext<int>(AsyncEnumerable.Return(42), default));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.OnErrorResumeNext<int>(default));
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.OnErrorResumeNext<int>(default(IEnumerable<IAsyncEnumerable<int>>)));
         }
 
@@ -565,9 +564,9 @@ namespace Tests
         [Fact]
         public void Retry_Null()
         {
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Retry<int>(default(IAsyncEnumerable<int>)));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Retry<int>(default));
 
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Retry<int>(default(IAsyncEnumerable<int>), 1));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Retry<int>(default, 1));
             AssertThrows<ArgumentOutOfRangeException>(() => AsyncEnumerable.Retry<int>(AsyncEnumerable.Return(42), -1));
         }
 

+ 39 - 17
Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs

@@ -6,10 +6,9 @@ using System;
 using System.Collections.Generic;
 using System.Diagnostics;
 using System.Linq;
-using System.Text;
-using Xunit;
 using System.Threading;
 using System.Threading.Tasks;
+using Xunit;
 
 namespace Tests
 {
@@ -20,7 +19,7 @@ namespace Tests
         {
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Concat<int>(null, AsyncEnumerable.Return(42)));
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Concat<int>(AsyncEnumerable.Return(42), null));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Concat<int>(default(IAsyncEnumerable<int>[])));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Concat<int>(default));
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Concat<int>(default(IEnumerable<IAsyncEnumerable<int>>)));
         }
 
@@ -204,8 +203,7 @@ namespace Tests
             Assert.Equal(8, await c.Count());
         }
 
-
-        static IEnumerable<IAsyncEnumerable<int>> ConcatXss()
+        private static IEnumerable<IAsyncEnumerable<int>> ConcatXss()
         {
             yield return new[] { 1, 2, 3 }.ToAsyncEnumerable();
             yield return new[] { 4, 5 }.ToAsyncEnumerable();
@@ -292,7 +290,7 @@ namespace Tests
             var ex = new Exception("Bang!");
             var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable();
             var ys = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable();
-            var res = xs.Zip(ys, (x, y) => { if (x > 0) throw ex; return x * y; });
+            var res = xs.Zip(ys, (x, y) => { if (x > 0) { throw ex; } return x * y; });
 
             var e = res.GetEnumerator();
             AssertThrows<Exception>(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex);
@@ -610,7 +608,7 @@ namespace Tests
             AssertThrows<Exception>(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is NotImplementedException);
         }
 
-        class EqEx : IEqualityComparer<int>
+        private class EqEx : IEqualityComparer<int>
         {
             public bool Equals(int x, int y)
             {
@@ -622,7 +620,7 @@ namespace Tests
                 throw new NotImplementedException();
             }
         }
-        
+
         [Fact]
         public void GroupJoin_Null()
         {
@@ -637,7 +635,7 @@ namespace Tests
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupJoin<int, int, int, int>(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), null, x => x, (x, y) => x, EqualityComparer<int>.Default));
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupJoin<int, int, int, int>(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, null, (x, y) => x, EqualityComparer<int>.Default));
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupJoin<int, int, int, int>(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, x => x, null, EqualityComparer<int>.Default));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupJoin<int, int, int, int>(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, x => x, (x, y) => x, default(IEqualityComparer<int>)));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupJoin<int, int, int, int>(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, x => x, (x, y) => x, default));
         }
 
         [Fact]
@@ -729,9 +727,13 @@ namespace Tests
             var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable();
             var ys = new[] { 3, 6, 4 }.ToAsyncEnumerable();
 
-            var res = xs.GroupJoin(ys, x => x % 3, y => y % 3, (x, i) => {
+            var res = xs.GroupJoin(ys, x => x % 3, y => y % 3, (x, i) =>
+            {
                 if (x == 1)
+                {
                     throw ex;
+                }
+
                 return x + " - " + i.Aggregate("", (s, j) => s + j).Result;
             });
 
@@ -754,7 +756,7 @@ namespace Tests
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Join<int, int, int, int>(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), null, x => x, (x, y) => x, EqualityComparer<int>.Default));
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Join<int, int, int, int>(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, null, (x, y) => x, EqualityComparer<int>.Default));
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Join<int, int, int, int>(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, x => x, null, EqualityComparer<int>.Default));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Join<int, int, int, int>(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, x => x, (x, y) => x, default(IEqualityComparer<int>)));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Join<int, int, int, int>(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, x => x, (x, y) => x, default));
         }
 
         [Fact]
@@ -962,7 +964,7 @@ namespace Tests
         [Fact]
         public void SelectManyMultiple_Null()
         {
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.SelectMany<int, int>(default(IAsyncEnumerable<int>), AsyncEnumerable.Return(42)));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.SelectMany<int, int>(default, AsyncEnumerable.Return(42)));
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.SelectMany<int, int>(AsyncEnumerable.Return(42), default(IAsyncEnumerable<int>)));
         }
 
@@ -1001,16 +1003,36 @@ namespace Tests
         {
             public bool Equals(CustomerOrder other)
             {
-                if (other is null) return false;
-                if (ReferenceEquals(this, other)) return true;
+                if (other is null)
+                {
+                    return false;
+                }
+
+                if (ReferenceEquals(this, other))
+                {
+                    return true;
+                }
+
                 return OrderId == other.OrderId && string.Equals(CustomerId, other.CustomerId);
             }
 
             public override bool Equals(object obj)
             {
-                if (obj is null) return false;
-                if (ReferenceEquals(this, obj)) return true;
-                if (obj.GetType() != GetType()) return false;
+                if (obj is null)
+                {
+                    return false;
+                }
+
+                if (ReferenceEquals(this, obj))
+                {
+                    return true;
+                }
+
+                if (obj.GetType() != GetType())
+                {
+                    return false;
+                }
+
                 return Equals((CustomerOrder)obj);
             }
 

+ 112 - 67
Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs

@@ -4,12 +4,10 @@
 
 using System;
 using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
 using System.Linq;
-using System.Text;
-using Xunit;
 using System.Threading;
 using System.Threading.Tasks;
+using Xunit;
 namespace Tests
 {
 
@@ -248,7 +246,7 @@ namespace Tests
         {
             var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable();
             var ex = new Exception("Bang");
-            var ys = xs.Where(x => { if (x == 4) throw ex; return true; });
+            var ys = xs.Where(x => { if (x == 4) { throw ex; } return true; });
 
             var e = ys.GetEnumerator();
             HasNext(e, 8);
@@ -262,7 +260,7 @@ namespace Tests
         {
             var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable();
             var ex = new Exception("Bang");
-            var ys = xs.Where((x, i) => { if (i == 3) throw ex; return true; });
+            var ys = xs.Where((x, i) => { if (i == 3) { throw ex; } return true; });
 
             var e = ys.GetEnumerator();
             HasNext(e, 8);
@@ -310,7 +308,7 @@ namespace Tests
         {
             var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable();
             var ys = xs.Where(x => x % 2 == 0);
-            
+
             await SequenceIdentity(ys);
         }
 
@@ -336,8 +334,8 @@ namespace Tests
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.SelectMany<int, int, int>(null, (x, i) => null, (x, y) => x));
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.SelectMany<int, int, int>(AsyncEnumerable.Return(42), default(Func<int, IAsyncEnumerable<int>>), (x, y) => x));
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.SelectMany<int, int, int>(AsyncEnumerable.Return(42), default(Func<int, int, IAsyncEnumerable<int>>), (x, y) => x));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.SelectMany<int, int, int>(AsyncEnumerable.Return(42), x => null, default(Func<int, int, int>)));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.SelectMany<int, int, int>(AsyncEnumerable.Return(42), (x, i) => null, default(Func<int, int, int>)));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.SelectMany<int, int, int>(AsyncEnumerable.Return(42), x => null, default));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.SelectMany<int, int, int>(AsyncEnumerable.Return(42), (x, i) => null, default));
         }
 
         [Fact]
@@ -364,9 +362,13 @@ namespace Tests
             var ys = xs.SelectMany(x =>
             {
                 if (x < 3)
+                {
                     return Enumerable.Range(0, x).ToAsyncEnumerable();
+                }
                 else
+                {
                     return AsyncEnumerable.Throw<int>(ex);
+                }
             });
 
             var e = ys.GetEnumerator();
@@ -395,9 +397,13 @@ namespace Tests
             var ys = xs.SelectMany(x =>
             {
                 if (x < 3)
+                {
                     return Enumerable.Range(0, x).ToAsyncEnumerable();
+                }
                 else
+                {
                     throw ex;
+                }
             });
 
             var e = ys.GetEnumerator();
@@ -431,9 +437,13 @@ namespace Tests
             var ys = xs.SelectMany((x, i) =>
             {
                 if (i < 2)
+                {
                     return Enumerable.Range(0, x).ToAsyncEnumerable();
+                }
                 else
+                {
                     return AsyncEnumerable.Throw<int>(ex);
+                }
             });
 
             var e = ys.GetEnumerator();
@@ -462,9 +472,13 @@ namespace Tests
             var ys = xs.SelectMany((x, i) =>
             {
                 if (i < 2)
+                {
                     return Enumerable.Range(0, x).ToAsyncEnumerable();
+                }
                 else
+                {
                     throw ex;
+                }
             });
 
             var e = ys.GetEnumerator();
@@ -514,7 +528,10 @@ namespace Tests
             var ys = xs.SelectMany(x => Enumerable.Range(3, x).ToAsyncEnumerable(), (x, y) =>
             {
                 if (x * y > 10)
+                {
                     throw ex;
+                }
+
                 return x * y;
             });
 
@@ -534,7 +551,10 @@ namespace Tests
             var ys = xs.SelectMany((x, i) => Enumerable.Range(i + 3, x).ToAsyncEnumerable(), (x, y) =>
             {
                 if (x * y > 10)
+                {
                     throw ex;
+                }
+
                 return x * y;
             });
 
@@ -622,7 +642,7 @@ namespace Tests
         [Fact]
         public void Cast2()
         {
-            var xs = new [] { new EventArgs(), new EventArgs(), new EventArgs() }.ToAsyncEnumerable();
+            var xs = new[] { new EventArgs(), new EventArgs(), new EventArgs() }.ToAsyncEnumerable();
             var ys = xs.Cast<EventArgs>();
 
             Assert.Same(xs, ys);
@@ -635,23 +655,23 @@ namespace Tests
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Do<int>(AsyncEnumerable.Return(42), default(Action<int>)));
 
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Do<int>(null, x => { }, () => { }));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Do<int>(AsyncEnumerable.Return(42), default(Action<int>), () => { }));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Do<int>(AsyncEnumerable.Return(42), default, () => { }));
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Do<int>(AsyncEnumerable.Return(42), x => { }, default(Action)));
 
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Do<int>(null, x => { }, ex => { }));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Do<int>(AsyncEnumerable.Return(42), default(Action<int>), ex => { }));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Do<int>(AsyncEnumerable.Return(42), default, ex => { }));
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Do<int>(AsyncEnumerable.Return(42), x => { }, default(Action<Exception>)));
 
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Do<int>(null, x => { }, ex => { }, () => { }));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Do<int>(AsyncEnumerable.Return(42), default(Action<int>), ex => { }, () => { }));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Do<int>(AsyncEnumerable.Return(42), x => { }, default(Action<Exception>), () => { }));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Do<int>(AsyncEnumerable.Return(42), x => { }, ex => { }, default(Action)));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Do<int>(AsyncEnumerable.Return(42), default, ex => { }, () => { }));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Do<int>(AsyncEnumerable.Return(42), x => { }, default, () => { }));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Do<int>(AsyncEnumerable.Return(42), x => { }, ex => { }, default));
 
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Do<int>(null, new MyObs()));
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Do<int>(AsyncEnumerable.Return(42), default(IObserver<int>)));
         }
 
-        class MyObs : IObserver<int>
+        private class MyObs : IObserver<int>
         {
             public void OnCompleted()
             {
@@ -1462,7 +1482,7 @@ namespace Tests
         public async Task DefaultIfEmpty11()
         {
             var xs = AsyncEnumerable.Empty<int>().DefaultIfEmpty(42);
-            
+
             Assert.Equal(1, await xs.Count());
         }
 
@@ -1525,7 +1545,7 @@ namespace Tests
                 .DefaultIfEmpty(24)
                 .Append(5); // for the onlyIsCheap to true
 
-            var r = new[] { 0, 1, 2, 3, 4, 5};
+            var r = new[] { 0, 1, 2, 3, 4, 5 };
 
             Assert.Equal(r, await xs.ToArray());
         }
@@ -1537,7 +1557,7 @@ namespace Tests
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Distinct<int>(null));
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Distinct<int>(null, new Eq()));
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Distinct<int>(AsyncEnumerable.Return(42), null));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Distinct<int, int>(AsyncEnumerable.Return(42), (Func<int, int>)null));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.Distinct<int, int>(AsyncEnumerable.Return(42), null));
         }
 
         [Fact]
@@ -1572,8 +1592,8 @@ namespace Tests
         public async Task Distinct3()
         {
             var xs = new[] { 1, 2, 1, 3, 5, 2, 1, 4 }.ToAsyncEnumerable().Distinct();
-            
-            var res = new [] { 1, 2, 3, 5, 4 };
+
+            var res = new[] { 1, 2, 3, 5, 4 };
             Assert.True(res.SequenceEqual(await xs.ToArray()));
         }
 
@@ -1590,7 +1610,7 @@ namespace Tests
         public async Task Distinct5()
         {
             var xs = new[] { 1, 2, 1, 3, 5, 2, 1, 4 }.ToAsyncEnumerable().Distinct();
-            
+
             Assert.Equal(5, await xs.Count());
         }
 
@@ -1642,7 +1662,7 @@ namespace Tests
             var xs = AsyncEnumerable.Empty<int>().Distinct(k => k);
 
             var e = xs.GetEnumerator();
-            
+
             NoNext(e);
         }
 
@@ -1823,7 +1843,10 @@ namespace Tests
 
             var e = ys.GetEnumerator();
             for (var i = 0; i < 10; i++)
+            {
                 HasNext(e, i);
+            }
+
             NoNext(e);
         }
 
@@ -1866,7 +1889,10 @@ namespace Tests
 
             var e = ys.GetEnumerator();
             for (var i = 9; i >= 0; i--)
+            {
                 HasNext(e, i);
+            }
+
             NoNext(e);
         }
 
@@ -1989,40 +2015,40 @@ namespace Tests
         public void GroupBy_Null()
         {
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int>(null, x => x));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int>(AsyncEnumerable.Return(42), default(Func<int, int>)));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int>(AsyncEnumerable.Return(42), default));
 
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int>(null, x => x, EqualityComparer<int>.Default));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int>(AsyncEnumerable.Return(42), default(Func<int, int>), EqualityComparer<int>.Default));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int>(AsyncEnumerable.Return(42), x => x, default(IEqualityComparer<int>)));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int>(AsyncEnumerable.Return(42), default, EqualityComparer<int>.Default));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int>(AsyncEnumerable.Return(42), x => x, default));
 
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int, int>(null, x => x, x => x));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int, int>(AsyncEnumerable.Return(42), default(Func<int, int>), x => x));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int, int>(AsyncEnumerable.Return(42), default, x => x));
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int, int>(AsyncEnumerable.Return(42), x => x, default(Func<int, int>)));
 
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int, int>(null, x => x, x => x, EqualityComparer<int>.Default));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int, int>(AsyncEnumerable.Return(42), default(Func<int, int>), x => x, EqualityComparer<int>.Default));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int, int>(AsyncEnumerable.Return(42), default, x => x, EqualityComparer<int>.Default));
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int, int>(AsyncEnumerable.Return(42), x => x, default(Func<int, int>), EqualityComparer<int>.Default));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int, int>(AsyncEnumerable.Return(42), x => x, x => x, default(IEqualityComparer<int>)));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int, int>(AsyncEnumerable.Return(42), x => x, x => x, default));
 
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int, int>(null, x => x, (x, ys) => x));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int, int>(AsyncEnumerable.Return(42), default(Func<int, int>), (x, ys) => x));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int, int>(AsyncEnumerable.Return(42), default, (x, ys) => x));
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int, int>(AsyncEnumerable.Return(42), x => x, default(Func<int, IAsyncEnumerable<int>, int>)));
 
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int, int>(null, x => x, (x, ys) => x, EqualityComparer<int>.Default));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int, int>(AsyncEnumerable.Return(42), default(Func<int, int>), (x, ys) => x, EqualityComparer<int>.Default));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int, int>(AsyncEnumerable.Return(42), default, (x, ys) => x, EqualityComparer<int>.Default));
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int, int>(AsyncEnumerable.Return(42), x => x, default(Func<int, IAsyncEnumerable<int>, int>), EqualityComparer<int>.Default));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int, int>(AsyncEnumerable.Return(42), x => x, (x, ys) => x, default(IEqualityComparer<int>)));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int, int>(AsyncEnumerable.Return(42), x => x, (x, ys) => x, default));
 
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int, int, int>(null, x => x, x => x, (x, ys) => x));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int, int, int>(AsyncEnumerable.Return(42), default(Func<int, int>), x => x, (x, ys) => x));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int, int, int>(AsyncEnumerable.Return(42), x => x, default(Func<int, int>), (x, ys) => x));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int, int, int>(AsyncEnumerable.Return(42), x => x, x => x, default(Func<int, IAsyncEnumerable<int>, int>)));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int, int, int>(AsyncEnumerable.Return(42), default, x => x, (x, ys) => x));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int, int, int>(AsyncEnumerable.Return(42), x => x, default, (x, ys) => x));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int, int, int>(AsyncEnumerable.Return(42), x => x, x => x, default));
 
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int, int, int>(null, x => x, x => x, (x, ys) => x, EqualityComparer<int>.Default));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int, int, int>(AsyncEnumerable.Return(42), default(Func<int, int>), x => x, (x, ys) => x, EqualityComparer<int>.Default));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int, int, int>(AsyncEnumerable.Return(42), x => x, default(Func<int, int>), (x, ys) => x, EqualityComparer<int>.Default));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int, int, int>(AsyncEnumerable.Return(42), x => x, x => x, default(Func<int, IAsyncEnumerable<int>, int>), EqualityComparer<int>.Default));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int, int, int>(AsyncEnumerable.Return(42), x => x, x => x, (x, ys) => x, default(IEqualityComparer<int>)));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int, int, int>(AsyncEnumerable.Return(42), default, x => x, (x, ys) => x, EqualityComparer<int>.Default));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int, int, int>(AsyncEnumerable.Return(42), x => x, default, (x, ys) => x, EqualityComparer<int>.Default));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int, int, int>(AsyncEnumerable.Return(42), x => x, x => x, default, EqualityComparer<int>.Default));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.GroupBy<int, int, int, int>(AsyncEnumerable.Return(42), x => x, x => x, (x, ys) => x, default));
         }
 
         [Fact]
@@ -2174,7 +2200,7 @@ namespace Tests
             //var g2e = g2.GetEnumerator();
             //HasNext(g2e, 43);
 
-            
+
             //AssertThrows<Exception>(() => g1e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!");
             //AssertThrows<Exception>(() => g2e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!");
         }
@@ -2196,10 +2222,10 @@ namespace Tests
             //HasNext(g1e, 42);
             //AssertThrows<Exception>(() => g1e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!");
 
-                    
+
         }
 
-        static IEnumerable<int> GetXs()
+        private static IEnumerable<int> GetXs()
         {
             yield return 42;
             yield return 43;
@@ -2222,7 +2248,7 @@ namespace Tests
         {
             var ex = new Exception("Bang!");
             var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable();
-            var ys = xs.GroupBy<int, int>(x => { if (x == 3) throw ex; return x; });
+            var ys = xs.GroupBy<int, int>(x => { if (x == 3) { throw ex; } return x; });
 
             var e = ys.GetEnumerator();
 
@@ -2240,7 +2266,7 @@ namespace Tests
             //var g2e = g2.GetEnumerator();
             //HasNext(g2e, 2);
 
-           
+
             //AssertThrows<Exception>(() => g1e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex);
             //AssertThrows<Exception>(() => g2e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex);
         }
@@ -2512,7 +2538,7 @@ namespace Tests
 
             var ys = xs.ToAsyncEnumerable();
 
-            var res = ys.GroupBy(x => x.Item/10);
+            var res = ys.GroupBy(x => x.Item / 10);
 
             await SequenceIdentity(res);
         }
@@ -2545,7 +2571,7 @@ namespace Tests
         {
             var xs = AsyncEnumerable.Range(0, 10);
             var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x), (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result);
-            
+
             Assert.Equal(3, await ys.Count());
         }
 
@@ -2574,7 +2600,7 @@ namespace Tests
 
             var gg1 = gar[0];
             var gg1a = await gg1.ToArray();
-            
+
             Assert.Equal(g1a, gg1a);
 
             var gg2 = gar[1];
@@ -2584,7 +2610,7 @@ namespace Tests
 
             var gg3 = gar[2];
             var gg3a = await gg3.ToArray();
-            Assert.Equal(g3a, gg3a); 
+            Assert.Equal(g3a, gg3a);
         }
 
         [Fact]
@@ -2619,7 +2645,7 @@ namespace Tests
         {
             var xs = AsyncEnumerable.Range(0, 10);
             var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x));
-            
+
             var gar = await ys.ToList();
 
             Assert.Equal(3, gar.Count);
@@ -2797,20 +2823,40 @@ namespace Tests
             await SequenceIdentity(ys);
         }
 
-        class Kvp : IEquatable<Kvp>
+        private class Kvp : IEquatable<Kvp>
         {
             public bool Equals(Kvp other)
             {
-                if (other is null) return false;
-                if (ReferenceEquals(this, other)) return true;
+                if (other is null)
+                {
+                    return false;
+                }
+
+                if (ReferenceEquals(this, other))
+                {
+                    return true;
+                }
+
                 return string.Equals(Key, other.Key) && Item == other.Item;
             }
 
             public override bool Equals(object obj)
             {
-                if (obj is null) return false;
-                if (ReferenceEquals(this, obj)) return true;
-                if (obj.GetType() != GetType()) return false;
+                if (obj is null)
+                {
+                    return false;
+                }
+
+                if (ReferenceEquals(this, obj))
+                {
+                    return true;
+                }
+
+                if (obj.GetType() != GetType())
+                {
+                    return false;
+                }
+
                 return Equals((Kvp)obj);
             }
 
@@ -2818,7 +2864,7 @@ namespace Tests
             {
                 unchecked
                 {
-                    return ((Key != null ? Key.GetHashCode() : 0)*397) ^ Item;
+                    return ((Key != null ? Key.GetHashCode() : 0) * 397) ^ Item;
                 }
             }
 
@@ -2843,8 +2889,7 @@ namespace Tests
             }
         }
 
-
-        class EqMod : IEqualityComparer<int>
+        private class EqMod : IEqualityComparer<int>
         {
             private readonly int _d;
 
@@ -2867,7 +2912,7 @@ namespace Tests
         [Fact]
         public void AsAsyncEnumerable_Null()
         {
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.AsAsyncEnumerable<int>((IAsyncEnumerable<int>)null));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.AsAsyncEnumerable<int>(null));
         }
 
         [Fact]
@@ -2963,7 +3008,7 @@ namespace Tests
             await SequenceIdentity(xs);
         }
 
-        static IEnumerable<int> RepeatXs(Action started)
+        private static IEnumerable<int> RepeatXs(Action started)
         {
             started();
 
@@ -2989,7 +3034,7 @@ namespace Tests
             AssertThrows<Exception>(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is NotImplementedException);
         }
 
-        class FailRepeat : IEnumerable<int>
+        private class FailRepeat : IEnumerable<int>
         {
             public IEnumerator<int> GetEnumerator()
             {
@@ -3062,7 +3107,7 @@ namespace Tests
         [Fact]
         public void StartWith_Null()
         {
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.StartWith(default(IAsyncEnumerable<int>), new[] { 1 }));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.StartWith(default, new[] { 1 }));
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.StartWith(AsyncEnumerable.Return(42), null));
         }
 
@@ -3179,15 +3224,15 @@ namespace Tests
         {
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.DistinctUntilChanged(default(IAsyncEnumerable<int>)));
 
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.DistinctUntilChanged(default(IAsyncEnumerable<int>), EqualityComparer<int>.Default));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.DistinctUntilChanged(AsyncEnumerable.Return(42), default(IEqualityComparer<int>)));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.DistinctUntilChanged(default, EqualityComparer<int>.Default));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.DistinctUntilChanged(AsyncEnumerable.Return(42), default));
 
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.DistinctUntilChanged(default(IAsyncEnumerable<int>), x => x));
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.DistinctUntilChanged(AsyncEnumerable.Return(42), default(Func<int, int>)));
 
             AssertThrows<ArgumentNullException>(() => AsyncEnumerable.DistinctUntilChanged(default(IAsyncEnumerable<int>), x => x, EqualityComparer<int>.Default));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.DistinctUntilChanged(AsyncEnumerable.Return(42), default(Func<int, int>), EqualityComparer<int>.Default));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.DistinctUntilChanged(AsyncEnumerable.Return(42), x => x, default(IEqualityComparer<int>)));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.DistinctUntilChanged(AsyncEnumerable.Return(42), default, EqualityComparer<int>.Default));
+            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.DistinctUntilChanged(AsyncEnumerable.Return(42), x => x, default));
         }
 
         [Fact]
@@ -3226,7 +3271,7 @@ namespace Tests
         public void DistinctUntilChanged3()
         {
             var ex = new Exception("Bang!");
-            var xs = new[] { 1, 2, 3, 4, 3, 5, 2 }.ToAsyncEnumerable().DistinctUntilChanged(x => { if (x == 4) throw ex; return x; });
+            var xs = new[] { 1, 2, 3, 4, 3, 5, 2 }.ToAsyncEnumerable().DistinctUntilChanged(x => { if (x == 4) { throw ex; } return x; });
 
             var e = xs.GetEnumerator();
             HasNext(e, 1);
@@ -3456,7 +3501,7 @@ namespace Tests
             var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().TakeLast(0);
 
             var e = xs.GetEnumerator();
-            
+
             NoNext(e);
         }
 

+ 1 - 5
Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.cs

@@ -3,15 +3,11 @@
 // See the LICENSE file in the project root for more information. 
 
 using System;
-using System.Collections;
 using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
 using System.Linq;
-using System.Reflection;
-using System.Threading;
 using System.Threading.Tasks;
-using Xunit;
 using FluentAssertions;
+using Xunit;
 
 
 namespace Tests

+ 1 - 1
Ix.NET/Source/System.Interactive.Async.Tests/TaskExtTests.cs

@@ -1,11 +1,11 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
-using Xunit;
 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Threading.Tasks;
+using Xunit;
 
 namespace Tests
 {

+ 39 - 2
Ix.NET/Source/System.Interactive.Async/Aggregate.cs

@@ -2,9 +2,7 @@
 // // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // // See the LICENSE file in the project root for more information. 
 
-using System;
 using System.Collections.Generic;
-using System.Linq;
 using System.Threading;
 using System.Threading.Tasks;
 
@@ -15,11 +13,19 @@ 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));
+            }
+
             if (accumulator == null)
+            {
                 throw new ArgumentNullException(nameof(accumulator));
+            }
+
             if (resultSelector == null)
+            {
                 throw new ArgumentNullException(nameof(resultSelector));
+            }
 
             return Aggregate(source, seed, accumulator, resultSelector, CancellationToken.None);
         }
@@ -27,9 +33,14 @@ 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));
+            }
+
             if (accumulator == null)
+            {
                 throw new ArgumentNullException(nameof(accumulator));
+            }
 
             return Aggregate(source, seed, accumulator, CancellationToken.None);
         }
@@ -37,9 +48,14 @@ 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));
+            }
+
             if (accumulator == null)
+            {
                 throw new ArgumentNullException(nameof(accumulator));
+            }
 
             return Aggregate(source, accumulator, CancellationToken.None);
         }
@@ -47,11 +63,19 @@ 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));
+            }
+
             if (accumulator == null)
+            {
                 throw new ArgumentNullException(nameof(accumulator));
+            }
+
             if (resultSelector == null)
+            {
                 throw new ArgumentNullException(nameof(resultSelector));
+            }
 
             return Aggregate_(source, seed, accumulator, resultSelector, cancellationToken);
         }
@@ -59,9 +83,14 @@ 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));
+            }
+
             if (accumulator == null)
+            {
                 throw new ArgumentNullException(nameof(accumulator));
+            }
 
             return source.Aggregate(seed, accumulator, x => x, cancellationToken);
         }
@@ -69,9 +98,14 @@ 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));
+            }
+
             if (accumulator == null)
+            {
                 throw new ArgumentNullException(nameof(accumulator));
+            }
 
             return Aggregate_(source, accumulator, cancellationToken);
         }
@@ -108,7 +142,10 @@ namespace System.Linq
                 }
             }
             if (first)
+            {
                 throw new InvalidOperationException(Strings.NO_ELEMENTS);
+            }
+
             return acc;
         }
     }

+ 28 - 2
Ix.NET/Source/System.Interactive.Async/AnyAll.cs

@@ -2,9 +2,7 @@
 // // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // // See the LICENSE file in the project root for more information. 
 
-using System;
 using System.Collections.Generic;
-using System.Linq;
 using System.Threading;
 using System.Threading.Tasks;
 
@@ -15,9 +13,14 @@ 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));
+            }
+
             if (predicate == null)
+            {
                 throw new ArgumentNullException(nameof(predicate));
+            }
 
             return All(source, predicate, CancellationToken.None);
         }
@@ -25,9 +28,14 @@ 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));
+            }
+
             if (predicate == null)
+            {
                 throw new ArgumentNullException(nameof(predicate));
+            }
 
             return All_(source, predicate, cancellationToken);
         }
@@ -35,9 +43,14 @@ 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));
+            }
+
             if (predicate == null)
+            {
                 throw new ArgumentNullException(nameof(predicate));
+            }
 
             return Any(source, predicate, CancellationToken.None);
         }
@@ -45,7 +58,9 @@ namespace System.Linq
         public static Task<bool> Any<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Any(source, CancellationToken.None);
         }
@@ -53,9 +68,14 @@ 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));
+            }
+
             if (predicate == null)
+            {
                 throw new ArgumentNullException(nameof(predicate));
+            }
 
             return Any_(source, predicate, cancellationToken);
         }
@@ -63,7 +83,9 @@ namespace System.Linq
         public static async Task<bool> Any<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             using (var e = source.GetEnumerator())
             {
@@ -79,7 +101,9 @@ namespace System.Linq
                               .ConfigureAwait(false))
                 {
                     if (!predicate(e.Current))
+                    {
                         return false;
+                    }
                 }
             }
             return true;
@@ -93,7 +117,9 @@ namespace System.Linq
                               .ConfigureAwait(false))
                 {
                     if (predicate(e.Current))
+                    {
                         return true;
+                    }
                 }
             }
             return false;

+ 11 - 10
Ix.NET/Source/System.Interactive.Async/AppendPrepend.cs

@@ -2,10 +2,8 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System;
 using System.Collections.Generic;
 using System.Diagnostics;
-using System.Linq;
 using System.Threading;
 using System.Threading.Tasks;
 
@@ -16,7 +14,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Append<TSource>(this IAsyncEnumerable<TSource> source, TSource element)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             if (source is AppendPrepentAsyncIterator<TSource> appendable)
             {
@@ -29,7 +29,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Prepend<TSource>(this IAsyncEnumerable<TSource> source, TSource element)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             if (source is AppendPrepentAsyncIterator<TSource> appendable)
             {
@@ -95,8 +97,7 @@ namespace System.Linq
         {
             private readonly TSource item;
             private readonly bool appending;
-
-            bool hasEnumerator;
+            private bool hasEnumerator;
 
             public AppendPrepend1AsyncIterator(IAsyncEnumerable<TSource> source, TSource item, bool appending)
                 : base(source)
@@ -130,7 +131,7 @@ namespace System.Linq
                         if (!hasEnumerator)
                         {
                             GetSourceEnumerator();
-                            hasEnumerator = true;   
+                            hasEnumerator = true;
                         }
 
                         if (enumerator != null)
@@ -327,8 +328,8 @@ namespace System.Linq
                 return new AppendPrependNAsyncIterator<TSource>(source, prepended, appended);
             }
 
-            int mode;
-            IEnumerator<TSource> appendedEnumerator;
+            private int mode;
+            private IEnumerator<TSource> appendedEnumerator;
 
             public override void Dispose()
             {
@@ -347,7 +348,7 @@ namespace System.Linq
                 {
                     case AsyncIteratorState.Allocated:
                         mode = 1;
-                        state = AsyncIteratorState.Iterating; 
+                        state = AsyncIteratorState.Iterating;
                         goto case AsyncIteratorState.Iterating;
 
                     case AsyncIteratorState.Iterating:
@@ -385,7 +386,7 @@ namespace System.Linq
                                 }
 
                                 break;
-                                
+
 
                             case 4:
                                 if (appendedEnumerator.MoveNext())
@@ -473,7 +474,7 @@ namespace System.Linq
                         list.Add(en.Current);
                     }
                 }
-                
+
                 if (appended != null)
                 {
 

+ 9 - 3
Ix.NET/Source/System.Interactive.Async/AsyncEnumerable.cs

@@ -2,9 +2,7 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System;
 using System.Collections.Generic;
-using System.Linq;
 using System.Threading;
 using System.Threading.Tasks;
 
@@ -15,7 +13,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> AsAsyncEnumerable<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return source.Select(x => x);
         }
@@ -31,7 +31,9 @@ namespace System.Linq
         public static Task<bool> IsEmpty<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return source.IsEmpty(CancellationToken.None);
         }
@@ -39,7 +41,9 @@ namespace System.Linq
         public static Task<bool> IsEmpty<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return IsEmpty_(source, cancellationToken);
         }
@@ -57,13 +61,15 @@ namespace System.Linq
 
         public static IAsyncEnumerable<TValue> Return<TValue>(TValue value)
         {
-            return new[] {value}.ToAsyncEnumerable();
+            return new[] { value }.ToAsyncEnumerable();
         }
 
         public static IAsyncEnumerable<TValue> Throw<TValue>(Exception exception)
         {
             if (exception == null)
+            {
                 throw new ArgumentNullException(nameof(exception));
+            }
 
             return CreateEnumerable(
                 () => CreateEnumerator<TValue>(

+ 3 - 3
Ix.NET/Source/System.Interactive.Async/AsyncEnumerator.cs

@@ -1,10 +1,8 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
-using System;
-using System.Linq;
-using System.Threading.Tasks;
 using System.Threading;
+using System.Threading.Tasks;
 
 namespace System.Collections.Generic
 {
@@ -20,7 +18,9 @@ namespace System.Collections.Generic
         public static Task<bool> MoveNext<T>(this IAsyncEnumerator<T> enumerator)
         {
             if (enumerator == null)
+            {
                 throw new ArgumentNullException(nameof(enumerator));
+            }
 
             return enumerator.MoveNext(CancellationToken.None);
         }

+ 4 - 1
Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs

@@ -59,7 +59,7 @@ namespace System.Linq
                     cancellationTokenSource.Dispose();
                 }
 
-                current = default(TSource);
+                current = default;
                 state = AsyncIteratorState.Disposed;
             }
 
@@ -68,7 +68,10 @@ namespace System.Linq
                 get
                 {
                     if (currentIsInvalid)
+                    {
                         throw new InvalidOperationException("Enumerator is in an invalid state");
+                    }
+
                     return current;
                 }
             }

+ 152 - 12
Ix.NET/Source/System.Interactive.Async/Average.cs

@@ -2,9 +2,7 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System;
 using System.Collections.Generic;
-using System.Linq;
 using System.Threading;
 using System.Threading.Tasks;
 
@@ -15,21 +13,29 @@ namespace System.Linq
         public static Task<double> Average(this IAsyncEnumerable<int> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             return Average(source, CancellationToken.None);
         }
 
         public static Task<double?> Average(this IAsyncEnumerable<int?> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             return Average(source, CancellationToken.None);
         }
 
         public static Task<double> Average(this IAsyncEnumerable<long> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Average(source, CancellationToken.None);
         }
@@ -37,7 +43,9 @@ namespace System.Linq
         public static Task<double?> Average(this IAsyncEnumerable<long?> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Average(source, CancellationToken.None);
         }
@@ -45,7 +53,9 @@ namespace System.Linq
         public static Task<double> Average(this IAsyncEnumerable<double> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Average(source, CancellationToken.None);
         }
@@ -53,7 +63,9 @@ namespace System.Linq
         public static Task<double?> Average(this IAsyncEnumerable<double?> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Average(source, CancellationToken.None);
         }
@@ -61,7 +73,9 @@ namespace System.Linq
         public static Task<float> Average(this IAsyncEnumerable<float> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Average(source, CancellationToken.None);
         }
@@ -69,7 +83,9 @@ namespace System.Linq
         public static Task<float?> Average(this IAsyncEnumerable<float?> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Average(source, CancellationToken.None);
         }
@@ -77,7 +93,9 @@ namespace System.Linq
         public static Task<decimal> Average(this IAsyncEnumerable<decimal> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Average(source, CancellationToken.None);
         }
@@ -85,7 +103,9 @@ namespace System.Linq
         public static Task<decimal?> Average(this IAsyncEnumerable<decimal?> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Average(source, CancellationToken.None);
         }
@@ -93,9 +113,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Average(source, selector, CancellationToken.None);
         }
@@ -103,9 +128,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Average(source, selector, CancellationToken.None);
         }
@@ -113,9 +143,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Average(source, selector, CancellationToken.None);
         }
@@ -123,9 +158,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Average(source, selector, CancellationToken.None);
         }
@@ -133,9 +173,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Average(source, selector, CancellationToken.None);
         }
@@ -143,9 +188,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Average(source, selector, CancellationToken.None);
         }
@@ -153,9 +203,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Average(source, selector, CancellationToken.None);
         }
@@ -163,9 +218,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Average(source, selector, CancellationToken.None);
         }
@@ -173,9 +233,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Average(source, selector, CancellationToken.None);
         }
@@ -183,9 +248,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Average(source, selector, CancellationToken.None);
         }
@@ -194,7 +264,9 @@ namespace System.Linq
         public static Task<double> Average(this IAsyncEnumerable<int> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Average_(source, cancellationToken);
         }
@@ -202,7 +274,9 @@ namespace System.Linq
         public static Task<double?> Average(this IAsyncEnumerable<int?> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Average_(source, cancellationToken);
         }
@@ -210,7 +284,9 @@ namespace System.Linq
         public static Task<double> Average(this IAsyncEnumerable<long> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Average_(source, cancellationToken);
         }
@@ -218,7 +294,9 @@ namespace System.Linq
         public static Task<double?> Average(this IAsyncEnumerable<long?> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Average_(source, cancellationToken);
         }
@@ -226,7 +304,9 @@ namespace System.Linq
         public static Task<double> Average(this IAsyncEnumerable<double> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Average_(source, cancellationToken);
         }
@@ -234,7 +314,9 @@ namespace System.Linq
         public static Task<double?> Average(this IAsyncEnumerable<double?> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Average_(source, cancellationToken);
         }
@@ -242,7 +324,9 @@ namespace System.Linq
         public static Task<float> Average(this IAsyncEnumerable<float> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Average_(source, cancellationToken);
         }
@@ -250,7 +334,9 @@ namespace System.Linq
         public static Task<float?> Average(this IAsyncEnumerable<float?> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Average_(source, cancellationToken);
         }
@@ -258,7 +344,9 @@ namespace System.Linq
         public static Task<decimal> Average(this IAsyncEnumerable<decimal> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Average_(source, cancellationToken);
         }
@@ -266,7 +354,9 @@ namespace System.Linq
         public static Task<decimal?> Average(this IAsyncEnumerable<decimal?> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Average_(source, cancellationToken);
         }
@@ -274,9 +364,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Average(cancellationToken);
@@ -285,9 +380,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Average(cancellationToken);
@@ -296,9 +396,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Average(cancellationToken);
@@ -307,9 +412,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Average(cancellationToken);
@@ -318,9 +428,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Average(cancellationToken);
@@ -329,9 +444,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Average(cancellationToken);
@@ -340,9 +460,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Average(cancellationToken);
@@ -351,9 +476,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Average(cancellationToken);
@@ -362,9 +492,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Average(cancellationToken);
@@ -373,9 +508,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Average(cancellationToken);
@@ -403,7 +543,7 @@ namespace System.Linq
                     }
                 }
 
-                return (double)sum/count;
+                return (double)sum / count;
             }
         }
 
@@ -433,7 +573,7 @@ namespace System.Linq
                             }
                         }
 
-                        return (double)sum/count;
+                        return (double)sum / count;
                     }
                 }
             }
@@ -463,7 +603,7 @@ namespace System.Linq
                     }
                 }
 
-                return (double)sum/count;
+                return (double)sum / count;
             }
         }
 
@@ -493,7 +633,7 @@ namespace System.Linq
                             }
                         }
 
-                        return (double)sum/count;
+                        return (double)sum / count;
                     }
                 }
             }
@@ -523,7 +663,7 @@ namespace System.Linq
                     ++count;
                 }
 
-                return sum/count;
+                return sum / count;
             }
         }
 
@@ -553,7 +693,7 @@ namespace System.Linq
                             }
                         }
 
-                        return sum/count;
+                        return sum / count;
                     }
                 }
             }
@@ -580,7 +720,7 @@ namespace System.Linq
                     ++count;
                 }
 
-                return (float)(sum/count);
+                return (float)(sum / count);
             }
         }
 
@@ -610,7 +750,7 @@ namespace System.Linq
                             }
                         }
 
-                        return (float)(sum/count);
+                        return (float)(sum / count);
                     }
                 }
             }
@@ -637,7 +777,7 @@ namespace System.Linq
                     ++count;
                 }
 
-                return sum/count;
+                return sum / count;
             }
         }
 
@@ -664,7 +804,7 @@ namespace System.Linq
                             }
                         }
 
-                        return sum/count;
+                        return sum / count;
                     }
                 }
             }

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

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

+ 4 - 3
Ix.NET/Source/System.Interactive.Async/Cast.cs

@@ -2,10 +2,7 @@
 // // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // // See the LICENSE file in the project root for more information. 
 
-using System;
 using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
 
 namespace System.Linq
 {
@@ -14,7 +11,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TResult> Cast<TResult>(this IAsyncEnumerable<object> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             // Check to see if it already is and short-circuit
             if (source is IAsyncEnumerable<TResult> typedSource)
@@ -28,7 +27,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TType> OfType<TType>(this IAsyncEnumerable<object> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return source.Where(x => x is TType)
                          .Cast<TType>();

+ 16 - 2
Ix.NET/Source/System.Interactive.Async/Catch.cs

@@ -16,9 +16,14 @@ namespace System.Linq
             where TException : Exception
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (handler == null)
+            {
                 throw new ArgumentNullException(nameof(handler));
+            }
 
             return new CatchAsyncIterator<TSource, TException>(source, handler);
         }
@@ -26,7 +31,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Catch<TSource>(this IEnumerable<IAsyncEnumerable<TSource>> sources)
         {
             if (sources == null)
+            {
                 throw new ArgumentNullException(nameof(sources));
+            }
 
             return sources.Catch_();
         }
@@ -34,7 +41,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Catch<TSource>(params IAsyncEnumerable<TSource>[] sources)
         {
             if (sources == null)
+            {
                 throw new ArgumentNullException(nameof(sources));
+            }
 
             return sources.Catch_();
         }
@@ -42,11 +51,16 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Catch<TSource>(this IAsyncEnumerable<TSource> first, IAsyncEnumerable<TSource> second)
         {
             if (first == null)
+            {
                 throw new ArgumentNullException(nameof(first));
+            }
+
             if (second == null)
+            {
                 throw new ArgumentNullException(nameof(second));
+            }
 
-            return new[] {first, second}.Catch_();
+            return new[] { first, second }.Catch_();
         }
 
         private static IAsyncEnumerable<TSource> Catch_<TSource>(this IEnumerable<IAsyncEnumerable<TSource>> sources)
@@ -233,7 +247,7 @@ namespace System.Linq
 
                         break; // case
                 }
-                
+
                 Dispose();
                 return false;
             }

+ 15 - 7
Ix.NET/Source/System.Interactive.Async/Concatenate.cs

@@ -14,9 +14,14 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Concat<TSource>(this IAsyncEnumerable<TSource> first, IAsyncEnumerable<TSource> second)
         {
             if (first == null)
+            {
                 throw new ArgumentNullException(nameof(first));
+            }
+
             if (second == null)
+            {
                 throw new ArgumentNullException(nameof(second));
+            }
 
             return first is ConcatAsyncIterator<TSource> concatFirst ?
                        concatFirst.Concat(second) :
@@ -26,7 +31,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Concat<TSource>(this IEnumerable<IAsyncEnumerable<TSource>> sources)
         {
             if (sources == null)
+            {
                 throw new ArgumentNullException(nameof(sources));
+            }
 
             return sources.Concat_();
         }
@@ -34,7 +41,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Concat<TSource>(params IAsyncEnumerable<TSource>[] sources)
         {
             if (sources == null)
+            {
                 throw new ArgumentNullException(nameof(sources));
+            }
 
             return sources.Concat_();
         }
@@ -81,9 +90,8 @@ namespace System.Linq
             private IEnumerator<IAsyncEnumerable<TSource>> _outerEnumerator;
             private IAsyncEnumerator<TSource> _currentEnumerator;
             private int _mode;
-
-            const int State_OuterNext = 1;
-            const int State_While = 4;
+            private const int State_OuterNext = 1;
+            private const int State_While = 4;
 
             protected override async Task<bool> MoveNextCore(CancellationToken cancellationToken)
             {
@@ -105,7 +113,7 @@ namespace System.Linq
                                     // make sure we dispose the previous one if we're about to replace it
                                     _currentEnumerator?.Dispose();
                                     _currentEnumerator = _outerEnumerator.Current.GetEnumerator();
-                                   
+
                                     _mode = State_While;
                                     goto case State_While;
                                 }
@@ -121,7 +129,7 @@ namespace System.Linq
 
                                 // No more on the inner enumerator, move to the next outer
                                 goto case State_OuterNext;
-                   
+
                         }
 
                         Dispose();
@@ -183,7 +191,7 @@ namespace System.Linq
             public async Task<List<TSource>> ToListAsync(CancellationToken cancellationToken)
             {
                 var list = new List<TSource>();
-                for (var i = 0;; i++)
+                for (var i = 0; ; i++)
                 {
                     var source = GetAsyncEnumerable(i);
                     if (source == null)
@@ -211,7 +219,7 @@ namespace System.Linq
                 }
 
                 var count = 0;
-                for (var i = 0;; i++)
+                for (var i = 0; ; i++)
                 {
                     var source = GetAsyncEnumerable(i);
                     if (source == null)

+ 14 - 2
Ix.NET/Source/System.Interactive.Async/Contains.cs

@@ -2,9 +2,7 @@
 // // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // // See the LICENSE file in the project root for more information. 
 
-using System;
 using System.Collections.Generic;
-using System.Linq;
 using System.Threading;
 using System.Threading.Tasks;
 
@@ -15,9 +13,14 @@ 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));
+            }
+
             if (comparer == null)
+            {
                 throw new ArgumentNullException(nameof(comparer));
+            }
 
             return Contains(source, value, comparer, CancellationToken.None);
         }
@@ -25,7 +28,9 @@ namespace System.Linq
         public static Task<bool> Contains<TSource>(this IAsyncEnumerable<TSource> source, TSource value)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Contains(source, value, CancellationToken.None);
         }
@@ -33,9 +38,14 @@ 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));
+            }
+
             if (comparer == null)
+            {
                 throw new ArgumentNullException(nameof(comparer));
+            }
 
             return source.Any(x => comparer.Equals(x, value), cancellationToken);
         }
@@ -43,7 +53,9 @@ 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));
+            }
 
             return source.Contains(value, EqualityComparer<TSource>.Default, cancellationToken);
         }

+ 28 - 2
Ix.NET/Source/System.Interactive.Async/Count.cs

@@ -2,9 +2,7 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System;
 using System.Collections.Generic;
-using System.Linq;
 using System.Threading;
 using System.Threading.Tasks;
 
@@ -15,7 +13,9 @@ namespace System.Linq
         public static Task<int> Count<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             if (source is ICollection<TSource> collection)
             {
@@ -33,9 +33,14 @@ 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));
+            }
+
             if (predicate == null)
+            {
                 throw new ArgumentNullException(nameof(predicate));
+            }
 
             return source.Where(predicate)
                          .Aggregate(0, (c, _) => checked(c + 1), cancellationToken);
@@ -44,7 +49,9 @@ namespace System.Linq
         public static Task<int> Count<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Count(source, CancellationToken.None);
         }
@@ -52,9 +59,14 @@ 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));
+            }
+
             if (predicate == null)
+            {
                 throw new ArgumentNullException(nameof(predicate));
+            }
 
             return Count(source, predicate, CancellationToken.None);
         }
@@ -62,7 +74,9 @@ namespace System.Linq
         public static Task<long> LongCount<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return source.Aggregate(0L, (c, _) => checked(c + 1), cancellationToken);
         }
@@ -70,9 +84,14 @@ 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));
+            }
+
             if (predicate == null)
+            {
                 throw new ArgumentNullException(nameof(predicate));
+            }
 
             return source.Where(predicate)
                          .Aggregate(0L, (c, _) => checked(c + 1), cancellationToken);
@@ -81,7 +100,9 @@ namespace System.Linq
         public static Task<long> LongCount<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return LongCount(source, CancellationToken.None);
         }
@@ -89,9 +110,14 @@ 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));
+            }
+
             if (predicate == null)
+            {
                 throw new ArgumentNullException(nameof(predicate));
+            }
 
             return LongCount(source, predicate, CancellationToken.None);
         }

+ 4 - 0
Ix.NET/Source/System.Interactive.Async/Create.cs

@@ -14,7 +14,9 @@ namespace System.Linq
         public static IAsyncEnumerable<T> CreateEnumerable<T>(Func<IAsyncEnumerator<T>> getEnumerator)
         {
             if (getEnumerator == null)
+            {
                 throw new ArgumentNullException(nameof(getEnumerator));
+            }
 
             return new AnonymousAsyncEnumerable<T>(getEnumerator);
         }
@@ -22,7 +24,9 @@ namespace System.Linq
         public static IAsyncEnumerator<T> CreateEnumerator<T>(Func<CancellationToken, Task<bool>> moveNext, Func<T> current, Action dispose)
         {
             if (moveNext == null)
+            {
                 throw new ArgumentNullException(nameof(moveNext));
+            }
 
             // Note: Many methods pass null in for the second two params. We're assuming
             // That the caller is responsible and knows what they're doing

+ 6 - 2
Ix.NET/Source/System.Interactive.Async/DefaultIfEmpty.cs

@@ -15,7 +15,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> DefaultIfEmpty<TSource>(this IAsyncEnumerable<TSource> source, TSource defaultValue)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return new DefaultIfEmptyAsyncIterator<TSource>(source, defaultValue);
         }
@@ -23,9 +25,11 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> DefaultIfEmpty<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
-            return DefaultIfEmpty(source, default(TSource));
+            return DefaultIfEmpty(source, default);
         }
 
         private sealed class DefaultIfEmptyAsyncIterator<TSource> : AsyncIterator<TSource>, IIListProvider<TSource>
@@ -77,7 +81,7 @@ namespace System.Linq
                             enumerator.Dispose();
                             enumerator = null;
 
-                            state = AsyncIteratorState.Disposed; 
+                            state = AsyncIteratorState.Disposed;
                         }
                         return true;
 

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

@@ -2,10 +2,7 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System;
 using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
 
 namespace System.Linq
 {
@@ -14,7 +11,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Defer<TSource>(Func<IAsyncEnumerable<TSource>> factory)
         {
             if (factory == null)
+            {
                 throw new ArgumentNullException(nameof(factory));
+            }
 
             return CreateEnumerable(
                 () => factory()

+ 3 - 3
Ix.NET/Source/System.Interactive.Async/Disposables.cs

@@ -5,7 +5,7 @@ using System.Threading;
 
 namespace System.Linq
 {
-    class CancellationTokenDisposable : IDisposable
+    internal class CancellationTokenDisposable : IDisposable
     {
         private readonly CancellationTokenSource cts = new CancellationTokenSource();
 
@@ -26,7 +26,7 @@ namespace System.Linq
         }
     }
 
-    static class Disposable
+    internal static class Disposable
     {
         public static IDisposable Create(IDisposable d1, IDisposable d2)
         {
@@ -34,7 +34,7 @@ namespace System.Linq
         }
     }
 
-    class BinaryDisposable : IDisposable
+    internal class BinaryDisposable : IDisposable
     {
         private IDisposable _d1;
         private IDisposable _d2;

+ 42 - 2
Ix.NET/Source/System.Interactive.Async/Distinct.cs

@@ -14,11 +14,19 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
+
             if (comparer == null)
+            {
                 throw new ArgumentNullException(nameof(comparer));
+            }
 
             return new DistinctAsyncIterator<TSource, TKey>(source, keySelector, comparer);
         }
@@ -26,9 +34,14 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
 
             return source.Distinct(keySelector, EqualityComparer<TKey>.Default);
         }
@@ -36,9 +49,14 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Distinct<TSource>(this IAsyncEnumerable<TSource> source, IEqualityComparer<TSource> comparer)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (comparer == null)
+            {
                 throw new ArgumentNullException(nameof(comparer));
+            }
 
             return new DistinctAsyncIterator<TSource>(source, comparer);
         }
@@ -46,7 +64,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Distinct<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return source.Distinct(EqualityComparer<TSource>.Default);
         }
@@ -54,7 +74,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> DistinctUntilChanged<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return source.DistinctUntilChanged(EqualityComparer<TSource>.Default);
         }
@@ -62,9 +84,14 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> DistinctUntilChanged<TSource>(this IAsyncEnumerable<TSource> source, IEqualityComparer<TSource> comparer)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (comparer == null)
+            {
                 throw new ArgumentNullException(nameof(comparer));
+            }
 
             return new DistinctUntilChangedAsyncIterator<TSource>(source, comparer);
         }
@@ -72,9 +99,14 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
 
             return source.DistinctUntilChanged_(keySelector, EqualityComparer<TKey>.Default);
         }
@@ -82,11 +114,19 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
+
             if (comparer == null)
+            {
                 throw new ArgumentNullException(nameof(comparer));
+            }
 
             return source.DistinctUntilChanged_(keySelector, comparer);
         }
@@ -369,7 +409,7 @@ namespace System.Linq
                 {
                     enumerator.Dispose();
                     enumerator = null;
-                    currentValue = default(TSource);
+                    currentValue = default;
                 }
 
                 base.Dispose();
@@ -440,7 +480,7 @@ namespace System.Linq
                 {
                     enumerator.Dispose();
                     enumerator = null;
-                    currentKeyValue = default(TKey);
+                    currentKeyValue = default;
                 }
 
                 base.Dispose();

+ 37 - 0
Ix.NET/Source/System.Interactive.Async/Do.cs

@@ -14,9 +14,14 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Do<TSource>(this IAsyncEnumerable<TSource> source, Action<TSource> onNext)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (onNext == null)
+            {
                 throw new ArgumentNullException(nameof(onNext));
+            }
 
             return DoHelper(source, onNext, null, null);
         }
@@ -24,11 +29,19 @@ 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));
+            }
+
             if (onNext == null)
+            {
                 throw new ArgumentNullException(nameof(onNext));
+            }
+
             if (onCompleted == null)
+            {
                 throw new ArgumentNullException(nameof(onCompleted));
+            }
 
             return DoHelper(source, onNext, null, onCompleted);
         }
@@ -36,11 +49,19 @@ 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));
+            }
+
             if (onNext == null)
+            {
                 throw new ArgumentNullException(nameof(onNext));
+            }
+
             if (onError == null)
+            {
                 throw new ArgumentNullException(nameof(onError));
+            }
 
             return DoHelper(source, onNext, onError, null);
         }
@@ -48,13 +69,24 @@ 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));
+            }
+
             if (onNext == null)
+            {
                 throw new ArgumentNullException(nameof(onNext));
+            }
+
             if (onError == null)
+            {
                 throw new ArgumentNullException(nameof(onError));
+            }
+
             if (onCompleted == null)
+            {
                 throw new ArgumentNullException(nameof(onCompleted));
+            }
 
             return DoHelper(source, onNext, onError, onCompleted);
         }
@@ -62,9 +94,14 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Do<TSource>(this IAsyncEnumerable<TSource> source, IObserver<TSource> observer)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (observer == null)
+            {
                 throw new ArgumentNullException(nameof(observer));
+            }
 
             return DoHelper(source, observer.OnNext, observer.OnError, observer.OnCompleted);
         }

+ 15 - 3
Ix.NET/Source/System.Interactive.Async/ElementAt.cs

@@ -2,9 +2,7 @@
 // // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // // See the LICENSE file in the project root for more information. 
 
-using System;
 using System.Collections.Generic;
-using System.Linq;
 using System.Threading;
 using System.Threading.Tasks;
 
@@ -15,9 +13,14 @@ 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));
+            }
+
             if (index < 0)
+            {
                 throw new ArgumentOutOfRangeException(nameof(index));
+            }
 
             return ElementAt_(source, index, cancellationToken);
         }
@@ -26,7 +29,9 @@ namespace System.Linq
         public static Task<TSource> ElementAt<TSource>(this IAsyncEnumerable<TSource> source, int index)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return ElementAt(source, index, CancellationToken.None);
         }
@@ -34,9 +39,14 @@ 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));
+            }
+
             if (index < 0)
+            {
                 throw new ArgumentOutOfRangeException(nameof(index));
+            }
 
             return ElementAtOrDefault_(source, index, cancellationToken);
         }
@@ -44,7 +54,9 @@ namespace System.Linq
         public static Task<TSource> ElementAtOrDefault<TSource>(this IAsyncEnumerable<TSource> source, int index)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return ElementAtOrDefault(source, index, CancellationToken.None);
         }
@@ -95,7 +107,7 @@ namespace System.Linq
                 }
             }
 
-            return default(TSource);
+            return default;
         }
     }
 }

+ 14 - 1
Ix.NET/Source/System.Interactive.Async/Except.cs

@@ -14,9 +14,14 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Except<TSource>(this IAsyncEnumerable<TSource> first, IAsyncEnumerable<TSource> second)
         {
             if (first == null)
+            {
                 throw new ArgumentNullException(nameof(first));
+            }
+
             if (second == null)
+            {
                 throw new ArgumentNullException(nameof(second));
+            }
 
             return first.Except(second, EqualityComparer<TSource>.Default);
         }
@@ -24,11 +29,19 @@ 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));
+            }
+
             if (second == null)
+            {
                 throw new ArgumentNullException(nameof(second));
+            }
+
             if (comparer == null)
+            {
                 throw new ArgumentNullException(nameof(comparer));
+            }
 
             return new ExceptAsyncIterator<TSource>(first, second, comparer);
         }
@@ -118,7 +131,7 @@ namespace System.Linq
                             }
 
                         } while (moveNext);
-                        
+
 
                         Dispose();
                         break;

+ 5 - 0
Ix.NET/Source/System.Interactive.Async/Expand.cs

@@ -14,9 +14,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return new ExpandAsyncIterator<TSource>(source, selector);
         }

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

@@ -14,9 +14,14 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Finally<TSource>(this IAsyncEnumerable<TSource> source, Action finallyAction)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (finallyAction == null)
+            {
                 throw new ArgumentNullException(nameof(finallyAction));
+            }
 
             return new FinallyAsyncIterator<TSource>(source, finallyAction);
         }
@@ -27,10 +32,8 @@ namespace System.Linq
             private readonly IAsyncEnumerable<TSource> source;
 
             private IAsyncEnumerator<TSource> enumerator;
-
-            CancellationTokenRegistration _tokenRegistration;
-
-            int _once;
+            private CancellationTokenRegistration _tokenRegistration;
+            private int _once;
 
             public FinallyAsyncIterator(IAsyncEnumerable<TSource> source, Action finallyAction)
             {

+ 29 - 3
Ix.NET/Source/System.Interactive.Async/First.cs

@@ -2,9 +2,7 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System;
 using System.Collections.Generic;
-using System.Linq;
 using System.Threading;
 using System.Threading.Tasks;
 
@@ -15,7 +13,9 @@ namespace System.Linq
         public static Task<TSource> First<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return First(source, CancellationToken.None);
         }
@@ -23,9 +23,14 @@ 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));
+            }
+
             if (predicate == null)
+            {
                 throw new ArgumentNullException(nameof(predicate));
+            }
 
             return First(source, predicate, CancellationToken.None);
         }
@@ -33,7 +38,9 @@ namespace System.Linq
         public static Task<TSource> First<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return First_(source, cancellationToken);
         }
@@ -41,9 +48,14 @@ 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));
+            }
+
             if (predicate == null)
+            {
                 throw new ArgumentNullException(nameof(predicate));
+            }
 
             return source.Where(predicate)
                          .First(cancellationToken);
@@ -52,7 +64,9 @@ namespace System.Linq
         public static Task<TSource> FirstOrDefault<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return FirstOrDefault(source, CancellationToken.None);
         }
@@ -60,9 +74,14 @@ 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));
+            }
+
             if (predicate == null)
+            {
                 throw new ArgumentNullException(nameof(predicate));
+            }
 
             return FirstOrDefault(source, predicate, CancellationToken.None);
         }
@@ -70,7 +89,9 @@ namespace System.Linq
         public static Task<TSource> FirstOrDefault<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return FirstOrDefault_(source, cancellationToken);
         }
@@ -78,9 +99,14 @@ 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));
+            }
+
             if (predicate == null)
+            {
                 throw new ArgumentNullException(nameof(predicate));
+            }
 
             return source.Where(predicate)
                          .FirstOrDefault(cancellationToken);
@@ -121,7 +147,7 @@ namespace System.Linq
                     return e.Current;
                 }
             }
-            return default(TSource);
+            return default;
         }
     }
 }

+ 40 - 2
Ix.NET/Source/System.Interactive.Async/ForEach.cs

@@ -2,9 +2,7 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System;
 using System.Collections.Generic;
-using System.Linq;
 using System.Threading;
 using System.Threading.Tasks;
 
@@ -15,9 +13,14 @@ namespace System.Linq
         public static void ForEach<TSource>(this IAsyncEnumerable<TSource> source, Action<TSource> action)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             source.ForEach(action, CancellationToken.None);
         }
@@ -25,9 +28,14 @@ namespace System.Linq
         public static void ForEach<TSource>(this IAsyncEnumerable<TSource> source, Action<TSource, int> action)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             source.ForEach(action, CancellationToken.None);
         }
@@ -36,9 +44,14 @@ namespace System.Linq
         public static void ForEach<TSource>(this IAsyncEnumerable<TSource> source, Action<TSource> action, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             source.ForEachAsync(action, cancellationToken)
                   .Wait(cancellationToken);
@@ -47,9 +60,14 @@ namespace System.Linq
         public static void ForEach<TSource>(this IAsyncEnumerable<TSource> source, Action<TSource, int> action, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             source.ForEachAsync(action, cancellationToken)
                   .Wait(cancellationToken);
@@ -58,9 +76,14 @@ namespace System.Linq
         public static Task ForEachAsync<TSource>(this IAsyncEnumerable<TSource> source, Action<TSource> action)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return ForEachAsync(source, action, CancellationToken.None);
         }
@@ -68,9 +91,14 @@ namespace System.Linq
         public static Task ForEachAsync<TSource>(this IAsyncEnumerable<TSource> source, Action<TSource, int> action)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return ForEachAsync(source, action, CancellationToken.None);
         }
@@ -78,9 +106,14 @@ 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));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return source.ForEachAsync((x, i) => action(x), cancellationToken);
         }
@@ -88,9 +121,14 @@ 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));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return ForEachAsync_(source, action, cancellationToken);
         }

+ 9 - 1
Ix.NET/Source/System.Interactive.Async/Generate.cs

@@ -14,11 +14,19 @@ 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));
+            }
+
             if (iterate == null)
+            {
                 throw new ArgumentNullException(nameof(iterate));
+            }
+
             if (resultSelector == null)
+            {
                 throw new ArgumentNullException(nameof(resultSelector));
+            }
 
             return new GenerateAsyncIterator<TState, TResult>(initialState, condition, iterate, resultSelector);
         }
@@ -53,7 +61,7 @@ namespace System.Linq
 
             public override void Dispose()
             {
-                currentState = default(TState);
+                currentState = default;
 
                 base.Dispose();
             }

+ 32 - 4
Ix.NET/Source/System.Interactive.Async/GroupJoin.cs

@@ -2,9 +2,7 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System;
 using System.Collections.Generic;
-using System.Linq;
 using System.Threading;
 using System.Threading.Tasks;
 
@@ -15,18 +13,34 @@ 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));
+            }
+
             if (inner == null)
+            {
                 throw new ArgumentNullException(nameof(inner));
+            }
+
             if (outerKeySelector == null)
+            {
                 throw new ArgumentNullException(nameof(outerKeySelector));
+            }
+
             if (innerKeySelector == null)
+            {
                 throw new ArgumentNullException(nameof(innerKeySelector));
+            }
+
             if (resultSelector == null)
+            {
                 throw new ArgumentNullException(nameof(resultSelector));
+            }
+
             if (comparer == null)
+            {
                 throw new ArgumentNullException(nameof(comparer));
-
+            }
 
             return new GroupJoinAsyncEnumerable<TOuter, TInner, TKey, TResult>(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer);
         }
@@ -34,20 +48,34 @@ 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));
+            }
+
             if (inner == null)
+            {
                 throw new ArgumentNullException(nameof(inner));
+            }
+
             if (outerKeySelector == null)
+            {
                 throw new ArgumentNullException(nameof(outerKeySelector));
+            }
+
             if (innerKeySelector == null)
+            {
                 throw new ArgumentNullException(nameof(innerKeySelector));
+            }
+
             if (resultSelector == null)
+            {
                 throw new ArgumentNullException(nameof(resultSelector));
+            }
 
             return outer.GroupJoin(inner, outerKeySelector, innerKeySelector, resultSelector, EqualityComparer<TKey>.Default);
         }
 
-       
+
 
 
         private sealed class GroupJoinAsyncEnumerable<TOuter, TInner, TKey, TResult> : IAsyncEnumerable<TResult>

+ 78 - 3
Ix.NET/Source/System.Interactive.Async/Grouping.cs

@@ -5,7 +5,6 @@
 using System.Collections;
 using System.Collections.Generic;
 using System.Diagnostics;
-using System.Runtime.ExceptionServices;
 using System.Threading;
 using System.Threading.Tasks;
 
@@ -16,13 +15,24 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
+
             if (elementSelector == null)
+            {
                 throw new ArgumentNullException(nameof(elementSelector));
+            }
+
             if (comparer == null)
+            {
                 throw new ArgumentNullException(nameof(comparer));
+            }
 
             return new GroupedAsyncEnumerable<TSource, TKey, TElement>(source, keySelector, elementSelector, comparer);
         }
@@ -30,11 +40,19 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
+
             if (elementSelector == null)
+            {
                 throw new ArgumentNullException(nameof(elementSelector));
+            }
 
             return source.GroupBy(keySelector, elementSelector, EqualityComparer<TKey>.Default);
         }
@@ -42,11 +60,19 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
+
             if (comparer == null)
+            {
                 throw new ArgumentNullException(nameof(comparer));
+            }
 
             return new GroupedAsyncEnumerable<TSource, TKey>(source, keySelector, comparer);
         }
@@ -54,9 +80,14 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
 
             return new GroupedAsyncEnumerable<TSource, TKey>(source, keySelector, EqualityComparer<TKey>.Default);
         }
@@ -64,15 +95,29 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
+
             if (elementSelector == null)
+            {
                 throw new ArgumentNullException(nameof(elementSelector));
+            }
+
             if (resultSelector == null)
+            {
                 throw new ArgumentNullException(nameof(resultSelector));
+            }
+
             if (comparer == null)
+            {
                 throw new ArgumentNullException(nameof(comparer));
+            }
 
             return source.GroupBy(keySelector, elementSelector, comparer)
                          .Select(g => resultSelector(g.Key, g));
@@ -81,13 +126,24 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
+
             if (elementSelector == null)
+            {
                 throw new ArgumentNullException(nameof(elementSelector));
+            }
+
             if (resultSelector == null)
+            {
                 throw new ArgumentNullException(nameof(resultSelector));
+            }
 
             return source.GroupBy(keySelector, elementSelector, EqualityComparer<TKey>.Default)
                          .Select(g => resultSelector(g.Key, g));
@@ -96,13 +152,24 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
+
             if (resultSelector == null)
+            {
                 throw new ArgumentNullException(nameof(resultSelector));
+            }
+
             if (comparer == null)
+            {
                 throw new ArgumentNullException(nameof(comparer));
+            }
 
             return new GroupedResultAsyncEnumerable<TSource, TKey, TResult>(source, keySelector, resultSelector, comparer);
         }
@@ -110,11 +177,19 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
+
             if (resultSelector == null)
+            {
                 throw new ArgumentNullException(nameof(resultSelector));
+            }
 
             return GroupBy(source, keySelector, resultSelector, EqualityComparer<TKey>.Default);
         }
@@ -271,7 +346,7 @@ namespace System.Linq
 
                 return false;
             }
-            
+
             public async Task<IAsyncGrouping<TKey, TElement>[]> ToArrayAsync(CancellationToken cancellationToken)
             {
                 IIListProvider<IAsyncGrouping<TKey, TElement>> l = await Internal.Lookup<TKey, TElement>.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false);
@@ -489,7 +564,7 @@ namespace System.Linq.Internal
         {
             if (_elements.Length == _count)
             {
-                Array.Resize(ref _elements, checked(_count*2));
+                Array.Resize(ref _elements, checked(_count * 2));
             }
 
             _elements[_count] = element;

+ 0 - 4
Ix.NET/Source/System.Interactive.Async/IAsyncEnumerable.cs

@@ -2,10 +2,6 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
 
 namespace System.Collections.Generic
 {

+ 0 - 3
Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs

@@ -2,9 +2,6 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System;
-using System.Collections.Generic;
-using System.Linq;
 using System.Threading;
 using System.Threading.Tasks;
 

+ 0 - 3
Ix.NET/Source/System.Interactive.Async/IAsyncGrouping.cs

@@ -2,10 +2,7 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System;
 using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
 
 namespace System.Linq
 {

+ 2 - 4
Ix.NET/Source/System.Interactive.Async/IIListProvider.cs

@@ -1,6 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
+using System.Collections.Generic;
 using System.Threading;
 using System.Threading.Tasks;
 
@@ -9,7 +7,7 @@ namespace System.Linq
     /// <summary>
     /// An iterator that can produce an array or <see cref="List{TElement}"/> through an optimized path.
     /// </summary>
-    interface IIListProvider<TElement> : IAsyncEnumerable<TElement>
+    internal interface IIListProvider<TElement> : IAsyncEnumerable<TElement>
     {
         /// <summary>
         /// Produce an array of the sequence through an optimized path.

+ 0 - 1
Ix.NET/Source/System.Interactive.Async/IOrderedAsyncEnumerable.cs

@@ -1,7 +1,6 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
-using System;
 using System.Collections.Generic;
 
 namespace System.Linq

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

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

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

@@ -14,11 +14,19 @@ 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));
+            }
+
             if (second == null)
+            {
                 throw new ArgumentNullException(nameof(second));
+            }
+
             if (comparer == null)
+            {
                 throw new ArgumentNullException(nameof(comparer));
+            }
 
             return new IntersectAsyncIterator<TSource>(first, second, comparer);
         }
@@ -27,9 +35,14 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Intersect<TSource>(this IAsyncEnumerable<TSource> first, IAsyncEnumerable<TSource> second)
         {
             if (first == null)
+            {
                 throw new ArgumentNullException(nameof(first));
+            }
+
             if (second == null)
+            {
                 throw new ArgumentNullException(nameof(second));
+            }
 
             return first.Intersect(second, EqualityComparer<TSource>.Default);
         }

+ 43 - 13
Ix.NET/Source/System.Interactive.Async/Join.cs

@@ -14,17 +14,34 @@ 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));
+            }
+
             if (inner == null)
+            {
                 throw new ArgumentNullException(nameof(inner));
+            }
+
             if (outerKeySelector == null)
+            {
                 throw new ArgumentNullException(nameof(outerKeySelector));
+            }
+
             if (innerKeySelector == null)
+            {
                 throw new ArgumentNullException(nameof(innerKeySelector));
+            }
+
             if (resultSelector == null)
+            {
                 throw new ArgumentNullException(nameof(resultSelector));
+            }
+
             if (comparer == null)
+            {
                 throw new ArgumentNullException(nameof(comparer));
+            }
 
             return new JoinAsyncIterator<TOuter, TInner, TKey, TResult>(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer);
         }
@@ -32,17 +49,31 @@ 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));
+            }
+
             if (inner == null)
+            {
                 throw new ArgumentNullException(nameof(inner));
+            }
+
             if (outerKeySelector == null)
+            {
                 throw new ArgumentNullException(nameof(outerKeySelector));
+            }
+
             if (innerKeySelector == null)
+            {
                 throw new ArgumentNullException(nameof(innerKeySelector));
+            }
+
             if (resultSelector == null)
+            {
                 throw new ArgumentNullException(nameof(resultSelector));
+            }
 
-            return new JoinAsyncIterator<TOuter,TInner,TKey,TResult>(outer, inner, outerKeySelector, innerKeySelector, resultSelector, EqualityComparer<TKey>.Default);
+            return new JoinAsyncIterator<TOuter, TInner, TKey, TResult>(outer, inner, outerKeySelector, innerKeySelector, resultSelector, EqualityComparer<TKey>.Default);
         }
 
         internal sealed class JoinAsyncIterator<TOuter, TInner, TKey, TResult> : AsyncIterator<TResult>
@@ -90,17 +121,16 @@ namespace System.Linq
             }
 
             // State machine vars
-            Internal.Lookup<TKey, TInner> lookup;
-            int count;
-            TInner[] elements;
-            int index;
-            TOuter item;
+            private Internal.Lookup<TKey, TInner> lookup;
+            private int count;
+            private TInner[] elements;
+            private int index;
+            private TOuter item;
             private int mode;
-
-            const int State_If = 1;
-            const int State_DoLoop = 2;
-            const int State_For = 3;
-            const int State_While = 4;
+            private const int State_If = 1;
+            private const int State_DoLoop = 2;
+            private const int State_For = 3;
+            private const int State_While = 4;
 
             protected override async Task<bool> MoveNextCore(CancellationToken cancellationToken)
             {
@@ -124,7 +154,7 @@ namespace System.Linq
                                     if (lookup.Count != 0)
                                     {
                                         mode = State_DoLoop;
-                                        goto case State_DoLoop;   
+                                        goto case State_DoLoop;
                                     }
                                 }
 
@@ -161,7 +191,7 @@ namespace System.Linq
                                     goto case State_DoLoop;
                                 }
 
-                             
+
                                 break;
                         }
 

+ 32 - 3
Ix.NET/Source/System.Interactive.Async/Last.cs

@@ -2,9 +2,7 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System;
 using System.Collections.Generic;
-using System.Linq;
 using System.Threading;
 using System.Threading.Tasks;
 
@@ -15,7 +13,9 @@ namespace System.Linq
         public static Task<TSource> Last<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Last(source, CancellationToken.None);
         }
@@ -23,9 +23,14 @@ 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));
+            }
+
             if (predicate == null)
+            {
                 throw new ArgumentNullException(nameof(predicate));
+            }
 
             return Last(source, predicate, CancellationToken.None);
         }
@@ -33,7 +38,9 @@ namespace System.Linq
         public static Task<TSource> Last<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Last_(source, cancellationToken);
         }
@@ -41,9 +48,14 @@ 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));
+            }
+
             if (predicate == null)
+            {
                 throw new ArgumentNullException(nameof(predicate));
+            }
 
             return source.Where(predicate)
                          .Last(cancellationToken);
@@ -52,7 +64,9 @@ namespace System.Linq
         public static Task<TSource> LastOrDefault<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return LastOrDefault(source, CancellationToken.None);
         }
@@ -60,9 +74,14 @@ 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));
+            }
+
             if (predicate == null)
+            {
                 throw new ArgumentNullException(nameof(predicate));
+            }
 
             return LastOrDefault(source, predicate, CancellationToken.None);
         }
@@ -70,7 +89,9 @@ namespace System.Linq
         public static Task<TSource> LastOrDefault<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return LastOrDefault_(source, cancellationToken);
         }
@@ -78,9 +99,14 @@ 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));
+            }
+
             if (predicate == null)
+            {
                 throw new ArgumentNullException(nameof(predicate));
+            }
 
             return source.Where(predicate)
                          .LastOrDefault(cancellationToken);
@@ -110,7 +136,10 @@ namespace System.Linq
                 }
             }
             if (!hasLast)
+            {
                 throw new InvalidOperationException(Strings.NO_ELEMENTS);
+            }
+
             return last;
         }
 
@@ -137,7 +166,7 @@ namespace System.Linq
                     last = e.Current;
                 }
             }
-            return !hasLast ? default(TSource) : last;
+            return !hasLast ? default : last;
         }
     }
 }

+ 71 - 9
Ix.NET/Source/System.Interactive.Async/Lookup.cs

@@ -2,11 +2,9 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System;
 using System.Collections;
 using System.Collections.Generic;
 using System.Diagnostics;
-using System.Linq;
 using System.Threading;
 using System.Threading.Tasks;
 
@@ -18,13 +16,24 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
+
             if (elementSelector == null)
+            {
                 throw new ArgumentNullException(nameof(elementSelector));
+            }
+
             if (comparer == null)
+            {
                 throw new ArgumentNullException(nameof(comparer));
+            }
 
             return ToLookup(source, keySelector, elementSelector, comparer, CancellationToken.None);
         }
@@ -32,11 +41,19 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
+
             if (elementSelector == null)
+            {
                 throw new ArgumentNullException(nameof(elementSelector));
+            }
 
             return ToLookup(source, keySelector, elementSelector, CancellationToken.None);
         }
@@ -44,11 +61,19 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
+
             if (comparer == null)
+            {
                 throw new ArgumentNullException(nameof(comparer));
+            }
 
             return ToLookup(source, keySelector, comparer, CancellationToken.None);
         }
@@ -56,9 +81,14 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
 
             return ToLookup(source, keySelector, CancellationToken.None);
         }
@@ -66,13 +96,24 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
+
             if (elementSelector == null)
+            {
                 throw new ArgumentNullException(nameof(elementSelector));
+            }
+
             if (comparer == null)
+            {
                 throw new ArgumentNullException(nameof(comparer));
+            }
 
             var lookup = await Internal.Lookup<TKey, TElement>.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken)
                                        .ConfigureAwait(false);
@@ -83,11 +124,19 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
+
             if (elementSelector == null)
+            {
                 throw new ArgumentNullException(nameof(elementSelector));
+            }
 
             return source.ToLookup(keySelector, elementSelector, EqualityComparer<TKey>.Default, cancellationToken);
         }
@@ -95,11 +144,19 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
+
             if (comparer == null)
+            {
                 throw new ArgumentNullException(nameof(comparer));
+            }
 
             return source.ToLookup(keySelector, x => x, comparer, cancellationToken);
         }
@@ -107,9 +164,14 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
 
             return source.ToLookup(keySelector, x => x, EqualityComparer<TKey>.Default, cancellationToken);
         }
@@ -188,7 +250,7 @@ namespace System.Linq.Internal
                 } while (g != _lastGrouping);
             }
         }
-        
+
         internal static async Task<Lookup<TKey, TElement>> CreateAsync<TSource>(IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
         {
             Debug.Assert(source != null);
@@ -209,7 +271,7 @@ namespace System.Linq.Internal
             return lookup;
         }
 
-        internal static async Task<Lookup<TKey, TElement>> CreateAsync(IAsyncEnumerable<TElement> source, Func<TElement, TKey> keySelector,  IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
+        internal static async Task<Lookup<TKey, TElement>> CreateAsync(IAsyncEnumerable<TElement> source, Func<TElement, TKey> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
         {
             Debug.Assert(source != null);
             Debug.Assert(keySelector != null);
@@ -251,7 +313,7 @@ namespace System.Linq.Internal
         internal Grouping<TKey, TElement> GetGrouping(TKey key, bool create)
         {
             var hashCode = InternalGetHashCode(key);
-            for (var g = _groupings[hashCode%_groupings.Length]; g != null; g = g._hashNext)
+            for (var g = _groupings[hashCode % _groupings.Length]; g != null; g = g._hashNext)
             {
                 if (g._hashCode == hashCode && _comparer.Equals(g._key, key))
                 {
@@ -266,7 +328,7 @@ namespace System.Linq.Internal
                     Resize();
                 }
 
-                var index = hashCode%_groupings.Length;
+                var index = hashCode % _groupings.Length;
                 var g = new Grouping<TKey, TElement>
                 {
                     _key = key,
@@ -337,20 +399,20 @@ namespace System.Linq.Internal
 
         private void Resize()
         {
-            var newSize = checked((Count*2) + 1);
+            var newSize = checked((Count * 2) + 1);
             var newGroupings = new Grouping<TKey, TElement>[newSize];
             var g = _lastGrouping;
             do
             {
                 g = g._next;
-                var index = g._hashCode%newSize;
+                var index = g._hashCode % newSize;
                 g._hashNext = newGroupings[index];
                 newGroupings[index] = g;
             } while (g != _lastGrouping);
 
             _groupings = newGroupings;
         }
-        
+
 
         public Task<int> GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken)
         {

+ 199 - 2
Ix.NET/Source/System.Interactive.Async/Max.cs

@@ -2,9 +2,7 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System;
 using System.Collections.Generic;
-using System.Linq;
 using System.Threading;
 using System.Threading.Tasks;
 
@@ -15,9 +13,14 @@ 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));
+            }
+
             if (comparer == null)
+            {
                 throw new ArgumentNullException(nameof(comparer));
+            }
 
             return Max_(source, comparer, cancellationToken);
         }
@@ -25,7 +28,9 @@ namespace System.Linq
         public static Task<int> Max(this IAsyncEnumerable<int> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Max(source, CancellationToken.None);
         }
@@ -33,7 +38,9 @@ namespace System.Linq
         public static Task<long> Max(this IAsyncEnumerable<long> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Max(source, CancellationToken.None);
         }
@@ -41,7 +48,9 @@ namespace System.Linq
         public static Task<double> Max(this IAsyncEnumerable<double> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Max(source, CancellationToken.None);
         }
@@ -49,7 +58,9 @@ namespace System.Linq
         public static Task<float> Max(this IAsyncEnumerable<float> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Max(source, CancellationToken.None);
         }
@@ -58,7 +69,9 @@ namespace System.Linq
         public static Task<int> Max(this IAsyncEnumerable<int> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return source.Aggregate(Math.Max, cancellationToken);
         }
@@ -66,7 +79,9 @@ namespace System.Linq
         public static Task<long> Max(this IAsyncEnumerable<long> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return source.Aggregate(Math.Max, cancellationToken);
         }
@@ -74,7 +89,9 @@ namespace System.Linq
         public static Task<double> Max(this IAsyncEnumerable<double> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return source.Aggregate(Math.Max, cancellationToken);
         }
@@ -82,7 +99,9 @@ namespace System.Linq
         public static Task<float> Max(this IAsyncEnumerable<float> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return source.Aggregate(Math.Max, cancellationToken);
         }
@@ -90,7 +109,9 @@ namespace System.Linq
         public static Task<decimal> Max(this IAsyncEnumerable<decimal> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return source.Aggregate(Math.Max, cancellationToken);
         }
@@ -98,7 +119,9 @@ namespace System.Linq
         public static Task<int?> Max(this IAsyncEnumerable<int?> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return source.Aggregate(default(int?), NullableMax, cancellationToken);
         }
@@ -106,7 +129,9 @@ namespace System.Linq
         public static Task<long?> Max(this IAsyncEnumerable<long?> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return source.Aggregate(default(long?), NullableMax, cancellationToken);
         }
@@ -114,7 +139,9 @@ namespace System.Linq
         public static Task<double?> Max(this IAsyncEnumerable<double?> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return source.Aggregate(default(double?), NullableMax, cancellationToken);
         }
@@ -122,7 +149,9 @@ namespace System.Linq
         public static Task<float?> Max(this IAsyncEnumerable<float?> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return source.Aggregate(default(float?), NullableMax, cancellationToken);
         }
@@ -130,7 +159,9 @@ namespace System.Linq
         public static Task<decimal?> Max(this IAsyncEnumerable<decimal?> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return source.Aggregate(default(decimal?), NullableMax, cancellationToken);
         }
@@ -138,7 +169,9 @@ namespace System.Linq
         public static Task<TSource> Max<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             var comparer = Comparer<TSource>.Default;
             return source.Aggregate((x, y) => comparer.Compare(x, y) >= 0 ? x : y, cancellationToken);
@@ -147,9 +180,14 @@ namespace System.Linq
         public static Task<int> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int> selector, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Max(cancellationToken);
@@ -158,9 +196,14 @@ namespace System.Linq
         public static Task<long> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long> selector, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Max(cancellationToken);
@@ -169,9 +212,14 @@ namespace System.Linq
         public static Task<double> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double> selector, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Max(cancellationToken);
@@ -180,9 +228,14 @@ namespace System.Linq
         public static Task<float> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float> selector, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Max(cancellationToken);
@@ -191,9 +244,14 @@ namespace System.Linq
         public static Task<decimal> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal> selector, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Max(cancellationToken);
@@ -202,9 +260,14 @@ namespace System.Linq
         public static Task<int?> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int?> selector, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Max(cancellationToken);
@@ -213,9 +276,14 @@ namespace System.Linq
         public static Task<long?> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long?> selector, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Max(cancellationToken);
@@ -224,9 +292,14 @@ namespace System.Linq
         public static Task<double?> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double?> selector, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Max(cancellationToken);
@@ -235,9 +308,14 @@ namespace System.Linq
         public static Task<float?> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float?> selector, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Max(cancellationToken);
@@ -246,9 +324,14 @@ namespace System.Linq
         public static Task<decimal?> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal?> selector, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Max(cancellationToken);
@@ -257,9 +340,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Max(cancellationToken);
@@ -269,7 +357,9 @@ namespace System.Linq
         public static Task<decimal> Max(this IAsyncEnumerable<decimal> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Max(source, CancellationToken.None);
         }
@@ -277,7 +367,9 @@ namespace System.Linq
         public static Task<int?> Max(this IAsyncEnumerable<int?> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Max(source, CancellationToken.None);
         }
@@ -285,7 +377,9 @@ namespace System.Linq
         public static Task<long?> Max(this IAsyncEnumerable<long?> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Max(source, CancellationToken.None);
         }
@@ -293,7 +387,9 @@ namespace System.Linq
         public static Task<double?> Max(this IAsyncEnumerable<double?> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Max(source, CancellationToken.None);
         }
@@ -301,7 +397,9 @@ namespace System.Linq
         public static Task<float?> Max(this IAsyncEnumerable<float?> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Max(source, CancellationToken.None);
         }
@@ -309,7 +407,9 @@ namespace System.Linq
         public static Task<decimal?> Max(this IAsyncEnumerable<decimal?> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Max(source, CancellationToken.None);
         }
@@ -317,7 +417,9 @@ namespace System.Linq
         public static Task<TSource> Max<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Max(source, CancellationToken.None);
         }
@@ -325,9 +427,14 @@ namespace System.Linq
         public static Task<int> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int> selector)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Max(source, selector, CancellationToken.None);
         }
@@ -335,9 +442,14 @@ namespace System.Linq
         public static Task<long> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long> selector)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Max(source, selector, CancellationToken.None);
         }
@@ -345,9 +457,14 @@ namespace System.Linq
         public static Task<double> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double> selector)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Max(source, selector, CancellationToken.None);
         }
@@ -355,9 +472,14 @@ namespace System.Linq
         public static Task<float> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float> selector)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Max(source, selector, CancellationToken.None);
         }
@@ -365,9 +487,14 @@ namespace System.Linq
         public static Task<decimal> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal> selector)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Max(source, selector, CancellationToken.None);
         }
@@ -375,9 +502,14 @@ namespace System.Linq
         public static Task<int?> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int?> selector)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Max(source, selector, CancellationToken.None);
         }
@@ -385,9 +517,14 @@ namespace System.Linq
         public static Task<long?> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long?> selector)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Max(source, selector, CancellationToken.None);
         }
@@ -395,9 +532,14 @@ namespace System.Linq
         public static Task<double?> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double?> selector)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Max(source, selector, CancellationToken.None);
         }
@@ -405,9 +547,14 @@ namespace System.Linq
         public static Task<float?> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float?> selector)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Max(source, selector, CancellationToken.None);
         }
@@ -415,9 +562,14 @@ namespace System.Linq
         public static Task<decimal?> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal?> selector)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Max(source, selector, CancellationToken.None);
         }
@@ -425,9 +577,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Max(source, selector, CancellationToken.None);
         }
@@ -436,9 +593,14 @@ namespace System.Linq
         public static Task<TSource> Max<TSource>(this IAsyncEnumerable<TSource> source, IComparer<TSource> comparer)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (comparer == null)
+            {
                 throw new ArgumentNullException(nameof(comparer));
+            }
 
             return source.Max(comparer, CancellationToken.None);
         }
@@ -446,9 +608,14 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
 
             return source.MaxBy(keySelector, CancellationToken.None);
         }
@@ -456,11 +623,19 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
+
             if (comparer == null)
+            {
                 throw new ArgumentNullException(nameof(comparer));
+            }
 
             return source.MaxBy(keySelector, comparer, CancellationToken.None);
         }
@@ -468,9 +643,14 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
 
             return MaxBy(source, keySelector, Comparer<TKey>.Default, cancellationToken);
         }
@@ -478,11 +658,19 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
+
             if (comparer == null)
+            {
                 throw new ArgumentNullException(nameof(comparer));
+            }
 
             return ExtremaBy(source, keySelector, (key, minValue) => comparer.Compare(key, minValue), cancellationToken);
         }
@@ -497,11 +685,20 @@ namespace System.Linq
             where T : struct, IComparable<T>
         {
             if (!x.HasValue)
+            {
                 return y;
+            }
+
             if (!y.HasValue)
+            {
                 return x;
+            }
+
             if (x.Value.CompareTo(y.Value) >= 0)
+            {
                 return x;
+            }
+
             return y;
         }
     }

+ 201 - 2
Ix.NET/Source/System.Interactive.Async/Min.cs

@@ -2,9 +2,7 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System;
 using System.Collections.Generic;
-using System.Linq;
 using System.Threading;
 using System.Threading.Tasks;
 
@@ -15,9 +13,14 @@ namespace System.Linq
         public static Task<decimal?> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal?> selector)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Min(source, selector, CancellationToken.None);
         }
@@ -25,9 +28,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Min(source, selector, CancellationToken.None);
         }
@@ -35,9 +43,14 @@ 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));
+            }
+
             if (comparer == null)
+            {
                 throw new ArgumentNullException(nameof(comparer));
+            }
 
             return Min_(source, comparer, cancellationToken);
         }
@@ -46,7 +59,9 @@ namespace System.Linq
         public static Task<int> Min(this IAsyncEnumerable<int> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Min(source, CancellationToken.None);
         }
@@ -54,7 +69,9 @@ namespace System.Linq
         public static Task<long> Min(this IAsyncEnumerable<long> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Min(source, CancellationToken.None);
         }
@@ -62,7 +79,9 @@ namespace System.Linq
         public static Task<double> Min(this IAsyncEnumerable<double> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Min(source, CancellationToken.None);
         }
@@ -70,7 +89,9 @@ namespace System.Linq
         public static Task<float> Min(this IAsyncEnumerable<float> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Min(source, CancellationToken.None);
         }
@@ -78,7 +99,9 @@ namespace System.Linq
         public static Task<decimal> Min(this IAsyncEnumerable<decimal> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Min(source, CancellationToken.None);
         }
@@ -86,7 +109,9 @@ namespace System.Linq
         public static Task<int?> Min(this IAsyncEnumerable<int?> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Min(source, CancellationToken.None);
         }
@@ -94,7 +119,9 @@ namespace System.Linq
         public static Task<long?> Min(this IAsyncEnumerable<long?> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Min(source, CancellationToken.None);
         }
@@ -102,7 +129,9 @@ namespace System.Linq
         public static Task<double?> Min(this IAsyncEnumerable<double?> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Min(source, CancellationToken.None);
         }
@@ -110,7 +139,9 @@ namespace System.Linq
         public static Task<float?> Min(this IAsyncEnumerable<float?> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Min(source, CancellationToken.None);
         }
@@ -118,7 +149,9 @@ namespace System.Linq
         public static Task<decimal?> Min(this IAsyncEnumerable<decimal?> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Min(source, CancellationToken.None);
         }
@@ -126,7 +159,9 @@ namespace System.Linq
         public static Task<TSource> Min<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Min(source, CancellationToken.None);
         }
@@ -134,9 +169,14 @@ namespace System.Linq
         public static Task<int> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int> selector)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Min(source, selector, CancellationToken.None);
         }
@@ -144,9 +184,14 @@ namespace System.Linq
         public static Task<long> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long> selector)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Min(source, selector, CancellationToken.None);
         }
@@ -154,9 +199,14 @@ namespace System.Linq
         public static Task<double> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double> selector)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Min(source, selector, CancellationToken.None);
         }
@@ -164,9 +214,14 @@ namespace System.Linq
         public static Task<float> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float> selector)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Min(source, selector, CancellationToken.None);
         }
@@ -174,9 +229,14 @@ namespace System.Linq
         public static Task<decimal> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal> selector)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Min(source, selector, CancellationToken.None);
         }
@@ -184,9 +244,14 @@ namespace System.Linq
         public static Task<int?> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int?> selector)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Min(source, selector, CancellationToken.None);
         }
@@ -194,9 +259,14 @@ namespace System.Linq
         public static Task<long?> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long?> selector)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Min(source, selector, CancellationToken.None);
         }
@@ -204,9 +274,14 @@ namespace System.Linq
         public static Task<double?> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double?> selector)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Min(source, selector, CancellationToken.None);
         }
@@ -215,7 +290,9 @@ namespace System.Linq
         public static Task<int> Min(this IAsyncEnumerable<int> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return source.Aggregate(Math.Min, cancellationToken);
         }
@@ -223,7 +300,9 @@ namespace System.Linq
         public static Task<long> Min(this IAsyncEnumerable<long> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return source.Aggregate(Math.Min, cancellationToken);
         }
@@ -231,7 +310,9 @@ namespace System.Linq
         public static Task<double> Min(this IAsyncEnumerable<double> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return source.Aggregate(Math.Min, cancellationToken);
         }
@@ -239,7 +320,9 @@ namespace System.Linq
         public static Task<float> Min(this IAsyncEnumerable<float> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return source.Aggregate(Math.Min, cancellationToken);
         }
@@ -247,7 +330,9 @@ namespace System.Linq
         public static Task<decimal> Min(this IAsyncEnumerable<decimal> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return source.Aggregate(Math.Min, cancellationToken);
         }
@@ -255,7 +340,9 @@ namespace System.Linq
         public static Task<int?> Min(this IAsyncEnumerable<int?> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return source.Aggregate(default(int?), NullableMin, cancellationToken);
         }
@@ -263,7 +350,9 @@ namespace System.Linq
         public static Task<long?> Min(this IAsyncEnumerable<long?> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return source.Aggregate(default(long?), NullableMin, cancellationToken);
         }
@@ -271,7 +360,9 @@ namespace System.Linq
         public static Task<double?> Min(this IAsyncEnumerable<double?> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return source.Aggregate(default(double?), NullableMin, cancellationToken);
         }
@@ -279,7 +370,9 @@ namespace System.Linq
         public static Task<float?> Min(this IAsyncEnumerable<float?> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return source.Aggregate(default(float?), NullableMin, cancellationToken);
         }
@@ -287,7 +380,9 @@ namespace System.Linq
         public static Task<decimal?> Min(this IAsyncEnumerable<decimal?> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return source.Aggregate(default(decimal?), NullableMin, cancellationToken);
         }
@@ -295,7 +390,9 @@ namespace System.Linq
         public static Task<TSource> Min<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             var comparer = Comparer<TSource>.Default;
             return source.Aggregate((x, y) => comparer.Compare(x, y) <= 0 ? x : y, cancellationToken);
@@ -304,9 +401,14 @@ namespace System.Linq
         public static Task<int> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int> selector, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Min(cancellationToken);
@@ -315,9 +417,14 @@ namespace System.Linq
         public static Task<long> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long> selector, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Min(cancellationToken);
@@ -326,9 +433,14 @@ namespace System.Linq
         public static Task<double> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double> selector, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Min(cancellationToken);
@@ -337,9 +449,14 @@ namespace System.Linq
         public static Task<float> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float> selector, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Min(cancellationToken);
@@ -348,9 +465,14 @@ namespace System.Linq
         public static Task<decimal> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal> selector, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Min(cancellationToken);
@@ -359,9 +481,14 @@ namespace System.Linq
         public static Task<int?> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int?> selector, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Min(cancellationToken);
@@ -370,9 +497,14 @@ namespace System.Linq
         public static Task<long?> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long?> selector, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Min(cancellationToken);
@@ -381,9 +513,14 @@ namespace System.Linq
         public static Task<double?> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double?> selector, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Min(cancellationToken);
@@ -392,9 +529,14 @@ namespace System.Linq
         public static Task<float?> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float?> selector, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Min(cancellationToken);
@@ -404,9 +546,14 @@ namespace System.Linq
         public static Task<TSource> Min<TSource>(this IAsyncEnumerable<TSource> source, IComparer<TSource> comparer)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (comparer == null)
+            {
                 throw new ArgumentNullException(nameof(comparer));
+            }
 
             return source.Min(comparer, CancellationToken.None);
         }
@@ -414,9 +561,14 @@ namespace System.Linq
         public static Task<decimal?> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal?> selector, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Min(cancellationToken);
@@ -425,9 +577,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Min(cancellationToken);
@@ -437,9 +594,14 @@ namespace System.Linq
         public static Task<float?> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float?> selector)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Min(source, selector, CancellationToken.None);
         }
@@ -447,9 +609,14 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
 
             return source.MinBy(keySelector, CancellationToken.None);
         }
@@ -457,11 +624,19 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
+
             if (comparer == null)
+            {
                 throw new ArgumentNullException(nameof(comparer));
+            }
 
             return source.MinBy(keySelector, comparer, CancellationToken.None);
         }
@@ -469,9 +644,14 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
 
             return MinBy(source, keySelector, Comparer<TKey>.Default, cancellationToken);
         }
@@ -479,11 +659,19 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
+
             if (comparer == null)
+            {
                 throw new ArgumentNullException(nameof(comparer));
+            }
 
             return ExtremaBy(source, keySelector, (key, minValue) => -comparer.Compare(key, minValue), cancellationToken);
         }
@@ -497,7 +685,9 @@ namespace System.Linq
             {
                 if (!await e.MoveNext(cancellationToken)
                             .ConfigureAwait(false))
+                {
                     throw new InvalidOperationException(Strings.NO_ELEMENTS);
+                }
 
                 var current = e.Current;
                 var resKey = keySelector(current);
@@ -538,11 +728,20 @@ namespace System.Linq
             where T : struct, IComparable<T>
         {
             if (!x.HasValue)
+            {
                 return y;
+            }
+
             if (!y.HasValue)
+            {
                 return x;
+            }
+
             if (x.Value.CompareTo(y.Value) <= 0)
+            {
                 return x;
+            }
+
             return y;
         }
     }

+ 12 - 5
Ix.NET/Source/System.Interactive.Async/OnErrorResumeNext.cs

@@ -2,10 +2,8 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System;
 using System.Collections.Generic;
 using System.Diagnostics;
-using System.Linq;
 using System.Threading;
 using System.Threading.Tasks;
 
@@ -16,17 +14,24 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> OnErrorResumeNext<TSource>(this IAsyncEnumerable<TSource> first, IAsyncEnumerable<TSource> second)
         {
             if (first == null)
+            {
                 throw new ArgumentNullException(nameof(first));
+            }
+
             if (second == null)
+            {
                 throw new ArgumentNullException(nameof(second));
+            }
 
-            return OnErrorResumeNext_(new[] {first, second});
+            return OnErrorResumeNext_(new[] { first, second });
         }
 
         public static IAsyncEnumerable<TSource> OnErrorResumeNext<TSource>(params IAsyncEnumerable<TSource>[] sources)
         {
             if (sources == null)
+            {
                 throw new ArgumentNullException(nameof(sources));
+            }
 
             return OnErrorResumeNext_(sources);
         }
@@ -34,7 +39,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> OnErrorResumeNext<TSource>(this IEnumerable<IAsyncEnumerable<TSource>> sources)
         {
             if (sources == null)
+            {
                 throw new ArgumentNullException(nameof(sources));
+            }
 
             return OnErrorResumeNext_(sources);
         }
@@ -123,9 +130,9 @@ namespace System.Linq
                         }
 
                         break; // case
-                        
+
                 }
-                
+
                 Dispose();
                 return false;
             }

+ 52 - 0
Ix.NET/Source/System.Interactive.Async/OrderBy.cs

@@ -11,11 +11,19 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
+
             if (comparer == null)
+            {
                 throw new ArgumentNullException(nameof(comparer));
+            }
 
             return new OrderedAsyncEnumerable<TSource, TKey>(source, keySelector, comparer, false, null);
         }
@@ -23,9 +31,14 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
 
             return source.OrderBy(keySelector, Comparer<TKey>.Default);
         }
@@ -33,11 +46,19 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
+
             if (comparer == null)
+            {
                 throw new ArgumentNullException(nameof(comparer));
+            }
 
             return new OrderedAsyncEnumerable<TSource, TKey>(source, keySelector, comparer, true, null);
         }
@@ -45,9 +66,14 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
 
             return source.OrderByDescending(keySelector, Comparer<TKey>.Default);
         }
@@ -55,9 +81,14 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
 
             return source.ThenBy(keySelector, Comparer<TKey>.Default);
         }
@@ -65,11 +96,19 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
+
             if (comparer == null)
+            {
                 throw new ArgumentNullException(nameof(comparer));
+            }
 
             return source.CreateOrderedEnumerable(keySelector, comparer, false);
         }
@@ -77,9 +116,14 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
 
             return source.ThenByDescending(keySelector, Comparer<TKey>.Default);
         }
@@ -87,11 +131,19 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
+
             if (comparer == null)
+            {
                 throw new ArgumentNullException(nameof(comparer));
+            }
 
             return source.CreateOrderedEnumerable(keySelector, comparer, true);
         }

+ 0 - 2
Ix.NET/Source/System.Interactive.Async/Properties/AssemblyInfo.cs

@@ -1,8 +1,6 @@
 using System;
-using System.Reflection;
 using System.Resources;
 using System.Runtime.InteropServices;
-using System.Security;
 
 [assembly: NeutralResourcesLanguage("en-US")]
 

+ 2 - 3
Ix.NET/Source/System.Interactive.Async/Range.cs

@@ -2,10 +2,7 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System;
 using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
 
 namespace System.Linq
 {
@@ -14,7 +11,9 @@ namespace System.Linq
         public static IAsyncEnumerable<int> Range(int start, int count)
         {
             if (count < 0)
+            {
                 throw new ArgumentOutOfRangeException(nameof(count));
+            }
 
             return Enumerable.Range(start, count)
                              .ToAsyncEnumerable();

+ 11 - 0
Ix.NET/Source/System.Interactive.Async/Repeat.cs

@@ -14,7 +14,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TResult> Repeat<TResult>(TResult element, int count)
         {
             if (count < 0)
+            {
                 throw new ArgumentOutOfRangeException(nameof(count));
+            }
 
             return Enumerable.Repeat(element, count)
                              .ToAsyncEnumerable();
@@ -28,9 +30,14 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Repeat<TSource>(this IAsyncEnumerable<TSource> source, int count)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (count < 0)
+            {
                 throw new ArgumentOutOfRangeException(nameof(count));
+            }
 
             return new RepeatSequenceAsyncIterator<TSource>(source, count);
         }
@@ -38,7 +45,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Repeat<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return new RepeatSequenceAsyncIterator<TSource>(source, -1);
         }
@@ -112,7 +121,9 @@ namespace System.Linq
                         }
 
                         if (!isInfinite && currentCount-- == 0)
+                        {
                             break;
+                        }
 
                         enumerator = source.GetEnumerator();
                         state = AsyncIteratorState.Iterating;

+ 17 - 5
Ix.NET/Source/System.Interactive.Async/Retry.cs

@@ -2,10 +2,7 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System;
 using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
 
 namespace System.Linq
 {
@@ -14,35 +11,50 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Retry<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
-            return new[] {source}.Repeat()
+            return new[] { source }.Repeat()
                                  .Catch();
         }
 
         public static IAsyncEnumerable<TSource> Retry<TSource>(this IAsyncEnumerable<TSource> source, int retryCount)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (retryCount < 0)
+            {
                 throw new ArgumentOutOfRangeException(nameof(retryCount));
+            }
 
-            return new[] {source}.Repeat(retryCount)
+            return new[] { source }.Repeat(retryCount)
                                  .Catch();
         }
 
         private static IEnumerable<TSource> Repeat<TSource>(this IEnumerable<TSource> source)
         {
             while (true)
+            {
                 foreach (var item in source)
+                {
                     yield return item;
+                }
+            }
         }
 
         private static IEnumerable<TSource> Repeat<TSource>(this IEnumerable<TSource> source, int count)
         {
             for (var i = 0; i < count; i++)
+            {
                 foreach (var item in source)
+                {
                     yield return item;
+                }
+            }
         }
     }
 }

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

@@ -15,7 +15,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Reverse<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return new ReverseAsyncIterator<TSource>(source);
         }

+ 14 - 4
Ix.NET/Source/System.Interactive.Async/Scan.cs

@@ -14,9 +14,14 @@ 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));
+            }
+
             if (accumulator == null)
+            {
                 throw new ArgumentNullException(nameof(accumulator));
+            }
 
             return new ScanAsyncEnumerable<TSource, TAccumulate>(source, seed, accumulator);
         }
@@ -24,9 +29,14 @@ 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));
+            }
+
             if (accumulator == null)
+            {
                 throw new ArgumentNullException(nameof(accumulator));
+            }
 
             return new ScanAsyncEnumerable<TSource>(source, accumulator);
         }
@@ -61,7 +71,7 @@ namespace System.Linq
                 {
                     enumerator.Dispose();
                     enumerator = null;
-                    accumulated = default(TAccumulate);
+                    accumulated = default;
                 }
 
                 base.Dispose();
@@ -89,7 +99,7 @@ namespace System.Linq
                         }
 
                         break;
-                        
+
                 }
 
                 Dispose();
@@ -127,7 +137,7 @@ namespace System.Linq
                 {
                     enumerator.Dispose();
                     enumerator = null;
-                    accumulated = default(TSource);
+                    accumulated = default;
                 }
 
                 base.Dispose();
@@ -140,7 +150,7 @@ namespace System.Linq
                     case AsyncIteratorState.Allocated:
                         enumerator = source.GetEnumerator();
                         hasSeed = false;
-                        accumulated = default(TSource);
+                        accumulated = default;
 
                         state = AsyncIteratorState.Iterating;
                         goto case AsyncIteratorState.Iterating;

+ 10 - 0
Ix.NET/Source/System.Interactive.Async/Select.cs

@@ -14,9 +14,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             if (source is AsyncIterator<TSource> iterator)
             {
@@ -34,9 +39,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return new SelectEnumerableWithIndexAsyncIterator<TSource, TResult>(source, selector);
         }

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

@@ -14,9 +14,14 @@ 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));
+            }
+
             if (other == null)
+            {
                 throw new ArgumentNullException(nameof(other));
+            }
 
             return source.SelectMany(_ => other);
         }
@@ -25,9 +30,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return new SelectManyAsyncIterator<TSource, TResult>(source, selector);
         }
@@ -35,9 +45,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return new SelectManyWithIndexAsyncIterator<TSource, TResult>(source, selector);
         }
@@ -45,11 +60,19 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
+
             if (resultSelector == null)
+            {
                 throw new ArgumentNullException(nameof(resultSelector));
+            }
 
             return new SelectManyAsyncIterator<TSource, TCollection, TResult>(source, selector, resultSelector);
         }
@@ -57,11 +80,19 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
+
             if (resultSelector == null)
+            {
                 throw new ArgumentNullException(nameof(resultSelector));
+            }
 
             return new SelectManyWithIndexAsyncIterator<TSource, TCollection, TResult>(source, selector, resultSelector);
         }
@@ -199,7 +230,7 @@ namespace System.Linq
                     resultEnumerator = null;
                 }
 
-                currentSource = default(TSource);
+                currentSource = default;
 
                 base.Dispose();
             }
@@ -296,7 +327,7 @@ namespace System.Linq
                     resultEnumerator = null;
                 }
 
-                currentSource = default(TSource);
+                currentSource = default;
 
                 base.Dispose();
             }

+ 26 - 2
Ix.NET/Source/System.Interactive.Async/SequenceEqual.cs

@@ -2,9 +2,7 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System;
 using System.Collections.Generic;
-using System.Linq;
 using System.Threading;
 using System.Threading.Tasks;
 
@@ -15,11 +13,19 @@ namespace System.Linq
         public static Task<bool> SequenceEqual<TSource>(this IAsyncEnumerable<TSource> first, IAsyncEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
         {
             if (first == null)
+            {
                 throw new ArgumentNullException(nameof(first));
+            }
+
             if (second == null)
+            {
                 throw new ArgumentNullException(nameof(second));
+            }
+
             if (comparer == null)
+            {
                 throw new ArgumentNullException(nameof(comparer));
+            }
 
             return SequenceEqual(first, second, comparer, CancellationToken.None);
         }
@@ -27,9 +33,14 @@ namespace System.Linq
         public static Task<bool> SequenceEqual<TSource>(this IAsyncEnumerable<TSource> first, IAsyncEnumerable<TSource> second)
         {
             if (first == null)
+            {
                 throw new ArgumentNullException(nameof(first));
+            }
+
             if (second == null)
+            {
                 throw new ArgumentNullException(nameof(second));
+            }
 
             return SequenceEqual(first, second, CancellationToken.None);
         }
@@ -38,11 +49,19 @@ namespace System.Linq
         public static Task<bool> SequenceEqual<TSource>(this IAsyncEnumerable<TSource> first, IAsyncEnumerable<TSource> second, IEqualityComparer<TSource> comparer, CancellationToken cancellationToken)
         {
             if (first == null)
+            {
                 throw new ArgumentNullException(nameof(first));
+            }
+
             if (second == null)
+            {
                 throw new ArgumentNullException(nameof(second));
+            }
+
             if (comparer == null)
+            {
                 throw new ArgumentNullException(nameof(comparer));
+            }
 
             return SequenceEqual_(first, second, comparer, cancellationToken);
         }
@@ -50,9 +69,14 @@ namespace System.Linq
         public static Task<bool> SequenceEqual<TSource>(this IAsyncEnumerable<TSource> first, IAsyncEnumerable<TSource> second, CancellationToken cancellationToken)
         {
             if (first == null)
+            {
                 throw new ArgumentNullException(nameof(first));
+            }
+
             if (second == null)
+            {
                 throw new ArgumentNullException(nameof(second));
+            }
 
             return first.SequenceEqual(second, EqualityComparer<TSource>.Default, cancellationToken);
         }

+ 6 - 9
Ix.NET/Source/System.Interactive.Async/Set.cs

@@ -2,12 +2,9 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System;
 using System.Collections.Generic;
 using System.Diagnostics;
 using System.Diagnostics.CodeAnalysis;
-using System.Linq;
-using System.Threading.Tasks;
 
 // from https://github.com/dotnet/corefx/blob/ec2685715b01d12f16b08d0dfa326649b12db8ec/src/System.Linq/src/System/Linq/Set.cs
 namespace System.Linq
@@ -38,7 +35,7 @@ namespace System.Linq
             Debug.Assert(!_haveRemoved, "This class is optimised for never calling Add after Remove. If your changes need to do so, undo that optimization.");
 #endif
             var hashCode = InternalGetHashCode(value);
-            for (var i = _buckets[hashCode%_buckets.Length] - 1; i >= 0; i = _slots[i]._next)
+            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))
                 {
@@ -53,7 +50,7 @@ namespace System.Linq
 
             var index = Count;
             Count++;
-            var bucket = hashCode%_buckets.Length;
+            var bucket = hashCode % _buckets.Length;
             _slots[index]._hashCode = hashCode;
             _slots[index]._value = value;
             _slots[index]._next = _buckets[bucket] - 1;
@@ -68,7 +65,7 @@ namespace System.Linq
             _haveRemoved = true;
 #endif
             var hashCode = InternalGetHashCode(value);
-            var bucket = hashCode%_buckets.Length;
+            var bucket = hashCode % _buckets.Length;
             var last = -1;
             for (var i = _buckets[bucket] - 1; i >= 0; last = i, i = _slots[i]._next)
             {
@@ -84,7 +81,7 @@ namespace System.Linq
                     }
 
                     _slots[i]._hashCode = -1;
-                    _slots[i]._value = default(TElement);
+                    _slots[i]._value = default;
                     _slots[i]._next = -1;
                     return true;
                 }
@@ -130,13 +127,13 @@ namespace System.Linq
 
         private void Resize()
         {
-            var newSize = checked((Count*2) + 1);
+            var newSize = checked((Count * 2) + 1);
             var newBuckets = new int[newSize];
             var newSlots = new Slot[newSize];
             Array.Copy(_slots, 0, newSlots, 0, Count);
             for (var i = 0; i < Count; i++)
             {
-                var bucket = newSlots[i]._hashCode%newSize;
+                var bucket = newSlots[i]._hashCode % newSize;
                 newSlots[i]._next = newBuckets[bucket] - 1;
                 newBuckets[bucket] = i + 1;
             }

+ 30 - 4
Ix.NET/Source/System.Interactive.Async/Single.cs

@@ -2,9 +2,7 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System;
 using System.Collections.Generic;
-using System.Linq;
 using System.Threading;
 using System.Threading.Tasks;
 
@@ -15,7 +13,9 @@ namespace System.Linq
         public static Task<TSource> Single<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Single(source, CancellationToken.None);
         }
@@ -23,9 +23,14 @@ 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));
+            }
+
             if (predicate == null)
+            {
                 throw new ArgumentNullException(nameof(predicate));
+            }
 
             return Single(source, predicate, CancellationToken.None);
         }
@@ -34,7 +39,9 @@ namespace System.Linq
         public static Task<TSource> Single<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Single_(source, cancellationToken);
         }
@@ -42,9 +49,14 @@ 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));
+            }
+
             if (predicate == null)
+            {
                 throw new ArgumentNullException(nameof(predicate));
+            }
 
             return source.Where(predicate)
                          .Single(cancellationToken);
@@ -53,7 +65,9 @@ namespace System.Linq
         public static Task<TSource> SingleOrDefault<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return SingleOrDefault(source, CancellationToken.None);
         }
@@ -61,9 +75,14 @@ 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));
+            }
+
             if (predicate == null)
+            {
                 throw new ArgumentNullException(nameof(predicate));
+            }
 
             return SingleOrDefault(source, predicate, CancellationToken.None);
         }
@@ -71,7 +90,9 @@ namespace System.Linq
         public static Task<TSource> SingleOrDefault<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return SingleOrDefault_(source, cancellationToken);
         }
@@ -79,9 +100,14 @@ 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));
+            }
+
             if (predicate == null)
+            {
                 throw new ArgumentNullException(nameof(predicate));
+            }
 
             return source.Where(predicate)
                          .SingleOrDefault(cancellationToken);
@@ -122,7 +148,7 @@ namespace System.Linq
             {
                 switch (list.Count)
                 {
-                    case 0: return default(TSource);
+                    case 0: return default;
                     case 1: return list[0];
                 }
                 throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT);
@@ -133,7 +159,7 @@ namespace System.Linq
                 if (!await e.MoveNext(cancellationToken)
                             .ConfigureAwait(false))
                 {
-                    return default(TSource);
+                    return default;
                 }
 
                 var result = e.Current;

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

@@ -14,7 +14,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Skip<TSource>(this IAsyncEnumerable<TSource> source, int count)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             if (count <= 0)
             {
@@ -34,7 +36,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> SkipLast<TSource>(this IAsyncEnumerable<TSource> source, int count)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             if (count <= 0)
             {
@@ -54,9 +58,14 @@ 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));
+            }
+
             if (predicate == null)
+            {
                 throw new ArgumentNullException(nameof(predicate));
+            }
 
             return new SkipWhileAsyncIterator<TSource>(source, predicate);
         }
@@ -64,9 +73,14 @@ 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));
+            }
+
             if (predicate == null)
+            {
                 throw new ArgumentNullException(nameof(predicate));
+            }
 
             return new SkipWhileWithIndexAsyncIterator<TSource>(source, predicate);
         }

+ 2 - 3
Ix.NET/Source/System.Interactive.Async/StartsWith.cs

@@ -2,10 +2,7 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System;
 using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
 
 namespace System.Linq
 {
@@ -14,7 +11,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> StartWith<TSource>(this IAsyncEnumerable<TSource> source, params TSource[] values)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return values.ToAsyncEnumerable()
                          .Concat(source);

+ 140 - 2
Ix.NET/Source/System.Interactive.Async/Sum.cs

@@ -2,9 +2,7 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System;
 using System.Collections.Generic;
-using System.Linq;
 using System.Threading;
 using System.Threading.Tasks;
 
@@ -15,7 +13,9 @@ namespace System.Linq
         public static Task<int> Sum(this IAsyncEnumerable<int> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return source.Aggregate(0, (x, y) => x + y, cancellationToken);
         }
@@ -23,7 +23,9 @@ namespace System.Linq
         public static Task<long> Sum(this IAsyncEnumerable<long> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return source.Aggregate(0L, (x, y) => x + y, cancellationToken);
         }
@@ -31,7 +33,9 @@ namespace System.Linq
         public static Task<double> Sum(this IAsyncEnumerable<double> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return source.Aggregate(0.0, (x, y) => x + y, cancellationToken);
         }
@@ -39,7 +43,9 @@ namespace System.Linq
         public static Task<float> Sum(this IAsyncEnumerable<float> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return source.Aggregate(0f, (x, y) => x + y, cancellationToken);
         }
@@ -47,7 +53,9 @@ namespace System.Linq
         public static Task<decimal> Sum(this IAsyncEnumerable<decimal> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return source.Aggregate(0m, (x, y) => x + y, cancellationToken);
         }
@@ -55,7 +63,9 @@ namespace System.Linq
         public static Task<int?> Sum(this IAsyncEnumerable<int?> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return source.Aggregate((int?)0, (x, y) => x + y.GetValueOrDefault(), cancellationToken);
         }
@@ -63,7 +73,9 @@ namespace System.Linq
         public static Task<long?> Sum(this IAsyncEnumerable<long?> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return source.Aggregate((long?)0, (x, y) => x + y.GetValueOrDefault(), cancellationToken);
         }
@@ -71,7 +83,9 @@ namespace System.Linq
         public static Task<double?> Sum(this IAsyncEnumerable<double?> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return source.Aggregate((double?)0, (x, y) => x + y.GetValueOrDefault(), cancellationToken);
         }
@@ -79,7 +93,9 @@ namespace System.Linq
         public static Task<float?> Sum(this IAsyncEnumerable<float?> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return source.Aggregate((float?)0, (x, y) => x + y.GetValueOrDefault(), cancellationToken);
         }
@@ -87,7 +103,9 @@ namespace System.Linq
         public static Task<decimal?> Sum(this IAsyncEnumerable<decimal?> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return source.Aggregate((decimal?)0, (x, y) => x + y.GetValueOrDefault(), cancellationToken);
         }
@@ -95,9 +113,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Sum(cancellationToken);
@@ -106,9 +129,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Sum(cancellationToken);
@@ -117,9 +145,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Sum(cancellationToken);
@@ -128,9 +161,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Sum(cancellationToken);
@@ -139,9 +177,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Sum(cancellationToken);
@@ -150,9 +193,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Sum(cancellationToken);
@@ -161,9 +209,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Sum(cancellationToken);
@@ -172,9 +225,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Sum(cancellationToken);
@@ -184,7 +242,9 @@ namespace System.Linq
         public static Task<int> Sum(this IAsyncEnumerable<int> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Sum(source, CancellationToken.None);
         }
@@ -192,7 +252,9 @@ namespace System.Linq
         public static Task<long> Sum(this IAsyncEnumerable<long> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Sum(source, CancellationToken.None);
         }
@@ -200,7 +262,9 @@ namespace System.Linq
         public static Task<double> Sum(this IAsyncEnumerable<double> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Sum(source, CancellationToken.None);
         }
@@ -208,7 +272,9 @@ namespace System.Linq
         public static Task<float> Sum(this IAsyncEnumerable<float> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Sum(source, CancellationToken.None);
         }
@@ -216,7 +282,9 @@ namespace System.Linq
         public static Task<decimal> Sum(this IAsyncEnumerable<decimal> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Sum(source, CancellationToken.None);
         }
@@ -224,7 +292,9 @@ namespace System.Linq
         public static Task<int?> Sum(this IAsyncEnumerable<int?> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Sum(source, CancellationToken.None);
         }
@@ -232,7 +302,9 @@ namespace System.Linq
         public static Task<long?> Sum(this IAsyncEnumerable<long?> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Sum(source, CancellationToken.None);
         }
@@ -240,7 +312,9 @@ namespace System.Linq
         public static Task<double?> Sum(this IAsyncEnumerable<double?> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Sum(source, CancellationToken.None);
         }
@@ -248,7 +322,9 @@ namespace System.Linq
         public static Task<float?> Sum(this IAsyncEnumerable<float?> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Sum(source, CancellationToken.None);
         }
@@ -256,7 +332,9 @@ namespace System.Linq
         public static Task<decimal?> Sum(this IAsyncEnumerable<decimal?> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return Sum(source, CancellationToken.None);
         }
@@ -264,9 +342,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Sum(source, selector, CancellationToken.None);
         }
@@ -274,9 +357,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Sum(source, selector, CancellationToken.None);
         }
@@ -284,9 +372,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Sum(source, selector, CancellationToken.None);
         }
@@ -294,9 +387,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Sum(source, selector, CancellationToken.None);
         }
@@ -304,9 +402,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Sum(source, selector, CancellationToken.None);
         }
@@ -314,9 +417,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Sum(source, selector, CancellationToken.None);
         }
@@ -324,9 +432,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Sum(source, selector, CancellationToken.None);
         }
@@ -334,9 +447,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Sum(source, selector, CancellationToken.None);
         }
@@ -344,9 +462,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Sum(source, selector, CancellationToken.None);
         }
@@ -354,9 +477,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return Sum(source, selector, CancellationToken.None);
         }
@@ -365,9 +493,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Sum(cancellationToken);
@@ -376,9 +509,14 @@ 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));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return source.Select(selector)
                          .Sum(cancellationToken);

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

@@ -14,7 +14,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Take<TSource>(this IAsyncEnumerable<TSource> source, int count)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             if (count <= 0)
             {
@@ -27,7 +29,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> TakeLast<TSource>(this IAsyncEnumerable<TSource> source, int count)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             if (count <= 0)
             {
@@ -40,9 +44,14 @@ 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));
+            }
+
             if (predicate == null)
+            {
                 throw new ArgumentNullException(nameof(predicate));
+            }
 
             return new TakeWhileAsyncIterator<TSource>(source, predicate);
         }
@@ -50,9 +59,14 @@ 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));
+            }
+
             if (predicate == null)
+            {
                 throw new ArgumentNullException(nameof(predicate));
+            }
 
             return new TakeWhileWithIndexAsyncIterator<TSource>(source, predicate);
         }

+ 1 - 2
Ix.NET/Source/System.Interactive.Async/TaskExt.cs

@@ -1,11 +1,10 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
-using System.Collections.Generic;
 
 namespace System.Threading.Tasks
 {
-    static class TaskExt
+    internal static class TaskExt
     {
         public static readonly Task<bool> True = Task.FromResult(true);
         public static readonly Task<bool> False = Task.FromResult(false);

+ 15 - 2
Ix.NET/Source/System.Interactive.Async/ToAsyncEnumerable.cs

@@ -15,14 +15,20 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> ToAsyncEnumerable<TSource>(this IEnumerable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             // optimize these adapters for lists and collections
             if (source is IList<TSource> list)
+            {
                 return new AsyncIListEnumerableAdapter<TSource>(list);
+            }
 
             if (source is ICollection<TSource> collection)
+            {
                 return new AsyncICollectionEnumerableAdapter<TSource>(collection);
+            }
 
             return new AsyncEnumerableAdapter<TSource>(source);
         }
@@ -30,7 +36,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> ToAsyncEnumerable<TSource>(this Task<TSource> task)
         {
             if (task == null)
+            {
                 throw new ArgumentNullException(nameof(task));
+            }
 
             return CreateEnumerable(
                 () =>
@@ -56,7 +64,9 @@ namespace System.Linq
         public static IEnumerable<TSource> ToEnumerable<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return ToEnumerable_(source);
         }
@@ -69,7 +79,10 @@ namespace System.Linq
                 {
                     if (!e.MoveNext(CancellationToken.None)
                           .Result)
+                    {
                         break;
+                    }
+
                     var c = e.Current;
                     yield return c;
                 }
@@ -81,7 +94,7 @@ namespace System.Linq
             private readonly IEnumerable<T> source;
 
             private IEnumerator<T> enumerator;
- 
+
             public AsyncEnumerableAdapter(IEnumerable<T> source)
             {
                 Debug.Assert(source != null);
@@ -124,7 +137,7 @@ namespace System.Linq
                         Dispose();
                         break;
                 }
-                
+
                 return Task.FromResult(false);
             }
 

+ 76 - 2
Ix.NET/Source/System.Interactive.Async/ToCollection.cs

@@ -2,9 +2,7 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System;
 using System.Collections.Generic;
-using System.Linq;
 using System.Threading;
 using System.Threading.Tasks;
 
@@ -15,7 +13,9 @@ namespace System.Linq
         public static Task<TSource[]> ToArray<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return ToArray(source, CancellationToken.None);
         }
@@ -23,10 +23,14 @@ namespace System.Linq
         public static Task<TSource[]> ToArray<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             if (source is IIListProvider<TSource> arrayProvider)
+            {
                 return arrayProvider.ToArrayAsync(cancellationToken);
+            }
 
             return AsyncEnumerableHelpers.ToArray(source, cancellationToken);
         }
@@ -34,13 +38,24 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
+
             if (elementSelector == null)
+            {
                 throw new ArgumentNullException(nameof(elementSelector));
+            }
+
             if (comparer == null)
+            {
                 throw new ArgumentNullException(nameof(comparer));
+            }
 
             return ToDictionary(source, keySelector, elementSelector, comparer, CancellationToken.None);
         }
@@ -48,11 +63,19 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
+
             if (elementSelector == null)
+            {
                 throw new ArgumentNullException(nameof(elementSelector));
+            }
 
             return ToDictionary(source, keySelector, elementSelector, CancellationToken.None);
         }
@@ -60,11 +83,19 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
+
             if (comparer == null)
+            {
                 throw new ArgumentNullException(nameof(comparer));
+            }
 
             return ToDictionary(source, keySelector, comparer, CancellationToken.None);
         }
@@ -72,9 +103,14 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
 
             return ToDictionary(source, keySelector, CancellationToken.None);
         }
@@ -82,13 +118,24 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
+
             if (elementSelector == null)
+            {
                 throw new ArgumentNullException(nameof(elementSelector));
+            }
+
             if (comparer == null)
+            {
                 throw new ArgumentNullException(nameof(comparer));
+            }
 
             return source.Aggregate(new Dictionary<TKey, TElement>(comparer), (d, x) =>
                                                                               {
@@ -100,11 +147,19 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
+
             if (elementSelector == null)
+            {
                 throw new ArgumentNullException(nameof(elementSelector));
+            }
 
             return source.ToDictionary(keySelector, elementSelector, EqualityComparer<TKey>.Default, cancellationToken);
         }
@@ -112,11 +167,19 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
+
             if (comparer == null)
+            {
                 throw new ArgumentNullException(nameof(comparer));
+            }
 
             return source.ToDictionary(keySelector, x => x, comparer, cancellationToken);
         }
@@ -124,9 +187,14 @@ 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));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
 
             return source.ToDictionary(keySelector, x => x, EqualityComparer<TKey>.Default, cancellationToken);
         }
@@ -134,7 +202,9 @@ namespace System.Linq
         public static Task<List<TSource>> ToList<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return ToList(source, CancellationToken.None);
         }
@@ -142,10 +212,14 @@ namespace System.Linq
         public static Task<List<TSource>> ToList<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             if (source is IIListProvider<TSource> listProvider)
+            {
                 return listProvider.ToListAsync(cancellationToken);
+            }
 
             return source.Aggregate(new List<TSource>(), (list, x) =>
                                                          {

+ 6 - 2
Ix.NET/Source/System.Interactive.Async/ToObservable.cs

@@ -2,9 +2,7 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System;
 using System.Collections.Generic;
-using System.Linq;
 using System.Threading.Tasks;
 
 namespace System.Linq
@@ -14,7 +12,9 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> ToAsyncEnumerable<TSource>(this IObservable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return CreateEnumerable(
                 () =>
@@ -78,7 +78,9 @@ namespace System.Linq
         public static IObservable<TSource> ToObservable<TSource>(this IAsyncEnumerable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return new ToObservableObservable<TSource>(source);
         }
@@ -203,7 +205,9 @@ namespace System.Linq
                                                      observer.OnNext(e.Current);
 
                                                      if (!ctd.Token.IsCancellationRequested)
+                                                     {
                                                          f();
+                                                     }
 
                                                      //In case cancellation is requested, this could only have happened
                                                      //by disposing the returned composite disposable (see below).

+ 13 - 3
Ix.NET/Source/System.Interactive.Async/Union.cs

@@ -2,10 +2,7 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System;
 using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
 
 namespace System.Linq
 {
@@ -14,11 +11,19 @@ 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));
+            }
+
             if (second == null)
+            {
                 throw new ArgumentNullException(nameof(second));
+            }
+
             if (comparer == null)
+            {
                 throw new ArgumentNullException(nameof(comparer));
+            }
 
             return first.Concat(second)
                         .Distinct(comparer);
@@ -27,9 +32,14 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Union<TSource>(this IAsyncEnumerable<TSource> first, IAsyncEnumerable<TSource> second)
         {
             if (first == null)
+            {
                 throw new ArgumentNullException(nameof(first));
+            }
+
             if (second == null)
+            {
                 throw new ArgumentNullException(nameof(second));
+            }
 
             return first.Union(second, EqualityComparer<TSource>.Default);
         }

+ 6 - 1
Ix.NET/Source/System.Interactive.Async/Using.cs

@@ -14,9 +14,14 @@ 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));
+            }
+
             if (enumerableFactory == null)
+            {
                 throw new ArgumentNullException(nameof(enumerableFactory));
+            }
 
             return new UsingAsyncIterator<TSource, TResource>(resourceFactory, enumerableFactory);
         }
@@ -55,7 +60,7 @@ namespace System.Linq
                 if (resource != null)
                 {
                     resource.Dispose();
-                    resource = default(TResource);
+                    resource = default;
                 }
 
                 base.Dispose();

+ 10 - 0
Ix.NET/Source/System.Interactive.Async/Where.cs

@@ -14,9 +14,14 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Where<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (predicate == null)
+            {
                 throw new ArgumentNullException(nameof(predicate));
+            }
 
             if (source is AsyncIterator<TSource> iterator)
             {
@@ -30,9 +35,14 @@ namespace System.Linq
         public static IAsyncEnumerable<TSource> Where<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int, bool> predicate)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (predicate == null)
+            {
                 throw new ArgumentNullException(nameof(predicate));
+            }
 
             return new WhereEnumerableWithIndexAsyncIterator<TSource>(source, predicate);
         }

+ 8 - 0
Ix.NET/Source/System.Interactive.Async/Zip.cs

@@ -14,11 +14,19 @@ 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));
+            }
+
             if (second == null)
+            {
                 throw new ArgumentNullException(nameof(second));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return new ZipAsyncIterator<TFirst, TSecond, TResult>(first, second, selector);
         }

+ 0 - 2
Ix.NET/Source/System.Interactive.Providers/Properties/AssemblyInfo.cs

@@ -1,8 +1,6 @@
 using System;
-using System.Reflection;
 using System.Resources;
 using System.Runtime.InteropServices;
-using System.Security;
 
 
 [assembly: NeutralResourcesLanguage("en-US")]

File diff suppressed because it is too large
+ 288 - 42
Ix.NET/Source/System.Interactive.Providers/QueryableEx.cs


+ 1 - 1
Ix.NET/Source/System.Interactive.Providers/Reflection.cs

@@ -19,7 +19,7 @@ namespace System.Reflection
 
 namespace System
 {
-    static class TypeExtensions
+    internal static class TypeExtensions
     {
         public static bool IsAssignableFrom(this Type t1, Type t2)
         {

+ 2 - 2
Ix.NET/Source/System.Interactive.Tests/AssertEx.cs

@@ -1,8 +1,8 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
-using Xunit;
 using System;
+using Xunit;
 
 namespace Tests
 {
@@ -37,7 +37,7 @@ namespace Tests
         {
             try
             {
-                action();   
+                action();
             }
             catch (AggregateException ex)
             {

+ 4 - 5
Ix.NET/Source/System.Interactive.Tests/Tests.Aggregates.cs

@@ -2,7 +2,6 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 using System;
-using System.Text;
 using System.Collections.Generic;
 using System.Linq;
 using Xunit;
@@ -42,7 +41,7 @@ namespace Tests
             Assert.Equal(3, new[] { 5, 3, 7 }.Min(new Mod3Comparer()));
         }
 
-        class Mod3Comparer : IComparer<int>
+        private class Mod3Comparer : IComparer<int>
         {
             public int Compare(int x, int y)
             {
@@ -56,7 +55,7 @@ namespace Tests
             AssertThrows<ArgumentNullException>(() => EnumerableEx.MinBy(null, (int x) => x));
             AssertThrows<ArgumentNullException>(() => EnumerableEx.MinBy(new[] { 1 }, default(Func<int, int>)));
             AssertThrows<ArgumentNullException>(() => EnumerableEx.MinBy(null, (int x) => x, Comparer<int>.Default));
-            AssertThrows<ArgumentNullException>(() => EnumerableEx.MinBy(new[] { 1 }, default(Func<int, int>), Comparer<int>.Default));
+            AssertThrows<ArgumentNullException>(() => EnumerableEx.MinBy(new[] { 1 }, default, Comparer<int>.Default));
             AssertThrows<ArgumentNullException>(() => EnumerableEx.MinBy(new[] { 1 }, (int x) => x, null));
         }
 
@@ -86,7 +85,7 @@ namespace Tests
             Assert.Equal(5, new[] { 2, 5, 3, 7 }.Max(new Mod7Comparer()));
         }
 
-        class Mod7Comparer : IComparer<int>
+        private class Mod7Comparer : IComparer<int>
         {
             public int Compare(int x, int y)
             {
@@ -100,7 +99,7 @@ namespace Tests
             AssertThrows<ArgumentNullException>(() => EnumerableEx.MaxBy(null, (int x) => x));
             AssertThrows<ArgumentNullException>(() => EnumerableEx.MaxBy(new[] { 1 }, default(Func<int, int>)));
             AssertThrows<ArgumentNullException>(() => EnumerableEx.MaxBy(null, (int x) => x, Comparer<int>.Default));
-            AssertThrows<ArgumentNullException>(() => EnumerableEx.MaxBy(new[] { 1 }, default(Func<int, int>), Comparer<int>.Default));
+            AssertThrows<ArgumentNullException>(() => EnumerableEx.MaxBy(new[] { 1 }, default, Comparer<int>.Default));
             AssertThrows<ArgumentNullException>(() => EnumerableEx.MaxBy(new[] { 1 }, (int x) => x, null));
         }
 

+ 8 - 7
Ix.NET/Source/System.Interactive.Tests/Tests.Buffering.cs

@@ -2,11 +2,10 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 using System;
-using System.Text;
+using System.Collections;
 using System.Collections.Generic;
 using System.Linq;
 using Xunit;
-using System.Collections;
 
 namespace Tests
 {
@@ -147,7 +146,7 @@ namespace Tests
             Assert.Equal(10, n);
         }
 
-        static IEnumerable<int> Tick(Action<int> t)
+        private static IEnumerable<int> Tick(Action<int> t)
         {
             var i = 0;
             while (true)
@@ -265,7 +264,7 @@ namespace Tests
             AssertThrows<MyException>(() => e2.MoveNext());
         }
 
-        class MyException : Exception
+        private class MyException : Exception
         {
         }
 
@@ -278,7 +277,7 @@ namespace Tests
             HasNext(e1, 0);
             HasNext(e1, 1);
             HasNext(e1, 2);
-            
+
             var e2 = rng.GetEnumerator();
             HasNext(e2, 3);
             HasNext(e2, 4);
@@ -550,12 +549,14 @@ namespace Tests
             Assert.True(rnd.Zip(rnd, (l, r) => l == r).All(x => x));
         }
 
-        static Random Random = new Random();
+        private static readonly Random Random = new Random();
 
-        static IEnumerable<int> Rand()
+        private static IEnumerable<int> Rand()
         {
             while (true)
+            {
                 yield return Random.Next();
+            }
         }
 
         [Fact]

+ 11 - 9
Ix.NET/Source/System.Interactive.Tests/Tests.Creation.cs

@@ -2,12 +2,11 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 using System;
-using System.Text;
+using System.Collections;
 using System.Collections.Generic;
 using System.Linq;
-using Xunit;
-using System.Collections;
 using System.Threading;
+using Xunit;
 
 namespace Tests
 {
@@ -16,7 +15,7 @@ namespace Tests
         [Fact]
         public void Create_Arguments()
         {
-            AssertThrows<ArgumentNullException>(() => EnumerableEx.Create<int>(default(Func<IEnumerator<int>>)));
+            AssertThrows<ArgumentNullException>(() => EnumerableEx.Create<int>(default));
         }
 
         [Fact]
@@ -48,7 +47,8 @@ namespace Tests
         {
             SynchronizationContext.SetSynchronizationContext(null);
 
-            var xs = EnumerableEx.Create<int>(async yield => {
+            var xs = EnumerableEx.Create<int>(async yield =>
+            {
                 var i = 0;
                 while (i < 10)
                 {
@@ -71,7 +71,8 @@ namespace Tests
         {
             SynchronizationContext.SetSynchronizationContext(null);
 
-            var xs = EnumerableEx.Create<int>(async yield => {
+            var xs = EnumerableEx.Create<int>(async yield =>
+            {
                 var i = 0;
                 while (true)
                 {
@@ -98,8 +99,9 @@ namespace Tests
         [Fact]
         public void YielderNoReset()
         {
-            var xs = EnumerableEx.Create<int>(async yield => {
-               await yield.Break();
+            var xs = EnumerableEx.Create<int>(async yield =>
+            {
+                await yield.Break();
             });
 
             AssertThrows<NotSupportedException>(() => xs.GetEnumerator().Reset());
@@ -237,7 +239,7 @@ namespace Tests
             Assert.True(d.Done);
         }
 
-        class MyDisposable : IDisposable
+        private class MyDisposable : IDisposable
         {
             public bool Done;
 

+ 2 - 3
Ix.NET/Source/System.Interactive.Tests/Tests.Exceptions.cs

@@ -2,7 +2,6 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 using System;
-using System.Text;
 using System.Collections.Generic;
 using System.Linq;
 using Xunit;
@@ -16,7 +15,7 @@ namespace Tests
         {
             AssertThrows<ArgumentNullException>(() => EnumerableEx.Catch<int>(null, new[] { 1 }));
             AssertThrows<ArgumentNullException>(() => EnumerableEx.Catch<int>(new[] { 1 }, null));
-            AssertThrows<ArgumentNullException>(() => EnumerableEx.Catch<int>(default(IEnumerable<int>[])));
+            AssertThrows<ArgumentNullException>(() => EnumerableEx.Catch<int>(default));
             AssertThrows<ArgumentNullException>(() => EnumerableEx.Catch<int>(default(IEnumerable<IEnumerable<int>>)));
             AssertThrows<ArgumentNullException>(() => EnumerableEx.Catch<int, Exception>(null, ex => new[] { 1 }));
             AssertThrows<ArgumentNullException>(() => EnumerableEx.Catch<int, Exception>(new[] { 1 }, null));
@@ -282,7 +281,7 @@ namespace Tests
         {
             AssertThrows<ArgumentNullException>(() => EnumerableEx.OnErrorResumeNext<int>(null, new[] { 1 }));
             AssertThrows<ArgumentNullException>(() => EnumerableEx.OnErrorResumeNext<int>(new[] { 1 }, null));
-            AssertThrows<ArgumentNullException>(() => EnumerableEx.OnErrorResumeNext<int>(default(IEnumerable<int>[])));
+            AssertThrows<ArgumentNullException>(() => EnumerableEx.OnErrorResumeNext<int>(default));
             AssertThrows<ArgumentNullException>(() => EnumerableEx.OnErrorResumeNext<int>(default(IEnumerable<IEnumerable<int>>)));
         }
 

+ 0 - 1
Ix.NET/Source/System.Interactive.Tests/Tests.Imperative.cs

@@ -2,7 +2,6 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 using System;
-using System.Text;
 using System.Collections.Generic;
 using System.Linq;
 using Xunit;

+ 1 - 2
Ix.NET/Source/System.Interactive.Tests/Tests.Multiple.cs

@@ -2,7 +2,6 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 using System;
-using System.Text;
 using System.Collections.Generic;
 using System.Linq;
 using Xunit;
@@ -38,7 +37,7 @@ namespace Tests
 
             var res = xss.Concat().Select(x => i + " - " + x).ToList();
 
-            Assert.True(Enumerable.SequenceEqual(res, new[] { 
+            Assert.True(Enumerable.SequenceEqual(res, new[] {
                 "1 - 0",
                 "2 - 0",
                 "2 - 1",

+ 18 - 5
Ix.NET/Source/System.Interactive.Tests/Tests.Qbservable.cs

@@ -3,14 +3,12 @@
 // See the LICENSE file in the project root for more information. 
 
 using System;
-using System.Collections.Generic;
+using System.ComponentModel;
 using System.Linq;
-using System.Text;
+using System.Linq.Expressions;
 using System.Reflection;
-using Xunit;
 using System.Runtime.CompilerServices;
-using System.Linq.Expressions;
-using System.ComponentModel;
+using Xunit;
 
 namespace Tests
 {
@@ -41,7 +39,9 @@ namespace Tests
                 {
                     var gd = t.GetGenericTypeDefinition();
                     if (gd == typeof(IBuffer<>))
+                    {
                         return false;
+                    }
                 }
                 return true;
             }
@@ -64,7 +64,9 @@ namespace Tests
                     .OrderBy(x => x).ToList();
 
                 if (!group.Name.Equals("Create"))
+                {
                     Assert.True(oss.SequenceEqual(qss), "Mismatch between QueryableEx and EnumerableEx for " + group.Name);
+                }
             }
         }
 
@@ -73,7 +75,9 @@ namespace Tests
             var ps = m.GetParameters();
             var pss = ps.AsEnumerable();
             if (correct && ps.Length > 0 && ps[0].ParameterType == typeof(IQueryProvider))
+            {
                 pss = pss.Skip(1);
+            }
 
             var gens = m.IsGenericMethod ? string.Format("<{0}>", string.Join(", ", m.GetGenericArguments().Select(a => GetTypeName(a, correct)).ToArray())) : "";
 
@@ -81,7 +85,9 @@ namespace Tests
             if (m.IsDefined(typeof(ExtensionAttribute)))
             {
                 if (pars.StartsWith("IQbservable") || pars.StartsWith("IQueryable"))
+                {
                     pars = "this " + pars;
+                }
             }
 
             return string.Format("{0} {1}{2}({3})", GetTypeName(m.ReturnType, correct), m.Name, gens, pars);
@@ -93,16 +99,23 @@ namespace Tests
             {
                 var gtd = t.GetGenericTypeDefinition();
                 if (gtd == typeof(Expression<>))
+                {
                     return GetTypeName(t.GenericTypeArguments[0], false);
+                }
 
                 var args = string.Join(", ", t.GenericTypeArguments.Select(a => GetTypeName(a, false)).ToArray());
 
                 var len = t.Name.IndexOf('`');
                 var name = len >= 0 ? t.Name.Substring(0, len) : t.Name;
                 if (correct && name == "IQbservable")
+                {
                     name = "IObservable";
+                }
+
                 if (correct && name == "IQueryable")
+                {
                     name = "IEnumerable";
+                }
 
                 return string.Format("{0}<{1}>", name, args);
             }

+ 9 - 10
Ix.NET/Source/System.Interactive.Tests/Tests.Single.cs

@@ -2,7 +2,6 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 using System;
-using System.Text;
 using System.Collections.Generic;
 using System.Linq;
 using Xunit;
@@ -132,12 +131,12 @@ namespace Tests
             AssertThrows<ArgumentNullException>(() => EnumerableEx.Do<int>(null, _ => { }, _ => { }));
             AssertThrows<ArgumentNullException>(() => EnumerableEx.Do<int>(null, _ => { }, _ => { }, () => { }));
             AssertThrows<ArgumentNullException>(() => EnumerableEx.Do<int>(new[] { 1 }, default(Action<int>)));
-            AssertThrows<ArgumentNullException>(() => EnumerableEx.Do<int>(new[] { 1 }, default(Action<int>), () => { }));
+            AssertThrows<ArgumentNullException>(() => EnumerableEx.Do<int>(new[] { 1 }, default, () => { }));
             AssertThrows<ArgumentNullException>(() => EnumerableEx.Do<int>(new[] { 1 }, _ => { }, default(Action)));
-            AssertThrows<ArgumentNullException>(() => EnumerableEx.Do<int>(new[] { 1 }, default(Action<int>), _ => { }, () => { }));
-            AssertThrows<ArgumentNullException>(() => EnumerableEx.Do<int>(new[] { 1 }, _ => { }, default(Action<Exception>), () => { }));
-            AssertThrows<ArgumentNullException>(() => EnumerableEx.Do<int>(new[] { 1 }, _ => { }, _ => { }, default(Action)));
-            AssertThrows<ArgumentNullException>(() => EnumerableEx.Do<int>(new[] { 1 }, default(Action<int>), _ => { }));
+            AssertThrows<ArgumentNullException>(() => EnumerableEx.Do<int>(new[] { 1 }, default, _ => { }, () => { }));
+            AssertThrows<ArgumentNullException>(() => EnumerableEx.Do<int>(new[] { 1 }, _ => { }, default, () => { }));
+            AssertThrows<ArgumentNullException>(() => EnumerableEx.Do<int>(new[] { 1 }, _ => { }, _ => { }, default));
+            AssertThrows<ArgumentNullException>(() => EnumerableEx.Do<int>(new[] { 1 }, default, _ => { }));
             AssertThrows<ArgumentNullException>(() => EnumerableEx.Do<int>(new[] { 1 }, _ => { }, default(Action<Exception>)));
             AssertThrows<ArgumentNullException>(() => EnumerableEx.Do<int>(null, new MyObserver()));
             AssertThrows<ArgumentNullException>(() => EnumerableEx.Do<int>(new[] { 1 }, default(IObserver<int>)));
@@ -180,7 +179,7 @@ namespace Tests
             Assert.Equal(45, obs.Sum);
         }
 
-        class MyObserver : IObserver<int>
+        private class MyObserver : IObserver<int>
         {
             public int Sum;
             public bool Done;
@@ -287,7 +286,7 @@ namespace Tests
             Assert.True(Enumerable.SequenceEqual(res, new[] { 0, 1 }));
         }
 
-        class MyEqualityComparer : IEqualityComparer<int>
+        private class MyEqualityComparer : IEqualityComparer<int>
         {
             public bool Equals(int x, int y)
             {
@@ -351,7 +350,7 @@ namespace Tests
         [Fact]
         public void TakeLast_TakeZero()
         {
-            var e = Enumerable.Range(1, 5) ;
+            var e = Enumerable.Range(1, 5);
 #if NETCOREAPP2_1 || WINDOWS_UWP
             var r = EnumerableEx.TakeLast(e, 0).ToList();
 #else
@@ -383,7 +382,7 @@ namespace Tests
 #else
             var r = e.TakeLast(5).ToList();
 #endif
-            
+
             Assert.True(Enumerable.SequenceEqual(r, e));
         }
 

+ 1 - 3
Ix.NET/Source/System.Interactive.Tests/Tests.cs

@@ -2,15 +2,13 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 using System;
-using System.Text;
 using System.Collections.Generic;
-using System.Linq;
 using Xunit;
 
 
 namespace Tests
 {
-    
+
     public partial class Tests
     {
 #pragma warning disable xUnit1013 // Public method should be marked as test

+ 22 - 4
Ix.NET/Source/System.Interactive/Buffer.cs

@@ -2,10 +2,7 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System;
 using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
 
 namespace System.Linq
 {
@@ -21,9 +18,14 @@ namespace System.Linq
         public static IEnumerable<IList<TSource>> Buffer<TSource>(this IEnumerable<TSource> source, int count)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (count <= 0)
+            {
                 throw new ArgumentOutOfRangeException(nameof(count));
+            }
 
             return source.Buffer_(count, count);
         }
@@ -39,11 +41,19 @@ namespace System.Linq
         public static IEnumerable<IList<TSource>> Buffer<TSource>(this IEnumerable<TSource> source, int count, int skip)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (count <= 0)
+            {
                 throw new ArgumentOutOfRangeException(nameof(count));
+            }
+
             if (skip <= 0)
+            {
                 throw new ArgumentOutOfRangeException(nameof(skip));
+            }
 
             return source.Buffer_(count, skip);
         }
@@ -55,21 +65,29 @@ namespace System.Linq
             var i = 0;
             foreach (var item in source)
             {
-                if (i%skip == 0)
+                if (i % skip == 0)
+                {
                     buffers.Enqueue(new List<TSource>(count));
+                }
 
                 foreach (var buffer in buffers)
+                {
                     buffer.Add(item);
+                }
 
                 if (buffers.Count > 0 && buffers.Peek()
                                                 .Count == count)
+                {
                     yield return buffers.Dequeue();
+                }
 
                 i++;
             }
 
             while (buffers.Count > 0)
+            {
                 yield return buffers.Dequeue();
+            }
         }
     }
 

+ 16 - 3
Ix.NET/Source/System.Interactive/Case.cs

@@ -2,10 +2,7 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System;
 using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
 
 namespace System.Linq
 {
@@ -22,9 +19,14 @@ namespace System.Linq
         public static IEnumerable<TResult> Case<TValue, TResult>(Func<TValue> selector, IDictionary<TValue, IEnumerable<TResult>> sources)
         {
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
+
             if (sources == null)
+            {
                 throw new ArgumentNullException(nameof(sources));
+            }
 
             return Case(selector, sources, Enumerable.Empty<TResult>());
         }
@@ -45,16 +47,27 @@ namespace System.Linq
         public static IEnumerable<TResult> Case<TValue, TResult>(Func<TValue> selector, IDictionary<TValue, IEnumerable<TResult>> sources, IEnumerable<TResult> defaultSource)
         {
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
+
             if (sources == null)
+            {
                 throw new ArgumentNullException(nameof(sources));
+            }
+
             if (defaultSource == null)
+            {
                 throw new ArgumentNullException(nameof(defaultSource));
+            }
 
             return Defer(() =>
                          {
                              if (!sources.TryGetValue(selector(), out var result))
+                             {
                                  result = defaultSource;
+                             }
+
                              return result;
                          });
         }

+ 25 - 4
Ix.NET/Source/System.Interactive/Catch.cs

@@ -2,10 +2,7 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System;
 using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
 
 namespace System.Linq
 {
@@ -24,9 +21,14 @@ namespace System.Linq
             where TException : Exception
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (handler == null)
+            {
                 throw new ArgumentNullException(nameof(handler));
+            }
 
             return source.Catch_(handler);
         }
@@ -40,7 +42,9 @@ namespace System.Linq
         public static IEnumerable<TSource> Catch<TSource>(this IEnumerable<IEnumerable<TSource>> sources)
         {
             if (sources == null)
+            {
                 throw new ArgumentNullException(nameof(sources));
+            }
 
             return sources.Catch_();
         }
@@ -54,7 +58,9 @@ namespace System.Linq
         public static IEnumerable<TSource> Catch<TSource>(params IEnumerable<TSource>[] sources)
         {
             if (sources == null)
+            {
                 throw new ArgumentNullException(nameof(sources));
+            }
 
             return sources.Catch_();
         }
@@ -69,11 +75,16 @@ namespace System.Linq
         public static IEnumerable<TSource> Catch<TSource>(this IEnumerable<TSource> first, IEnumerable<TSource> second)
         {
             if (first == null)
+            {
                 throw new ArgumentNullException(nameof(first));
+            }
+
             if (second == null)
+            {
                 throw new ArgumentNullException(nameof(second));
+            }
 
-            return new[] {first, second}.Catch_();
+            return new[] { first, second }.Catch_();
         }
 
         private static IEnumerable<TSource> Catch_<TSource, TException>(this IEnumerable<TSource> source, Func<TException, IEnumerable<TSource>> handler)
@@ -90,7 +101,9 @@ namespace System.Linq
                     try
                     {
                         if (!e.MoveNext())
+                        {
                             break;
+                        }
 
                         c = e.Current;
                     }
@@ -107,7 +120,9 @@ namespace System.Linq
             if (err != null)
             {
                 foreach (var item in err)
+                {
                     yield return item;
+                }
             }
         }
 
@@ -128,7 +143,9 @@ namespace System.Linq
                         try
                         {
                             if (!e.MoveNext())
+                            {
                                 break;
+                            }
 
                             c = e.Current;
                         }
@@ -142,12 +159,16 @@ namespace System.Linq
                     }
 
                     if (error == null)
+                    {
                         break;
+                    }
                 }
             }
 
             if (error != null)
+            {
                 throw error;
+            }
         }
     }
 }

+ 8 - 3
Ix.NET/Source/System.Interactive/Concatenate.cs

@@ -2,10 +2,7 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System;
 using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
 
 namespace System.Linq
 {
@@ -20,7 +17,9 @@ namespace System.Linq
         public static IEnumerable<TSource> Concat<TSource>(this IEnumerable<IEnumerable<TSource>> sources)
         {
             if (sources == null)
+            {
                 throw new ArgumentNullException(nameof(sources));
+            }
 
             return sources.Concat_();
         }
@@ -34,7 +33,9 @@ namespace System.Linq
         public static IEnumerable<TSource> Concat<TSource>(params IEnumerable<TSource>[] sources)
         {
             if (sources == null)
+            {
                 throw new ArgumentNullException(nameof(sources));
+            }
 
             return sources.Concat_();
         }
@@ -42,8 +43,12 @@ namespace System.Linq
         private static IEnumerable<TSource> Concat_<TSource>(this IEnumerable<IEnumerable<TSource>> sources)
         {
             foreach (var source in sources)
+            {
                 foreach (var item in source)
+                {
                     yield return item;
+                }
+            }
         }
     }
 }

+ 6 - 3
Ix.NET/Source/System.Interactive/Create.cs

@@ -2,11 +2,8 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System;
 using System.Collections;
 using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
 
 namespace System.Linq
 {
@@ -21,7 +18,9 @@ namespace System.Linq
         public static IEnumerable<TResult> Create<TResult>(Func<IEnumerator<TResult>> getEnumerator)
         {
             if (getEnumerator == null)
+            {
                 throw new ArgumentNullException(nameof(getEnumerator));
+            }
 
             return new AnonymousEnumerable<TResult>(getEnumerator);
         }
@@ -38,10 +37,14 @@ namespace System.Linq
         public static IEnumerable<T> Create<T>(Action<IYielder<T>> create)
         {
             if (create == null)
+            {
                 throw new ArgumentNullException(nameof(create));
+            }
 
             foreach (var x in new Yielder<T>(create))
+            {
                 yield return x;
+            }
         }
 
         private class AnonymousEnumerable<TResult> : IEnumerable<TResult>

Some files were not shown because too many files changed in this diff