浏览代码

Cleaning up Ix code.

Bart De Smet 8 年之前
父节点
当前提交
94924c06c3
共有 29 个文件被更改,包括 194 次插入106 次删除
  1. 13 6
      Ix.NET/Source/System.Interactive/System/Linq/Operators/Buffer.cs
  2. 8 8
      Ix.NET/Source/System.Interactive/System/Linq/Operators/Case.cs
  3. 8 6
      Ix.NET/Source/System.Interactive/System/Linq/Operators/Catch.cs
  4. 7 3
      Ix.NET/Source/System.Interactive/System/Linq/Operators/Concat.cs
  5. 2 0
      Ix.NET/Source/System.Interactive/System/Linq/Operators/Create.cs
  6. 4 2
      Ix.NET/Source/System.Interactive/System/Linq/Operators/Defer.cs
  7. 6 3
      Ix.NET/Source/System.Interactive/System/Linq/Operators/Distinct.cs
  8. 6 5
      Ix.NET/Source/System.Interactive/System/Linq/Operators/DistinctUntilChanged.cs
  9. 7 23
      Ix.NET/Source/System.Interactive/System/Linq/Operators/Do.cs
  10. 28 0
      Ix.NET/Source/System.Interactive/System/Linq/Operators/DoWhile.cs
  11. 2 2
      Ix.NET/Source/System.Interactive/System/Linq/Operators/Expand.cs
  12. 4 2
      Ix.NET/Source/System.Interactive/System/Linq/Operators/Finally.cs
  13. 1 2
      Ix.NET/Source/System.Interactive/System/Linq/Operators/For.cs
  14. 4 0
      Ix.NET/Source/System.Interactive/System/Linq/Operators/ForEach.cs
  15. 4 2
      Ix.NET/Source/System.Interactive/System/Linq/Operators/Generate.cs
  16. 6 4
      Ix.NET/Source/System.Interactive/System/Linq/Operators/Hide.cs
  17. 3 3
      Ix.NET/Source/System.Interactive/System/Linq/Operators/IgnoreElements.cs
  18. 1 4
      Ix.NET/Source/System.Interactive/System/Linq/Operators/MaxBy.cs
  19. 5 4
      Ix.NET/Source/System.Interactive/System/Linq/Operators/OnErrorResumeNext.cs
  20. 17 5
      Ix.NET/Source/System.Interactive/System/Linq/Operators/Publish.cs
  21. 14 4
      Ix.NET/Source/System.Interactive/System/Linq/Operators/Repeat.cs
  22. 6 4
      Ix.NET/Source/System.Interactive/System/Linq/Operators/Scan.cs
  23. 9 2
      Ix.NET/Source/System.Interactive/System/Linq/Operators/Share.cs
  24. 5 2
      Ix.NET/Source/System.Interactive/System/Linq/Operators/SkipLast.cs
  25. 6 2
      Ix.NET/Source/System.Interactive/System/Linq/Operators/StartsWith.cs
  26. 7 2
      Ix.NET/Source/System.Interactive/System/Linq/Operators/TakeLast.cs
  27. 2 2
      Ix.NET/Source/System.Interactive/System/Linq/Operators/Throw.cs
  28. 6 2
      Ix.NET/Source/System.Interactive/System/Linq/Operators/Using.cs
  29. 3 2
      Ix.NET/Source/System.Interactive/System/Linq/Operators/While.cs

+ 13 - 6
Ix.NET/Source/System.Interactive/System/Linq/Operators/Buffer.cs

@@ -22,7 +22,7 @@ namespace System.Linq
             if (count <= 0)
                 throw new ArgumentOutOfRangeException(nameof(count));
 
-            return source.Buffer_(count, count);
+            return BufferCore(source, count, count);
         }
 
         /// <summary>
@@ -42,31 +42,38 @@ namespace System.Linq
             if (skip <= 0)
                 throw new ArgumentOutOfRangeException(nameof(skip));
 
-            return source.Buffer_(count, skip);
+            return BufferCore(source, count, skip);
         }
 
