1
0
Bart De Smet 8 жил өмнө
parent
commit
b313e4060f

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

@@ -64,8 +64,7 @@ namespace System.Linq
             if (selector == null)
                 throw new ArgumentNullException(nameof(selector));
 
-            return source.Select(selector)
-                         .Max(cancellationToken);
+            return source.Select(selector).Max(cancellationToken);
         }
 
         public static Task<TResult> Max<TSource, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TResult>> selector)
@@ -85,8 +84,7 @@ namespace System.Linq
             if (selector == null)
                 throw new ArgumentNullException(nameof(selector));
 
-            return source.Select(selector)
-                         .Max(cancellationToken);
+            return source.Select(selector).Max(cancellationToken);
         }
 
         public static Task<IList<TSource>> MaxBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector)
@@ -135,8 +133,7 @@ namespace System.Linq
 
         private static async Task<TSource> Max_<TSource>(IAsyncEnumerable<TSource> source, IComparer<TSource> comparer, CancellationToken cancellationToken)
         {
-            return (await MaxBy(source, x => x, comparer, cancellationToken)
-                        .ConfigureAwait(false)).First();
+            return (await MaxBy(source, x => x, comparer, cancellationToken).ConfigureAwait(false)).First();
         }
     }
-}
+}

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

@@ -64,8 +64,7 @@ namespace System.Linq
             if (selector == null)
                 throw new ArgumentNullException(nameof(selector));
 
-            return source.Select(selector)
-                         .Min(cancellationToken);
+            return source.Select(selector).Min(cancellationToken);
         }
 
         public static Task<TResult> Min<TSource, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<TResult>> selector)
@@ -85,8 +84,7 @@ namespace System.Linq
             if (selector == null)
                 throw new ArgumentNullException(nameof(selector));
 
-            return source.Select(selector)
-                         .Min(cancellationToken);
+            return source.Select(selector).Min(cancellationToken);
         }
 
         public static Task<IList<TSource>> MinBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector)
@@ -135,8 +133,7 @@ namespace System.Linq
 
         private static async Task<TSource> Min_<TSource>(IAsyncEnumerable<TSource> source, IComparer<TSource> comparer, CancellationToken cancellationToken)
         {
-            return (await MinBy(source, x => x, comparer, cancellationToken)
-                        .ConfigureAwait(false)).First();
+            return (await MinBy(source, x => x, comparer, cancellationToken).ConfigureAwait(false)).First();
         }
 
         private static async Task<IList<TSource>> ExtremaBy<TSource, TKey>(IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TKey, TKey, int> compare, CancellationToken cancellationToken)
@@ -147,16 +144,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 current = e.Current;
                 var resKey = keySelector(current);
                 result.Add(current);
 
-                while (await e.MoveNextAsync(cancellationToken)
-                              .ConfigureAwait(false))
+                while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false))
                 {
                     var cur = e.Current;
                     var key = keySelector(cur);
@@ -168,10 +163,7 @@ namespace System.Linq
                     }
                     else if (cmp > 0)
                     {
-                        result = new List<TSource>
-                        {
-                            cur
-                        };
+                        result = new List<TSource> { cur };
                         resKey = key;
                     }
                 }
@@ -184,4 +176,4 @@ namespace System.Linq
             return result;
         }
     }
-}
+}

+ 3 - 8
Ix.NET/Source/System.Interactive.Async/OnErrorResumeNext.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.Generic;
 using System.Diagnostics;
-using System.Linq;
-using System.Threading;
 using System.Threading.Tasks;
 
 namespace System.Linq
@@ -20,7 +17,7 @@ namespace System.Linq
             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)
@@ -105,8 +102,7 @@ namespace System.Linq
 
                             try
                             {
-                                if (await enumerator.MoveNextAsync()
-                                                    .ConfigureAwait(false))
+                                if (await enumerator.MoveNextAsync().ConfigureAwait(false))
                                 {
                                     current = enumerator.Current;
                                     return true;
@@ -123,7 +119,6 @@ namespace System.Linq
                         }
 
                         break; // case
-                        
                 }
 
                 await DisposeAsync().ConfigureAwait(false);
