Ver Fonte

some more cleanup

Brendan Forster há 9 anos atrás
pai
commit
61c7b19dcd

+ 1 - 2
Ix.NET/Source/System.Interactive.Async/DefaultIfEmpty.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;
 
@@ -34,6 +32,7 @@ namespace System.Linq
         {
             private readonly IAsyncEnumerable<TSource> source;
             private readonly TSource defaultValue;
+
             private IAsyncEnumerator<TSource> enumerator;
 
             public DefaultIfEmptyAsyncIterator(IAsyncEnumerable<TSource> source, TSource defaultValue)

+ 6 - 3
Ix.NET/Source/System.Interactive.Async/Distinct.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;
 
@@ -110,6 +108,8 @@ namespace System.Linq
             public DistinctAsyncIterator(IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
             {
                 Debug.Assert(source != null);
+                Debug.Assert(keySelector != null);
+                Debug.Assert(comparer != null);
 
                 this.source = source;
                 this.keySelector = keySelector;
@@ -344,13 +344,16 @@ namespace System.Linq
         {
             private readonly IEqualityComparer<TSource> comparer;
             private readonly IAsyncEnumerable<TSource> source;
-            private TSource currentValue;
 
+            private TSource currentValue;
             private IAsyncEnumerator<TSource> enumerator;
             private bool hasCurrentValue;
 
             public DistinctUntilChangedAsyncIterator(IAsyncEnumerable<TSource> source, IEqualityComparer<TSource> comparer)
             {
+                Debug.Assert(comparer != null);
+                Debug.Assert(source != null);
+
                 this.source = source;
                 this.comparer = comparer;
             }

+ 0 - 2
Ix.NET/Source/System.Interactive.Async/Do.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;
 

+ 5 - 2
Ix.NET/Source/System.Interactive.Async/Except.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;
 
@@ -49,6 +48,10 @@ namespace System.Linq
 
             public ExceptAsyncIterator(IAsyncEnumerable<TSource> first, IAsyncEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
             {
+                Debug.Assert(first != null);
+                Debug.Assert(second != null);
+                Debug.Assert(comparer != null);
+
                 this.first = first;
                 this.second = second;
                 this.comparer = comparer;

+ 5 - 2
Ix.NET/Source/System.Interactive.Async/Expand.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,12 +25,16 @@ namespace System.Linq
         {
             private readonly Func<TSource, IAsyncEnumerable<TSource>> selector;
             private readonly IAsyncEnumerable<TSource> source;
+
             private IAsyncEnumerator<TSource> enumerator;
 
             private Queue<IAsyncEnumerable<TSource>> queue;
 
             public ExpandAsyncIterator(IAsyncEnumerable<TSource> source, Func<TSource, IAsyncEnumerable<TSource>> selector)
             {
+                Debug.Assert(source != null);
+                Debug.Assert(selector != null);
+
                 this.source = source;
                 this.selector = selector;
             }

+ 4 - 2
Ix.NET/Source/System.Interactive.Async/Finally.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;
 
@@ -31,6 +30,9 @@ namespace System.Linq
 
             public FinallyAsyncIterator(IAsyncEnumerable<TSource> source, Action finallyAction)
             {
+                Debug.Assert(source != null);
+                Debug.Assert(finallyAction != null);
+
                 this.source = source;
                 this.finallyAction = finallyAction;
             }

+ 6 - 2
Ix.NET/Source/System.Interactive.Async/Generate.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;
 
@@ -30,12 +29,17 @@ namespace System.Linq
             private readonly TState initialState;
             private readonly Func<TState, TState> iterate;
             private readonly Func<TState, TResult> resultSelector;
+
             private TState currentState;
 
             private bool started;
 
             public GenerateAsyncIterator(TState initialState, Func<TState, bool> condition, Func<TState, TState> iterate, Func<TState, TResult> resultSelector)
             {
+                Debug.Assert(condition != null);
+                Debug.Assert(iterate != null);
+                Debug.Assert(resultSelector != null);
+
                 this.initialState = initialState;
                 this.condition = condition;
                 this.iterate = iterate;

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

@@ -2,10 +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.Linq;
+using System.Diagnostics;
 using System.Runtime.ExceptionServices;
 using System.Threading;
 using System.Threading.Tasks;
@@ -127,14 +126,15 @@ namespace System.Linq
             private readonly Func<TKey, IAsyncEnumerable<TSource>, TResult> resultSelector;
             private readonly IEqualityComparer<TKey> comparer;
 
-            Internal.Lookup<TKey, TSource> lookup;
-            IEnumerator<TResult> enumerator;
+            private Internal.Lookup<TKey, TSource> lookup;
+            private IEnumerator<TResult> enumerator;
 
             public GroupedResultAsyncEnumerable(IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TKey, IAsyncEnumerable<TSource>, TResult> resultSelector, IEqualityComparer<TKey> comparer)
             {
-                if (source == null) throw new ArgumentNullException(nameof(source));
-                if (keySelector == null) throw new ArgumentNullException(nameof(keySelector));
-                if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector));
+                Debug.Assert(source != null);
+                Debug.Assert(keySelector != null);
+                Debug.Assert(resultSelector != null);
+                Debug.Assert(comparer != null);
 
                 this.source = source;
                 this.keySelector = keySelector;
@@ -220,9 +220,10 @@ namespace System.Linq
 
             public GroupedAsyncEnumerable(IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer)
             {
-                if (source == null) throw new ArgumentNullException(nameof(source));
-                if (keySelector == null) throw new ArgumentNullException(nameof(keySelector));
-                if (elementSelector == null) throw new ArgumentNullException(nameof(elementSelector));
+                Debug.Assert(source != null);
+                Debug.Assert(keySelector != null);
+                Debug.Assert(elementSelector != null);
+                Debug.Assert(comparer != null);
 
                 this.source = source;
                 this.keySelector = keySelector;
@@ -307,8 +308,9 @@ namespace System.Linq
 
             public GroupedAsyncEnumerable(IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
             {
-                if (source == null) throw new ArgumentNullException(nameof(source));
-                if (keySelector == null) throw new ArgumentNullException(nameof(keySelector));
+                Debug.Assert(source != null);
+                Debug.Assert(keySelector != null);
+                Debug.Assert(comparer != null);
 
                 this.source = source;
                 this.keySelector = keySelector;