Bart De Smet преди 8 години
родител
ревизия
ae718bad3d

+ 1 - 0
Ix.NET/Source/System.Interactive.Async/Disposables.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. 
+
 using System.Threading;
 
 namespace System.Linq

+ 21 - 30
Ix.NET/Source/System.Interactive.Async/Distinct.cs

@@ -118,15 +118,13 @@ namespace System.Linq
 
             public async Task<TSource[]> ToArrayAsync(CancellationToken cancellationToken)
             {
-                var s = await FillSet(cancellationToken)
-                            .ConfigureAwait(false);
+                var s = await FillSetAsync(cancellationToken).ConfigureAwait(false);
                 return s.ToArray();
             }
 
             public async Task<List<TSource>> ToListAsync(CancellationToken cancellationToken)
             {
-                var s = await FillSet(cancellationToken)
-                            .ConfigureAwait(false);
+                var s = await FillSetAsync(cancellationToken).ConfigureAwait(false);
                 return s;
             }
 
@@ -144,8 +142,7 @@ namespace System.Linq
 
                 try
                 {
-                    while (await enu.MoveNextAsync()
-                                    .ConfigureAwait(false))
+                    while (await enu.MoveNextAsync().ConfigureAwait(false))
                     {
                         var item = enu.Current;
                         if (s.Add(keySelector(item)))
@@ -185,8 +182,8 @@ namespace System.Linq
                 {
                     case AsyncIteratorState.Allocated:
                         enumerator = source.GetAsyncEnumerator();
-                        if (!await enumerator.MoveNextAsync()
-                                             .ConfigureAwait(false))
+
+                        if (!await enumerator.MoveNextAsync().ConfigureAwait(false))
                         {
                             await DisposeAsync().ConfigureAwait(false);
                             return false;
@@ -196,12 +193,12 @@ namespace System.Linq
                         set = new Set<TKey>(comparer);
                         set.Add(keySelector(element));
                         current = element;
+
                         state = AsyncIteratorState.Iterating;
                         return true;
 
                     case AsyncIteratorState.Iterating:
-                        while (await enumerator.MoveNextAsync()
-                                               .ConfigureAwait(false))
+                        while (await enumerator.MoveNextAsync().ConfigureAwait(false))
                         {
                             element = enumerator.Current;
                             if (set.Add(keySelector(element)))
@@ -218,7 +215,7 @@ namespace System.Linq
                 return false;
             }
 
-            private async Task<List<TSource>> FillSet(CancellationToken cancellationToken)
+            private async Task<List<TSource>> FillSetAsync(CancellationToken cancellationToken)
             {
                 var s = new Set<TKey>(comparer);
                 var r = new List<TSource>();
@@ -227,8 +224,7 @@ namespace System.Linq
 
                 try
                 {
-                    while (await enu.MoveNextAsync(cancellationToken)
-                                    .ConfigureAwait(false))
+                    while (await enu.MoveNextAsync(cancellationToken).ConfigureAwait(false))
                     {
                         var item = enu.Current;
                         if (s.Add(keySelector(item)))
@@ -264,22 +260,20 @@ namespace System.Linq
 
             public async Task<TSource[]> ToArrayAsync(CancellationToken cancellationToken)
             {
-                var s = await FillSet(cancellationToken)
-                            .ConfigureAwait(false);
+                var s = await FillSetAsync(cancellationToken).ConfigureAwait(false);
                 return s.ToArray();
             }
 
             public async Task<List<TSource>> ToListAsync(CancellationToken cancellationToken)
             {
-                var s = await FillSet(cancellationToken)
+                var s = await FillSetAsync(cancellationToken)
                             .ConfigureAwait(false);
                 return s.ToList();
             }
 
             public async Task<int> GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken)
             {
-                return onlyIfCheap ? -1 : (await FillSet(cancellationToken)
-                                               .ConfigureAwait(false)).Count;
+                return onlyIfCheap ? -1 : (await FillSetAsync(cancellationToken).ConfigureAwait(false)).Count;
             }
 
             public override AsyncIterator<TSource> Clone()
@@ -305,8 +299,7 @@ namespace System.Linq
                 {
                     case AsyncIteratorState.Allocated:
                         enumerator = source.GetAsyncEnumerator();
-                        if (!await enumerator.MoveNextAsync()
-                                             .ConfigureAwait(false))
+                        if (!await enumerator.MoveNextAsync().ConfigureAwait(false))
                         {
                             await DisposeAsync().ConfigureAwait(false);
                             return false;
@@ -316,12 +309,12 @@ namespace System.Linq
                         set = new Set<TSource>(comparer);
                         set.Add(element);
                         current = element;
+
                         state = AsyncIteratorState.Iterating;
                         return true;
 
                     case AsyncIteratorState.Iterating:
-                        while (await enumerator.MoveNextAsync()
-                                               .ConfigureAwait(false))
+                        while (await enumerator.MoveNextAsync().ConfigureAwait(false))
                         {
                             element = enumerator.Current;
                             if (set.Add(element))
@@ -338,7 +331,7 @@ namespace System.Linq
                 return false;
             }
 
-            private async Task<Set<TSource>> FillSet(CancellationToken cancellationToken)
+            private async Task<Set<TSource>> FillSetAsync(CancellationToken cancellationToken)
             {
                 var s = new Set<TSource>(comparer);
 
@@ -346,8 +339,7 @@ namespace System.Linq
 
                 try
                 {
-                    while (await enu.MoveNextAsync(cancellationToken)
-                                    .ConfigureAwait(false))
+                    while (await enu.MoveNextAsync(cancellationToken).ConfigureAwait(false))
                     {
                         s.Add(enu.Current);
                     }
@@ -406,8 +398,7 @@ namespace System.Linq
                         goto case AsyncIteratorState.Iterating;
 
                     case AsyncIteratorState.Iterating:
-                        while (await enumerator.MoveNextAsync()
-                                            .ConfigureAwait(false))
+                        while (await enumerator.MoveNextAsync().ConfigureAwait(false))
                         {
                             var item = enumerator.Current;
                             var comparerEquals = false;
@@ -416,6 +407,7 @@ namespace System.Linq
                             {
                                 comparerEquals = comparer.Equals(currentValue, item);
                             }
+
                             if (!hasCurrentValue || !comparerEquals)
                             {
                                 hasCurrentValue = true;
@@ -477,8 +469,7 @@ namespace System.Linq
                         goto case AsyncIteratorState.Iterating;
 
                     case AsyncIteratorState.Iterating:
-                        while (await enumerator.MoveNextAsync()
-                                               .ConfigureAwait(false))
+                        while (await enumerator.MoveNextAsync().ConfigureAwait(false))
                         {
                             var item = enumerator.Current;
                             var key = keySelector(item);
@@ -505,4 +496,4 @@ namespace System.Linq
             }
         }
     }
-}
+}

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

@@ -4,7 +4,6 @@
 
 using System.Collections.Generic;
 using System.Diagnostics;
-using System.Threading;
 using System.Threading.Tasks;
 
 namespace System.Linq
@@ -122,8 +121,7 @@ namespace System.Linq
                     case AsyncIteratorState.Iterating:
                         try
                         {
-                            if (await enumerator.MoveNextAsync()
-                                                .ConfigureAwait(false))
+                            if (await enumerator.MoveNextAsync().ConfigureAwait(false))
                             {
                                 current = enumerator.Current;
                                 onNext(current);
@@ -151,4 +149,4 @@ namespace System.Linq
             }
         }
     }
-}
+}

+ 3 - 8
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;
 
@@ -22,7 +20,6 @@ namespace System.Linq
             return ElementAt_(source, index, cancellationToken);
         }
 
-
         public static Task<TSource> ElementAt<TSource>(this IAsyncEnumerable<TSource> source, int index)
         {
             if (source == null)
@@ -62,8 +59,7 @@ namespace System.Linq
 
                 try
                 {
-                    while (await e.MoveNextAsync(cancellationToken)
-                                  .ConfigureAwait(false))
+                    while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false))
                     {
                         if (index == 0)
                         {
@@ -90,8 +86,7 @@ namespace System.Linq
 
                 try
                 {
-                    while (await e.MoveNextAsync(cancellationToken)
-                                  .ConfigureAwait(false))
+                    while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false))
                     {
                         if (index == 0)
                         {
@@ -110,4 +105,4 @@ namespace System.Linq
             return default(TSource);
         }
     }
-}
+}

+ 2 - 4
Ix.NET/Source/System.Interactive.Async/EmptyArray.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. 
+
 #if NO_ARRAY_EMPTY
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
 
 namespace System.Linq
 {
@@ -14,4 +11,5 @@ namespace System.Linq
         public static readonly TElement[] Value = new TElement[0];
     }
 }
+
 #endif

+ 8 - 11
Ix.NET/Source/System.Interactive.Async/Except.cs

@@ -83,7 +83,7 @@ namespace System.Linq
                         firstEnumerator = first.GetAsyncEnumerator();
                         set = new Set<TSource>(comparer);
                         setFilled = false;
-                        fillSetTask = FillSet();
+                        fillSetTask = FillSetAsync();
 
                         state = AsyncIteratorState.Iterating;
                         goto case AsyncIteratorState.Iterating;
@@ -96,15 +96,14 @@ namespace System.Linq
                             {
                                 // This is here so we don't need to call Task.WhenAll each time after the set is filled
                                 var moveNextTask = firstEnumerator.MoveNextAsync();
-                                await Task.WhenAll(moveNextTask, fillSetTask)
-                                          .ConfigureAwait(false);
+                                await Task.WhenAll(moveNextTask, fillSetTask).ConfigureAwait(false);
+
                                 setFilled = true;
                                 moveNext = moveNextTask.Result;
                             }
                             else
                             {
-                                moveNext = await firstEnumerator.MoveNextAsync()
-                                                                .ConfigureAwait(false);
+                                moveNext = await firstEnumerator.MoveNextAsync().ConfigureAwait(false);
                             }
 
                             if (moveNext)
@@ -116,10 +115,8 @@ namespace System.Linq
                                     return true;
                                 }
                             }
