Brendan Forster пре 9 година
родитељ
комит
9d645a3e27

+ 12 - 2
Ix.NET/Source/System.Interactive.Async/SelectMany.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;
 
@@ -246,9 +245,11 @@ namespace System.Linq
         {
             private const int State_Source = 1;
             private const int State_Result = 2;
+
             private readonly Func<TSource, int, IAsyncEnumerable<TCollection>> collectionSelector;
             private readonly Func<TSource, TCollection, TResult> resultSelector;
             private readonly IAsyncEnumerable<TSource> source;
+
             private TSource currentSource;
             private int index;
             private int mode;
@@ -257,6 +258,10 @@ namespace System.Linq
 
             public SelectManyWithIndexAsyncIterator(IAsyncEnumerable<TSource> source, Func<TSource, int, 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;
@@ -344,8 +349,10 @@ namespace System.Linq
         {
             private const int State_Source = 1;
             private const int State_Result = 2;
+
             private readonly Func<TSource, int, IAsyncEnumerable<TResult>> selector;
             private readonly IAsyncEnumerable<TSource> source;
+
             private int index;
             private int mode;
             private IAsyncEnumerator<TResult> resultEnumerator;
@@ -353,6 +360,9 @@ namespace System.Linq
 
             public SelectManyWithIndexAsyncIterator(IAsyncEnumerable<TSource> source, Func<TSource, int, IAsyncEnumerable<TResult>> selector)
             {
+                Debug.Assert(source != null);
+                Debug.Assert(selector != null);
+
                 this.source = source;
                 this.selector = selector;
             }

+ 6 - 2
Ix.NET/Source/System.Interactive.Async/Skip.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;
 
@@ -77,11 +75,14 @@ namespace System.Linq
         {
             private readonly int count;
             private readonly IAsyncEnumerable<TSource> source;
+
             private int currentCount;
             private IAsyncEnumerator<TSource> enumerator;
 
             public SkipAsyncIterator(IAsyncEnumerable<TSource> source, int count)
             {
+                Debug.Assert(source != null);
+
                 this.source = source;
                 this.count = count;
                 currentCount = count;
@@ -144,11 +145,14 @@ namespace System.Linq
         {
             private readonly int count;
             private readonly IAsyncEnumerable<TSource> source;
+
             private IAsyncEnumerator<TSource> enumerator;
             private Queue<TSource> queue;
 
             public SkipLastAsyncIterator(IAsyncEnumerable<TSource> source, int count)
             {
+                Debug.Assert(source != null);
+
                 this.source = source;
                 this.count = count;
             }

+ 6 - 2
Ix.NET/Source/System.Interactive.Async/Take.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;
 
@@ -63,11 +61,14 @@ namespace System.Linq
         {
             private readonly int count;
             private readonly IAsyncEnumerable<TSource> source;
+
             private int currentCount;
             private IAsyncEnumerator<TSource> enumerator;
 
             public TakeAsyncIterator(IAsyncEnumerable<TSource> source, int count)
             {
+                Debug.Assert(source != null);
+
                 this.source = source;
                 this.count = count;
                 currentCount = count;
@@ -121,12 +122,15 @@ namespace System.Linq
         {
             private readonly int count;
             private readonly IAsyncEnumerable<TSource> source;
+
             private IAsyncEnumerator<TSource> enumerator;
             private bool isDone;
             private Queue<TSource> queue;
 
             public TakeLastAsyncIterator(IAsyncEnumerable<TSource> source, int count)
             {
+                Debug.Assert(source != null);
+
                 this.source = source;
                 this.count = count;
             }

+ 5 - 3
Ix.NET/Source/System.Interactive.Async/Using.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;
 
@@ -26,13 +25,16 @@ namespace System.Linq
         {
             private readonly Func<TResource, IAsyncEnumerable<TSource>> enumerableFactory;
             private readonly Func<TResource> resourceFactory;
+
             private IAsyncEnumerable<TSource> enumerable;
             private IAsyncEnumerator<TSource> enumerator;
-
             private TResource resource;
 
             public UsingAsyncIterator(Func<TResource> resourceFactory, Func<TResource, IAsyncEnumerable<TSource>> enumerableFactory)
             {
+                Debug.Assert(resourceFactory != null);
+                Debug.Assert(enumerableFactory != null);
+
                 this.resourceFactory = resourceFactory;
                 this.enumerableFactory = enumerableFactory;
             }

+ 2 - 2
Ix.NET/Source/System.Interactive.Async/Where.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;
 
@@ -119,6 +117,7 @@ namespace System.Linq
         {
             private readonly Func<TSource, int, bool> predicate;
             private readonly IAsyncEnumerable<TSource> source;
+
             private IAsyncEnumerator<TSource> enumerator;
             private int index;
 
@@ -185,6 +184,7 @@ namespace System.Linq
             private readonly Func<TSource, bool> predicate;
             private readonly Func<TSource, TResult> selector;
             private readonly IAsyncEnumerable<TSource> source;
+
             private IAsyncEnumerator<TSource> enumerator;
 
             public WhereSelectEnumerableAsyncIterator(IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate, Func<TSource, TResult> selector)