浏览代码

More code cosmetics.

Bart De Smet 8 年之前
父节点
当前提交
4e6c9fb11e

+ 8 - 12
Ix.NET/Source/System.Interactive.Async/Aggregate.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. 
+// 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;
-using System.Linq;
 using System.Threading;
 using System.Threading.Tasks;
 
@@ -76,8 +74,7 @@ namespace System.Linq
             return Aggregate_(source, accumulator, cancellationToken);
         }
 
-        private static async Task<TResult> Aggregate_<TSource, TAccumulate, TResult>(IAsyncEnumerable<TSource> source, TAccumulate seed,
-                                                                                     Func<TAccumulate, TSource, TAccumulate> accumulator, Func<TAccumulate, TResult> resultSelector, CancellationToken cancellationToken)
+        private static async Task<TResult> Aggregate_<TSource, TAccumulate, TResult>(IAsyncEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> accumulator, Func<TAccumulate, TResult> resultSelector, CancellationToken cancellationToken)
         {
             var acc = seed;
 
@@ -85,8 +82,7 @@ namespace System.Linq
 
             try
             {
-                while (await e.MoveNextAsync(cancellationToken)
-                              .ConfigureAwait(false))
+                while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false))
                 {
                     acc = accumulator(acc, e.Current);
                 }
@@ -108,8 +104,7 @@ namespace System.Linq
 
             try
             {
-                while (await e.MoveNextAsync(cancellationToken)
-                              .ConfigureAwait(false))
+                while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false))
                 {
                     acc = first ? e.Current : accumulator(acc, e.Current);
                     first = false;
@@ -122,7 +117,8 @@ namespace System.Linq
 
             if (first)
                 throw new InvalidOperationException(Strings.NO_ELEMENTS);
+
             return acc;
         }
     }
-}
+}

+ 8 - 14
Ix.NET/Source/System.Interactive.Async/AnyAll.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. 
+// 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;
-using System.Linq;
 using System.Threading;
 using System.Threading.Tasks;
 
@@ -123,8 +121,7 @@ namespace System.Linq
 
             try
             {
-                while (await e.MoveNextAsync(cancellationToken)
-                              .ConfigureAwait(false))
+                while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false))
                 {
                     if (!predicate(e.Current))
                         return false;
@@ -144,8 +141,7 @@ namespace System.Linq
 
             try
             {
-                while (await e.MoveNextAsync(cancellationToken)
-                              .ConfigureAwait(false))
+                while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false))
                 {
                     if (!await predicate(e.Current).ConfigureAwait(false))
                         return false;
@@ -165,8 +161,7 @@ namespace System.Linq
 
             try
             {
-                while (await e.MoveNextAsync(cancellationToken)
-                              .ConfigureAwait(false))
+                while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false))
                 {
                     if (predicate(e.Current))
                         return true;
@@ -186,8 +181,7 @@ namespace System.Linq
 
             try
             {
-                while (await e.MoveNextAsync(cancellationToken)
-                              .ConfigureAwait(false))
+                while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false))
                 {
                     if (await predicate(e.Current).ConfigureAwait(false))
                         return true;
@@ -201,4 +195,4 @@ namespace System.Linq
             return false;
         }
     }
-}
+}

+ 11 - 19
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;
 
@@ -60,10 +58,9 @@ namespace System.Linq
             public abstract AppendPrepentAsyncIterator<TSource> Append(TSource item);
             public abstract AppendPrepentAsyncIterator<TSource> Prepend(TSource item);
 
