Ver código fonte

some more cleanup

Brendan Forster 9 anos atrás
pai
commit
1973ec1633

+ 0 - 2
Ix.NET/Source/System.Interactive.Async/AsyncEnumerableHelpers.cs

@@ -2,8 +2,6 @@
 // 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;

+ 3 - 3
Ix.NET/Source/System.Interactive.Async/AsyncIterator.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;
 
@@ -15,9 +13,11 @@ namespace System.Linq
         internal abstract class AsyncIterator<TSource> : IAsyncEnumerable<TSource>, IAsyncEnumerator<TSource>
         {
             private readonly int threadId;
+
             private CancellationTokenSource cancellationTokenSource;
-            internal TSource current;
             private bool currentIsInvalid = true;
+
+            internal TSource current;
             internal AsyncIteratorState state = AsyncIteratorState.New;
 
             protected AsyncIterator()

+ 3 - 2
Ix.NET/Source/System.Interactive.Async/Buffer.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;
 
@@ -47,6 +46,8 @@ namespace System.Linq
 
             public BufferAsyncIterator(IAsyncEnumerable<TSource> source, int count, int skip)
             {
+                Debug.Assert(source != null);
+
                 this.source = source;
                 this.count = count;
                 this.skip = skip;

+ 7 - 2
Ix.NET/Source/System.Interactive.Async/Catch.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.Runtime.ExceptionServices;
 using System.Threading;
 using System.Threading.Tasks;
@@ -65,6 +64,9 @@ namespace System.Linq
 
             public CatchAsyncIterator(IAsyncEnumerable<TSource> source, Func<TException, IAsyncEnumerable<TSource>> handler)
             {
+                Debug.Assert(source != null);
+                Debug.Assert(handler != null);
+
                 this.source = source;
                 this.handler = handler;
             }
@@ -145,6 +147,7 @@ namespace System.Linq
         private sealed class CatchAsyncIterator<TSource> : AsyncIterator<TSource>
         {
             private readonly IEnumerable<IAsyncEnumerable<TSource>> sources;
+
             private IAsyncEnumerator<TSource> enumerator;
             private ExceptionDispatchInfo error;
 
@@ -152,6 +155,8 @@ namespace System.Linq
 
             public CatchAsyncIterator(IEnumerable<IAsyncEnumerable<TSource>> sources)
             {
+                Debug.Assert(sources != null);
+
                 this.sources = sources;
             }
 

+ 7 - 6
Ix.NET/Source/System.Interactive.Async/Concatenate.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;
 
@@ -53,6 +51,8 @@ namespace System.Linq
 
             public ConcatEnumerableAsyncIterator(IEnumerable<IAsyncEnumerable<TSource>> source)
             {
+                Debug.Assert(source != null);
+
                 this.source = source;
             }
 
@@ -79,9 +79,9 @@ namespace System.Linq
             }
 
             // State machine vars
-            IEnumerator<IAsyncEnumerable<TSource>> outerEnumerator;
-            IAsyncEnumerator<TSource> currentEnumerator;
-            int mode;
+            private IEnumerator<IAsyncEnumerable<TSource>> outerEnumerator;
+            private IAsyncEnumerator<TSource> currentEnumerator;
+            private int mode;
 
             const int State_OuterNext = 1;
             const int State_While = 4;
@@ -140,7 +140,8 @@ namespace System.Linq
 
             internal Concat2AsyncIterator(IAsyncEnumerable<TSource> first, IAsyncEnumerable<TSource> second)
             {
-                Debug.Assert(first != null && second != null);
+                Debug.Assert(first != null);
+                Debug.Assert(second != null);
 
                 this.first = first;
                 this.second = second;

+ 5 - 4
Ix.NET/Source/System.Interactive.Async/Create.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;
 
@@ -48,8 +47,6 @@ namespace System.Linq
             return self;
         }
 
-        
-
         private class AnonymousAsyncEnumerable<T> : IAsyncEnumerable<T>
         {
             private readonly Func<IAsyncEnumerator<T>> getEnumerator;
@@ -74,6 +71,10 @@ namespace System.Linq
 
             public AnonymousAsyncIterator(Func<CancellationToken, Task<bool>> moveNext, Func<T> currentFunc, Action dispose)
             {
+                Debug.Assert(moveNext != null);
+                Debug.Assert(currentFunc != null);
+                Debug.Assert(dispose != null);
+
                 this.moveNext = moveNext;
                 this.currentFunc = currentFunc;
                 this.dispose = dispose;