-        private static IEnumerable<IList<TSource>> Buffer_<TSource>(this IEnumerable<TSource> source, int count, int skip)
+        private static IEnumerable<IList<TSource>> BufferCore<TSource>(IEnumerable<TSource> source, int count, int skip)
         {
             var buffers = new Queue<IList<TSource>>();
 
             var i = 0;
             foreach (var item in source)
             {
-                if (i%skip == 0)
+                if (i % skip == 0)
+                {
                     buffers.Enqueue(new List<TSource>(count));
+                }
 
                 foreach (var buffer in buffers)
+                {
                     buffer.Add(item);
+                }
 
-                if (buffers.Count > 0 && buffers.Peek()
-                                                .Count == count)
+                if (buffers.Count > 0 && buffers.Peek().Count == count)
+                {
                     yield return buffers.Dequeue();
+                }
 
                 i++;
             }
 
             while (buffers.Count > 0)
+            {
                 yield return buffers.Dequeue();
+            }
         }
     }
 }

+ 8 - 8
Ix.NET/Source/System.Interactive/System/Linq/Operators/Case.cs

@@ -2,10 +2,7 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System;
 using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
 
 namespace System.Linq
 {
@@ -52,11 +49,14 @@ namespace System.Linq
                 throw new ArgumentNullException(nameof(defaultSource));
 
             return Defer(() =>
-                         {
-                             if (!sources.TryGetValue(selector(), out var result))
-                                 result = defaultSource;
-                             return result;
-                         });
+            {
+                if (!sources.TryGetValue(selector(), out var result))
+                {
+                    result = defaultSource;
+                }
+
+                return result;
+            });
         }
     }
 }

+ 8 - 6
Ix.NET/Source/System.Interactive/System/Linq/Operators/Catch.cs

@@ -25,7 +25,7 @@ namespace System.Linq
             if (handler == null)
                 throw new ArgumentNullException(nameof(handler));
 
-            return source.Catch_(handler);
+            return CatchCore(source, handler);
         }
 
         /// <summary>
@@ -39,7 +39,7 @@ namespace System.Linq
             if (sources == null)
                 throw new ArgumentNullException(nameof(sources));
 
-            return sources.Catch_();
+            return CatchCore(sources);
         }
 
         /// <summary>
@@ -53,7 +53,7 @@ namespace System.Linq
             if (sources == null)
                 throw new ArgumentNullException(nameof(sources));
 
-            return sources.Catch_();
+            return CatchCore(sources);
         }
 
         /// <summary>
@@ -70,10 +70,10 @@ namespace System.Linq
             if (second == null)
                 throw new ArgumentNullException(nameof(second));
 
-            return new[] {first, second}.Catch_();
+            return CatchCore(new[] { first, second });
         }
 
-        private static IEnumerable<TSource> Catch_<TSource, TException>(this IEnumerable<TSource> source, Func<TException, IEnumerable<TSource>> handler)
+        private static IEnumerable<TSource> CatchCore<TSource, TException>(IEnumerable<TSource> source, Func<TException, IEnumerable<TSource>> handler)
             where TException : Exception
         {
             var err = default(IEnumerable<TSource>);
@@ -104,11 +104,13 @@ namespace System.Linq
             if (err != null)
             {
                 foreach (var item in err)
+                {
                     yield return item;
+                }
             }
         }
 
-        private static IEnumerable<TSource> Catch_<TSource>(this IEnumerable<IEnumerable<TSource>> sources)
+        private static IEnumerable<TSource> CatchCore<TSource>(IEnumerable<IEnumerable<TSource>> sources)
         {
             var error = default(Exception);
 

+ 7 - 3
Ix.NET/Source/System.Interactive/System/Linq/Operators/Concat.cs

@@ -19,7 +19,7 @@ namespace System.Linq
             if (sources == null)
                 throw new ArgumentNullException(nameof(sources));
 
-            return sources.Concat_();
+            return ConcatCore(sources);
         }
 
         /// <summary>
@@ -33,14 +33,18 @@ namespace System.Linq
             if (sources == null)
                 throw new ArgumentNullException(nameof(sources));
 
-            return sources.Concat_();
+            return ConcatCore(sources);
         }
 
-        private static IEnumerable<TSource> Concat_<TSource>(this IEnumerable<IEnumerable<TSource>> sources)
+        private static IEnumerable<TSource> ConcatCore<TSource>(IEnumerable<IEnumerable<TSource>> sources)
         {
             foreach (var source in sources)
+            {
                 foreach (var item in source)
+                {
                     yield return item;
+                }
+            }
         }
     }
 }

+ 2 - 0
Ix.NET/Source/System.Interactive/System/Linq/Operators/Create.cs

@@ -38,7 +38,9 @@ namespace System.Linq
                 throw new ArgumentNullException(nameof(create));
 
             foreach (var x in new Yielder<T>(create))