@@ -131,4 +126,4 @@ namespace System.Linq
             }
         }
     }
-}
+}

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

@@ -96,4 +96,4 @@ namespace System.Linq
             return source.CreateOrderedEnumerable(keySelector, comparer, true);
         }
     }
-}
+}

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

@@ -4,7 +4,6 @@
 
 using System.Collections.Generic;
 using System.Diagnostics;
-using System.Threading;
 using System.Threading.Tasks;
 
 namespace System.Linq
@@ -64,6 +63,7 @@ namespace System.Linq
                 await parentEnumerator.DisposeAsync().ConfigureAwait(false);
                 parentEnumerator = null;
             }
+
             await base.DisposeAsync().ConfigureAwait(false);
         }
 
@@ -73,8 +73,7 @@ namespace System.Linq
             {
                 case AsyncEnumerable.AsyncIteratorState.Allocated:
 
-                    await Initialize()
-                        .ConfigureAwait(false);
+                    await Initialize().ConfigureAwait(false);
 
                     enumerator = enumerable.GetEnumerator();
                     state = AsyncEnumerable.AsyncIteratorState.Iterating;
@@ -98,17 +97,15 @@ namespace System.Linq
         {
             if (parent == null)
             {
-                var buffer = await source.ToList()
-                                         .ConfigureAwait(false);
+                var buffer = await source.ToList().ConfigureAwait(false);
                 enumerable = (!@descending ? buffer.OrderBy(keySelector, comparer) : buffer.OrderByDescending(keySelector, comparer));
             }
             else
             {
                 parentEnumerator = parent.GetAsyncEnumerator();
-                await parent.Initialize()
-                            .ConfigureAwait(false);
+                await parent.Initialize().ConfigureAwait(false);
                 enumerable = parent.enumerable.CreateOrderedEnumerable(keySelector, comparer, @descending);
             }
         }
     }
-}
+}

+ 2 - 6
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
 {
@@ -16,8 +13,7 @@ namespace System.Linq
             if (count < 0)
                 throw new ArgumentOutOfRangeException(nameof(count));
 
-            return Enumerable.Range(start, count)
-                             .ToAsyncEnumerable();
+            return Enumerable.Range(start, count).ToAsyncEnumerable();
         }
     }
-}
+}

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

@@ -4,7 +4,6 @@
 
 using System.Collections.Generic;
 using System.Diagnostics;
-using System.Threading;
 using System.Threading.Tasks;
 
 namespace System.Linq
@@ -16,8 +15,7 @@ namespace System.Linq
             if (count < 0)
                 throw new ArgumentOutOfRangeException(nameof(count));
 
-            return Enumerable.Repeat(element, count)
-                             .ToAsyncEnumerable();
+            return Enumerable.Repeat(element, count).ToAsyncEnumerable();
         }
 
         public static IAsyncEnumerable<TResult> Repeat<TResult>(TResult element)
@@ -116,18 +114,17 @@ namespace System.Linq
 
                         enumerator = source.GetAsyncEnumerator();
                         state = AsyncIteratorState.Iterating;
+
                         goto case AsyncIteratorState.Iterating;
 
                     case AsyncIteratorState.Iterating:
-                        if (await enumerator.MoveNextAsync()
-                                            .ConfigureAwait(false))
+                        if (await enumerator.MoveNextAsync().ConfigureAwait(false))
                         {
                             current = enumerator.Current;
                             return true;
                         }
 
                         goto case AsyncIteratorState.Allocated;
-
                 }
 
                 await DisposeAsync().ConfigureAwait(false);
@@ -136,4 +133,4 @@ namespace System.Linq
             }
         }
     }
-}
+}

+ 3 - 8
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
 {
@@ -16,8 +13,7 @@ namespace System.Linq
             if (source == null)
                 throw new ArgumentNullException(nameof(source));
 
-            return new[] {source}.Repeat()
-                                 .Catch();
+            return new[] { source }.Repeat().Catch();
         }
 
         public static IAsyncEnumerable<TSource> Retry<TSource>(this IAsyncEnumerable<TSource> source, int retryCount)
