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

+ 5 - 13
Ix.NET/Source/System.Interactive.Async/SequenceEqual.cs

@@ -2,9 +2,7 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System;
 using System.Collections.Generic;
-using System.Linq;
 using System.Threading;
 using System.Threading.Tasks;
 
@@ -60,12 +58,9 @@ namespace System.Linq
         private static async Task<bool> SequenceEqual_<TSource>(IAsyncEnumerable<TSource> first, IAsyncEnumerable<TSource> second, IEqualityComparer<TSource> comparer,
                                                                 CancellationToken cancellationToken)
         {
-            if (first is ICollection<TSource> firstCol)
+            if (first is ICollection<TSource> firstCol && second is ICollection<TSource> secondCol && firstCol.Count != secondCol.Count)
             {
-                if (second is ICollection<TSource> secondCol && firstCol.Count != secondCol.Count)
-                {
-                    return false;
-                }
+                return false;
             }
 
             var e1 = first.GetAsyncEnumerator();
@@ -76,18 +71,15 @@ namespace System.Linq
 
                 try
                 {
-                    while (await e1.MoveNextAsync()
-                                   .ConfigureAwait(false))
+                    while (await e1.MoveNextAsync().ConfigureAwait(false))
                     {
-                        if (!(await e2.MoveNextAsync()
-                                      .ConfigureAwait(false) && comparer.Equals(e1.Current, e2.Current)))
+                        if (!(await e2.MoveNextAsync().ConfigureAwait(false) && comparer.Equals(e1.Current, e2.Current)))
                         {
                             return false;
                         }
                     }
 
-                    return !await e2.MoveNextAsync()
-                                    .ConfigureAwait(false);
+                    return !await e2.MoveNextAsync().ConfigureAwait(false);
                 }
                 finally
                 {

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

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

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

@@ -20,8 +20,7 @@ namespace System.Linq
             if (comparer == null)
                 throw new ArgumentNullException(nameof(comparer));
 
-            return first.Concat(second)
-                        .Distinct(comparer);
+            return first.Concat(second).Distinct(comparer);
         }
 
         public static IAsyncEnumerable<TSource> Union<TSource>(this IAsyncEnumerable<TSource> first, IAsyncEnumerable<TSource> second)
@@ -34,4 +33,4 @@ namespace System.Linq
             return first.Union(second, EqualityComparer<TSource>.Default);
         }
     }
-}
+}

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

@@ -4,7 +4,6 @@
 
 using System.Collections.Generic;
 using System.Diagnostics;
-using System.Threading;
 using System.Threading.Tasks;
 
 namespace System.Linq
@@ -71,8 +70,7 @@ namespace System.Linq
                         goto case AsyncIteratorState.Iterating;
 
                     case AsyncIteratorState.Iterating:
-                        while (await enumerator.MoveNextAsync()
-                                               .ConfigureAwait(false))
+                        while (await enumerator.MoveNextAsync().ConfigureAwait(false))
                         {
                             current = enumerator.Current;
                             return true;
@@ -94,4 +92,4 @@ namespace System.Linq
             }
         }
     }
-}
+}

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

@@ -99,6 +99,7 @@ namespace System.Linq
                     await enumerator.DisposeAsync().ConfigureAwait(false);
                     enumerator = null;
                 }
+
                 await base.DisposeAsync().ConfigureAwait(false);
             }
 
@@ -122,8 +123,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;
                             if (predicate(item))
@@ -170,6 +170,7 @@ namespace System.Linq
                     await enumerator.DisposeAsync().ConfigureAwait(false);
                     enumerator = null;
                 }
+
                 await base.DisposeAsync().ConfigureAwait(false);
             }
 
@@ -184,8 +185,7 @@ namespace System.Linq
                         goto case AsyncIteratorState.Iterating;
 
                     case AsyncIteratorState.Iterating:
-                        while (await enumerator.MoveNextAsync()
-                                               .ConfigureAwait(false))
+                        while (await enumerator.MoveNextAsync().ConfigureAwait(false))
                         {
                             checked
                             {
@@ -234,6 +234,7 @@ namespace System.Linq
                     await enumerator.DisposeAsync().ConfigureAwait(false);
                     enumerator = null;
                 }
+
                 await base.DisposeAsync().ConfigureAwait(false);
             }
 
@@ -252,8 +253,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;
                             if (await predicate(item).ConfigureAwait(false))
@@ -300,6 +300,7 @@ namespace System.Linq
                     await enumerator.DisposeAsync().ConfigureAwait(false);
                     enumerator = null;
                 }
+
                 await base.DisposeAsync().ConfigureAwait(false);
             }
 
@@ -314,8 +315,7 @@ namespace System.Linq
                         goto case AsyncIteratorState.Iterating;
 
                     case AsyncIteratorState.Iterating:
-                        while (await enumerator.MoveNextAsync()
-                                               .ConfigureAwait(false))
+                        while (await enumerator.MoveNextAsync().ConfigureAwait(false))
                         {
                             checked
                             {
@@ -387,8 +387,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;
                             if (predicate(item))
@@ -406,4 +405,4 @@ namespace System.Linq
             }
         }
     }
-}
+}

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

@@ -66,6 +66,7 @@ namespace System.Linq
                     await firstEnumerator.DisposeAsync().ConfigureAwait(false);
                     firstEnumerator = null;
                 }
+
                 if (secondEnumerator != null)
                 {
                     await secondEnumerator.DisposeAsync().ConfigureAwait(false);
@@ -91,8 +92,7 @@ namespace System.Linq
                         // We kick these off and join so they can potentially run in parallel
                         var ft = firstEnumerator.MoveNextAsync();
                         var st = secondEnumerator.MoveNextAsync();
-                        await Task.WhenAll(ft, st)
-                                  .ConfigureAwait(false);
+                        await Task.WhenAll(ft, st).ConfigureAwait(false);
 
                         if (ft.Result && st.Result)
                         {
@@ -140,6 +140,7 @@ namespace System.Linq
                     await firstEnumerator.DisposeAsync().ConfigureAwait(false);
                     firstEnumerator = null;
                 }
+
                 if (secondEnumerator != null)
                 {
                     await secondEnumerator.DisposeAsync().ConfigureAwait(false);
@@ -165,8 +166,7 @@ namespace System.Linq
                         // We kick these off and join so they can potentially run in parallel
                         var ft = firstEnumerator.MoveNextAsync();
                         var st = secondEnumerator.MoveNextAsync();
-                        await Task.WhenAll(ft, st)
-                                  .ConfigureAwait(false);
+                        await Task.WhenAll(ft, st).ConfigureAwait(false);
 
                         if (ft.Result && st.Result)
                         {
@@ -182,4 +182,4 @@ namespace System.Linq
             }
         }
     }
-}
+}