+            {
                 yield return x;
+            }
         }
 
         private sealed class AnonymousEnumerable<TResult> : IEnumerable<TResult>

+ 4 - 2
Ix.NET/Source/System.Interactive/System/Linq/Operators/Defer.cs

@@ -19,13 +19,15 @@ namespace System.Linq
             if (enumerableFactory == null)
                 throw new ArgumentNullException(nameof(enumerableFactory));
 
-            return Defer_(enumerableFactory);
+            return DeferCore(enumerableFactory);
         }
 
-        private static IEnumerable<TSource> Defer_<TSource>(Func<IEnumerable<TSource>> enumerableFactory)
+        private static IEnumerable<TSource> DeferCore<TSource>(Func<IEnumerable<TSource>> enumerableFactory)
         {
             foreach (var item in enumerableFactory())
+            {
                 yield return item;
+            }
         }
     }
 }

+ 6 - 3
Ix.NET/Source/System.Interactive/System/Linq/Operators/Distinct.cs

@@ -23,7 +23,7 @@ namespace System.Linq
             if (keySelector == null)
                 throw new ArgumentNullException(nameof(keySelector));
 
-            return source.Distinct_(keySelector, EqualityComparer<TKey>.Default);
+            return DistinctCore(source, keySelector, EqualityComparer<TKey>.Default);
         }
 
         /// <summary>
@@ -44,18 +44,21 @@ namespace System.Linq
             if (comparer == null)
                 throw new ArgumentNullException(nameof(comparer));
 
-            return source.Distinct_(keySelector, comparer);
+            return DistinctCore(source, keySelector, comparer);
         }
 
-        private static IEnumerable<TSource> Distinct_<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
+        private static IEnumerable<TSource> DistinctCore<TSource, TKey>(IEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
         {
             var set = new HashSet<TKey>(comparer);
 
             foreach (var item in source)
             {
                 var key = keySelector(item);
+
                 if (set.Add(key))
+                {
                     yield return item;
+                }
             }
         }
     }

+ 6 - 5
Ix.NET/Source/System.Interactive/System/Linq/Operators/DistinctUntilChanged.cs

@@ -19,7 +19,7 @@ namespace System.Linq
             if (source == null)
                 throw new ArgumentNullException(nameof(source));
 
-            return source.DistinctUntilChanged_(x => x, EqualityComparer<TSource>.Default);
+            return DistinctUntilChangedCore(source, x => x, EqualityComparer<TSource>.Default);
         }
 
         /// <summary>
@@ -36,7 +36,7 @@ namespace System.Linq
             if (comparer == null)
                 throw new ArgumentNullException(nameof(comparer));
 
-            return source.DistinctUntilChanged_(x => x, comparer);
+            return DistinctUntilChangedCore(source, x => x, comparer);
         }
 
         /// <summary>
@@ -54,7 +54,7 @@ namespace System.Linq
             if (keySelector == null)
                 throw new ArgumentNullException(nameof(keySelector));
 
-            return source.DistinctUntilChanged_(keySelector, EqualityComparer<TKey>.Default);
+            return DistinctUntilChangedCore(source, keySelector, EqualityComparer<TKey>.Default);
         }
 
         /// <summary>
@@ -75,10 +75,10 @@ namespace System.Linq
             if (comparer == null)
                 throw new ArgumentNullException(nameof(comparer));
 
-            return source.DistinctUntilChanged_(keySelector, comparer);
+            return DistinctUntilChangedCore(source, keySelector, comparer);
         }
 
-        private static IEnumerable<TSource> DistinctUntilChanged_<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
+        private static IEnumerable<TSource> DistinctUntilChangedCore<TSource, TKey>(IEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
         {
             var currentKey = default(TKey);
             var hasCurrentKey = false;
@@ -97,6 +97,7 @@ namespace System.Linq
                 {
                     hasCurrentKey = true;
                     currentKey = key;
+
                     yield return item;
                 }
             }

+ 7 - 23
Ix.NET/Source/System.Interactive/System/Linq/Operators/Do.cs

@@ -22,7 +22,7 @@ namespace System.Linq
             if (onNext == null)
                 throw new ArgumentNullException(nameof(onNext));
 
-            return DoHelper(source, onNext, _ => { }, () => { });
+            return DoCore(source, onNext, _ => { }, () => { });
         }
 
         /// <summary>