-            protected async Task<bool> LoadFromEnumerator()
+            protected async Task<bool> LoadFromEnumeratorAsync()
             {
-                if (await enumerator.MoveNextAsync()
-                                    .ConfigureAwait(false))
+                if (await enumerator.MoveNextAsync().ConfigureAwait(false))
                 {
                     current = enumerator.Current;
                     return true;
@@ -113,7 +110,6 @@ namespace System.Linq
                 return new AppendPrepend1AsyncIterator<TSource>(source, item, appending);
             }
 
-
             protected override async Task<bool> MoveNextCore()
             {
                 switch (state)
@@ -133,12 +129,12 @@ namespace System.Linq
                         if (!hasEnumerator)
                         {
                             GetSourceEnumerator();
-                            hasEnumerator = true;   
+                            hasEnumerator = true;
                         }
 
                         if (enumerator != null)
                         {
-                            if (await LoadFromEnumerator()
+                            if (await LoadFromEnumeratorAsync()
                                 .ConfigureAwait(false))
                             {
                                 return true;
@@ -208,8 +204,7 @@ namespace System.Linq
 
                     try
                     {
-                        while (await en.MoveNextAsync(cancellationToken)
-                                       .ConfigureAwait(false))
+                        while (await en.MoveNextAsync(cancellationToken).ConfigureAwait(false))
                         {
                             array[index] = en.Current;
                             ++index;
@@ -244,8 +239,7 @@ namespace System.Linq
 
                 try
                 {
-                    while (await en.MoveNextAsync(cancellationToken)
-                                   .ConfigureAwait(false))
+                    while (await en.MoveNextAsync(cancellationToken).ConfigureAwait(false))
                     {
                         list.Add(en.Current);
                     }
@@ -362,7 +356,7 @@ namespace System.Linq
                 {
                     case AsyncIteratorState.Allocated:
                         mode = 1;
-                        state = AsyncIteratorState.Iterating; 
+                        state = AsyncIteratorState.Iterating;
                         goto case AsyncIteratorState.Iterating;
 
                     case AsyncIteratorState.Iterating:
@@ -386,8 +380,7 @@ namespace System.Linq
                                 goto case 3;
 
                             case 3:
-                                if (await LoadFromEnumerator()
-                                        .ConfigureAwait(false))
+                                if (await LoadFromEnumeratorAsync().ConfigureAwait(false))
                                 {
                                     return true;
                                 }
@@ -400,7 +393,7 @@ namespace System.Linq
                                 }
 
                                 break;
-                                
+
 
                             case 4:
                                 if (appendedEnumerator.MoveNext())
@@ -490,8 +483,7 @@ namespace System.Linq
 
                 try
                 {
-                    while (await en.MoveNextAsync(cancellationToken)
-                                   .ConfigureAwait(false))
+                    while (await en.MoveNextAsync(cancellationToken).ConfigureAwait(false))
                     {
                         list.Add(en.Current);
                     }
@@ -527,4 +519,4 @@ namespace System.Linq
             }
         }
     }
-}
+}

+ 6 - 17
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;
 
@@ -22,10 +20,7 @@ namespace System.Linq
 
         public static IAsyncEnumerable<TValue> Empty<TValue>()
         {
-            return CreateEnumerable(
-                () => CreateEnumerator<TValue>(
-                    ct => TaskExt.False, null, null)
-            );
+            return CreateEnumerable(() => CreateEnumerator<TValue>(ct => TaskExt.False, current: null, dispose: null));
         }
 
         public static Task<bool> IsEmpty<TSource>(this IAsyncEnumerable<TSource> source)
@@ -46,12 +41,7 @@ namespace System.Linq
 
         public static IAsyncEnumerable<TValue> Never<TValue>()
         {
-            return CreateEnumerable(
-                () => CreateEnumerator<TValue>(
-                    tcs => tcs.Task,
-                    null,
-                    null)
-            );
+            return CreateEnumerable(() => CreateEnumerator<TValue>(tcs => tcs.Task, current: null, dispose: null));
         }
 
 
@@ -73,15 +63,14 @@ namespace System.Linq
                         tcs.TrySetException(exception);
                         return tcs.Task;
                     },
-                    null,
-                    null)
+                    current: null,
+                    dispose: null)
             );
         }
 
         private static async Task<bool> IsEmpty_<TSource>(IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
         {
-            return !await source.Any(cancellationToken)
-                                .ConfigureAwait(false);
+            return !await source.Any(cancellationToken).ConfigureAwait(false);
         }
     }
-}
+}

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