@@ -27,8 +23,7 @@ namespace System.Linq
             if (retryCount < 0)
                 throw new ArgumentOutOfRangeException(nameof(retryCount));
 
-            return new[] {source}.Repeat(retryCount)
-                                 .Catch();
+            return new[] { source }.Repeat(retryCount).Catch();
         }
 
         private static IEnumerable<TSource> Repeat<TSource>(this IEnumerable<TSource> source)
@@ -45,4 +40,4 @@ namespace System.Linq
                     yield return item;
         }
     }
-}
+}

+ 4 - 8
Ix.NET/Source/System.Interactive.Async/Reverse.cs

@@ -36,8 +36,7 @@ namespace System.Linq
 
             public async Task<TSource[]> ToArrayAsync(CancellationToken cancellationToken)
             {
-                var array = await source.ToArray(cancellationToken)
-                                        .ConfigureAwait(false);
+                var array = await source.ToArray(cancellationToken).ConfigureAwait(false);
 
                 // Array.Reverse() involves boxing for non-primitive value types, but
                 // checking that has its own cost, so just use this approach for all types.
@@ -53,8 +52,7 @@ namespace System.Linq
 
             public async Task<List<TSource>> ToListAsync(CancellationToken cancellationToken)
             {
-                var list = await source.ToList(cancellationToken)
-                                       .ConfigureAwait(false);
+                var list = await source.ToList(cancellationToken).ConfigureAwait(false);
 
                 list.Reverse();
                 return list;
@@ -89,14 +87,12 @@ namespace System.Linq
                 await base.DisposeAsync().ConfigureAwait(false);
             }
 
-
             protected override async Task<bool> MoveNextCore()
             {
                 switch (state)
                 {
                     case AsyncIteratorState.Allocated:
-                        items = await source.ToArray()
-                                            .ConfigureAwait(false);
+                        items = await source.ToArray().ConfigureAwait(false);
                         index = items.Length - 1;
 
                         state = AsyncIteratorState.Iterating;
@@ -118,4 +114,4 @@ namespace System.Linq
             }
         }
     }
-}
+}

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

@@ -4,7 +4,6 @@
 
 using System.Collections.Generic;
 using System.Diagnostics;
-using System.Threading;
 using System.Threading.Tasks;
 
 namespace System.Linq
@@ -147,8 +146,7 @@ namespace System.Linq
 
                     case AsyncIteratorState.Iterating:
 
-                        while (await enumerator.MoveNextAsync()
-                                               .ConfigureAwait(false))
+                        while (await enumerator.MoveNextAsync().ConfigureAwait(false))
                         {
                             var item = enumerator.Current;
                             if (!hasSeed)
@@ -172,4 +170,4 @@ namespace System.Linq
             }
         }
     }
-}
+}

+ 4 - 8
Ix.NET/Source/System.Interactive.Async/Select.cs

@@ -127,8 +127,7 @@ namespace System.Linq
                         goto case AsyncIteratorState.Iterating;
 
                     case AsyncIteratorState.Iterating:
-                        if (await enumerator.MoveNextAsync()
-                                            .ConfigureAwait(false))
+                        if (await enumerator.MoveNextAsync().ConfigureAwait(false))
                         {
                             current = selector(enumerator.Current);
                             return true;
@@ -185,8 +184,7 @@ namespace System.Linq
                         goto case AsyncIteratorState.Iterating;
 
                     case AsyncIteratorState.Iterating:
-                        if (await enumerator.MoveNextAsync()
-                                            .ConfigureAwait(false))
+                        if (await enumerator.MoveNextAsync().ConfigureAwait(false))
                         {
                             checked
                             {
@@ -311,8 +309,7 @@ namespace System.Linq
                         goto case AsyncIteratorState.Iterating;
 
                     case AsyncIteratorState.Iterating:
-                        if (await enumerator.MoveNextAsync()
-                                            .ConfigureAwait(false))
+                        if (await enumerator.MoveNextAsync().ConfigureAwait(false))
                         {
                             current = await selector(enumerator.Current).ConfigureAwait(false);
                             return true;
@@ -369,8 +366,7 @@ namespace System.Linq
                         goto case AsyncIteratorState.Iterating;
 
                     case AsyncIteratorState.Iterating:
-                        if (await enumerator.MoveNextAsync()
-                                            .ConfigureAwait(false))
+                        if (await enumerator.MoveNextAsync().ConfigureAwait(false))
                         {
                             checked
                             {

+ 10 - 20
Ix.NET/Source/System.Interactive.Async/SelectMany.cs

@@ -4,7 +4,6 @@
 
 using System.Collections.Generic;
 using System.Diagnostics;
-using System.Threading;
 using System.Threading.Tasks;
 
 namespace System.Linq
@@ -123,8 +122,7 @@ namespace System.Linq
                         switch (mode)
                         {
                             case State_Source:
-                                if (await sourceEnumerator.MoveNextAsync()
-                                                          .ConfigureAwait(false))
+                                if (await sourceEnumerator.MoveNextAsync().ConfigureAwait(false))
                                 {
                                     if (resultEnumerator != null)
                                     {
@@ -140,8 +138,7 @@ namespace System.Linq
                                 break;
 
                             case State_Result:
-                                if (await resultEnumerator.MoveNextAsync()
-                                                          .ConfigureAwait(false))
+                                if (await resultEnumerator.MoveNextAsync().ConfigureAwait(false))
                                 {
                                     current = resultEnumerator.Current;
                                     return true;
@@ -222,8 +219,7 @@ namespace System.Linq
                         switch (mode)
                         {
                             case State_Source:
-                                if (await sourceEnumerator.MoveNextAsync()
-                                                          .ConfigureAwait(false))
+                                if (await sourceEnumerator.MoveNextAsync().ConfigureAwait(false))
                                 {
                                     if (resultEnumerator != null)
                                     {
@@ -240,8 +236,7 @@ namespace System.Linq
                                 break;
 
                             case State_Result:
-                                if (await resultEnumerator.MoveNextAsync()
-                                                          .ConfigureAwait(false))
+                                if (await resultEnumerator.MoveNextAsync().ConfigureAwait(false))
                                 {
                                     current = resultSelector(currentSource, resultEnumerator.Current);
                                     return true;
@@ -324,8 +319,7 @@ namespace System.Linq
                         switch (mode)
                         {
                             case State_Source:
-                                if (await sourceEnumerator.MoveNextAsync()
-                                                          .ConfigureAwait(false))
+                                if (await sourceEnumerator.MoveNextAsync().ConfigureAwait(false))
                                 {
                                     if (resultEnumerator != null)
                                     {
@@ -339,8 +333,7 @@ namespace System.Linq
                                         index++;
                                     }
 
-                                    resultEnumerator = collectionSelector(currentSource, index)
-                                        .GetAsyncEnumerator();
+                                    resultEnumerator = collectionSelector(currentSource, index).GetAsyncEnumerator();
 
                                     mode = State_Result;
                                     goto case State_Result;
@@ -348,8 +341,7 @@ namespace System.Linq
                                 break;
 
                             case State_Result:
-                                if (await resultEnumerator.MoveNextAsync()
-                                                          .ConfigureAwait(false))
+                                if (await resultEnumerator.MoveNextAsync().ConfigureAwait(false))
                                 {
                                     current = resultSelector(currentSource, resultEnumerator.Current);
                                     return true;
@@ -426,8 +418,7 @@ namespace System.Linq
                         switch (mode)
                         {
                             case State_Source:
-                                if (await sourceEnumerator.MoveNextAsync()
-                                                          .ConfigureAwait(false))
+                                if (await sourceEnumerator.MoveNextAsync().ConfigureAwait(false))
                                 {
                                     if (resultEnumerator != null)
                                     {
@@ -447,8 +438,7 @@ namespace System.Linq
                                 break;
 
                             case State_Result:
-                                if (await resultEnumerator.MoveNextAsync()
-                                                          .ConfigureAwait(false))
+                                if (await resultEnumerator.MoveNextAsync().ConfigureAwait(false))
                                 {
                                     current = resultEnumerator.Current;
                                     return true;
@@ -466,4 +456,4 @@ namespace System.Linq
             }
         }
     }
-}
+}

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

@@ -55,8 +55,7 @@ namespace System.Linq
             return first.SequenceEqual(second, EqualityComparer<TSource>.Default, cancellationToken);
         }
 
-        private static async Task<bool> SequenceEqual_<TSource>(IAsyncEnumerable<TSource> first, IAsyncEnumerable<TSource> second, IEqualityComparer<TSource> comparer,
-                                                                CancellationToken cancellationToken)
+        private static async Task<bool> SequenceEqual_<TSource>(IAsyncEnumerable<TSource> first, IAsyncEnumerable<TSource> second, IEqualityComparer<TSource> comparer, CancellationToken cancellationToken)
         {
             if (first is ICollection<TSource> firstCol && second is ICollection<TSource> secondCol && firstCol.Count != secondCol.Count)
             {
@@ -92,4 +91,4 @@ namespace System.Linq
             }
         }
     }
-}
+}

+ 1 - 4
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
@@ -152,4 +149,4 @@ namespace System.Linq
             internal TElement _value;
         }
     }
-}
+}

+ 13 - 17
Ix.NET/Source/System.Interactive.Async/Single.cs

@@ -53,8 +53,7 @@ namespace System.Linq
             if (predicate == null)
                 throw new ArgumentNullException(nameof(predicate));
 
-            return source.Where(predicate)
-                         .Single(cancellationToken);
+            return source.Where(predicate).Single(cancellationToken);
         }
 
         public static Task<TSource> Single<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate, CancellationToken cancellationToken)
@@ -64,8 +63,7 @@ namespace System.Linq
             if (predicate == null)
                 throw new ArgumentNullException(nameof(predicate));
 
-            return source.Where(predicate)
-                         .Single(cancellationToken);
+            return source.Where(predicate).Single(cancellationToken);
         }
 
         public static Task<TSource> SingleOrDefault<TSource>(this IAsyncEnumerable<TSource> source)
@@ -111,8 +109,7 @@ namespace System.Linq
             if (predicate == null)
                 throw new ArgumentNullException(nameof(predicate));
 
-            return source.Where(predicate)
-                         .SingleOrDefault(cancellationToken);
+            return source.Where(predicate).SingleOrDefault(cancellationToken);
         }
 
         public static Task<TSource> SingleOrDefault<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, Task<bool>> predicate, CancellationToken cancellationToken)
@@ -122,8 +119,7 @@ namespace System.Linq
             if (predicate == null)
                 throw new ArgumentNullException(nameof(predicate));
 
-            return source.Where(predicate)
-                         .SingleOrDefault(cancellationToken);
+            return source.Where(predicate).SingleOrDefault(cancellationToken);
         }
 
         private static async Task<TSource> Single_<TSource>(IAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
@@ -135,6 +131,7 @@ namespace System.Linq
                     case 0: throw new InvalidOperationException(Strings.NO_ELEMENTS);
                     case 1: return list[0];
                 }
+
                 throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT);
             }
 