@@ -42,7 +42,7 @@ namespace System.Linq
             if (onCompleted == null)
                 throw new ArgumentNullException(nameof(onCompleted));
 
-            return DoHelper(source, onNext, _ => { }, onCompleted);
+            return DoCore(source, onNext, _ => { }, onCompleted);
         }
 
         /// <summary>
@@ -62,7 +62,7 @@ namespace System.Linq
             if (onError == null)
                 throw new ArgumentNullException(nameof(onError));
 
-            return DoHelper(source, onNext, onError, () => { });
+            return DoCore(source, onNext, onError, () => { });
         }
 
         /// <summary>
@@ -86,7 +86,7 @@ namespace System.Linq
             if (onCompleted == null)
                 throw new ArgumentNullException(nameof(onCompleted));
 
-            return DoHelper(source, onNext, onError, onCompleted);
+            return DoCore(source, onNext, onError, onCompleted);
         }
 
         /// <summary>
@@ -103,27 +103,10 @@ namespace System.Linq
             if (observer == null)
                 throw new ArgumentNullException(nameof(observer));
 
-            return DoHelper(source, observer.OnNext, observer.OnError, observer.OnCompleted);
+            return DoCore(source, observer.OnNext, observer.OnError, observer.OnCompleted);
         }
 
-        /// <summary>
-        /// Generates an enumerable sequence by repeating a source sequence as long as the given loop postcondition holds.
-        /// </summary>
-        /// <typeparam name="TResult">Result sequence element type.</typeparam>
-        /// <param name="source">Source sequence to repeat while the condition evaluates true.</param>
-        /// <param name="condition">Loop condition.</param>
-        /// <returns>Sequence generated by repeating the given sequence until the condition evaluates to false.</returns>
-        public static IEnumerable<TResult> DoWhile<TResult>(this IEnumerable<TResult> source, Func<bool> condition)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-            if (condition == null)
-                throw new ArgumentNullException(nameof(condition));
-
-            return source.Concat(While(condition, source));
-        }
-
-        private static IEnumerable<TSource> DoHelper<TSource>(this IEnumerable<TSource> source, Action<TSource> onNext, Action<Exception> onError, Action onCompleted)
+        private static IEnumerable<TSource> DoCore<TSource>(IEnumerable<TSource> source, Action<TSource> onNext, Action<Exception> onError, Action onCompleted)
         {
             using (var e = source.GetEnumerator())
             {
@@ -144,6 +127,7 @@ namespace System.Linq
                     }
 
                     onNext(current);
+
                     yield return current;
                 }
 

+ 28 - 0
Ix.NET/Source/System.Interactive/System/Linq/Operators/DoWhile.cs

@@ -0,0 +1,28 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the Apache 2.0 License.
+// See the LICENSE file in the project root for more information. 
+
+using System.Collections.Generic;
+
+namespace System.Linq
+{
+    public static partial class EnumerableEx
+    {
+        /// <summary>
+        /// Generates an enumerable sequence by repeating a source sequence as long as the given loop postcondition holds.
+        /// </summary>
+        /// <typeparam name="TResult">Result sequence element type.</typeparam>
+        /// <param name="source">Source sequence to repeat while the condition evaluates true.</param>
+        /// <param name="condition">Loop condition.</param>
+        /// <returns>Sequence generated by repeating the given sequence until the condition evaluates to false.</returns>
+        public static IEnumerable<TResult> DoWhile<TResult>(this IEnumerable<TResult> source, Func<bool> condition)
+        {
+            if (source == null)
+                throw new ArgumentNullException(nameof(source));
+            if (condition == null)
+                throw new ArgumentNullException(nameof(condition));
+
+            return source.Concat(While(condition, source));
+        }
+    }
+}

+ 2 - 2
Ix.NET/Source/System.Interactive/System/Linq/Operators/Expand.cs

@@ -22,10 +22,10 @@ namespace System.Linq
             if (selector == null)
                 throw new ArgumentNullException(nameof(selector));
 
-            return source.Expand_(selector);
+            return ExpandCore(source, selector);
         }
 