@@ -13,8 +13,7 @@ namespace System.Collections.Generic
     {
         internal static async Task<T[]> ToArray<T>(IAsyncEnumerable<T> source, CancellationToken cancellationToken)
         {
-            var result = await ToArrayWithLength(source, cancellationToken)
-                             .ConfigureAwait(false);
+            var result = await ToArrayWithLength(source, cancellationToken).ConfigureAwait(false);
             Array.Resize(ref result.array, result.length);
             return result.array;
         }
@@ -47,16 +46,14 @@ namespace System.Collections.Generic
 
                 try
                 {
-                    if (await en.MoveNextAsync(cancellationToken)
-                                .ConfigureAwait(false))
+                    if (await en.MoveNextAsync(cancellationToken).ConfigureAwait(false))
                     {
                         const int DefaultCapacity = 4;
                         var arr = new T[DefaultCapacity];
                         arr[0] = en.Current;
                         var count = 1;
 
-                        while (await en.MoveNextAsync(cancellationToken)
-                                       .ConfigureAwait(false))
+                        while (await en.MoveNextAsync(cancellationToken).ConfigureAwait(false))
                         {
                             if (count == arr.Length)
                             {
@@ -115,4 +112,4 @@ namespace System.Collections.Generic
             public int length;
         }
     }
-}
+}

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

@@ -10,7 +10,7 @@ namespace System.Linq
 {
     public static partial class AsyncEnumerable
     {
-        private static readonly Task CompletedTask = Task.FromResult(true); // TODO: Change to Task.CompletedTask when all build targets allow.
+        private static readonly Task CompletedTask = TaskExt.True;
 
         internal abstract class AsyncIterator<TSource> : IAsyncEnumerable<TSource>, IAsyncEnumerator<TSource>
         {
@@ -49,7 +49,6 @@ namespace System.Linq
                 return enumerator;
             }
 
-
             public virtual Task DisposeAsync()
             {
                 if (cancellationTokenSource != null)
@@ -73,6 +72,7 @@ namespace System.Linq
                 {
                     if (currentIsInvalid)
                         throw new InvalidOperationException("Enumerator is in an invalid state");
+
                     return current;
                 }
             }
@@ -90,8 +90,7 @@ namespace System.Linq
 
                 try
                 {
-                    var result = await MoveNextCore()
-                                        .ConfigureAwait(false);
+                    var result = await MoveNextCore().ConfigureAwait(false);
 
                     currentIsInvalid = !result; // if move next is false, invalid otherwise valid
 
@@ -142,4 +141,4 @@ namespace System.Linq
             Disposed = -1
         }
     }
-}
+}

+ 20 - 40
Ix.NET/Source/System.Interactive.Async/Average.cs

@@ -16,8 +16,7 @@ namespace System.Linq
 
             try
             {
-                if (!await e.MoveNextAsync(cancellationToken)
-                            .ConfigureAwait(false))
+                if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false))
                 {
                     throw new InvalidOperationException(Strings.NO_ELEMENTS);
                 }
@@ -26,8 +25,7 @@ namespace System.Linq
                 long count = 1;
                 checked
                 {
-                    while (await e.MoveNextAsync(cancellationToken)
-                                  .ConfigureAwait(false))
+                    while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false))
                     {
                         sum += e.Current;
                         ++count;
@@ -48,8 +46,7 @@ namespace System.Linq
 
             try
             {
-                while (await e.MoveNextAsync(cancellationToken)
-                              .ConfigureAwait(false))
+                while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false))
                 {
                     var v = e.Current;
                     if (v.HasValue)
@@ -58,8 +55,7 @@ namespace System.Linq
                         long count = 1;
                         checked
                         {
-                            while (await e.MoveNextAsync(cancellationToken)
-                                          .ConfigureAwait(false))
+                            while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false))
                             {
                                 v = e.Current;
                                 if (v.HasValue)
@@ -88,8 +84,7 @@ namespace System.Linq
 
             try
             {
-                if (!await e.MoveNextAsync(cancellationToken)
-                            .ConfigureAwait(false))
+                if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false))
                 {
                     throw new InvalidOperationException(Strings.NO_ELEMENTS);
                 }
@@ -98,8 +93,7 @@ namespace System.Linq
                 long count = 1;
                 checked
                 {
-                    while (await e.MoveNextAsync(cancellationToken)
-                                  .ConfigureAwait(false))
+                    while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false))
                     {
                         sum += e.Current;
                         ++count;
@@ -120,8 +114,7 @@ namespace System.Linq
 
             try
             {
-                while (await e.MoveNextAsync(cancellationToken)
-                              .ConfigureAwait(false))
+                while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false))
                 {
                     var v = e.Current;
                     if (v.HasValue)
@@ -130,8 +123,7 @@ namespace System.Linq
                         long count = 1;
                         checked
                         {
-                            while (await e.MoveNextAsync(cancellationToken)
-                                          .ConfigureAwait(false))
+                            while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false))
                             {
                                 v = e.Current;
                                 if (v.HasValue)
@@ -160,16 +152,14 @@ namespace System.Linq
 
             try
             {
-                if (!await e.MoveNextAsync(cancellationToken)
-                            .ConfigureAwait(false))
+                if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false))
                 {
                     throw new InvalidOperationException(Strings.NO_ELEMENTS);
                 }
 
                 var sum = e.Current;
                 long count = 1;