@@ -142,17 +139,17 @@ 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 result = e.Current;
-                if (await e.MoveNextAsync(cancellationToken)
-                           .ConfigureAwait(false))
+                if (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false))
                 {
                     throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT);
                 }
+
                 return result;
             }
             finally
@@ -170,6 +167,7 @@ namespace System.Linq
                     case 0: return default(TSource);
                     case 1: return list[0];
                 }
+
                 throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT);
             }
 
@@ -177,15 +175,13 @@ namespace System.Linq
 
             try
             {
-                if (!await e.MoveNextAsync(cancellationToken)
-                            .ConfigureAwait(false))
+                if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false))
                 {
                     return default(TSource);
                 }
 
                 var result = e.Current;
-                if (!await e.MoveNextAsync(cancellationToken)
-                            .ConfigureAwait(false))
+                if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false))
                 {
                     return result;
                 }
@@ -198,4 +194,4 @@ namespace System.Linq
             throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT);
         }
     }
-}
+}

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

@@ -123,7 +123,6 @@ namespace System.Linq
                 await base.DisposeAsync().ConfigureAwait(false);
             }
 
-
             protected override async Task<bool> MoveNextCore()
             {
                 switch (state)
@@ -132,21 +131,21 @@ namespace System.Linq
                         enumerator = source.GetAsyncEnumerator();
 
                         // skip elements as requested
-                        while (currentCount > 0 && await enumerator.MoveNextAsync()
-                                                                   .ConfigureAwait(false))
+                        while (currentCount > 0 && await enumerator.MoveNextAsync().ConfigureAwait(false))
                         {
                             currentCount--;
                         }
+
                         if (currentCount <= 0)
                         {
                             state = AsyncIteratorState.Iterating;
                             goto case AsyncIteratorState.Iterating;
                         }
+
                         break;
 
                     case AsyncIteratorState.Iterating:
-                        if (await enumerator.MoveNextAsync()
-                                            .ConfigureAwait(false))
+                        if (await enumerator.MoveNextAsync().ConfigureAwait(false))
                         {
                             current = enumerator.Current;
                             return true;
@@ -188,6 +187,7 @@ namespace System.Linq
                     await enumerator.DisposeAsync().ConfigureAwait(false);
                     enumerator = null;
                 }
+
                 queue = null; // release the memory
 
                 await base.DisposeAsync().ConfigureAwait(false);
@@ -207,11 +207,11 @@ namespace System.Linq
 
 
                     case AsyncIteratorState.Iterating:
-                        while (await enumerator.MoveNextAsync()
-                                            .ConfigureAwait(false))
+                        while (await enumerator.MoveNextAsync().ConfigureAwait(false))
                         {
                             var item = enumerator.Current;
                             queue.Enqueue(item);
+
                             if (queue.Count > count)
                             {
                                 current = queue.Dequeue();
@@ -268,8 +268,7 @@ namespace System.Linq
                         enumerator = source.GetAsyncEnumerator();
 
                         // skip elements as requested
-                        while (await enumerator.MoveNextAsync()
-                                               .ConfigureAwait(false))
+                        while (await enumerator.MoveNextAsync().ConfigureAwait(false))
                         {
                             var element = enumerator.Current;
                             if (!predicate(element))
@@ -279,15 +278,16 @@ namespace System.Linq
                                 goto case AsyncIteratorState.Iterating;
                             }
                         }
+
                         break;
 
                     case AsyncIteratorState.Iterating:
-                        if (doMoveNext && await enumerator.MoveNextAsync()
-                                                          .ConfigureAwait(false))
+                        if (doMoveNext && await enumerator.MoveNextAsync().ConfigureAwait(false))
                         {
                             current = enumerator.Current;
                             return true;
                         }
+
                         if (!doMoveNext)
                         {
                             current = enumerator.Current;
@@ -346,8 +346,7 @@ namespace System.Linq
                         index = -1;
 
                         // skip elements as requested
-                        while (await enumerator.MoveNextAsync()
-                                               .ConfigureAwait(false))
+                        while (await enumerator.MoveNextAsync().ConfigureAwait(false))
                         {
                             checked
                             {
@@ -362,15 +361,16 @@ namespace System.Linq
                                 goto case AsyncIteratorState.Iterating;
                             }
                         }
+
                         break;
 
                     case AsyncIteratorState.Iterating:
-                        if (doMoveNext && await enumerator.MoveNextAsync()
-                                                          .ConfigureAwait(false))
+                        if (doMoveNext && await enumerator.MoveNextAsync().ConfigureAwait(false))
                         {
                             current = enumerator.Current;
                             return true;
                         }
+
                         if (!doMoveNext)
                         {
                             current = enumerator.Current;
@@ -427,8 +427,7 @@ namespace System.Linq
                         enumerator = source.GetAsyncEnumerator();
 
                         // skip elements as requested
-                        while (await enumerator.MoveNextAsync()
-                                               .ConfigureAwait(false))
+                        while (await enumerator.MoveNextAsync().ConfigureAwait(false))
                         {
                             var element = enumerator.Current;
                             if (!await predicate(element).ConfigureAwait(false))
@@ -438,15 +437,16 @@ namespace System.Linq
                                 goto case AsyncIteratorState.Iterating;
                             }
                         }
+
                         break;
 
                     case AsyncIteratorState.Iterating:
-                        if (doMoveNext && await enumerator.MoveNextAsync()
-                                                          .ConfigureAwait(false))
+                        if (doMoveNext && await enumerator.MoveNextAsync().ConfigureAwait(false))
                         {
                             current = enumerator.Current;
                             return true;
                         }
+
                         if (!doMoveNext)
                         {
                             current = enumerator.Current;
@@ -505,8 +505,7 @@ namespace System.Linq
                         index = -1;
 
                         // skip elements as requested
-                        while (await enumerator.MoveNextAsync()
-                                               .ConfigureAwait(false))
+                        while (await enumerator.MoveNextAsync().ConfigureAwait(false))
                         {
                             checked
                             {
@@ -521,15 +520,16 @@ namespace System.Linq
                                 goto case AsyncIteratorState.Iterating;
                             }
                         }
+
                         break;
 
                     case AsyncIteratorState.Iterating:
-                        if (doMoveNext && await enumerator.MoveNextAsync()
-                                                          .ConfigureAwait(false))
+                        if (doMoveNext && await enumerator.MoveNextAsync().ConfigureAwait(false))
                         {
                             current = enumerator.Current;
                             return true;
                         }
+
                         if (!doMoveNext)
                         {
                             current = enumerator.Current;
@@ -545,4 +545,4 @@ namespace System.Linq
             }
         }
     }
-}
+}