-        private static IEnumerable<TSource> Expand_<TSource>(this IEnumerable<TSource> source, Func<TSource, IEnumerable<TSource>> selector)
+        private static IEnumerable<TSource> ExpandCore<TSource>(IEnumerable<TSource> source, Func<TSource, IEnumerable<TSource>> selector)
         {
             var queue = new Queue<IEnumerable<TSource>>();
             queue.Enqueue(source);

+ 4 - 2
Ix.NET/Source/System.Interactive/System/Linq/Operators/Finally.cs

@@ -22,15 +22,17 @@ namespace System.Linq
             if (finallyAction == null)
                 throw new ArgumentNullException(nameof(finallyAction));
 
-            return source.Finally_(finallyAction);
+            return FinallyCore(source, finallyAction);
         }
 
-        private static IEnumerable<TSource> Finally_<TSource>(this IEnumerable<TSource> source, Action finallyAction)
+        private static IEnumerable<TSource> FinallyCore<TSource>(IEnumerable<TSource> source, Action finallyAction)
         {
             try
             {
                 foreach (var item in source)
+                {
                     yield return item;
+                }
             }
             finally
             {

+ 1 - 2
Ix.NET/Source/System.Interactive/System/Linq/Operators/For.cs

@@ -27,8 +27,7 @@ namespace System.Linq
             if (resultSelector == null)
                 throw new ArgumentNullException(nameof(resultSelector));
 
-            return ForCore(source, resultSelector)
-                .Concat();
+            return ForCore(source, resultSelector).Concat();
         }
 
         private static IEnumerable<IEnumerable<TResult>> ForCore<TSource, TResult>(IEnumerable<TSource> source, Func<TSource, IEnumerable<TResult>> resultSelector)

+ 4 - 0
Ix.NET/Source/System.Interactive/System/Linq/Operators/ForEach.cs

@@ -22,7 +22,9 @@ namespace System.Linq
                 throw new ArgumentNullException(nameof(onNext));
 
             foreach (var item in source)
+            {
                 onNext(item);
+            }
         }
 
         /// <summary>
@@ -40,7 +42,9 @@ namespace System.Linq
 
             var i = 0;
             foreach (var item in source)
+            {
                 onNext(item, checked(i++));
+            }
         }
     }
 }

+ 4 - 2
Ix.NET/Source/System.Interactive/System/Linq/Operators/Generate.cs

@@ -27,13 +27,15 @@ namespace System.Linq
             if (resultSelector == null)
                 throw new ArgumentNullException(nameof(resultSelector));
 
-            return Generate_(initialState, condition, iterate, resultSelector);
+            return GenerateCore(initialState, condition, iterate, resultSelector);
         }
 
-        private static IEnumerable<TResult> Generate_<TState, TResult>(TState initialState, Func<TState, bool> condition, Func<TState, TState> iterate, Func<TState, TResult> resultSelector)
+        private static IEnumerable<TResult> GenerateCore<TState, TResult>(TState initialState, Func<TState, bool> condition, Func<TState, TState> iterate, Func<TState, TResult> resultSelector)
         {
             for (var i = initialState; condition(i); i = iterate(i))
+            {
                 yield return resultSelector(i);
+            }
         }
     }
 }

+ 6 - 4
Ix.NET/Source/System.Interactive/System/Linq/Operators/Hide.cs

@@ -15,21 +15,23 @@ namespace System.Linq
         /// <param name="source">Source sequence.</param>
         /// <returns>Enumerable sequence with the same behavior as the original, but hiding the source object identity.</returns>
         /// <remarks>
-        /// AsEnumerable doesn't hide the object identity, and simply acts as a cast to the IEnumerable&lt;TSource&gt;
-        /// interface.
+        /// <see cref="Enumerable.AsEnumerable{TSource}(IEnumerable{TSource})"/> doesn't hide the object identity, and simply acts as a cast
+        /// to the <see cref="IEnumerable{T}"/> interface type.
         /// </remarks>
         public static IEnumerable<TSource> Hide<TSource>(this IEnumerable<TSource> source)
         {
             if (source == null)
                 throw new ArgumentNullException(nameof(source));
 
-            return source.Hide_();
+            return HideCore(source);
         }
 
-        private static IEnumerable<TSource> Hide_<TSource>(this IEnumerable<TSource> source)
+        private static IEnumerable<TSource> HideCore<TSource>(this IEnumerable<TSource> source)
         {
             foreach (var item in source)
+            {
                 yield return item;
+            }
         }
     }
 }

+ 3 - 3
Ix.NET/Source/System.Interactive/System/Linq/Operators/IgnoreElements.cs

@@ -19,13 +19,13 @@ namespace System.Linq
             if (source == null)
                 throw new ArgumentNullException(nameof(source));
 