-                while (await e.MoveNextAsync(cancellationToken)
-                              .ConfigureAwait(false))
+                while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false))
                 {
                     // There is an opportunity to short-circuit here, in that if e.Current is
                     // ever NaN then the result will always be NaN. Assuming that this case is
@@ -192,8 +182,7 @@ namespace System.Linq
 
             try
             {
-                while (await e.MoveNextAsync(cancellationToken)
-                              .ConfigureAwait(false))
+                while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false))
                 {
                     var v = e.Current;
                     if (v.HasValue)
@@ -202,8 +191,7 @@ namespace System.Linq
                         long count = 1;
                         checked
                         {
-                            while (await e.MoveNextAsync(cancellationToken)
-                                          .ConfigureAwait(false))
+                            while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false))
                             {
                                 v = e.Current;
                                 if (v.HasValue)
@@ -232,16 +220,14 @@ namespace System.Linq
 
             try
             {
-                if (!await e.MoveNextAsync(cancellationToken)
-                            .ConfigureAwait(false))
+                if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false))
                 {
                     throw new InvalidOperationException(Strings.NO_ELEMENTS);
                 }
 
                 double sum = e.Current;
                 long count = 1;
-                while (await e.MoveNextAsync(cancellationToken)
-                              .ConfigureAwait(false))
+                while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false))
                 {
                     sum += e.Current;
                     ++count;
@@ -261,8 +247,7 @@ namespace System.Linq
 
             try
             {
-                while (await e.MoveNextAsync(cancellationToken)
-                              .ConfigureAwait(false))
+                while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false))
                 {
                     var v = e.Current;
                     if (v.HasValue)
@@ -271,8 +256,7 @@ namespace System.Linq
                         long count = 1;
                         checked
                         {
-                            while (await e.MoveNextAsync(cancellationToken)
-                                          .ConfigureAwait(false))
+                            while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false))
                             {
                                 v = e.Current;
                                 if (v.HasValue)
@@ -301,16 +285,14 @@ namespace System.Linq
 
             try
             {
-                if (!await e.MoveNextAsync(cancellationToken)
-                            .ConfigureAwait(false))
+                if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false))
                 {
                     throw new InvalidOperationException(Strings.NO_ELEMENTS);
                 }
 
                 var sum = e.Current;
                 long count = 1;
-                while (await e.MoveNextAsync(cancellationToken)
-                              .ConfigureAwait(false))
+                while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false))
                 {
                     sum += e.Current;
                     ++count;
@@ -330,16 +312,14 @@ namespace System.Linq
 
             try
             {
-                while (await e.MoveNextAsync(cancellationToken)
-                              .ConfigureAwait(false))
+                while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false))
                 {
                     var v = e.Current;
                     if (v.HasValue)
                     {
                         var sum = v.GetValueOrDefault();
                         long count = 1;
-                        while (await e.MoveNextAsync(cancellationToken)
-                                      .ConfigureAwait(false))
+                        while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false))
                         {
                             v = e.Current;
                             if (v.HasValue)

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

@@ -4,7 +4,6 @@
 
 using System.Collections.Generic;
 using System.Diagnostics;
-using System.Threading;
 using System.Threading.Tasks;
 
 namespace System.Linq
@@ -89,8 +88,7 @@ namespace System.Linq
                         {
                             if (!stopped)
                             {
-                                if (await enumerator.MoveNextAsync()
-                                                    .ConfigureAwait(false))
+                                if (await enumerator.MoveNextAsync().ConfigureAwait(false))
                                 {
                                     var item = enumerator.Current;
                                     if (index++ % skip == 0)
@@ -103,8 +101,7 @@ namespace System.Linq
                                         buffer.Add(item);
                                     }
 
-                                    if (buffers.Count > 0 && buffers.Peek()
-                                                                    .Count == count)
+                                    if (buffers.Count > 0 && buffers.Peek().Count == count)
                                     {
                                         current = buffers.Dequeue();
                                         return true;
@@ -136,4 +133,4 @@ namespace System.Linq
             }
         }
     }
-}
+}

+ 5 - 9
Ix.NET/Source/System.Interactive.Async/Cast.cs