+ 2 - 6
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
 {
@@ -16,8 +13,7 @@ namespace System.Linq
             if (source == null)
                 throw new ArgumentNullException(nameof(source));
 
-            return values.ToAsyncEnumerable()
-                         .Concat(source);
+            return values.ToAsyncEnumerable().Concat(source);
         }
     }
-}
+}

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

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

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

@@ -121,8 +121,7 @@ namespace System.Linq
                         goto case AsyncIteratorState.Iterating;
 
                     case AsyncIteratorState.Iterating:
-                        if (currentCount > 0 && await enumerator.MoveNextAsync()
-                                                                .ConfigureAwait(false))
+                        if (currentCount > 0 && await enumerator.MoveNextAsync().ConfigureAwait(false))
                         {
                             current = enumerator.Current;
                             currentCount--;
@@ -166,12 +165,12 @@ namespace System.Linq
                     await enumerator.DisposeAsync().ConfigureAwait(false);
                     enumerator = null;
                 }
+
                 queue = null; // release the memory
 
                 await base.DisposeAsync().ConfigureAwait(false);
             }
 
-
             protected override async Task<bool> MoveNextCore()
             {
                 switch (state)
@@ -190,8 +189,7 @@ namespace System.Linq
                         {
                             if (!isDone)
                             {
-                                if (await enumerator.MoveNextAsync()
-                                                    .ConfigureAwait(false))
+                                if (await enumerator.MoveNextAsync().ConfigureAwait(false))
                                 {
                                     if (count > 0)
                                     {
@@ -275,14 +273,14 @@ namespace System.Linq
 
 
                     case AsyncIteratorState.Iterating:
-                        if (await enumerator.MoveNextAsync()
-                                            .ConfigureAwait(false))
+                        if (await enumerator.MoveNextAsync().ConfigureAwait(false))
                         {
                             var item = enumerator.Current;
                             if (!predicate(item))
                             {
                                 break;
                             }
+
                             current = item;
                             return true;
                         }
@@ -340,8 +338,7 @@ namespace System.Linq
 
 
                     case AsyncIteratorState.Iterating:
-                        if (await enumerator.MoveNextAsync()
-                                            .ConfigureAwait(false))
+                        if (await enumerator.MoveNextAsync().ConfigureAwait(false))
                         {
                             var item = enumerator.Current;
                             checked
@@ -353,6 +350,7 @@ namespace System.Linq
                             {
                                 break;
                             }
+
                             current = item;
                             return true;
                         }
@@ -409,14 +407,14 @@ namespace System.Linq
 
 
                     case AsyncIteratorState.Iterating:
-                        if (await enumerator.MoveNextAsync()
-                                            .ConfigureAwait(false))
+                        if (await enumerator.MoveNextAsync().ConfigureAwait(false))
                         {
                             var item = enumerator.Current;
                             if (!await predicate(item).ConfigureAwait(false))
                             {
                                 break;
                             }
+
                             current = item;
                             return true;
                         }
@@ -474,8 +472,7 @@ namespace System.Linq
 
 
                     case AsyncIteratorState.Iterating:
-                        if (await enumerator.MoveNextAsync()
-                                            .ConfigureAwait(false))
+                        if (await enumerator.MoveNextAsync().ConfigureAwait(false))
                         {
                             var item = enumerator.Current;
                             checked
@@ -487,6 +484,7 @@ namespace System.Linq
                             {
                                 break;
                             }
+
                             current = item;
                             return true;
                         }
@@ -499,4 +497,4 @@ namespace System.Linq
             }
         }
     }
-}
+}