-
                         } while (moveNext);
 
-
                         await DisposeAsync().ConfigureAwait(false);
                         break;
                 }
@@ -127,10 +124,10 @@ namespace System.Linq
                 return false;
             }
 
-            private async Task FillSet()
+            private async Task FillSetAsync()
             {
-                var array = await second.ToArray()
-                                        .ConfigureAwait(false);
+                var array = await second.ToArray().ConfigureAwait(false);
+
                 foreach (var t in array)
                 {
                     set.Add(t);
@@ -138,4 +135,4 @@ namespace System.Linq
             }
         }
     }
-}
+}

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

@@ -12,4 +12,4 @@ namespace System.Diagnostics.CodeAnalysis
     }
 }
 
-#endif
+#endif

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

@@ -90,8 +90,7 @@ namespace System.Linq
                                 break; // while
                             }
 
-                            if (await enumerator.MoveNextAsync()
-                                                .ConfigureAwait(false))
+                            if (await enumerator.MoveNextAsync().ConfigureAwait(false))
                             {
                                 var item = enumerator.Current;
                                 var next = selector(item);
@@ -99,6 +98,7 @@ namespace System.Linq
                                 current = item;
                                 return true;
                             }
+
                             await enumerator.DisposeAsync().ConfigureAwait(false);
                             enumerator = null;
                         }
@@ -111,4 +111,4 @@ namespace System.Linq
             }
         }
     }
-}
+}