@@ -1,11 +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. 
+// 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;
-using System.Linq;
-using System.Threading.Tasks;
 
 namespace System.Linq
 {
@@ -30,8 +27,7 @@ namespace System.Linq
             if (source == null)
                 throw new ArgumentNullException(nameof(source));
 
-            return source.Where(x => x is TType)
-                         .Cast<TType>();
+            return source.Where(x => x is TType).Cast<TType>();
         }
     }
-}
+}

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

@@ -46,7 +46,7 @@ namespace System.Linq
             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)
@@ -105,8 +105,7 @@ namespace System.Linq
                             {
                                 try
                                 {
-                                    if (await enumerator.MoveNextAsync()
-                                                        .ConfigureAwait(false))
+                                    if (await enumerator.MoveNextAsync().ConfigureAwait(false))
                                     {
                                         current = enumerator.Current;
                                         return true;
@@ -131,8 +130,7 @@ namespace System.Linq
                                 }
                             }
 
-                            if (await enumerator.MoveNextAsync()
-                                                .ConfigureAwait(false))
+                            if (await enumerator.MoveNextAsync().ConfigureAwait(false))
                             {
                                 current = enumerator.Current;
                                 return true;
@@ -217,8 +215,7 @@ namespace System.Linq
 
                             try
                             {
-                                if (await enumerator.MoveNextAsync()
-                                                    .ConfigureAwait(false))
+                                if (await enumerator.MoveNextAsync().ConfigureAwait(false))
                                 {
                                     current = enumerator.Current;
                                     return true;
@@ -244,4 +241,4 @@ namespace System.Linq
             }
         }
     }
-}
+}

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

@@ -83,8 +83,8 @@ namespace System.Linq
             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()
             {
@@ -117,8 +117,7 @@ namespace System.Linq
 
                                 break;
                             case State_While:
-                                if (await currentEnumerator.MoveNextAsync()
-                                                           .ConfigureAwait(false))
+                                if (await currentEnumerator.MoveNextAsync().ConfigureAwait(false))
                                 {
                                     current = currentEnumerator.Current;
                                     return true;
@@ -200,8 +199,7 @@ namespace System.Linq
 
                     try
                     {
-                        while (await e.MoveNextAsync(cancellationToken)
-                                      .ConfigureAwait(false))
+                        while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false))
                         {
                             list.Add(e.Current);
                         }
@@ -255,8 +253,7 @@ namespace System.Linq
             {
                 if (state == AsyncIteratorState.Allocated)
                 {
-                    enumerator = GetAsyncEnumerable(0)
-                        .GetAsyncEnumerator();
+                    enumerator = GetAsyncEnumerable(0).GetAsyncEnumerator();
                     state = AsyncIteratorState.Iterating;
                     counter = 2;
                 }
@@ -265,8 +262,7 @@ namespace System.Linq
                 {
                     while (true)
                     {
-                        if (await enumerator.MoveNextAsync()
-                                            .ConfigureAwait(false))
+                        if (await enumerator.MoveNextAsync().ConfigureAwait(false))
                         {
                             current = enumerator.Current;
                             return true;
@@ -367,4 +363,4 @@ namespace System.Linq
             }
         }
     }
-}
+}

+ 4 - 6
Ix.NET/Source/System.Interactive.Async/Contains.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. 
+// 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;
-using System.Linq;
 using System.Threading;
 using System.Threading.Tasks;
 
@@ -48,4 +46,4 @@ namespace System.Linq
             return source.Contains(value, EqualityComparer<TSource>.Default, cancellationToken);
         }
     }
-}
+}

+ 5 - 11
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;
 
@@ -37,8 +35,7 @@ namespace System.Linq
             if (predicate == null)
                 throw new ArgumentNullException(nameof(predicate));
 
-            return source.Where(predicate)
-                         .Aggregate(0, (c, _) => checked(c + 1), cancellationToken);
+            return source.Where(predicate).Aggregate(0, (c, _) => checked(c + 1), cancellationToken);
         }
 
         public static Task<int> Count<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate, CancellationToken cancellationToken)
@@ -48,8 +45,7 @@ namespace System.Linq
             if (predicate == null)
                 throw new ArgumentNullException(nameof(predicate));
 
-            return source.Where(predicate)
-                         .Aggregate(0, (c, _) => checked(c + 1), cancellationToken);
+            return source.Where(predicate).Aggregate(0, (c, _) => checked(c + 1), cancellationToken);
         }
 
         public static Task<int> Count<TSource>(this IAsyncEnumerable<TSource> source)
@@ -95,8 +91,7 @@ namespace System.Linq
             if (predicate == null)
                 throw new ArgumentNullException(nameof(predicate));
 
