浏览代码

a bit more cleanup

Brendan Forster 9 年之前
父节点
当前提交
d89c9717a1

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

@@ -67,7 +67,6 @@ namespace System.Linq
             base.Dispose();
         }
 
-
         protected override async Task<bool> MoveNextCore(CancellationToken cancellationToken)
         {
             switch (state)

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

@@ -2,9 +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.Linq;
+using System.Diagnostics;
 using System.Threading;
 using System.Threading.Tasks;
 
@@ -76,13 +75,14 @@ namespace System.Linq
 
             public RepeatSequenceAsyncIterator(IAsyncEnumerable<TSource> source, int count)
             {
+                Debug.Assert(source != null);
+
                 this.source = source;
                 this.count = count;
                 isInfinite = count < 0;
                 currentCount = count;
             }
 
-
             public override AsyncIterator<TSource> Clone()
             {
                 return new RepeatSequenceAsyncIterator<TSource>(source, count);
@@ -127,9 +127,8 @@ namespace System.Linq
                         }
 
                         goto case AsyncIteratorState.Allocated;
-                        
-                }
 
+                }
 
                 Dispose();
 

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

@@ -2,11 +2,9 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System;
 using System.Collections;
 using System.Collections.Generic;
 using System.Diagnostics;
-using System.Linq;
 using System.Threading;
 using System.Threading.Tasks;
 
@@ -25,12 +23,14 @@ namespace System.Linq
         private sealed class ReverseAsyncIterator<TSource> : AsyncIterator<TSource>, IIListProvider<TSource>
         {
             private readonly IAsyncEnumerable<TSource> source;
+
             private int index;
             private TSource[] items;
 
             public ReverseAsyncIterator(IAsyncEnumerable<TSource> source)
             {
                 Debug.Assert(source != null);
+
                 this.source = source;
             }
 
@@ -67,7 +67,7 @@ namespace System.Linq
                     var listProv = source as IIListProvider<TSource>;
                     if (listProv != null)
                     {
-                        return listProv.GetCountAsync(onlyIfCheap, cancellationToken);
+                        return listProv.GetCountAsync(true, cancellationToken);
                     }
 
                     if (!(source is ICollection<TSource>) && !(source is ICollection))

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

@@ -2,9 +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.Linq;
+using System.Diagnostics;
 using System.Threading;
 using System.Threading.Tasks;
 
@@ -43,6 +42,9 @@ namespace System.Linq
 
             public ScanAsyncEnumerable(IAsyncEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> accumulator)
             {
+                Debug.Assert(source != null);
+                Debug.Assert(accumulator != null);
+
                 this.source = source;
                 this.seed = seed;
                 this.accumulator = accumulator;
@@ -99,6 +101,7 @@ namespace System.Linq
         {
             private readonly Func<TSource, TSource, TSource> accumulator;
             private readonly IAsyncEnumerable<TSource> source;
+
             private TSource accumulated;
             private IAsyncEnumerator<TSource> enumerator;
 
@@ -106,6 +109,9 @@ namespace System.Linq
 
             public ScanAsyncEnumerable(IAsyncEnumerable<TSource> source, Func<TSource, TSource, TSource> accumulator)
             {
+                Debug.Assert(source != null);
+                Debug.Assert(accumulator != null);
+
                 this.source = source;
                 this.accumulator = accumulator;
             }

+ 2 - 5
Ix.NET/Source/System.Interactive.Async/Select.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;
 
@@ -19,8 +17,7 @@ namespace System.Linq
                 throw new ArgumentNullException(nameof(source));
             if (selector == null)
                 throw new ArgumentNullException(nameof(selector));
-
-
+            
             var iterator = source as AsyncIterator<TSource>;
             if (iterator != null)
             {
@@ -47,7 +44,6 @@ namespace System.Linq
         }
 
         private static Func<TSource, TResult> CombineSelectors<TSource, TMiddle, TResult>(Func<TSource, TMiddle> selector1, Func<TMiddle, TResult> selector2)
-
         {
             return x => selector2(selector1(x));
         }
@@ -56,6 +52,7 @@ namespace System.Linq
         {
             private readonly Func<TSource, TResult> selector;
             private readonly IAsyncEnumerable<TSource> source;
+
             private IAsyncEnumerator<TSource> enumerator;
 
             public SelectEnumerableAsyncIterator(IAsyncEnumerable<TSource> source, Func<TSource, TResult> selector)

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

@@ -70,15 +70,19 @@ namespace System.Linq
         {
             private const int State_Source = 1;
             private const int State_Result = 2;
+
             private readonly Func<TSource, IAsyncEnumerable<TResult>> selector;
             private readonly IAsyncEnumerable<TSource> source;
+
             private int mode;
             private IAsyncEnumerator<TResult> resultEnumerator;
-
             private IAsyncEnumerator<TSource> sourceEnumerator;
 
             public SelectManyAsyncIterator(IAsyncEnumerable<TSource> source, Func<TSource, IAsyncEnumerable<TResult>> selector)
             {
+                Debug.Assert(source != null);
+                Debug.Assert(selector != null);
+
                 this.source = source;
                 this.selector = selector;
             }
@@ -155,9 +159,11 @@ namespace System.Linq
         {
             private const int State_Source = 1;
             private const int State_Result = 2;
+
             private readonly Func<TSource, IAsyncEnumerable<TCollection>> collectionSelector;
             private readonly Func<TSource, TCollection, TResult> resultSelector;
             private readonly IAsyncEnumerable<TSource> source;
+
             private TSource currentSource;
             private int mode;
             private IAsyncEnumerator<TCollection> resultEnumerator;
@@ -165,6 +171,10 @@ namespace System.Linq
 
             public SelectManyAsyncIterator(IAsyncEnumerable<TSource> source, Func<TSource, IAsyncEnumerable<TCollection>> collectionSelector, Func<TSource, TCollection, TResult> resultSelector)
             {
+                Debug.Assert(source != null);
+                Debug.Assert(collectionSelector != null);
+                Debug.Assert(resultSelector != null);
+
                 this.source = source;
                 this.collectionSelector = collectionSelector;
                 this.resultSelector = resultSelector;