-            return source.IgnoreElements_();
+            return IgnoreElementsCore(source);
         }
 
-        private static IEnumerable<TSource> IgnoreElements_<TSource>(this IEnumerable<TSource> source)
+        private static IEnumerable<TSource> IgnoreElementsCore<TSource>(IEnumerable<TSource> source)
         {
             foreach (var item in source)
-            ;
+                ;
 
             yield break;
         }

+ 1 - 4
Ix.NET/Source/System.Interactive/System/Linq/Operators/MaxBy.cs

@@ -72,10 +72,7 @@ namespace System.Linq
                     }
                     else if (cmp > 0)
                     {
-                        result = new List<TSource>
-                        {
-                            cur
-                        };
+                        result = new List<TSource> { cur };
                         resKey = key;
                     }
                 }

+ 5 - 4
Ix.NET/Source/System.Interactive/System/Linq/Operators/OnErrorResumeNext.cs

@@ -22,7 +22,7 @@ namespace System.Linq
             if (second == null)
                 throw new ArgumentNullException(nameof(second));
 
-            return OnErrorResumeNext_(new[] { first, second });
+            return OnErrorResumeNextCore(new[] { first, second });
         }
 
         /// <summary>
@@ -37,7 +37,7 @@ namespace System.Linq
             if (sources == null)
                 throw new ArgumentNullException(nameof(sources));
 
-            return OnErrorResumeNext_(sources);
+            return OnErrorResumeNextCore(sources);
         }
 
         /// <summary>
@@ -52,10 +52,10 @@ namespace System.Linq
             if (sources == null)
                 throw new ArgumentNullException(nameof(sources));
 
-            return OnErrorResumeNext_(sources);
+            return OnErrorResumeNextCore(sources);
         }
 
-        private static IEnumerable<TSource> OnErrorResumeNext_<TSource>(IEnumerable<IEnumerable<TSource>> sources)
+        private static IEnumerable<TSource> OnErrorResumeNextCore<TSource>(IEnumerable<IEnumerable<TSource>> sources)
         {
             foreach (var source in sources)
             {
@@ -68,6 +68,7 @@ namespace System.Linq
                         {
                             if (!innerEnumerator.MoveNext())
                                 break;
+
                             value = innerEnumerator.Current;
                         }
                         catch

+ 17 - 5
Ix.NET/Source/System.Interactive/System/Linq/Operators/Publish.cs

@@ -56,11 +56,10 @@ namespace System.Linq
             if (selector == null)
                 throw new ArgumentNullException(nameof(selector));
 
-            return Create(() => selector(source.Publish())
-                              .GetEnumerator());
+            return Create(() => selector(source.Publish()).GetEnumerator());
         }
 
-        private class PublishedBuffer<T> : IBuffer<T>
+        private sealed class PublishedBuffer<T> : IBuffer<T>
         {
             private RefCountList<T> _buffer;
             private bool _disposed;
@@ -86,7 +85,7 @@ namespace System.Linq
                     _buffer.ReaderCount++;
                 }
 
-                return GetEnumerator_(i);
+                return GetEnumeratorCore(i);
             }
 
             IEnumerator IEnumerable.GetEnumerator()
@@ -114,7 +113,7 @@ namespace System.Linq
                 }
             }
 
-            private IEnumerator<T> GetEnumerator_(int i)
+            private IEnumerator<T> GetEnumeratorCore(int i)
             {
                 try
                 {
@@ -135,8 +134,11 @@ namespace System.Linq
                                     try
                                     {
                                         hasValue = _source.MoveNext();
+
                                         if (hasValue)
+                                        {
                                             current = _source.Current;
+                                        }
                                     }
                                     catch (Exception ex)
                                     {
@@ -150,9 +152,13 @@ namespace System.Linq
                                 if (_stopped)
                                 {
                                     if (_error != null)
+                                    {
                                         throw _error;
+                                    }
                                     else
+                                    {
                                         break;
+                                    }
                                 }
 
                                 if (hasValue)
@@ -167,9 +173,13 @@ namespace System.Linq
                         }
 
                         if (hasValue)
+                        {
                             yield return _buffer[i];
+                        }
                         else
+                        {
                             break;
+                        }
 
                         i++;
                     }
@@ -177,7 +187,9 @@ namespace System.Linq
                 finally
                 {
                     if (_buffer != null)
+                    {
                         _buffer.Done(i + 1);
+                    }
                 }
             }
         }