+ 0 - 1
Ix.NET/Source/System.Interactive.Async/TaskExt.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.Collections.Generic;
 
 namespace System.Threading.Tasks
 {

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

@@ -69,10 +69,11 @@ namespace System.Linq
             {
                 while (true)
                 {
-                    if (!e.MoveNextAsync()
-                          .Result)
+                    if (!e.MoveNextAsync().Result)
                         break;
+
                     var c = e.Current;
+
                     yield return c;
                 }
             }
@@ -279,6 +280,7 @@ namespace System.Linq
                     enumerator.Dispose();
                     enumerator = null;
                 }
+
                 await base.DisposeAsync().ConfigureAwait(false);
             }
 
@@ -290,15 +292,18 @@ namespace System.Linq
                         enumerator = source.GetEnumerator();
                         state = AsyncIteratorState.Iterating;
                         goto case AsyncIteratorState.Iterating;
+
                     case AsyncIteratorState.Iterating:
                         if (enumerator.MoveNext())
                         {
                             current = enumerator.Current;
                             return true;
                         }
+
                         await DisposeAsync().ConfigureAwait(false);
                         break;
                 }
+
                 return false;
             }
 

+ 19 - 13
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;
 
@@ -90,11 +88,15 @@ namespace System.Linq
             if (comparer == null)
                 throw new ArgumentNullException(nameof(comparer));
 
-            return source.Aggregate(new Dictionary<TKey, TElement>(comparer), (d, x) =>
-                                                                              {
-                                                                                  d.Add(keySelector(x), elementSelector(x));
-                                                                                  return d;
-                                                                              }, cancellationToken);
+            return source.Aggregate(
+                new Dictionary<TKey, TElement>(comparer),
+                (d, x) =>
+                {
+                    d.Add(keySelector(x), elementSelector(x));
+                    return d;
+                },
+                cancellationToken
+            );
         }
 
         public static Task<Dictionary<TKey, TElement>> ToDictionary<TSource, TKey, TElement>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, CancellationToken cancellationToken)
@@ -147,11 +149,15 @@ namespace System.Linq
             if (source is IIListProvider<TSource> listProvider)
                 return listProvider.ToListAsync(cancellationToken);
 
-            return source.Aggregate(new List<TSource>(), (list, x) =>
-                                                         {
-                                                             list.Add(x);
-                                                             return list;
-                                                         }, cancellationToken);
+            return source.Aggregate(
+                new List<TSource>(),
+                (list, x) =>
+                {
+                    list.Add(x);
+                    return list;
+                },
+                cancellationToken
+            );
         }
     }
-}
+}