Browse Source

Some stylistic changes.

Bart De Smet 7 years ago
parent
commit
e2b5a524e1

+ 2 - 2
Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs

@@ -98,7 +98,7 @@ namespace Tests
 
             var result = new[] { 1 }.ToAsyncEnumerable().SelectMany(i => disposeCounter).Select(i => i).ToList().Result;
 
-            Assert.Equal(0, result.Count);
+            Assert.Empty(result);
             Assert.Equal(1, disposeCounter.DisposeCount);
         }
 
@@ -109,7 +109,7 @@ namespace Tests
 
             var result = AsyncEnumerable.Range(0, 10).SelectMany(i => disposes[i]).Select(i => i).ToList().Result;
 
-            Assert.Equal(0, result.Count);
+            Assert.Empty(result);
             Assert.True(disposes.All(d => d.DisposeCount == 1));
         }
 

+ 24 - 24
Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs

@@ -36,57 +36,57 @@ namespace System.Linq
 
         private sealed class RepeatElementAsyncIterator<TResult> : AsyncIterator<TResult>
         {
-            private readonly TResult element;
+            private readonly TResult _element;
 
             public RepeatElementAsyncIterator(TResult element)
             {
-                this.element = element;
+                _element = element;
             }
 
             public override AsyncIterator<TResult> Clone()
             {
-                return new RepeatElementAsyncIterator<TResult>(element);
+                return new RepeatElementAsyncIterator<TResult>(_element);
             }
 
             protected override ValueTask<bool> MoveNextCore(CancellationToken cancellationToken)
             {
                 cancellationToken.ThrowIfCancellationRequested();
 
-                current = element;
+                current = _element;
                 return TaskExt.True;
             }
         }
 
         private sealed class RepeatSequenceAsyncIterator<TSource> : AsyncIterator<TSource>
         {
-            private readonly int count;
-            private readonly bool isInfinite;
-            private readonly IAsyncEnumerable<TSource> source;
+            private readonly int _count;
+            private readonly bool _isInfinite;
+            private readonly IAsyncEnumerable<TSource> _source;
 
-            private int currentCount;
-            private IAsyncEnumerator<TSource> enumerator;
+            private int _currentCount;
+            private IAsyncEnumerator<TSource> _enumerator;
 
             public RepeatSequenceAsyncIterator(IAsyncEnumerable<TSource> source, int count)
             {
                 Debug.Assert(source != null);
 
-                this.source = source;
-                this.count = count;
-                isInfinite = count < 0;
-                currentCount = count;
+                _source = source;
+                _count = count;
+                _isInfinite = count < 0;
+                _currentCount = count;
             }
 
             public override AsyncIterator<TSource> Clone()
             {
-                return new RepeatSequenceAsyncIterator<TSource>(source, count);
+                return new RepeatSequenceAsyncIterator<TSource>(_source, _count);
             }
 
             public override async ValueTask DisposeAsync()
             {
-                if (enumerator != null)
+                if (_enumerator != null)
                 {
-                    await enumerator.DisposeAsync().ConfigureAwait(false);
-                    enumerator = null;
+                    await _enumerator.DisposeAsync().ConfigureAwait(false);
+                    _enumerator = null;
                 }
 
                 await base.DisposeAsync().ConfigureAwait(false);
@@ -98,24 +98,24 @@ namespace System.Linq
                 {
                     case AsyncIteratorState.Allocated:
 
-                        if (enumerator != null)
+                        if (_enumerator != null)
                         {
-                            await enumerator.DisposeAsync().ConfigureAwait(false);
-                            enumerator = null;
+                            await _enumerator.DisposeAsync().ConfigureAwait(false);
+                            _enumerator = null;
                         }
 
-                        if (!isInfinite && currentCount-- == 0)
+                        if (!_isInfinite && _currentCount-- == 0)
                             break;
 
-                        enumerator = source.GetAsyncEnumerator(cancellationToken);
+                        _enumerator = _source.GetAsyncEnumerator(cancellationToken);
                         state = AsyncIteratorState.Iterating;
 
                         goto case AsyncIteratorState.Iterating;
 
                     case AsyncIteratorState.Iterating:
-                        if (await enumerator.MoveNextAsync().ConfigureAwait(false))
+                        if (await _enumerator.MoveNextAsync().ConfigureAwait(false))
                         {
-                            current = enumerator.Current;
+                            current = _enumerator.Current;
                             return true;
                         }
 

+ 2 - 2
Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToAsyncEnumerable.cs

@@ -262,7 +262,7 @@ namespace Tests
 
         private sealed class MyObservable<T> : IObservable<T>
         {
-            private Func<IObserver<T>, IDisposable> _subscribe;
+            private readonly Func<IObserver<T>, IDisposable> _subscribe;
 
             public MyObservable(Func<IObserver<T>, IDisposable> subscribe)
             {
@@ -277,7 +277,7 @@ namespace Tests
 
         private sealed class MyDisposable : IDisposable
         {
-            private Action _dispose;
+            private readonly Action _dispose;
 
             public MyDisposable(Action dispose)
             {

+ 9 - 9
Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs

@@ -106,17 +106,17 @@ namespace System.Collections.Generic
 
         private sealed class AnonymousAsyncIterator<T> : AsyncIterator<T>
         {
-            private readonly Func<T> currentFunc;
-            private readonly Func<ValueTask<bool>> moveNext;
-            private Func<ValueTask> dispose;
+            private readonly Func<T> _currentFunc;
+            private readonly Func<ValueTask<bool>> _moveNext;
+            private Func<ValueTask> _dispose;
 
             public AnonymousAsyncIterator(Func<ValueTask<bool>> moveNext, Func<T> currentFunc, Func<ValueTask> dispose)
             {
                 Debug.Assert(moveNext != null);
 
-                this.moveNext = moveNext;
-                this.currentFunc = currentFunc;
-                this.dispose = dispose;
+                _moveNext = moveNext;
+                _currentFunc = currentFunc;
+                _dispose = dispose;
 
                 // Explicit call to initialize enumerator mode
                 GetAsyncEnumerator(default);
@@ -129,7 +129,7 @@ namespace System.Collections.Generic
 
             public override async ValueTask DisposeAsync()
             {
-                var dispose = Interlocked.Exchange(ref this.dispose, null);
+                var dispose = Interlocked.Exchange(ref this._dispose, null);
 
                 if (dispose != null)
                 {
@@ -148,9 +148,9 @@ namespace System.Collections.Generic
                         goto case AsyncIteratorState.Iterating;
 
                     case AsyncIteratorState.Iterating:
-                        if (await moveNext().ConfigureAwait(false))
+                        if (await _moveNext().ConfigureAwait(false))
                         {
-                            current = currentFunc();
+                            current = _currentFunc();
                             return true;
                         }
 

+ 7 - 7
Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs

@@ -10,9 +10,9 @@ namespace System.Linq
 {
     internal abstract class AsyncIterator<TSource> : IAsyncEnumerable<TSource>, IAsyncEnumerator<TSource>
     {
-        private readonly int threadId;
+        private readonly int _threadId;
 
-        private bool currentIsInvalid = true;
+        private bool _currentIsInvalid = true;
 
         internal TSource current;
         internal AsyncIteratorState state = AsyncIteratorState.New;
@@ -20,12 +20,12 @@ namespace System.Linq
 
         protected AsyncIterator()
         {
-            threadId = Environment.CurrentManagedThreadId;
+            _threadId = Environment.CurrentManagedThreadId;
         }
 
         public IAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken)
         {
-            var enumerator = state == AsyncIteratorState.New && threadId == Environment.CurrentManagedThreadId
+            var enumerator = state == AsyncIteratorState.New && _threadId == Environment.CurrentManagedThreadId
                 ? this
                 : Clone();
 
@@ -57,7 +57,7 @@ namespace System.Linq
         {
             get
             {
-                if (currentIsInvalid)
+                if (_currentIsInvalid)
                     throw new InvalidOperationException("Enumerator is in an invalid state");
 
                 return current;
@@ -79,13 +79,13 @@ namespace System.Linq
             {
                 var result = await MoveNextCore(cancellationToken).ConfigureAwait(false);
 
-                currentIsInvalid = !result; // if move next is false, invalid otherwise valid
+                _currentIsInvalid = !result; // if move next is false, invalid otherwise valid
 
                 return result;
             }
             catch
             {
-                currentIsInvalid = true;
+                _currentIsInvalid = true;
                 await DisposeAsync().ConfigureAwait(false);
                 throw;
             }

+ 66 - 67
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs

@@ -93,21 +93,21 @@ namespace System.Linq
 
         private sealed class AppendPrepend1AsyncIterator<TSource> : AppendPrependAsyncIterator<TSource>
         {
-            private readonly TSource item;
-            private readonly bool appending;
+            private readonly TSource _item;
+            private readonly bool _appending;
 
-            bool hasEnumerator;
+            bool _hasEnumerator;
 
             public AppendPrepend1AsyncIterator(IAsyncEnumerable<TSource> source, TSource item, bool appending)
                 : base(source)
             {
-                this.item = item;
-                this.appending = appending;
+                _item = item;
+                _appending = appending;
             }
 
             public override AsyncIterator<TSource> Clone()
             {
-                return new AppendPrepend1AsyncIterator<TSource>(source, item, appending);
+                return new AppendPrepend1AsyncIterator<TSource>(source, _item, _appending);
             }
 
             protected override async ValueTask<bool> MoveNextCore(CancellationToken cancellationToken)
@@ -115,21 +115,21 @@ namespace System.Linq
                 switch (state)
                 {
                     case AsyncIteratorState.Allocated:
-                        hasEnumerator = false;
+                        _hasEnumerator = false;
                         state = AsyncIteratorState.Iterating;
-                        if (!appending)
+                        if (!_appending)
                         {
-                            current = item;
+                            current = _item;
                             return true;
                         }
 
                         goto case AsyncIteratorState.Iterating;
 
                     case AsyncIteratorState.Iterating:
-                        if (!hasEnumerator)
+                        if (!_hasEnumerator)
                         {
                             GetSourceEnumerator(cancellationToken);
-                            hasEnumerator = true;
+                            _hasEnumerator = true;
                         }
 
                         if (enumerator != null)
@@ -140,9 +140,9 @@ namespace System.Linq
                                 return true;
                             }
 
-                            if (appending)
+                            if (_appending)
                             {
-                                current = item;
+                                current = _item;
                                 return true;
                             }
                         }
@@ -156,25 +156,25 @@ namespace System.Linq
 
             public override AppendPrependAsyncIterator<TSource> Append(TSource element)
             {
-                if (appending)
+                if (_appending)
                 {
-                    return new AppendPrependNAsyncIterator<TSource>(source, null, new SingleLinkedNode<TSource>(item).Add(element), prependCount: 0, appendCount: 2);
+                    return new AppendPrependNAsyncIterator<TSource>(source, null, new SingleLinkedNode<TSource>(_item).Add(element), prependCount: 0, appendCount: 2);
                 }
                 else
                 {
-                    return new AppendPrependNAsyncIterator<TSource>(source, new SingleLinkedNode<TSource>(item), new SingleLinkedNode<TSource>(element), prependCount: 1, appendCount: 1);
+                    return new AppendPrependNAsyncIterator<TSource>(source, new SingleLinkedNode<TSource>(_item), new SingleLinkedNode<TSource>(element), prependCount: 1, appendCount: 1);
                 }
             }
 
             public override AppendPrependAsyncIterator<TSource> Prepend(TSource element)
             {
-                if (appending)
+                if (_appending)
                 {
-                    return new AppendPrependNAsyncIterator<TSource>(source, new SingleLinkedNode<TSource>(element), new SingleLinkedNode<TSource>(item), prependCount: 1, appendCount: 1);
+                    return new AppendPrependNAsyncIterator<TSource>(source, new SingleLinkedNode<TSource>(element), new SingleLinkedNode<TSource>(_item), prependCount: 1, appendCount: 1);
                 }
                 else
                 {
-                    return new AppendPrependNAsyncIterator<TSource>(source, new SingleLinkedNode<TSource>(item).Add(element), null, prependCount: 2, appendCount: 0);
+                    return new AppendPrependNAsyncIterator<TSource>(source, new SingleLinkedNode<TSource>(_item).Add(element), null, prependCount: 2, appendCount: 0);
                 }
             }
 
@@ -188,13 +188,13 @@ namespace System.Linq
 
                 var array = new TSource[count];
                 int index;
-                if (appending)
+                if (_appending)
                 {
                     index = 0;
                 }
                 else
                 {
-                    array[0] = item;
+                    array[0] = _item;
                     index = 1;
                 }
 
@@ -220,9 +220,9 @@ namespace System.Linq
                     }
                 }
 
-                if (appending)
+                if (_appending)
                 {
-                    array[array.Length - 1] = item;
+                    array[array.Length - 1] = _item;
                 }
 
                 return array;
@@ -233,9 +233,9 @@ namespace System.Linq
                 var count = await GetCountAsync(onlyIfCheap: true, cancellationToken: cancellationToken).ConfigureAwait(false);
                 var list = count == -1 ? new List<TSource>() : new List<TSource>(count);
 
-                if (!appending)
+                if (!_appending)
                 {
-                    list.Add(item);
+                    list.Add(_item);
                 }
 
 
@@ -253,9 +253,9 @@ namespace System.Linq
                     await en.DisposeAsync().ConfigureAwait(false);
                 }
 
-                if (appending)
+                if (_appending)
                 {
-                    list.Add(item);
+                    list.Add(_item);
                 }
 
                 return list;
@@ -275,11 +275,13 @@ namespace System.Linq
 
         private sealed class AppendPrependNAsyncIterator<TSource> : AppendPrependAsyncIterator<TSource>
         {
-            private readonly SingleLinkedNode<TSource> prepended;
-            private readonly SingleLinkedNode<TSource> appended;
-            private readonly int prependCount;
-            private readonly int appendCount;
-            private SingleLinkedNode<TSource> node;
+            private readonly SingleLinkedNode<TSource> _prepended;
+            private readonly SingleLinkedNode<TSource> _appended;
+            private readonly int _prependCount;
+            private readonly int _appendCount;
+            private SingleLinkedNode<TSource> _node;
+            private int _mode;
+            private IEnumerator<TSource> _appendedEnumerator;
 
             public AppendPrependNAsyncIterator(IAsyncEnumerable<TSource> source, SingleLinkedNode<TSource> prepended, SingleLinkedNode<TSource> appended, int prependCount, int appendCount)
                 : base(source)
@@ -290,26 +292,23 @@ namespace System.Linq
                 Debug.Assert((prepended?.GetCount() ?? 0) == prependCount);
                 Debug.Assert((appended?.GetCount() ?? 0) == appendCount);
 
-                this.prepended = prepended;
-                this.appended = appended;
-                this.prependCount = prependCount;
-                this.appendCount = appendCount;
+                this._prepended = prepended;
+                this._appended = appended;
+                this._prependCount = prependCount;
+                this._appendCount = appendCount;
             }
 
             public override AsyncIterator<TSource> Clone()
             {
-                return new AppendPrependNAsyncIterator<TSource>(source, prepended, appended, prependCount, appendCount);
+                return new AppendPrependNAsyncIterator<TSource>(source, _prepended, _appended, _prependCount, _appendCount);
             }
 
-            int mode;
-            IEnumerator<TSource> appendedEnumerator;
-
             public override async ValueTask DisposeAsync()
             {
-                if (appendedEnumerator != null)
+                if (_appendedEnumerator != null)
                 {
-                    appendedEnumerator.Dispose();
-                    appendedEnumerator = null;
+                    _appendedEnumerator.Dispose();
+                    _appendedEnumerator = null;
                 }
 
                 await base.DisposeAsync().ConfigureAwait(false);
@@ -320,28 +319,28 @@ namespace System.Linq
                 switch (state)
                 {
                     case AsyncIteratorState.Allocated:
-                        mode = 1;
+                        _mode = 1;
                         state = AsyncIteratorState.Iterating;
                         goto case AsyncIteratorState.Iterating;
 
                     case AsyncIteratorState.Iterating:
-                        switch (mode)
+                        switch (_mode)
                         {
                             case 1:
-                                node = prepended;
-                                mode = 2;
+                                _node = _prepended;
+                                _mode = 2;
                                 goto case 2;
 
                             case 2:
-                                if (node != null)
+                                if (_node != null)
                                 {
-                                    current = node.Item;
-                                    node = node.Linked;
+                                    current = _node.Item;
+                                    _node = _node.Linked;
                                     return true;
                                 }
 
                                 GetSourceEnumerator(cancellationToken);
-                                mode = 3;
+                                _mode = 3;
                                 goto case 3;
 
                             case 3:
@@ -350,10 +349,10 @@ namespace System.Linq
                                     return true;
                                 }
 
-                                if (appended != null)
+                                if (_appended != null)
                                 {
-                                    appendedEnumerator = appended.GetEnumerator(appendCount);
-                                    mode = 4;
+                                    _appendedEnumerator = _appended.GetEnumerator(_appendCount);
+                                    _mode = 4;
                                     goto case 4;
                                 }
 
@@ -361,9 +360,9 @@ namespace System.Linq
 
 
                             case 4:
-                                if (appendedEnumerator.MoveNext())
+                                if (_appendedEnumerator.MoveNext())
                                 {
-                                    current = appendedEnumerator.Current;
+                                    current = _appendedEnumerator.Current;
                                     return true;
                                 }
                                 break;
@@ -378,14 +377,14 @@ namespace System.Linq
 
             public override AppendPrependAsyncIterator<TSource> Append(TSource item)
             {
-                var res = appended != null ? appended.Add(item) : new SingleLinkedNode<TSource>(item);
-                return new AppendPrependNAsyncIterator<TSource>(source, prepended, res, prependCount, appendCount + 1);
+                var res = _appended != null ? _appended.Add(item) : new SingleLinkedNode<TSource>(item);
+                return new AppendPrependNAsyncIterator<TSource>(source, _prepended, res, _prependCount, _appendCount + 1);
             }
 
             public override AppendPrependAsyncIterator<TSource> Prepend(TSource item)
             {
-                var res = prepended != null ? prepended.Add(item) : new SingleLinkedNode<TSource>(item);
-                return new AppendPrependNAsyncIterator<TSource>(source, res, appended, prependCount + 1, appendCount);
+                var res = _prepended != null ? _prepended.Add(item) : new SingleLinkedNode<TSource>(item);
+                return new AppendPrependNAsyncIterator<TSource>(source, res, _appended, _prependCount + 1, _appendCount);
             }
 
             public override async Task<TSource[]> ToArrayAsync(CancellationToken cancellationToken)
@@ -398,7 +397,7 @@ namespace System.Linq
 
                 var array = new TSource[count];
                 var index = 0;
-                for (var n = prepended; n != null; n = n.Linked)
+                for (var n = _prepended; n != null; n = n.Linked)
                 {
                     array[index] = n.Item;
                     ++index;
@@ -427,7 +426,7 @@ namespace System.Linq
                 }
 
                 index = array.Length;
-                for (var n = appended; n != null; n = n.Linked)
+                for (var n = _appended; n != null; n = n.Linked)
                 {
                     --index;
                     array[index] = n.Item;
@@ -440,7 +439,7 @@ namespace System.Linq
             {
                 var count = await GetCountAsync(onlyIfCheap: true, cancellationToken: cancellationToken).ConfigureAwait(false);
                 var list = count == -1 ? new List<TSource>() : new List<TSource>(count);
-                for (var n = prepended; n != null; n = n.Linked)
+                for (var n = _prepended; n != null; n = n.Linked)
                 {
                     list.Add(n.Item);
                 }
@@ -459,9 +458,9 @@ namespace System.Linq
                     await en.DisposeAsync().ConfigureAwait(false);
                 }
 
-                if (appended != null)
+                if (_appended != null)
                 {
-                    using (var en2 = appended.GetEnumerator(appendCount))
+                    using (var en2 = _appended.GetEnumerator(_appendCount))
                     {
                         while (en2.MoveNext())
                         {
@@ -478,10 +477,10 @@ namespace System.Linq
                 if (source is IAsyncIListProvider<TSource> listProv)
                 {
                     var count = await listProv.GetCountAsync(onlyIfCheap, cancellationToken).ConfigureAwait(false);
-                    return count == -1 ? -1 : count + appendCount + prependCount;
+                    return count == -1 ? -1 : count + _appendCount + _prependCount;
                 }
 
-                return !onlyIfCheap || source is ICollection<TSource> ? await source.Count(cancellationToken).ConfigureAwait(false) + appendCount + prependCount : -1;
+                return !onlyIfCheap || source is ICollection<TSource> ? await source.Count(cancellationToken).ConfigureAwait(false) + _appendCount + _prependCount : -1;
             }
         }
     }

+ 84 - 84
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs

@@ -81,14 +81,14 @@ namespace System.Linq
 
         internal sealed class JoinAsyncIterator<TOuter, TInner, TKey, TResult> : AsyncIterator<TResult>
         {
-            private readonly IAsyncEnumerable<TOuter> outer;
-            private readonly IAsyncEnumerable<TInner> inner;
-            private readonly Func<TOuter, TKey> outerKeySelector;
-            private readonly Func<TInner, TKey> innerKeySelector;
-            private readonly Func<TOuter, TInner, TResult> resultSelector;
-            private readonly IEqualityComparer<TKey> comparer;
+            private readonly IAsyncEnumerable<TOuter> _outer;
+            private readonly IAsyncEnumerable<TInner> _inner;
+            private readonly Func<TOuter, TKey> _outerKeySelector;
+            private readonly Func<TInner, TKey> _innerKeySelector;
+            private readonly Func<TOuter, TInner, TResult> _resultSelector;
+            private readonly IEqualityComparer<TKey> _comparer;
 
-            private IAsyncEnumerator<TOuter> outerEnumerator;
+            private IAsyncEnumerator<TOuter> _outerEnumerator;
 
             public JoinAsyncIterator(IAsyncEnumerable<TOuter> outer, IAsyncEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector, IEqualityComparer<TKey> comparer)
             {
@@ -99,37 +99,37 @@ namespace System.Linq
                 Debug.Assert(resultSelector != null);
                 Debug.Assert(comparer != null);
 
-                this.outer = outer;
-                this.inner = inner;
-                this.outerKeySelector = outerKeySelector;
-                this.innerKeySelector = innerKeySelector;
-                this.resultSelector = resultSelector;
-                this.comparer = comparer;
+                _outer = outer;
+                _inner = inner;
+                _outerKeySelector = outerKeySelector;
+                _innerKeySelector = innerKeySelector;
+                _resultSelector = resultSelector;
+                _comparer = comparer;
             }
 
             public override AsyncIterator<TResult> Clone()
             {
-                return new JoinAsyncIterator<TOuter, TInner, TKey, TResult>(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer);
+                return new JoinAsyncIterator<TOuter, TInner, TKey, TResult>(_outer, _inner, _outerKeySelector, _innerKeySelector, _resultSelector, _comparer);
             }
 
             public override async ValueTask DisposeAsync()
             {
-                if (outerEnumerator != null)
+                if (_outerEnumerator != null)
                 {
-                    await outerEnumerator.DisposeAsync().ConfigureAwait(false);
-                    outerEnumerator = null;
+                    await _outerEnumerator.DisposeAsync().ConfigureAwait(false);
+                    _outerEnumerator = null;
                 }
 
                 await base.DisposeAsync().ConfigureAwait(false);
             }
 
             // State machine vars
-            private Internal.Lookup<TKey, TInner> lookup;
-            private int count;
-            private TInner[] elements;
-            private int index;
-            private TOuter item;
-            private int mode;
+            private Internal.Lookup<TKey, TInner> _lookup;
+            private int _count;
+            private TInner[] _elements;
+            private int _index;
+            private TOuter _item;
+            private int _mode;
 
             private const int State_If = 1;
             private const int State_DoLoop = 2;
@@ -141,22 +141,22 @@ namespace System.Linq
                 switch (state)
                 {
                     case AsyncIteratorState.Allocated:
-                        outerEnumerator = outer.GetAsyncEnumerator(cancellationToken);
-                        mode = State_If;
+                        _outerEnumerator = _outer.GetAsyncEnumerator(cancellationToken);
+                        _mode = State_If;
                         state = AsyncIteratorState.Iterating;
                         goto case AsyncIteratorState.Iterating;
 
                     case AsyncIteratorState.Iterating:
-                        switch (mode)
+                        switch (_mode)
                         {
                             case State_If:
-                                if (await outerEnumerator.MoveNextAsync().ConfigureAwait(false))
+                                if (await _outerEnumerator.MoveNextAsync().ConfigureAwait(false))
                                 {
-                                    lookup = await Internal.Lookup<TKey, TInner>.CreateForJoinAsync(inner, innerKeySelector, comparer, cancellationToken).ConfigureAwait(false);
+                                    _lookup = await Internal.Lookup<TKey, TInner>.CreateForJoinAsync(_inner, _innerKeySelector, _comparer, cancellationToken).ConfigureAwait(false);
 
-                                    if (lookup.Count != 0)
+                                    if (_lookup.Count != 0)
                                     {
-                                        mode = State_DoLoop;
+                                        _mode = State_DoLoop;
                                         goto case State_DoLoop;
                                     }
                                 }
@@ -164,33 +164,33 @@ namespace System.Linq
                                 break;
 
                             case State_DoLoop:
-                                item = outerEnumerator.Current;
-                                var g = lookup.GetGrouping(outerKeySelector(item), create: false);
+                                _item = _outerEnumerator.Current;
+                                var g = _lookup.GetGrouping(_outerKeySelector(_item), create: false);
                                 if (g != null)
                                 {
-                                    count = g._count;
-                                    elements = g._elements;
-                                    index = 0;
-                                    mode = State_For;
+                                    _count = g._count;
+                                    _elements = g._elements;
+                                    _index = 0;
+                                    _mode = State_For;
                                     goto case State_For;
                                 }
 
                                 // advance to while
-                                mode = State_While;
+                                _mode = State_While;
                                 goto case State_While;
 
                             case State_For:
-                                current = resultSelector(item, elements[index]);
-                                index++;
-                                if (index == count)
+                                current = _resultSelector(_item, _elements[_index]);
+                                _index++;
+                                if (_index == _count)
                                 {
-                                    mode = State_While;
+                                    _mode = State_While;
                                 }
 
                                 return true;
 
                             case State_While:
-                                var hasNext = await outerEnumerator.MoveNextAsync().ConfigureAwait(false);
+                                var hasNext = await _outerEnumerator.MoveNextAsync().ConfigureAwait(false);
                                 if (hasNext)
                                 {
                                     goto case State_DoLoop;
@@ -209,14 +209,14 @@ namespace System.Linq
 
         internal sealed class JoinAsyncIteratorWithTask<TOuter, TInner, TKey, TResult> : AsyncIterator<TResult>
         {
-            private readonly IAsyncEnumerable<TOuter> outer;
-            private readonly IAsyncEnumerable<TInner> inner;
-            private readonly Func<TOuter, Task<TKey>> outerKeySelector;
-            private readonly Func<TInner, Task<TKey>> innerKeySelector;
-            private readonly Func<TOuter, TInner, Task<TResult>> resultSelector;
-            private readonly IEqualityComparer<TKey> comparer;
+            private readonly IAsyncEnumerable<TOuter> _outer;
+            private readonly IAsyncEnumerable<TInner> _inner;
+            private readonly Func<TOuter, Task<TKey>> _outerKeySelector;
+            private readonly Func<TInner, Task<TKey>> _innerKeySelector;
+            private readonly Func<TOuter, TInner, Task<TResult>> _resultSelector;
+            private readonly IEqualityComparer<TKey> _comparer;
 
-            private IAsyncEnumerator<TOuter> outerEnumerator;
+            private IAsyncEnumerator<TOuter> _outerEnumerator;
 
             public JoinAsyncIteratorWithTask(IAsyncEnumerable<TOuter> outer, IAsyncEnumerable<TInner> inner, Func<TOuter, Task<TKey>> outerKeySelector, Func<TInner, Task<TKey>> innerKeySelector, Func<TOuter, TInner, Task<TResult>> resultSelector, IEqualityComparer<TKey> comparer)
             {
@@ -227,37 +227,37 @@ namespace System.Linq
                 Debug.Assert(resultSelector != null);
                 Debug.Assert(comparer != null);
 
-                this.outer = outer;
-                this.inner = inner;
-                this.outerKeySelector = outerKeySelector;
-                this.innerKeySelector = innerKeySelector;
-                this.resultSelector = resultSelector;
-                this.comparer = comparer;
+                _outer = outer;
+                _inner = inner;
+                _outerKeySelector = outerKeySelector;
+                _innerKeySelector = innerKeySelector;
+                _resultSelector = resultSelector;
+                _comparer = comparer;
             }
 
             public override AsyncIterator<TResult> Clone()
             {
-                return new JoinAsyncIteratorWithTask<TOuter, TInner, TKey, TResult>(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer);
+                return new JoinAsyncIteratorWithTask<TOuter, TInner, TKey, TResult>(_outer, _inner, _outerKeySelector, _innerKeySelector, _resultSelector, _comparer);
             }
 
             public override async ValueTask DisposeAsync()
             {
-                if (outerEnumerator != null)
+                if (_outerEnumerator != null)
                 {
-                    await outerEnumerator.DisposeAsync().ConfigureAwait(false);
-                    outerEnumerator = null;
+                    await _outerEnumerator.DisposeAsync().ConfigureAwait(false);
+                    _outerEnumerator = null;
                 }
 
                 await base.DisposeAsync().ConfigureAwait(false);
             }
 
             // State machine vars
-            private Internal.LookupWithTask<TKey, TInner> lookup;
-            private int count;
-            private TInner[] elements;
-            private int index;
-            private TOuter item;
-            private int mode;
+            private Internal.LookupWithTask<TKey, TInner> _lookup;
+            private int _count;
+            private TInner[] _elements;
+            private int _index;
+            private TOuter _item;
+            private int _mode;
 
             private const int State_If = 1;
             private const int State_DoLoop = 2;
@@ -269,22 +269,22 @@ namespace System.Linq
                 switch (state)
                 {
                     case AsyncIteratorState.Allocated:
-                        outerEnumerator = outer.GetAsyncEnumerator(cancellationToken);
-                        mode = State_If;
+                        _outerEnumerator = _outer.GetAsyncEnumerator(cancellationToken);
+                        _mode = State_If;
                         state = AsyncIteratorState.Iterating;
                         goto case AsyncIteratorState.Iterating;
 
                     case AsyncIteratorState.Iterating:
-                        switch (mode)
+                        switch (_mode)
                         {
                             case State_If:
-                                if (await outerEnumerator.MoveNextAsync().ConfigureAwait(false))
+                                if (await _outerEnumerator.MoveNextAsync().ConfigureAwait(false))
                                 {
-                                    lookup = await Internal.LookupWithTask<TKey, TInner>.CreateForJoinAsync(inner, innerKeySelector, comparer, cancellationToken).ConfigureAwait(false);
+                                    _lookup = await Internal.LookupWithTask<TKey, TInner>.CreateForJoinAsync(_inner, _innerKeySelector, _comparer, cancellationToken).ConfigureAwait(false);
 
-                                    if (lookup.Count != 0)
+                                    if (_lookup.Count != 0)
                                     {
-                                        mode = State_DoLoop;
+                                        _mode = State_DoLoop;
                                         goto case State_DoLoop;
                                     }
                                 }
@@ -292,33 +292,33 @@ namespace System.Linq
                                 break;
 
                             case State_DoLoop:
-                                item = outerEnumerator.Current;
-                                var g = lookup.GetGrouping(await outerKeySelector(item).ConfigureAwait(false), create: false);
+                                _item = _outerEnumerator.Current;
+                                var g = _lookup.GetGrouping(await _outerKeySelector(_item).ConfigureAwait(false), create: false);
                                 if (g != null)
                                 {
-                                    count = g._count;
-                                    elements = g._elements;
-                                    index = 0;
-                                    mode = State_For;
+                                    _count = g._count;
+                                    _elements = g._elements;
+                                    _index = 0;
+                                    _mode = State_For;
                                     goto case State_For;
                                 }
 
                                 // advance to while
-                                mode = State_While;
+                                _mode = State_While;
                                 goto case State_While;
 
                             case State_For:
-                                current = await resultSelector(item, elements[index]).ConfigureAwait(false);
-                                index++;
-                                if (index == count)
+                                current = await _resultSelector(_item, _elements[_index]).ConfigureAwait(false);
+                                _index++;
+                                if (_index == _count)
                                 {
-                                    mode = State_While;
+                                    _mode = State_While;
                                 }
 
                                 return true;
 
                             case State_While:
-                                var hasNext = await outerEnumerator.MoveNextAsync().ConfigureAwait(false);
+                                var hasNext = await _outerEnumerator.MoveNextAsync().ConfigureAwait(false);
                                 if (hasNext)
                                 {
                                     goto case State_DoLoop;

+ 50 - 50
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs

@@ -29,13 +29,13 @@ namespace System.Linq
 
     internal sealed class OrderedAsyncEnumerable<TElement, TKey> : OrderedAsyncEnumerable<TElement>
     {
-        private readonly IComparer<TKey> comparer;
-        private readonly bool descending;
-        private readonly Func<TElement, TKey> keySelector;
-        private readonly OrderedAsyncEnumerable<TElement> parent;
+        private readonly IComparer<TKey> _comparer;
+        private readonly bool _descending;
+        private readonly Func<TElement, TKey> _keySelector;
+        private readonly OrderedAsyncEnumerable<TElement> _parent;
 
-        private IEnumerator<TElement> enumerator;
-        private IAsyncEnumerator<TElement> parentEnumerator;
+        private IEnumerator<TElement> _enumerator;
+        private IAsyncEnumerator<TElement> _parentEnumerator;
 
         public OrderedAsyncEnumerable(IAsyncEnumerable<TElement> source, Func<TElement, TKey> keySelector, IComparer<TKey> comparer, bool descending, OrderedAsyncEnumerable<TElement> parent)
         {
@@ -44,29 +44,29 @@ namespace System.Linq
             Debug.Assert(comparer != null);
 
             this.source = source;
-            this.keySelector = keySelector;
-            this.comparer = comparer;
-            this.descending = descending;
-            this.parent = parent;
+            _keySelector = keySelector;
+            _comparer = comparer;
+            _descending = descending;
+            _parent = parent;
         }
 
         public override AsyncIterator<TElement> Clone()
         {
-            return new OrderedAsyncEnumerable<TElement, TKey>(source, keySelector, comparer, descending, parent);
+            return new OrderedAsyncEnumerable<TElement, TKey>(source, _keySelector, _comparer, _descending, _parent);
         }
 
         public override async ValueTask DisposeAsync()
         {
-            if (enumerator != null)
+            if (_enumerator != null)
             {
-                enumerator.Dispose();
-                enumerator = null;
+                _enumerator.Dispose();
+                _enumerator = null;
             }
 
-            if (parentEnumerator != null)
+            if (_parentEnumerator != null)
             {
-                await parentEnumerator.DisposeAsync().ConfigureAwait(false);
-                parentEnumerator = null;
+                await _parentEnumerator.DisposeAsync().ConfigureAwait(false);
+                _parentEnumerator = null;
             }
 
             await base.DisposeAsync().ConfigureAwait(false);
@@ -80,14 +80,14 @@ namespace System.Linq
 
                     await Initialize(cancellationToken).ConfigureAwait(false);
 
-                    enumerator = enumerable.GetEnumerator();
+                    _enumerator = enumerable.GetEnumerator();
                     state = AsyncIteratorState.Iterating;
                     goto case AsyncIteratorState.Iterating;
 
                 case AsyncIteratorState.Iterating:
-                    if (enumerator.MoveNext())
+                    if (_enumerator.MoveNext())
                     {
-                        current = enumerator.Current;
+                        current = _enumerator.Current;
                         return true;
                     }
 
@@ -100,29 +100,29 @@ namespace System.Linq
 
         internal override async Task Initialize(CancellationToken cancellationToken)
         {
-            if (parent == null)
+            if (_parent == null)
             {
                 var buffer = await source.ToList(cancellationToken).ConfigureAwait(false);
-                enumerable = (!@descending ? buffer.OrderBy(keySelector, comparer) : buffer.OrderByDescending(keySelector, comparer));
+                enumerable = (!_descending ? buffer.OrderBy(_keySelector, _comparer) : buffer.OrderByDescending(_keySelector, _comparer));
             }
             else
             {
-                parentEnumerator = parent.GetAsyncEnumerator(cancellationToken);
-                await parent.Initialize(cancellationToken).ConfigureAwait(false);
-                enumerable = parent.enumerable.CreateOrderedEnumerable(keySelector, comparer, @descending);
+                _parentEnumerator = _parent.GetAsyncEnumerator(cancellationToken);
+                await _parent.Initialize(cancellationToken).ConfigureAwait(false);
+                enumerable = _parent.enumerable.CreateOrderedEnumerable(_keySelector, _comparer, _descending);
             }
         }
     }
 
     internal sealed class OrderedAsyncEnumerableWithTask<TElement, TKey> : OrderedAsyncEnumerable<TElement>
     {
-        private readonly IComparer<TKey> comparer;
-        private readonly bool descending;
-        private readonly Func<TElement, Task<TKey>> keySelector;
-        private readonly OrderedAsyncEnumerable<TElement> parent;
+        private readonly IComparer<TKey> _comparer;
+        private readonly bool _descending;
+        private readonly Func<TElement, Task<TKey>> _keySelector;
+        private readonly OrderedAsyncEnumerable<TElement> _parent;
 
-        private IEnumerator<TElement> enumerator;
-        private IAsyncEnumerator<TElement> parentEnumerator;
+        private IEnumerator<TElement> _enumerator;
+        private IAsyncEnumerator<TElement> _parentEnumerator;
 
         public OrderedAsyncEnumerableWithTask(IAsyncEnumerable<TElement> source, Func<TElement, Task<TKey>> keySelector, IComparer<TKey> comparer, bool descending, OrderedAsyncEnumerable<TElement> parent)
         {
@@ -131,29 +131,29 @@ namespace System.Linq
             Debug.Assert(comparer != null);
 
             this.source = source;
-            this.keySelector = keySelector;
-            this.comparer = comparer;
-            this.descending = descending;
-            this.parent = parent;
+            _keySelector = keySelector;
+            _comparer = comparer;
+            _descending = descending;
+            _parent = parent;
         }
 
         public override AsyncIterator<TElement> Clone()
         {
-            return new OrderedAsyncEnumerableWithTask<TElement, TKey>(source, keySelector, comparer, descending, parent);
+            return new OrderedAsyncEnumerableWithTask<TElement, TKey>(source, _keySelector, _comparer, _descending, _parent);
         }
 
         public override async ValueTask DisposeAsync()
         {
-            if (enumerator != null)
+            if (_enumerator != null)
             {
-                enumerator.Dispose();
-                enumerator = null;
+                _enumerator.Dispose();
+                _enumerator = null;
             }
 
-            if (parentEnumerator != null)
+            if (_parentEnumerator != null)
             {
-                await parentEnumerator.DisposeAsync().ConfigureAwait(false);
-                parentEnumerator = null;
+                await _parentEnumerator.DisposeAsync().ConfigureAwait(false);
+                _parentEnumerator = null;
             }
 
             await base.DisposeAsync().ConfigureAwait(false);
@@ -167,14 +167,14 @@ namespace System.Linq
 
                     await Initialize(cancellationToken).ConfigureAwait(false);
 
-                    enumerator = enumerable.GetEnumerator();
+                    _enumerator = enumerable.GetEnumerator();
                     state = AsyncIteratorState.Iterating;
                     goto case AsyncIteratorState.Iterating;
 
                 case AsyncIteratorState.Iterating:
-                    if (enumerator.MoveNext())
+                    if (_enumerator.MoveNext())
                     {
-                        current = enumerator.Current;
+                        current = _enumerator.Current;
                         return true;
                     }
 
@@ -187,16 +187,16 @@ namespace System.Linq
 
         internal override async Task Initialize(CancellationToken cancellationToken)
         {
-            if (parent == null)
+            if (_parent == null)
             {
                 var buffer = await source.ToList(cancellationToken).ConfigureAwait(false);
-                enumerable = (!@descending ? buffer.OrderByAsync(keySelector, comparer) : buffer.OrderByDescendingAsync(keySelector, comparer));
+                enumerable = (!_descending ? buffer.OrderByAsync(_keySelector, _comparer) : buffer.OrderByDescendingAsync(_keySelector, _comparer));
             }
             else
             {
-                parentEnumerator = parent.GetAsyncEnumerator(cancellationToken);
-                await parent.Initialize(cancellationToken).ConfigureAwait(false);
-                enumerable = parent.enumerable.CreateOrderedEnumerableAsync(keySelector, comparer, @descending);
+                _parentEnumerator = _parent.GetAsyncEnumerator(cancellationToken);
+                await _parent.Initialize(cancellationToken).ConfigureAwait(false);
+                enumerable = _parent.enumerable.CreateOrderedEnumerableAsync(_keySelector, _comparer, _descending);
             }
         }
     }

+ 240 - 240
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs

@@ -104,39 +104,39 @@ 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 readonly Func<TSource, IAsyncEnumerable<TResult>> _selector;
+            private readonly IAsyncEnumerable<TSource> _source;
 
-            private int mode;
-            private IAsyncEnumerator<TResult> resultEnumerator;
-            private IAsyncEnumerator<TSource> sourceEnumerator;
+            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;
+                _source = source;
+                _selector = selector;
             }
 
             public override AsyncIterator<TResult> Clone()
             {
-                return new SelectManyAsyncIterator<TSource, TResult>(source, selector);
+                return new SelectManyAsyncIterator<TSource, TResult>(_source, _selector);
             }
 
             public override async ValueTask DisposeAsync()
             {
-                if (sourceEnumerator != null)
+                if (_sourceEnumerator != null)
                 {
-                    await sourceEnumerator.DisposeAsync().ConfigureAwait(false);
-                    sourceEnumerator = null;
+                    await _sourceEnumerator.DisposeAsync().ConfigureAwait(false);
+                    _sourceEnumerator = null;
                 }
 
-                if (resultEnumerator != null)
+                if (_resultEnumerator != null)
                 {
-                    await resultEnumerator.DisposeAsync().ConfigureAwait(false);
-                    resultEnumerator = null;
+                    await _resultEnumerator.DisposeAsync().ConfigureAwait(false);
+                    _resultEnumerator = null;
                 }
 
                 await base.DisposeAsync().ConfigureAwait(false);
@@ -147,38 +147,38 @@ namespace System.Linq
                 switch (state)
                 {
                     case AsyncIteratorState.Allocated:
-                        sourceEnumerator = source.GetAsyncEnumerator(cancellationToken);
-                        mode = State_Source;
+                        _sourceEnumerator = _source.GetAsyncEnumerator(cancellationToken);
+                        _mode = State_Source;
                         state = AsyncIteratorState.Iterating;
                         goto case AsyncIteratorState.Iterating;
 
                     case AsyncIteratorState.Iterating:
-                        switch (mode)
+                        switch (_mode)
                         {
                             case State_Source:
-                                if (await sourceEnumerator.MoveNextAsync().ConfigureAwait(false))
+                                if (await _sourceEnumerator.MoveNextAsync().ConfigureAwait(false))
                                 {
-                                    if (resultEnumerator != null)
+                                    if (_resultEnumerator != null)
                                     {
-                                        await resultEnumerator.DisposeAsync().ConfigureAwait(false);
+                                        await _resultEnumerator.DisposeAsync().ConfigureAwait(false);
                                     }
 
-                                    var inner = selector(sourceEnumerator.Current);
-                                    resultEnumerator = inner.GetAsyncEnumerator(cancellationToken);
+                                    var inner = _selector(_sourceEnumerator.Current);
+                                    _resultEnumerator = inner.GetAsyncEnumerator(cancellationToken);
 
-                                    mode = State_Result;
+                                    _mode = State_Result;
                                     goto case State_Result;
                                 }
                                 break;
 
                             case State_Result:
-                                if (await resultEnumerator.MoveNextAsync().ConfigureAwait(false))
+                                if (await _resultEnumerator.MoveNextAsync().ConfigureAwait(false))
                                 {
-                                    current = resultEnumerator.Current;
+                                    current = _resultEnumerator.Current;
                                     return true;
                                 }
 
-                                mode = State_Source;
+                                _mode = State_Source;
                                 goto case State_Source; // loop
                         }
 
@@ -195,39 +195,39 @@ namespace System.Linq
             private const int State_Source = 1;
             private const int State_Result = 2;
 
-            private readonly Func<TSource, Task<IAsyncEnumerable<TResult>>> selector;
-            private readonly IAsyncEnumerable<TSource> source;
+            private readonly Func<TSource, Task<IAsyncEnumerable<TResult>>> _selector;
+            private readonly IAsyncEnumerable<TSource> _source;
 
-            private int mode;
-            private IAsyncEnumerator<TResult> resultEnumerator;
-            private IAsyncEnumerator<TSource> sourceEnumerator;
+            private int _mode;
+            private IAsyncEnumerator<TResult> _resultEnumerator;
+            private IAsyncEnumerator<TSource> _sourceEnumerator;
 
             public SelectManyAsyncIteratorWithTask(IAsyncEnumerable<TSource> source, Func<TSource, Task<IAsyncEnumerable<TResult>>> selector)
             {
                 Debug.Assert(source != null);
                 Debug.Assert(selector != null);
 
-                this.source = source;
-                this.selector = selector;
+                _source = source;
+                _selector = selector;
             }
 
             public override AsyncIterator<TResult> Clone()
             {
-                return new SelectManyAsyncIteratorWithTask<TSource, TResult>(source, selector);
+                return new SelectManyAsyncIteratorWithTask<TSource, TResult>(_source, _selector);
             }
 
             public override async ValueTask DisposeAsync()
             {
-                if (sourceEnumerator != null)
+                if (_sourceEnumerator != null)
                 {
-                    await sourceEnumerator.DisposeAsync().ConfigureAwait(false);
-                    sourceEnumerator = null;
+                    await _sourceEnumerator.DisposeAsync().ConfigureAwait(false);
+                    _sourceEnumerator = null;
                 }
 
-                if (resultEnumerator != null)
+                if (_resultEnumerator != null)
                 {
-                    await resultEnumerator.DisposeAsync().ConfigureAwait(false);
-                    resultEnumerator = null;
+                    await _resultEnumerator.DisposeAsync().ConfigureAwait(false);
+                    _resultEnumerator = null;
                 }
 
                 await base.DisposeAsync().ConfigureAwait(false);
@@ -238,38 +238,38 @@ namespace System.Linq
                 switch (state)
                 {
                     case AsyncIteratorState.Allocated:
-                        sourceEnumerator = source.GetAsyncEnumerator(cancellationToken);
-                        mode = State_Source;
+                        _sourceEnumerator = _source.GetAsyncEnumerator(cancellationToken);
+                        _mode = State_Source;
                         state = AsyncIteratorState.Iterating;
                         goto case AsyncIteratorState.Iterating;
 
                     case AsyncIteratorState.Iterating:
-                        switch (mode)
+                        switch (_mode)
                         {
                             case State_Source:
-                                if (await sourceEnumerator.MoveNextAsync().ConfigureAwait(false))
+                                if (await _sourceEnumerator.MoveNextAsync().ConfigureAwait(false))
                                 {
-                                    if (resultEnumerator != null)
+                                    if (_resultEnumerator != null)
                                     {
-                                        await resultEnumerator.DisposeAsync().ConfigureAwait(false);
+                                        await _resultEnumerator.DisposeAsync().ConfigureAwait(false);
                                     }
 
-                                    var inner = await selector(sourceEnumerator.Current).ConfigureAwait(false);
-                                    resultEnumerator = inner.GetAsyncEnumerator(cancellationToken);
+                                    var inner = await _selector(_sourceEnumerator.Current).ConfigureAwait(false);
+                                    _resultEnumerator = inner.GetAsyncEnumerator(cancellationToken);
 
-                                    mode = State_Result;
+                                    _mode = State_Result;
                                     goto case State_Result;
                                 }
                                 break;
 
                             case State_Result:
-                                if (await resultEnumerator.MoveNextAsync().ConfigureAwait(false))
+                                if (await _resultEnumerator.MoveNextAsync().ConfigureAwait(false))
                                 {
-                                    current = resultEnumerator.Current;
+                                    current = _resultEnumerator.Current;
                                     return true;
                                 }
 
-                                mode = State_Source;
+                                _mode = State_Source;
                                 goto case State_Source; // loop
                         }
 
@@ -286,14 +286,14 @@ 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 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;
-            private IAsyncEnumerator<TSource> sourceEnumerator;
+            private TSource _currentSource;
+            private int _mode;
+            private IAsyncEnumerator<TCollection> _resultEnumerator;
+            private IAsyncEnumerator<TSource> _sourceEnumerator;
 
             public SelectManyAsyncIterator(IAsyncEnumerable<TSource> source, Func<TSource, IAsyncEnumerable<TCollection>> collectionSelector, Func<TSource, TCollection, TResult> resultSelector)
             {
@@ -301,31 +301,31 @@ namespace System.Linq
                 Debug.Assert(collectionSelector != null);
                 Debug.Assert(resultSelector != null);
 
-                this.source = source;
-                this.collectionSelector = collectionSelector;
-                this.resultSelector = resultSelector;
+                _source = source;
+                _collectionSelector = collectionSelector;
+                _resultSelector = resultSelector;
             }
 
             public override AsyncIterator<TResult> Clone()
             {
-                return new SelectManyAsyncIterator<TSource, TCollection, TResult>(source, collectionSelector, resultSelector);
+                return new SelectManyAsyncIterator<TSource, TCollection, TResult>(_source, _collectionSelector, _resultSelector);
             }
 
             public override async ValueTask DisposeAsync()
             {
-                if (sourceEnumerator != null)
+                if (_sourceEnumerator != null)
                 {
-                    await sourceEnumerator.DisposeAsync().ConfigureAwait(false);
-                    sourceEnumerator = null;
+                    await _sourceEnumerator.DisposeAsync().ConfigureAwait(false);
+                    _sourceEnumerator = null;
                 }
 
-                if (resultEnumerator != null)
+                if (_resultEnumerator != null)
                 {
-                    await resultEnumerator.DisposeAsync().ConfigureAwait(false);
-                    resultEnumerator = null;
+                    await _resultEnumerator.DisposeAsync().ConfigureAwait(false);
+                    _resultEnumerator = null;
                 }
 
-                currentSource = default(TSource);
+                _currentSource = default(TSource);
 
                 await base.DisposeAsync().ConfigureAwait(false);
             }
@@ -335,39 +335,39 @@ namespace System.Linq
                 switch (state)
                 {
                     case AsyncIteratorState.Allocated:
-                        sourceEnumerator = source.GetAsyncEnumerator(cancellationToken);
-                        mode = State_Source;
+                        _sourceEnumerator = _source.GetAsyncEnumerator(cancellationToken);
+                        _mode = State_Source;
                         state = AsyncIteratorState.Iterating;
                         goto case AsyncIteratorState.Iterating;
 
                     case AsyncIteratorState.Iterating:
-                        switch (mode)
+                        switch (_mode)
                         {
                             case State_Source:
-                                if (await sourceEnumerator.MoveNextAsync().ConfigureAwait(false))
+                                if (await _sourceEnumerator.MoveNextAsync().ConfigureAwait(false))
                                 {
-                                    if (resultEnumerator != null)
+                                    if (_resultEnumerator != null)
                                     {
-                                        await resultEnumerator.DisposeAsync().ConfigureAwait(false);
+                                        await _resultEnumerator.DisposeAsync().ConfigureAwait(false);
                                     }
 
-                                    currentSource = sourceEnumerator.Current;
-                                    var inner = collectionSelector(currentSource);
-                                    resultEnumerator = inner.GetAsyncEnumerator(cancellationToken);
+                                    _currentSource = _sourceEnumerator.Current;
+                                    var inner = _collectionSelector(_currentSource);
+                                    _resultEnumerator = inner.GetAsyncEnumerator(cancellationToken);
 
-                                    mode = State_Result;
+                                    _mode = State_Result;
                                     goto case State_Result;
                                 }
                                 break;
 
                             case State_Result:
-                                if (await resultEnumerator.MoveNextAsync().ConfigureAwait(false))
+                                if (await _resultEnumerator.MoveNextAsync().ConfigureAwait(false))
                                 {
-                                    current = resultSelector(currentSource, resultEnumerator.Current);
+                                    current = _resultSelector(_currentSource, _resultEnumerator.Current);
                                     return true;
                                 }
 
-                                mode = State_Source;
+                                _mode = State_Source;
                                 goto case State_Source; // loop
                         }
 
@@ -384,14 +384,14 @@ namespace System.Linq
             private const int State_Source = 1;
             private const int State_Result = 2;
 
-            private readonly Func<TSource, Task<IAsyncEnumerable<TCollection>>> collectionSelector;
-            private readonly Func<TSource, TCollection, Task<TResult>> resultSelector;
-            private readonly IAsyncEnumerable<TSource> source;
+            private readonly Func<TSource, Task<IAsyncEnumerable<TCollection>>> _collectionSelector;
+            private readonly Func<TSource, TCollection, Task<TResult>> _resultSelector;
+            private readonly IAsyncEnumerable<TSource> _source;
 
-            private TSource currentSource;
-            private int mode;
-            private IAsyncEnumerator<TCollection> resultEnumerator;
-            private IAsyncEnumerator<TSource> sourceEnumerator;
+            private TSource _currentSource;
+            private int _mode;
+            private IAsyncEnumerator<TCollection> _resultEnumerator;
+            private IAsyncEnumerator<TSource> _sourceEnumerator;
 
             public SelectManyAsyncIteratorWithTask(IAsyncEnumerable<TSource> source, Func<TSource, Task<IAsyncEnumerable<TCollection>>> collectionSelector, Func<TSource, TCollection, Task<TResult>> resultSelector)
             {
@@ -399,31 +399,31 @@ namespace System.Linq
                 Debug.Assert(collectionSelector != null);
                 Debug.Assert(resultSelector != null);
 
-                this.source = source;
-                this.collectionSelector = collectionSelector;
-                this.resultSelector = resultSelector;
+                _source = source;
+                _collectionSelector = collectionSelector;
+                _resultSelector = resultSelector;
             }
 
             public override AsyncIterator<TResult> Clone()
             {
-                return new SelectManyAsyncIteratorWithTask<TSource, TCollection, TResult>(source, collectionSelector, resultSelector);
+                return new SelectManyAsyncIteratorWithTask<TSource, TCollection, TResult>(_source, _collectionSelector, _resultSelector);
             }
 
             public override async ValueTask DisposeAsync()
             {
-                if (sourceEnumerator != null)
+                if (_sourceEnumerator != null)
                 {
-                    await sourceEnumerator.DisposeAsync().ConfigureAwait(false);
-                    sourceEnumerator = null;
+                    await _sourceEnumerator.DisposeAsync().ConfigureAwait(false);
+                    _sourceEnumerator = null;
                 }
 
-                if (resultEnumerator != null)
+                if (_resultEnumerator != null)
                 {
-                    await resultEnumerator.DisposeAsync().ConfigureAwait(false);
-                    resultEnumerator = null;
+                    await _resultEnumerator.DisposeAsync().ConfigureAwait(false);
+                    _resultEnumerator = null;
                 }
 
-                currentSource = default(TSource);
+                _currentSource = default(TSource);
 
                 await base.DisposeAsync().ConfigureAwait(false);
             }
@@ -433,39 +433,39 @@ namespace System.Linq
                 switch (state)
                 {
                     case AsyncIteratorState.Allocated:
-                        sourceEnumerator = source.GetAsyncEnumerator(cancellationToken);
-                        mode = State_Source;
+                        _sourceEnumerator = _source.GetAsyncEnumerator(cancellationToken);
+                        _mode = State_Source;
                         state = AsyncIteratorState.Iterating;
                         goto case AsyncIteratorState.Iterating;
 
                     case AsyncIteratorState.Iterating:
-                        switch (mode)
+                        switch (_mode)
                         {
                             case State_Source:
-                                if (await sourceEnumerator.MoveNextAsync().ConfigureAwait(false))
+                                if (await _sourceEnumerator.MoveNextAsync().ConfigureAwait(false))
                                 {
-                                    if (resultEnumerator != null)
+                                    if (_resultEnumerator != null)
                                     {
-                                        await resultEnumerator.DisposeAsync().ConfigureAwait(false);
+                                        await _resultEnumerator.DisposeAsync().ConfigureAwait(false);
                                     }
 
-                                    currentSource = sourceEnumerator.Current;
-                                    var inner = await collectionSelector(currentSource).ConfigureAwait(false);
-                                    resultEnumerator = inner.GetAsyncEnumerator(cancellationToken);
+                                    _currentSource = _sourceEnumerator.Current;
+                                    var inner = await _collectionSelector(_currentSource).ConfigureAwait(false);
+                                    _resultEnumerator = inner.GetAsyncEnumerator(cancellationToken);
 
-                                    mode = State_Result;
+                                    _mode = State_Result;
                                     goto case State_Result;
                                 }
                                 break;
 
                             case State_Result:
-                                if (await resultEnumerator.MoveNextAsync().ConfigureAwait(false))
+                                if (await _resultEnumerator.MoveNextAsync().ConfigureAwait(false))
                                 {
-                                    current = await resultSelector(currentSource, resultEnumerator.Current).ConfigureAwait(false);
+                                    current = await _resultSelector(_currentSource, _resultEnumerator.Current).ConfigureAwait(false);
                                     return true;
                                 }
 
-                                mode = State_Source;
+                                _mode = State_Source;
                                 goto case State_Source; // loop
                         }
 
@@ -482,15 +482,15 @@ 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 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;
-            private IAsyncEnumerator<TCollection> resultEnumerator;
-            private IAsyncEnumerator<TSource> sourceEnumerator;
+            private TSource _currentSource;
+            private int _index;
+            private int _mode;
+            private IAsyncEnumerator<TCollection> _resultEnumerator;
+            private IAsyncEnumerator<TSource> _sourceEnumerator;
 
             public SelectManyWithIndexAsyncIterator(IAsyncEnumerable<TSource> source, Func<TSource, int, IAsyncEnumerable<TCollection>> collectionSelector, Func<TSource, TCollection, TResult> resultSelector)
             {
@@ -498,31 +498,31 @@ namespace System.Linq
                 Debug.Assert(collectionSelector != null);
                 Debug.Assert(resultSelector != null);
 
-                this.source = source;
-                this.collectionSelector = collectionSelector;
-                this.resultSelector = resultSelector;
+                _source = source;
+                _collectionSelector = collectionSelector;
+                _resultSelector = resultSelector;
             }
 
             public override AsyncIterator<TResult> Clone()
             {
-                return new SelectManyWithIndexAsyncIterator<TSource, TCollection, TResult>(source, collectionSelector, resultSelector);
+                return new SelectManyWithIndexAsyncIterator<TSource, TCollection, TResult>(_source, _collectionSelector, _resultSelector);
             }
 
             public override async ValueTask DisposeAsync()
             {
-                if (sourceEnumerator != null)
+                if (_sourceEnumerator != null)
                 {
-                    await sourceEnumerator.DisposeAsync().ConfigureAwait(false);
-                    sourceEnumerator = null;
+                    await _sourceEnumerator.DisposeAsync().ConfigureAwait(false);
+                    _sourceEnumerator = null;
                 }
 
-                if (resultEnumerator != null)
+                if (_resultEnumerator != null)
                 {
-                    await resultEnumerator.DisposeAsync().ConfigureAwait(false);
-                    resultEnumerator = null;
+                    await _resultEnumerator.DisposeAsync().ConfigureAwait(false);
+                    _resultEnumerator = null;
                 }
 
-                currentSource = default(TSource);
+                _currentSource = default(TSource);
 
                 await base.DisposeAsync().ConfigureAwait(false);
             }
@@ -532,46 +532,46 @@ namespace System.Linq
                 switch (state)
                 {
                     case AsyncIteratorState.Allocated:
-                        sourceEnumerator = source.GetAsyncEnumerator(cancellationToken);
-                        index = -1;
-                        mode = State_Source;
+                        _sourceEnumerator = _source.GetAsyncEnumerator(cancellationToken);
+                        _index = -1;
+                        _mode = State_Source;
                         state = AsyncIteratorState.Iterating;
                         goto case AsyncIteratorState.Iterating;
 
                     case AsyncIteratorState.Iterating:
-                        switch (mode)
+                        switch (_mode)
                         {
                             case State_Source:
-                                if (await sourceEnumerator.MoveNextAsync().ConfigureAwait(false))
+                                if (await _sourceEnumerator.MoveNextAsync().ConfigureAwait(false))
                                 {
-                                    if (resultEnumerator != null)
+                                    if (_resultEnumerator != null)
                                     {
-                                        await resultEnumerator.DisposeAsync().ConfigureAwait(false);
+                                        await _resultEnumerator.DisposeAsync().ConfigureAwait(false);
                                     }
 
-                                    currentSource = sourceEnumerator.Current;
+                                    _currentSource = _sourceEnumerator.Current;
 
                                     checked
                                     {
-                                        index++;
+                                        _index++;
                                     }
 
-                                    var inner = collectionSelector(currentSource, index);
-                                    resultEnumerator = inner.GetAsyncEnumerator(cancellationToken);
+                                    var inner = _collectionSelector(_currentSource, _index);
+                                    _resultEnumerator = inner.GetAsyncEnumerator(cancellationToken);
 
-                                    mode = State_Result;
+                                    _mode = State_Result;
                                     goto case State_Result;
                                 }
                                 break;
 
                             case State_Result:
-                                if (await resultEnumerator.MoveNextAsync().ConfigureAwait(false))
+                                if (await _resultEnumerator.MoveNextAsync().ConfigureAwait(false))
                                 {
-                                    current = resultSelector(currentSource, resultEnumerator.Current);
+                                    current = _resultSelector(_currentSource, _resultEnumerator.Current);
                                     return true;
                                 }
 
-                                mode = State_Source;
+                                _mode = State_Source;
                                 goto case State_Source; // loop
                         }
 
@@ -588,15 +588,15 @@ namespace System.Linq
             private const int State_Source = 1;
             private const int State_Result = 2;
 
-            private readonly Func<TSource, int, Task<IAsyncEnumerable<TCollection>>> collectionSelector;
-            private readonly Func<TSource, TCollection, Task<TResult>> resultSelector;
-            private readonly IAsyncEnumerable<TSource> source;
+            private readonly Func<TSource, int, Task<IAsyncEnumerable<TCollection>>> _collectionSelector;
+            private readonly Func<TSource, TCollection, Task<TResult>> _resultSelector;
+            private readonly IAsyncEnumerable<TSource> _source;
 
-            private TSource currentSource;
-            private int index;
-            private int mode;
-            private IAsyncEnumerator<TCollection> resultEnumerator;
-            private IAsyncEnumerator<TSource> sourceEnumerator;
+            private TSource _currentSource;
+            private int _index;
+            private int _mode;
+            private IAsyncEnumerator<TCollection> _resultEnumerator;
+            private IAsyncEnumerator<TSource> _sourceEnumerator;
 
             public SelectManyWithIndexAsyncIteratorWithTask(IAsyncEnumerable<TSource> source, Func<TSource, int, Task<IAsyncEnumerable<TCollection>>> collectionSelector, Func<TSource, TCollection, Task<TResult>> resultSelector)
             {
@@ -604,31 +604,31 @@ namespace System.Linq
                 Debug.Assert(collectionSelector != null);
                 Debug.Assert(resultSelector != null);
 
-                this.source = source;
-                this.collectionSelector = collectionSelector;
-                this.resultSelector = resultSelector;
+                _source = source;
+                _collectionSelector = collectionSelector;
+                _resultSelector = resultSelector;
             }
 
             public override AsyncIterator<TResult> Clone()
             {
-                return new SelectManyWithIndexAsyncIteratorWithTask<TSource, TCollection, TResult>(source, collectionSelector, resultSelector);
+                return new SelectManyWithIndexAsyncIteratorWithTask<TSource, TCollection, TResult>(_source, _collectionSelector, _resultSelector);
             }
 
             public override async ValueTask DisposeAsync()
             {
-                if (sourceEnumerator != null)
+                if (_sourceEnumerator != null)
                 {
-                    await sourceEnumerator.DisposeAsync().ConfigureAwait(false);
-                    sourceEnumerator = null;
+                    await _sourceEnumerator.DisposeAsync().ConfigureAwait(false);
+                    _sourceEnumerator = null;
                 }
 
-                if (resultEnumerator != null)
+                if (_resultEnumerator != null)
                 {
-                    await resultEnumerator.DisposeAsync().ConfigureAwait(false);
-                    resultEnumerator = null;
+                    await _resultEnumerator.DisposeAsync().ConfigureAwait(false);
+                    _resultEnumerator = null;
                 }
 
-                currentSource = default(TSource);
+                _currentSource = default(TSource);
 
                 await base.DisposeAsync().ConfigureAwait(false);
             }
@@ -638,46 +638,46 @@ namespace System.Linq
                 switch (state)
                 {
                     case AsyncIteratorState.Allocated:
-                        sourceEnumerator = source.GetAsyncEnumerator(cancellationToken);
-                        index = -1;
-                        mode = State_Source;
+                        _sourceEnumerator = _source.GetAsyncEnumerator(cancellationToken);
+                        _index = -1;
+                        _mode = State_Source;
                         state = AsyncIteratorState.Iterating;
                         goto case AsyncIteratorState.Iterating;
 
                     case AsyncIteratorState.Iterating:
-                        switch (mode)
+                        switch (_mode)
                         {
                             case State_Source:
-                                if (await sourceEnumerator.MoveNextAsync().ConfigureAwait(false))
+                                if (await _sourceEnumerator.MoveNextAsync().ConfigureAwait(false))
                                 {
-                                    if (resultEnumerator != null)
+                                    if (_resultEnumerator != null)
                                     {
-                                        await resultEnumerator.DisposeAsync().ConfigureAwait(false);
+                                        await _resultEnumerator.DisposeAsync().ConfigureAwait(false);
                                     }
 
-                                    currentSource = sourceEnumerator.Current;
+                                    _currentSource = _sourceEnumerator.Current;
 
                                     checked
                                     {
-                                        index++;
+                                        _index++;
                                     }
 
-                                    var inner = await collectionSelector(currentSource, index).ConfigureAwait(false);
-                                    resultEnumerator = inner.GetAsyncEnumerator(cancellationToken);
+                                    var inner = await _collectionSelector(_currentSource, _index).ConfigureAwait(false);
+                                    _resultEnumerator = inner.GetAsyncEnumerator(cancellationToken);
 
-                                    mode = State_Result;
+                                    _mode = State_Result;
                                     goto case State_Result;
                                 }
                                 break;
 
                             case State_Result:
-                                if (await resultEnumerator.MoveNextAsync().ConfigureAwait(false))
+                                if (await _resultEnumerator.MoveNextAsync().ConfigureAwait(false))
                                 {
-                                    current = await resultSelector(currentSource, resultEnumerator.Current).ConfigureAwait(false);
+                                    current = await _resultSelector(_currentSource, _resultEnumerator.Current).ConfigureAwait(false);
                                     return true;
                                 }
 
-                                mode = State_Source;
+                                _mode = State_Source;
                                 goto case State_Source; // loop
                         }
 
@@ -694,40 +694,40 @@ 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 readonly Func<TSource, int, IAsyncEnumerable<TResult>> _selector;
+            private readonly IAsyncEnumerable<TSource> _source;
 
-            private int index;
-            private int mode;
-            private IAsyncEnumerator<TResult> resultEnumerator;
-            private IAsyncEnumerator<TSource> sourceEnumerator;
+            private int _index;
+            private int _mode;
+            private IAsyncEnumerator<TResult> _resultEnumerator;
+            private IAsyncEnumerator<TSource> _sourceEnumerator;
 
             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;
+                _source = source;
+                _selector = selector;
             }
 
             public override AsyncIterator<TResult> Clone()
             {
-                return new SelectManyWithIndexAsyncIterator<TSource, TResult>(source, selector);
+                return new SelectManyWithIndexAsyncIterator<TSource, TResult>(_source, _selector);
             }
 
             public override async ValueTask DisposeAsync()
             {
-                if (sourceEnumerator != null)
+                if (_sourceEnumerator != null)
                 {
-                    await sourceEnumerator.DisposeAsync().ConfigureAwait(false);
-                    sourceEnumerator = null;
+                    await _sourceEnumerator.DisposeAsync().ConfigureAwait(false);
+                    _sourceEnumerator = null;
                 }
 
-                if (resultEnumerator != null)
+                if (_resultEnumerator != null)
                 {
-                    await resultEnumerator.DisposeAsync().ConfigureAwait(false);
-                    resultEnumerator = null;
+                    await _resultEnumerator.DisposeAsync().ConfigureAwait(false);
+                    _resultEnumerator = null;
                 }
 
                 await base.DisposeAsync().ConfigureAwait(false);
@@ -738,44 +738,44 @@ namespace System.Linq
                 switch (state)
                 {
                     case AsyncIteratorState.Allocated:
-                        sourceEnumerator = source.GetAsyncEnumerator(cancellationToken);
-                        index = -1;
-                        mode = State_Source;
+                        _sourceEnumerator = _source.GetAsyncEnumerator(cancellationToken);
+                        _index = -1;
+                        _mode = State_Source;
                         state = AsyncIteratorState.Iterating;
                         goto case AsyncIteratorState.Iterating;
 
                     case AsyncIteratorState.Iterating:
-                        switch (mode)
+                        switch (_mode)
                         {
                             case State_Source:
-                                if (await sourceEnumerator.MoveNextAsync().ConfigureAwait(false))
+                                if (await _sourceEnumerator.MoveNextAsync().ConfigureAwait(false))
                                 {
-                                    if (resultEnumerator != null)
+                                    if (_resultEnumerator != null)
                                     {
-                                        await resultEnumerator.DisposeAsync().ConfigureAwait(false);
+                                        await _resultEnumerator.DisposeAsync().ConfigureAwait(false);
                                     }
 
                                     checked
                                     {
-                                        index++;
+                                        _index++;
                                     }
 
-                                    var inner = selector(sourceEnumerator.Current, index);
-                                    resultEnumerator = inner.GetAsyncEnumerator(cancellationToken);
+                                    var inner = _selector(_sourceEnumerator.Current, _index);
+                                    _resultEnumerator = inner.GetAsyncEnumerator(cancellationToken);
 
-                                    mode = State_Result;
+                                    _mode = State_Result;
                                     goto case State_Result;
                                 }
                                 break;
 
                             case State_Result:
-                                if (await resultEnumerator.MoveNextAsync().ConfigureAwait(false))
+                                if (await _resultEnumerator.MoveNextAsync().ConfigureAwait(false))
                                 {
-                                    current = resultEnumerator.Current;
+                                    current = _resultEnumerator.Current;
                                     return true;
                                 }
 
-                                mode = State_Source;
+                                _mode = State_Source;
                                 goto case State_Source; // loop
                         }
 
@@ -792,40 +792,40 @@ namespace System.Linq
             private const int State_Source = 1;
             private const int State_Result = 2;
 
-            private readonly Func<TSource, int, Task<IAsyncEnumerable<TResult>>> selector;
-            private readonly IAsyncEnumerable<TSource> source;
+            private readonly Func<TSource, int, Task<IAsyncEnumerable<TResult>>> _selector;
+            private readonly IAsyncEnumerable<TSource> _source;
 
-            private int index;
-            private int mode;
-            private IAsyncEnumerator<TResult> resultEnumerator;
-            private IAsyncEnumerator<TSource> sourceEnumerator;
+            private int _index;
+            private int _mode;
+            private IAsyncEnumerator<TResult> _resultEnumerator;
+            private IAsyncEnumerator<TSource> _sourceEnumerator;
 
             public SelectManyWithIndexAsyncIteratorWithTask(IAsyncEnumerable<TSource> source, Func<TSource, int, Task<IAsyncEnumerable<TResult>>> selector)
             {
                 Debug.Assert(source != null);
                 Debug.Assert(selector != null);
 
-                this.source = source;
-                this.selector = selector;
+                _source = source;
+                _selector = selector;
             }
 
             public override AsyncIterator<TResult> Clone()
             {
-                return new SelectManyWithIndexAsyncIteratorWithTask<TSource, TResult>(source, selector);
+                return new SelectManyWithIndexAsyncIteratorWithTask<TSource, TResult>(_source, _selector);
             }
 
             public override async ValueTask DisposeAsync()
             {
-                if (sourceEnumerator != null)
+                if (_sourceEnumerator != null)
                 {
-                    await sourceEnumerator.DisposeAsync().ConfigureAwait(false);
-                    sourceEnumerator = null;
+                    await _sourceEnumerator.DisposeAsync().ConfigureAwait(false);
+                    _sourceEnumerator = null;
                 }
 
-                if (resultEnumerator != null)
+                if (_resultEnumerator != null)
                 {
-                    await resultEnumerator.DisposeAsync().ConfigureAwait(false);
-                    resultEnumerator = null;
+                    await _resultEnumerator.DisposeAsync().ConfigureAwait(false);
+                    _resultEnumerator = null;
                 }
 
                 await base.DisposeAsync().ConfigureAwait(false);
@@ -836,44 +836,44 @@ namespace System.Linq
                 switch (state)
                 {
                     case AsyncIteratorState.Allocated:
-                        sourceEnumerator = source.GetAsyncEnumerator(cancellationToken);
-                        index = -1;
-                        mode = State_Source;
+                        _sourceEnumerator = _source.GetAsyncEnumerator(cancellationToken);
+                        _index = -1;
+                        _mode = State_Source;
                         state = AsyncIteratorState.Iterating;
                         goto case AsyncIteratorState.Iterating;
 
                     case AsyncIteratorState.Iterating:
-                        switch (mode)
+                        switch (_mode)
                         {
                             case State_Source:
-                                if (await sourceEnumerator.MoveNextAsync().ConfigureAwait(false))
+                                if (await _sourceEnumerator.MoveNextAsync().ConfigureAwait(false))
                                 {
-                                    if (resultEnumerator != null)
+                                    if (_resultEnumerator != null)
                                     {
-                                        await resultEnumerator.DisposeAsync().ConfigureAwait(false);
+                                        await _resultEnumerator.DisposeAsync().ConfigureAwait(false);
                                     }
 
                                     checked
                                     {
-                                        index++;
+                                        _index++;
                                     }
 
-                                    var inner = await selector(sourceEnumerator.Current, index).ConfigureAwait(false);
-                                    resultEnumerator = inner.GetAsyncEnumerator(cancellationToken);
+                                    var inner = await _selector(_sourceEnumerator.Current, _index).ConfigureAwait(false);
+                                    _resultEnumerator = inner.GetAsyncEnumerator(cancellationToken);
 
-                                    mode = State_Result;
+                                    _mode = State_Result;
                                     goto case State_Result;
                                 }
                                 break;
 
                             case State_Result:
-                                if (await resultEnumerator.MoveNextAsync().ConfigureAwait(false))
+                                if (await _resultEnumerator.MoveNextAsync().ConfigureAwait(false))
                                 {
-                                    current = resultEnumerator.Current;
+                                    current = _resultEnumerator.Current;
                                     return true;
                                 }
 
-                                mode = State_Source;
+                                _mode = State_Source;
                                 goto case State_Source; // loop
                         }