-            return source.Where(predicate)
-                         .Aggregate(0L, (c, _) => checked(c + 1), cancellationToken);
+            return source.Where(predicate).Aggregate(0L, (c, _) => checked(c + 1), cancellationToken);
         }
 
         public static Task<long> LongCount<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate, CancellationToken cancellationToken)
@@ -106,8 +101,7 @@ namespace System.Linq
             if (predicate == null)
                 throw new ArgumentNullException(nameof(predicate));
 
-            return source.Where(predicate)
-                         .Aggregate(0L, (c, _) => checked(c + 1), cancellationToken);
+            return source.Where(predicate).Aggregate(0L, (c, _) => checked(c + 1), cancellationToken);
         }
 
         public static Task<long> LongCount<TSource>(this IAsyncEnumerable<TSource> source)
@@ -138,4 +132,4 @@ namespace System.Linq
             return LongCount(source, predicate, CancellationToken.None);
         }
     }
-}
+}

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

@@ -4,7 +4,6 @@
 
 using System.Collections.Generic;
 using System.Diagnostics;
-using System.Threading;
 using System.Threading.Tasks;
 
 namespace System.Linq
@@ -36,22 +35,18 @@ namespace System.Linq
                 {
                     var tcs = new TaskCompletionSource<bool>();
 
-                    var stop = new Action(
-                        () =>
-                        {
-                            tcs.TrySetCanceled();
-                        });
+                    var stop = new Action(() => tcs.TrySetCanceled());
 
-                    return await moveNext(tcs)
-                                .ConfigureAwait(false);
+                    return await moveNext(tcs).ConfigureAwait(false);
                 },
                 current,
                 dispose
             );
+
             return self;
         }
 
-        private class AnonymousAsyncEnumerable<T> : IAsyncEnumerable<T>
+        private sealed class AnonymousAsyncEnumerable<T> : IAsyncEnumerable<T>
         {
             private readonly Func<IAsyncEnumerator<T>> getEnumerator;
 
@@ -62,10 +57,7 @@ namespace System.Linq
                 this.getEnumerator = getEnumerator;
             }
 
-            public IAsyncEnumerator<T> GetAsyncEnumerator()
-            {
-                return getEnumerator();
-            }
+            public IAsyncEnumerator<T> GetAsyncEnumerator() => getEnumerator();
         }
 
         private sealed class AnonymousAsyncIterator<T> : AsyncIterator<T>
@@ -74,7 +66,6 @@ namespace System.Linq
             private readonly Func<Task> dispose;
             private readonly Func<Task<bool>> moveNext;
 
-
             public AnonymousAsyncIterator(Func<Task<bool>> moveNext, Func<T> currentFunc, Func<Task> dispose)
             {
                 Debug.Assert(moveNext != null);
@@ -125,4 +116,4 @@ namespace System.Linq
             }
         }
     }
-}
+}

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

@@ -65,8 +65,7 @@ namespace System.Linq
                 {
                     case AsyncIteratorState.Allocated:
                         enumerator = source.GetAsyncEnumerator();
-                        if (await enumerator.MoveNextAsync()
-                                            .ConfigureAwait(false))
+                        if (await enumerator.MoveNextAsync().ConfigureAwait(false))
                         {
                             current = enumerator.Current;
                             state = AsyncIteratorState.Iterating;
@@ -77,13 +76,12 @@ namespace System.Linq
                             await enumerator.DisposeAsync().ConfigureAwait(false);
                             enumerator = null;
 
-                            state = AsyncIteratorState.Disposed; 
+                            state = AsyncIteratorState.Disposed;
                         }
                         return true;
 
                     case AsyncIteratorState.Iterating:
-                        if (await enumerator.MoveNextAsync()
-                                            .ConfigureAwait(false))
+                        if (await enumerator.MoveNextAsync().ConfigureAwait(false))
                         {
                             current = enumerator.Current;
                             return true;
@@ -129,4 +127,4 @@ namespace System.Linq
             }
         }
     }
-}
+}

+ 2 - 7
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
 {
@@ -16,9 +13,7 @@ namespace System.Linq
             if (factory == null)
                 throw new ArgumentNullException(nameof(factory));
 
-            return CreateEnumerable(
-                () => factory()
-                    .GetAsyncEnumerator());
+            return CreateEnumerable(() => factory().GetAsyncEnumerator());
         }
     }
-}
+}

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

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