+ 14 - 4
Ix.NET/Source/System.Interactive/System/Linq/Operators/Repeat.cs

@@ -17,7 +17,9 @@ namespace System.Linq
         public static IEnumerable<TResult> Repeat<TResult>(TResult value)
         {
             while (true)
+            {
                 yield return value;
+            }
         }
 
         /// <summary>
@@ -43,7 +45,7 @@ namespace System.Linq
             if (source == null)
                 throw new ArgumentNullException(nameof(source));
 
-            return Repeat_(source);
+            return RepeatCore(source);
         }
 
         /// <summary>
@@ -60,21 +62,29 @@ namespace System.Linq
             if (count < 0)
                 throw new ArgumentOutOfRangeException(nameof(count));
 
-            return Repeat_(source, count);
+            return RepeatCore(source, count);
         }
 
-        private static IEnumerable<TSource> Repeat_<TSource>(IEnumerable<TSource> source)
+        private static IEnumerable<TSource> RepeatCore<TSource>(IEnumerable<TSource> source)
         {
             while (true)
+            {
                 foreach (var item in source)
+                {
                     yield return item;
+                }
+            }
         }
 
-        private static IEnumerable<TSource> Repeat_<TSource>(IEnumerable<TSource> source, int count)
+        private static IEnumerable<TSource> RepeatCore<TSource>(IEnumerable<TSource> source, int count)
         {
             for (var i = 0; i < count; i++)
+            {
                 foreach (var item in source)
+                {
                     yield return item;
+                }
+            }
         }
     }
 }

+ 6 - 4
Ix.NET/Source/System.Interactive/System/Linq/Operators/Scan.cs

@@ -27,7 +27,7 @@ namespace System.Linq
             if (accumulator == null)
                 throw new ArgumentNullException(nameof(accumulator));
 
-            return source.Scan_(seed, accumulator);
+            return ScanCore(source, seed, accumulator);
         }
 
         /// <summary>
@@ -47,21 +47,22 @@ namespace System.Linq
             if (accumulator == null)
                 throw new ArgumentNullException(nameof(accumulator));
 
-            return source.Scan_(accumulator);
+            return ScanCore(source, accumulator);
         }
 
-        private static IEnumerable<TAccumulate> Scan_<TSource, TAccumulate>(this IEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> accumulator)
+        private static IEnumerable<TAccumulate> ScanCore<TSource, TAccumulate>(IEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> accumulator)
         {
             var acc = seed;
 
             foreach (var item in source)
             {
                 acc = accumulator(acc, item);
+
                 yield return acc;
             }
         }
 
-        private static IEnumerable<TSource> Scan_<TSource>(this IEnumerable<TSource> source, Func<TSource, TSource, TSource> accumulator)
+        private static IEnumerable<TSource> ScanCore<TSource>(IEnumerable<TSource> source, Func<TSource, TSource, TSource> accumulator)
         {
             var hasSeed = false;
             var acc = default(TSource);
@@ -76,6 +77,7 @@ namespace System.Linq
                 }
 
                 acc = accumulator(acc, item);
+
                 yield return acc;
             }
         }

+ 9 - 2
Ix.NET/Source/System.Interactive/System/Linq/Operators/Share.cs

@@ -71,7 +71,7 @@ namespace System.Linq
                 if (_disposed)
                     throw new ObjectDisposedException("");
 
-                return GetEnumerator_();
+                return GetEnumeratorCore();
             }
 
             IEnumerator IEnumerable.GetEnumerator()
@@ -96,7 +96,7 @@ namespace System.Linq
                 }
             }
 
-            private IEnumerator<T> GetEnumerator_()
+            private IEnumerator<T> GetEnumeratorCore()
             {
                 while (true)
                 {
@@ -109,14 +109,21 @@ namespace System.Linq
                     lock (_source)
                     {
                         hasValue = _source.MoveNext();
+
                         if (hasValue)
+                        {
                             current = _source.Current;
+                        }
                     }
 
                     if (hasValue)
+                    {
                         yield return current;
+                    }
                     else
+                    {
                         break;
+                    }
                 }
             }
         }

+ 5 - 2
Ix.NET/Source/System.Interactive/System/Linq/Operators/SkipLast.cs

@@ -25,18 +25,21 @@ namespace System.Linq
             if (count < 0)
                 throw new ArgumentOutOfRangeException(nameof(count));
 
-            return source.SkipLast_(count);
+            return SkipLastCore(source, count);
         }
 
-        private static IEnumerable<TSource> SkipLast_<TSource>(this IEnumerable<TSource> source, int count)
+        private static IEnumerable<TSource> SkipLastCore<TSource>(this IEnumerable<TSource> source, int count)
         {
             var q = new Queue<TSource>();
 
             foreach (var x in source)
             {
                 q.Enqueue(x);
+
                 if (q.Count > count)
+                {
                     yield return q.Dequeue();
+                }
             }
         }
     }

+ 6 - 2
Ix.NET/Source/System.Interactive/System/Linq/Operators/StartsWith.cs

@@ -20,16 +20,20 @@ namespace System.Linq
             if (source == null)
                 throw new ArgumentNullException(nameof(source));
 
-            return source.StartWith_(values);
+            return StartWithCore(source, values);
         }
 
-        private static IEnumerable<TSource> StartWith_<TSource>(this IEnumerable<TSource> source, params TSource[] values)
+        private static IEnumerable<TSource> StartWithCore<TSource>(IEnumerable<TSource> source, params TSource[] values)
         {
             foreach (var x in values)
+            {
                 yield return x;
+            }
 
             foreach (var item in source)
+            {
                 yield return item;
+            }
         }
     }
 }

+ 7 - 2
Ix.NET/Source/System.Interactive/System/Linq/Operators/TakeLast.cs

@@ -22,10 +22,10 @@ namespace System.Linq
             if (count < 0)
                 throw new ArgumentOutOfRangeException(nameof(count));
 
-            return source.TakeLast_(count);
+            return TakeLastCore(source, count);
         }
 
-        private static IEnumerable<TSource> TakeLast_<TSource>(this IEnumerable<TSource> source, int count)
+        private static IEnumerable<TSource> TakeLastCore<TSource>(IEnumerable<TSource> source, int count)
         {
             if (count == 0)
             {
@@ -37,12 +37,17 @@ namespace System.Linq
             foreach (var item in source)
             {
                 if (q.Count >= count)
+                {
                     q.Dequeue();
+                }
+
                 q.Enqueue(item);
             }
 
             while (q.Count > 0)
+            {
                 yield return q.Dequeue();
+            }
         }
     }
 }

+ 2 - 2
Ix.NET/Source/System.Interactive/System/Linq/Operators/Throw.cs

@@ -19,10 +19,10 @@ namespace System.Linq
             if (exception == null)
                 throw new ArgumentNullException(nameof(exception));
 
-            return Throw_<TResult>(exception);
+            return ThrowCore<TResult>(exception);
         }
 
-        private static IEnumerable<TResult> Throw_<TResult>(Exception exception)
+        private static IEnumerable<TResult> ThrowCore<TResult>(Exception exception)
         {
             throw exception;
 #pragma warning disable 0162

+ 6 - 2
Ix.NET/Source/System.Interactive/System/Linq/Operators/Using.cs

@@ -24,14 +24,18 @@ namespace System.Linq
             if (enumerableFactory == null)
                 throw new ArgumentNullException(nameof(enumerableFactory));
 
-            return Using_(resourceFactory, enumerableFactory);
+            return UsingCore(resourceFactory, enumerableFactory);
         }
 
-        private static IEnumerable<TSource> Using_<TSource, TResource>(Func<TResource> resourceFactory, Func<TResource, IEnumerable<TSource>> enumerableFactory) where TResource : IDisposable
+        private static IEnumerable<TSource> UsingCore<TSource, TResource>(Func<TResource> resourceFactory, Func<TResource, IEnumerable<TSource>> enumerableFactory) where TResource : IDisposable
         {
             using (var res = resourceFactory())
+            {
                 foreach (var item in enumerableFactory(res))
+                {
                     yield return item;
+                }
+            }
         }
     }
 }

+ 3 - 2
Ix.NET/Source/System.Interactive/System/Linq/Operators/While.cs

@@ -22,14 +22,15 @@ namespace System.Linq
             if (source == null)
                 throw new ArgumentNullException(nameof(source));
 
-            return WhileCore(condition, source)
-                .Concat();
+            return WhileCore(condition, source).Concat();
         }
 
         private static IEnumerable<IEnumerable<TSource>> WhileCore<TSource>(Func<bool> condition, IEnumerable<TSource> source)
         {
             while (condition())
+            {
                 yield return source;
+            }
         }
     }
 }