浏览代码

Code clean up based on editorconfig

Oren Novotny 7 年之前
父节点
当前提交
03202e0418
共有 100 个文件被更改,包括 4632 次插入1204 次删除
  1. 1 1
      Rx.NET/Source/benchmarks/Benchmarks.System.Reactive/BufferCountBenchmark.cs
  2. 2 2
      Rx.NET/Source/benchmarks/Benchmarks.System.Reactive/Program.cs
  3. 2 3
      Rx.NET/Source/benchmarks/Benchmarks.System.Reactive/RangeBenchmark.cs
  4. 17 20
      Rx.NET/Source/src/Microsoft.Reactive.Testing/ColdObservable.cs
  5. 18 21
      Rx.NET/Source/src/Microsoft.Reactive.Testing/HotObservable.cs
  6. 5 8
      Rx.NET/Source/src/Microsoft.Reactive.Testing/MockObserver.cs
  7. 1 1
      Rx.NET/Source/src/Microsoft.Reactive.Testing/NamespaceDoc.cs
  8. 0 1
      Rx.NET/Source/src/Microsoft.Reactive.Testing/Properties/AssemblyInfo.cs
  9. 57 3
      Rx.NET/Source/src/Microsoft.Reactive.Testing/ReactiveAssert.cs
  10. 33 7
      Rx.NET/Source/src/Microsoft.Reactive.Testing/ReactiveTest.cs
  11. 3 0
      Rx.NET/Source/src/Microsoft.Reactive.Testing/Recorded.cs
  12. 10 3
      Rx.NET/Source/src/Microsoft.Reactive.Testing/Subscription.cs
  13. 12 0
      Rx.NET/Source/src/Microsoft.Reactive.Testing/TestScheduler.cs
  14. 0 2
      Rx.NET/Source/src/System.Reactive.Observable.Aliases/Observable.Aliases.cs
  15. 0 7
      Rx.NET/Source/src/System.Reactive.Observable.Aliases/Qbservable.Aliases.Generated.cs
  16. 1 4
      Rx.NET/Source/src/System.Reactive/AnonymousObservable.cs
  17. 3 10
      Rx.NET/Source/src/System.Reactive/AnonymousObserver.cs
  18. 2 1
      Rx.NET/Source/src/System.Reactive/AnonymousSafeObserver.cs
  19. 6 2
      Rx.NET/Source/src/System.Reactive/Concurrency/AsyncLock.cs
  20. 5 1
      Rx.NET/Source/src/System.Reactive/Concurrency/CatchScheduler.cs
  21. 7 4
      Rx.NET/Source/src/System.Reactive/Concurrency/ConcurrencyAbstractionLayerImpl.cs
  22. 4 2
      Rx.NET/Source/src/System.Reactive/Concurrency/CurrentThreadScheduler.cs
  23. 14 1
      Rx.NET/Source/src/System.Reactive/Concurrency/DefaultScheduler.cs
  24. 15 5
      Rx.NET/Source/src/System.Reactive/Concurrency/EventLoopScheduler.cs
  25. 2 1
      Rx.NET/Source/src/System.Reactive/Concurrency/HistoricalScheduler.cs
  26. 8 0
      Rx.NET/Source/src/System.Reactive/Concurrency/ImmediateScheduler.cs
  27. 6 0
      Rx.NET/Source/src/System.Reactive/Concurrency/LocalScheduler.TimerQueue.cs
  28. 10 0
      Rx.NET/Source/src/System.Reactive/Concurrency/LocalScheduler.cs
  29. 19 8
      Rx.NET/Source/src/System.Reactive/Concurrency/NewThreadScheduler.cs
  30. 4 12
      Rx.NET/Source/src/System.Reactive/Concurrency/ScheduledItem.cs
  31. 75 2
      Rx.NET/Source/src/System.Reactive/Concurrency/Scheduler.Async.cs
  32. 46 17
      Rx.NET/Source/src/System.Reactive/Concurrency/Scheduler.Recursive.cs
  33. 28 0
      Rx.NET/Source/src/System.Reactive/Concurrency/Scheduler.Services.Emulation.cs
  34. 36 1
      Rx.NET/Source/src/System.Reactive/Concurrency/Scheduler.Simple.cs
  35. 12 0
      Rx.NET/Source/src/System.Reactive/Concurrency/Scheduler.Wrappers.cs
  36. 4 1
      Rx.NET/Source/src/System.Reactive/Concurrency/Scheduler.cs
  37. 4 0
      Rx.NET/Source/src/System.Reactive/Concurrency/SchedulerOperation.cs
  38. 2 0
      Rx.NET/Source/src/System.Reactive/Concurrency/SchedulerQueue.cs
  39. 10 0
      Rx.NET/Source/src/System.Reactive/Concurrency/SchedulerWrapper.cs
  40. 34 8
      Rx.NET/Source/src/System.Reactive/Concurrency/Synchronization.cs
  41. 6 8
      Rx.NET/Source/src/System.Reactive/Concurrency/SynchronizationContextScheduler.cs
  42. 12 6
      Rx.NET/Source/src/System.Reactive/Concurrency/TaskPoolScheduler.cs
  43. 1 1
      Rx.NET/Source/src/System.Reactive/Concurrency/Thread.Stub.cs
  44. 12 1
      Rx.NET/Source/src/System.Reactive/Concurrency/ThreadPoolScheduler.cs
  45. 10 0
      Rx.NET/Source/src/System.Reactive/Concurrency/VirtualTimeScheduler.Extensions.cs
  46. 24 6
      Rx.NET/Source/src/System.Reactive/Concurrency/VirtualTimeScheduler.cs
  47. 1 4
      Rx.NET/Source/src/System.Reactive/Disposables/CancellationDisposable.cs
  48. 19 7
      Rx.NET/Source/src/System.Reactive/Disposables/CompositeDisposable.cs
  49. 3 3
      Rx.NET/Source/src/System.Reactive/Disposables/ContextDisposable.cs
  50. 15 1
      Rx.NET/Source/src/System.Reactive/Disposables/Disposable.cs
  51. 0 1
      Rx.NET/Source/src/System.Reactive/Disposables/MultipleAssignmentDisposable.cs
  52. 7 6
      Rx.NET/Source/src/System.Reactive/Disposables/RefCountDisposable.cs
  53. 3 4
      Rx.NET/Source/src/System.Reactive/Disposables/ScheduledDisposable.cs
  54. 0 1
      Rx.NET/Source/src/System.Reactive/Disposables/SerialDisposable.cs
  55. 0 1
      Rx.NET/Source/src/System.Reactive/Disposables/SingleAssignmentDisposable.cs
  56. 11 0
      Rx.NET/Source/src/System.Reactive/Disposables/StableCompositeDisposable.cs
  57. 6 1
      Rx.NET/Source/src/System.Reactive/EventPattern.cs
  58. 9 7
      Rx.NET/Source/src/System.Reactive/EventPatternSourceBase.cs
  59. 1 1
      Rx.NET/Source/src/System.Reactive/ExperimentalAttribute.cs
  60. 3 3
      Rx.NET/Source/src/System.Reactive/Internal/Constants.cs
  61. 4 2
      Rx.NET/Source/src/System.Reactive/Internal/CurrentPlatformEnlightenmentProvider.cs
  62. 11 1
      Rx.NET/Source/src/System.Reactive/Internal/Either.Generic.cs
  63. 5 6
      Rx.NET/Source/src/System.Reactive/Internal/ExceptionHelper.cs
  64. 0 3
      Rx.NET/Source/src/System.Reactive/Internal/HalfSerializer.cs
  65. 4 0
      Rx.NET/Source/src/System.Reactive/Internal/Helpers.cs
  66. 2 0
      Rx.NET/Source/src/System.Reactive/Internal/Lookup.cs
  67. 2 5
      Rx.NET/Source/src/System.Reactive/Internal/PlatformEnlightenmentProvider.cs
  68. 21 2
      Rx.NET/Source/src/System.Reactive/Internal/PriorityQueue.cs
  69. 5 2
      Rx.NET/Source/src/System.Reactive/Internal/Producer.cs
  70. 23 0
      Rx.NET/Source/src/System.Reactive/Internal/ReflectionUtils.cs
  71. 3 1
      Rx.NET/Source/src/System.Reactive/Internal/SafeObserver.cs
  72. 47 29
      Rx.NET/Source/src/System.Reactive/Internal/ScheduledObserver.cs
  73. 0 1
      Rx.NET/Source/src/System.Reactive/Internal/Sink.cs
  74. 1 1
      Rx.NET/Source/src/System.Reactive/Internal/Stubs.cs
  75. 14 14
      Rx.NET/Source/src/System.Reactive/Internal/TailRecursiveSink.cs
  76. 51 18
      Rx.NET/Source/src/System.Reactive/Joins/ActivePlan.cs
  77. 6 0
      Rx.NET/Source/src/System.Reactive/Joins/JoinObserver.cs
  78. 60 0
      Rx.NET/Source/src/System.Reactive/Joins/Pattern.cs
  79. 871 871
      Rx.NET/Source/src/System.Reactive/Joins/Plan.cs
  80. 58 0
      Rx.NET/Source/src/System.Reactive/Joins/QueryablePattern.cs
  81. 0 1
      Rx.NET/Source/src/System.Reactive/Linq/LocalQueryMethodImplementationTypeAttribute.cs
  82. 287 0
      Rx.NET/Source/src/System.Reactive/Linq/Observable.Aggregates.cs
  83. 306 0
      Rx.NET/Source/src/System.Reactive/Linq/Observable.Async.cs
  84. 9 2
      Rx.NET/Source/src/System.Reactive/Linq/Observable.Awaiter.cs
  85. 177 1
      Rx.NET/Source/src/System.Reactive/Linq/Observable.Binding.cs
  86. 83 0
      Rx.NET/Source/src/System.Reactive/Linq/Observable.Blocking.cs
  87. 27 0
      Rx.NET/Source/src/System.Reactive/Linq/Observable.Concurrency.cs
  88. 28 0
      Rx.NET/Source/src/System.Reactive/Linq/Observable.Conversions.cs
  89. 86 1
      Rx.NET/Source/src/System.Reactive/Linq/Observable.Creation.cs
  90. 208 1
      Rx.NET/Source/src/System.Reactive/Linq/Observable.Events.cs
  91. 77 0
      Rx.NET/Source/src/System.Reactive/Linq/Observable.Imperative.cs
  92. 15 2
      Rx.NET/Source/src/System.Reactive/Linq/Observable.Joins.cs
  93. 490 0
      Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.cs
  94. 4 0
      Rx.NET/Source/src/System.Reactive/Linq/Observable.Queryable.cs
  95. 193 0
      Rx.NET/Source/src/System.Reactive/Linq/Observable.Single.cs
  96. 401 0
      Rx.NET/Source/src/System.Reactive/Linq/Observable.StandardSequenceOperators.cs
  97. 378 0
      Rx.NET/Source/src/System.Reactive/Linq/Observable.Time.cs
  98. 3 3
      Rx.NET/Source/src/System.Reactive/Linq/Observable/Aggregate.cs
  99. 2 2
      Rx.NET/Source/src/System.Reactive/Linq/Observable/All.cs
  100. 9 14
      Rx.NET/Source/src/System.Reactive/Linq/Observable/Amb.cs

+ 1 - 1
Rx.NET/Source/benchmarks/Benchmarks.System.Reactive/BufferCountBenchmark.cs

@@ -13,7 +13,7 @@ namespace Benchmarks.System.Reactive
     [MemoryDiagnoser]
     public class BufferCountBenchmark
     {
-        IList<int> _store;
+        private IList<int> _store;
 
         [Benchmark]
         public void Exact()

+ 2 - 2
Rx.NET/Source/benchmarks/Benchmarks.System.Reactive/Program.cs

@@ -7,9 +7,9 @@ using BenchmarkDotNet.Running;
 
 namespace Benchmarks.System.Reactive
 {
-    class Program
+    internal class Program
     {
-        static void Main()
+        private static void Main()
         {
             var switcher = new BenchmarkSwitcher(new[] {
                 typeof(ZipBenchmark),

+ 2 - 3
Rx.NET/Source/benchmarks/Benchmarks.System.Reactive/RangeBenchmark.cs

@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// 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.
 
@@ -14,8 +14,7 @@ namespace Benchmarks.System.Reactive
     {
         [Params(1, 10, 100, 1000, 10000, 100000, 1000000)]
         public int N;
-
-        int _store;
+        private int _store;
 
         [Benchmark]
         public void Range()

+ 17 - 20
Rx.NET/Source/src/Microsoft.Reactive.Testing/ColdObservable.cs

@@ -2,61 +2,58 @@
 // 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.Reactive;
-using System;
 using System.Reactive.Disposables;
 
 namespace Microsoft.Reactive.Testing
 {
-    class ColdObservable<T> : ITestableObservable<T>
+    internal class ColdObservable<T> : ITestableObservable<T>
     {
-        readonly TestScheduler scheduler;
-        readonly Recorded<Notification<T>>[] messages;
-        readonly List<Subscription> subscriptions = new List<Subscription>();
+        private readonly TestScheduler _scheduler;
+        private readonly Recorded<Notification<T>>[] _messages;
+        private readonly List<Subscription> _subscriptions = new List<Subscription>();
 
         public ColdObservable(TestScheduler scheduler, params Recorded<Notification<T>>[] messages)
         {
-            if (scheduler == null)
-                throw new ArgumentNullException(nameof(scheduler));
-            if (messages == null)
-                throw new ArgumentNullException(nameof(messages));
-
-            this.scheduler = scheduler;
-            this.messages = messages;
+            _scheduler = scheduler ?? throw new ArgumentNullException(nameof(scheduler));
+            _messages = messages ?? throw new ArgumentNullException(nameof(messages));
         }
 
         public virtual IDisposable Subscribe(IObserver<T> observer)
         {
             if (observer == null)
+            {
                 throw new ArgumentNullException(nameof(observer));
+            }
 
-            subscriptions.Add(new Subscription(scheduler.Clock));
-            var index = subscriptions.Count - 1;
+            _subscriptions.Add(new Subscription(_scheduler.Clock));
+            var index = _subscriptions.Count - 1;
 
             var d = new CompositeDisposable();
 
-            for (var i = 0; i < messages.Length; ++i)
+            for (var i = 0; i < _messages.Length; ++i)
             {
-                var notification = messages[i].Value;
-                d.Add(scheduler.ScheduleRelative(default(object), messages[i].Time, (scheduler1, state1) => { notification.Accept(observer); return Disposable.Empty; }));
+                var notification = _messages[i].Value;
+                d.Add(_scheduler.ScheduleRelative(default(object), _messages[i].Time, (scheduler1, state1) => { notification.Accept(observer); return Disposable.Empty; }));
             }
 
             return Disposable.Create(() =>
             {
-                subscriptions[index] = new Subscription(subscriptions[index].Subscribe, scheduler.Clock);
+                _subscriptions[index] = new Subscription(_subscriptions[index].Subscribe, _scheduler.Clock);
                 d.Dispose();
             });
         }
 
         public IList<Subscription> Subscriptions
         {
-            get { return subscriptions; }
+            get { return _subscriptions; }
         }
 
         public IList<Recorded<Notification<T>>> Messages
         {
-            get { return messages; }
+            get { return _messages; }
         }
     }
 }

+ 18 - 21
Rx.NET/Source/src/Microsoft.Reactive.Testing/HotObservable.cs

@@ -2,36 +2,31 @@
 // 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.Reactive;
-using System;
 using System.Reactive.Disposables;
 
 namespace Microsoft.Reactive.Testing
 {
-    class HotObservable<T> : ITestableObservable<T>
+    internal class HotObservable<T> : ITestableObservable<T>
     {
-        readonly TestScheduler scheduler;
-        readonly List<IObserver<T>> observers = new List<IObserver<T>>();
-        readonly List<Subscription> subscriptions = new List<Subscription>();
-        readonly Recorded<Notification<T>>[] messages;
+        private readonly TestScheduler _scheduler;
+        private readonly List<IObserver<T>> _observers = new List<IObserver<T>>();
+        private readonly List<Subscription> _subscriptions = new List<Subscription>();
+        private readonly Recorded<Notification<T>>[] _messages;
 
         public HotObservable(TestScheduler scheduler, params Recorded<Notification<T>>[] messages)
         {
-            if (scheduler == null)
-                throw new ArgumentNullException(nameof(scheduler));
-            if (messages == null)
-                throw new ArgumentNullException(nameof(messages));
-
-            this.scheduler = scheduler;
-            this.messages = messages;
+            _scheduler = scheduler ?? throw new ArgumentNullException(nameof(scheduler));
+            _messages = messages ?? throw new ArgumentNullException(nameof(messages));
 
             for (var i = 0; i < messages.Length; ++i)
             {
                 var notification = messages[i].Value;
                 scheduler.ScheduleAbsolute(default(object), messages[i].Time, (scheduler1, state1) =>
                 {
-                    var _observers = observers.ToArray();
+                    var _observers = this._observers.ToArray();
                     for (var j = 0; j < _observers.Length; ++j)
                     {
                         notification.Accept(_observers[j]);
@@ -44,27 +39,29 @@ namespace Microsoft.Reactive.Testing
         public virtual IDisposable Subscribe(IObserver<T> observer)
         {
             if (observer == null)
+            {
                 throw new ArgumentNullException(nameof(observer));
+            }
 
-            observers.Add(observer);
-            subscriptions.Add(new Subscription(scheduler.Clock));
-            var index = subscriptions.Count - 1;
+            _observers.Add(observer);
+            _subscriptions.Add(new Subscription(_scheduler.Clock));
+            var index = _subscriptions.Count - 1;
 
             return Disposable.Create(() =>
             {
-                observers.Remove(observer);
-                subscriptions[index] = new Subscription(subscriptions[index].Subscribe, scheduler.Clock);
+                _observers.Remove(observer);
+                _subscriptions[index] = new Subscription(_subscriptions[index].Subscribe, _scheduler.Clock);
             });
         }
 
         public IList<Subscription> Subscriptions
         {
-            get { return subscriptions; }
+            get { return _subscriptions; }
         }
 
         public IList<Recorded<Notification<T>>> Messages
         {
-            get { return messages; }
+            get { return _messages; }
         }
     }
 }

+ 5 - 8
Rx.NET/Source/src/Microsoft.Reactive.Testing/MockObserver.cs

@@ -2,23 +2,20 @@
 // 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.Reactive;
-using System;
 
 namespace Microsoft.Reactive.Testing
 {
-    class MockObserver<T> : ITestableObserver<T>
+    internal class MockObserver<T> : ITestableObserver<T>
     {
-        TestScheduler scheduler;
-        List<Recorded<Notification<T>>> messages;
+        private TestScheduler scheduler;
+        private List<Recorded<Notification<T>>> messages;
 
         public MockObserver(TestScheduler scheduler)
         {
-            if (scheduler == null)
-                throw new ArgumentNullException(nameof(scheduler));
-
-            this.scheduler = scheduler;
+            this.scheduler = scheduler ?? throw new ArgumentNullException(nameof(scheduler));
             messages = new List<Recorded<Notification<T>>>();
         }
 

+ 1 - 1
Rx.NET/Source/src/Microsoft.Reactive.Testing/NamespaceDoc.cs

@@ -8,7 +8,7 @@ namespace Microsoft.Reactive.Testing
     /// The <b>Microsoft.Reactive.Testing</b> namespace contains interfaces and classes providing functionality to test applications and libraries built using Reactive Extensions.
     /// </summary>
     [System.Runtime.CompilerServices.CompilerGeneratedAttribute]
-    class NamespaceDoc
+    internal class NamespaceDoc
     {
     }
 }

+ 0 - 1
Rx.NET/Source/src/Microsoft.Reactive.Testing/Properties/AssemblyInfo.cs

@@ -1,6 +1,5 @@
 using System;
 using System.Runtime.InteropServices;
-using System.Security;
 
 
 

+ 57 - 3
Rx.NET/Source/src/Microsoft.Reactive.Testing/ReactiveAssert.cs

@@ -6,9 +6,8 @@ using System;
 using System.Collections.Generic;
 using System.Globalization;
 using System.Linq;
-using System.Text;
-using System.Reactive.Disposables;
 using System.Reactive.Linq;
+using System.Text;
 using Xunit;
 
 namespace Microsoft.Reactive.Testing
@@ -18,7 +17,7 @@ namespace Microsoft.Reactive.Testing
     /// </summary>
     public static class ReactiveAssert
     {
-        static string Message<T>(IEnumerable<T> actual, IEnumerable<T> expected)
+        private static string Message<T>(IEnumerable<T> actual, IEnumerable<T> expected)
         {
             var sb = new StringBuilder();
             sb.AppendLine();
@@ -43,12 +42,19 @@ namespace Microsoft.Reactive.Testing
         public static void AreElementsEqual<T>(IEnumerable<T> expected, IEnumerable<T> actual)
         {
             if (expected == null)
+            {
                 throw new ArgumentNullException(nameof(expected));
+            }
+
             if (actual == null)
+            {
                 throw new ArgumentNullException(nameof(actual));
+            }
 
             if (!expected.SequenceEqual(actual))
+            {
                 Assert.True(false, Message(actual, expected));
+            }
         }
 
         /// <summary>
@@ -62,12 +68,19 @@ namespace Microsoft.Reactive.Testing
         public static void AreElementsEqual<T>(IEnumerable<T> expected, IEnumerable<T> actual, string message)
         {
             if (expected == null)
+            {
                 throw new ArgumentNullException(nameof(expected));
+            }
+
             if (actual == null)
+            {
                 throw new ArgumentNullException(nameof(actual));
+            }
 
             if (!expected.SequenceEqual(actual))
+            {
                 Assert.True(false, message);
+            }
         }
 
         /// <summary>
@@ -80,9 +93,14 @@ namespace Microsoft.Reactive.Testing
         public static void AreElementsEqual<T>(IObservable<T> expected, IObservable<T> actual)
         {
             if (expected == null)
+            {
                 throw new ArgumentNullException(nameof(expected));
+            }
+
             if (actual == null)
+            {
                 throw new ArgumentNullException(nameof(actual));
+            }
 
             AreElementsEqual(expected.Materialize().ToEnumerable(), actual.Materialize().ToEnumerable());
         }
@@ -98,9 +116,14 @@ namespace Microsoft.Reactive.Testing
         public static void AreElementsEqual<T>(IObservable<T> expected, IObservable<T> actual, string message)
         {
             if (expected == null)
+            {
                 throw new ArgumentNullException(nameof(expected));
+            }
+
             if (actual == null)
+            {
                 throw new ArgumentNullException(nameof(actual));
+            }
 
             AreElementsEqual(expected.Materialize().ToEnumerable(), actual.Materialize().ToEnumerable(), message);
         }
@@ -114,7 +137,9 @@ namespace Microsoft.Reactive.Testing
         public static void Throws<TException>(Action action) where TException : Exception
         {
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             var failed = false;
             try
@@ -131,7 +156,9 @@ namespace Microsoft.Reactive.Testing
             }
 
             if (failed)
+            {
                 Assert.True(false, string.Format(CultureInfo.CurrentCulture, "Expected {0}.", typeof(TException).Name));
+            }
         }
 
         /// <summary>
@@ -144,7 +171,9 @@ namespace Microsoft.Reactive.Testing
         public static void Throws<TException>(Action action, string message) where TException : Exception
         {
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             var failed = false;
             try
@@ -161,7 +190,9 @@ namespace Microsoft.Reactive.Testing
             }
 
             if (failed)
+            {
                 Assert.True(false, message);
+            }
         }
 
         /// <summary>
@@ -174,7 +205,9 @@ namespace Microsoft.Reactive.Testing
         public static void Throws<TException>(TException exception, Action action) where TException : Exception
         {
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             var failed = false;
             try
@@ -192,7 +225,9 @@ namespace Microsoft.Reactive.Testing
             }
 
             if (failed)
+            {
                 Assert.True(false, string.Format(CultureInfo.CurrentCulture, "Expected {0}.", typeof(TException).Name));
+            }
         }
 
         /// <summary>
@@ -206,7 +241,9 @@ namespace Microsoft.Reactive.Testing
         public static void Throws<TException>(TException exception, Action action, string message) where TException : Exception
         {
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             var failed = false;
             try
@@ -224,7 +261,9 @@ namespace Microsoft.Reactive.Testing
             }
 
             if (failed)
+            {
                 Assert.True(false, message);
+            }
         }
 
         /// <summary>
@@ -237,9 +276,14 @@ namespace Microsoft.Reactive.Testing
         public static void AssertEqual<T>(this IEnumerable<T> actual, IEnumerable<T> expected)
         {
             if (actual == null)
+            {
                 throw new ArgumentNullException(nameof(actual));
+            }
+
             if (expected == null)
+            {
                 throw new ArgumentNullException(nameof(expected));
+            }
 
             ReactiveAssert.AreElementsEqual(expected, actual);
         }
@@ -254,9 +298,14 @@ namespace Microsoft.Reactive.Testing
         public static void AssertEqual<T>(this IEnumerable<T> actual, params T[] expected)
         {
             if (actual == null)
+            {
                 throw new ArgumentNullException(nameof(actual));
+            }
+
             if (expected == null)
+            {
                 throw new ArgumentNullException(nameof(expected));
+            }
 
             ReactiveAssert.AreElementsEqual(expected, actual);
         }
@@ -271,9 +320,14 @@ namespace Microsoft.Reactive.Testing
         public static void AssertEqual<T>(this IObservable<T> actual, IObservable<T> expected)
         {
             if (actual == null)
+            {
                 throw new ArgumentNullException(nameof(actual));
+            }
+
             if (expected == null)
+            {
                 throw new ArgumentNullException(nameof(expected));
+            }
 
             ReactiveAssert.AreElementsEqual(expected, actual);
         }

+ 33 - 7
Rx.NET/Source/src/Microsoft.Reactive.Testing/ReactiveTest.cs

@@ -16,7 +16,7 @@ namespace Microsoft.Reactive.Testing
         /// Default virtual time used for creation of observable sequences in <see cref="ReactiveTest"/>-based unit tests.
         /// </summary>
         public const long Created = 100;
-        
+
         /// <summary>
         /// Default virtual time used to subscribe to observable sequences in <see cref="ReactiveTest"/>-based unit tests.
         /// </summary>
@@ -50,7 +50,9 @@ namespace Microsoft.Reactive.Testing
         public static Recorded<Notification<T>> OnNext<T>(long ticks, Func<T, bool> predicate)
         {
             if (predicate == null)
+            {
                 throw new ArgumentNullException(nameof(predicate));
+            }
 
             return new Recorded<Notification<T>>(ticks, new OnNextPredicate<T>(predicate));
         }
@@ -89,7 +91,9 @@ namespace Microsoft.Reactive.Testing
         public static Recorded<Notification<T>> OnError<T>(long ticks, Exception exception)
         {
             if (exception == null)
+            {
                 throw new ArgumentNullException(nameof(exception));
+            }
 
             return new Recorded<Notification<T>>(ticks, Notification.CreateOnError<T>(exception));
         }
@@ -105,11 +109,13 @@ namespace Microsoft.Reactive.Testing
         public static Recorded<Notification<T>> OnError<T>(long ticks, Func<Exception, bool> predicate)
         {
             if (predicate == null)
+            {
                 throw new ArgumentNullException(nameof(predicate));
+            }
 
             return new Recorded<Notification<T>>(ticks, new OnErrorPredicate<T>(predicate));
         }
-        
+
         /// <summary>
         /// Factory method for an OnError notification record at a given time with a given error, using inference to determine the type of <typeparamref name="T"/>.
         /// </summary>
@@ -122,7 +128,9 @@ namespace Microsoft.Reactive.Testing
         public static Recorded<Notification<T>> OnError<T>(long ticks, Exception exception, T witness)
         {
             if (exception == null)
+            {
                 throw new ArgumentNullException(nameof(exception));
+            }
 
             return new Recorded<Notification<T>>(ticks, Notification.CreateOnError<T>(exception));
         }
@@ -139,7 +147,9 @@ namespace Microsoft.Reactive.Testing
         public static Recorded<Notification<T>> OnError<T>(long ticks, Func<Exception, bool> predicate, T witness)
         {
             if (predicate == null)
+            {
                 throw new ArgumentNullException(nameof(predicate));
+            }
 
             return new Recorded<Notification<T>>(ticks, new OnErrorPredicate<T>(predicate));
         }
@@ -167,7 +177,7 @@ namespace Microsoft.Reactive.Testing
 
         #region Predicate-based notification assert helper classes
 
-        class OnNextPredicate<T> : PredicateNotification<T>
+        private class OnNextPredicate<T> : PredicateNotification<T>
         {
             private readonly Func<T, bool> _predicate;
 
@@ -179,17 +189,25 @@ namespace Microsoft.Reactive.Testing
             public override bool Equals(Notification<T> other)
             {
                 if (Object.ReferenceEquals(this, other))
+                {
                     return true;
-                if (Object.ReferenceEquals(other, null))
+                }
+
+                if (other is null)
+                {
                     return false;
+                }
+
                 if (other.Kind != NotificationKind.OnNext)
+                {
                     return false;
+                }
 
                 return _predicate(other.Value);
             }
         }
 
-        class OnErrorPredicate<T> : PredicateNotification<T>
+        private class OnErrorPredicate<T> : PredicateNotification<T>
         {
             private readonly Func<Exception, bool> _predicate;
 
@@ -201,17 +219,25 @@ namespace Microsoft.Reactive.Testing
             public override bool Equals(Notification<T> other)
             {
                 if (Object.ReferenceEquals(this, other))
+                {
                     return true;
-                if (Object.ReferenceEquals(other, null))
+                }
+
+                if (other is null)
+                {
                     return false;
+                }
+
                 if (other.Kind != NotificationKind.OnError)
+                {
                     return false;
+                }
 
                 return _predicate(other.Exception);
             }
         }
 
-        abstract class PredicateNotification<T> : Notification<T>
+        private abstract class PredicateNotification<T> : Notification<T>
         {
             #region Non-implemented members (by design)
 

+ 3 - 0
Rx.NET/Source/src/Microsoft.Reactive.Testing/Recorded.cs

@@ -83,7 +83,10 @@ namespace Microsoft.Reactive.Testing
         public override bool Equals(object obj)
         {
             if (obj is Recorded<T>)
+            {
                 return Equals((Recorded<T>)obj);
+            }
+
             return false;
         }
 

+ 10 - 3
Rx.NET/Source/src/Microsoft.Reactive.Testing/Subscription.cs

@@ -22,8 +22,8 @@ namespace Microsoft.Reactive.Testing
         /// </summary>
         public const long Infinite = long.MaxValue;
 
-        private long _subscribe;
-        private long _unsubscribe;
+        private readonly long _subscribe;
+        private readonly long _unsubscribe;
 
         /// <summary>
         /// Gets the subscription virtual time.
@@ -72,7 +72,7 @@ namespace Microsoft.Reactive.Testing
         /// <param name="left">The first Subscription value to compare.</param>
         /// <param name="right">The second Subscription value to compare.</param>
         /// <returns>true if the first Subscription value has the same Subscribe and Unsubscribe as the second Subscription value; otherwise, false.</returns>
-        public static bool operator==(Subscription left, Subscription right)
+        public static bool operator ==(Subscription left, Subscription right)
         {
             return left.Equals(right);
         }
@@ -96,7 +96,10 @@ namespace Microsoft.Reactive.Testing
         public override bool Equals(object obj)
         {
             if (obj is Subscription)
+            {
                 return Equals((Subscription)obj);
+            }
+
             return false;
         }
 
@@ -116,9 +119,13 @@ namespace Microsoft.Reactive.Testing
         public override string ToString()
         {
             if (Unsubscribe == Infinite)
+            {
                 return string.Format(CultureInfo.CurrentCulture, "({0}, Infinite)", Subscribe);
+            }
             else
+            {
                 return string.Format(CultureInfo.CurrentCulture, "({0}, {1})", Subscribe, Unsubscribe);
+            }
         }
     }
 }

+ 12 - 0
Rx.NET/Source/src/Microsoft.Reactive.Testing/TestScheduler.cs

@@ -26,7 +26,9 @@ namespace Microsoft.Reactive.Testing
         public override IDisposable ScheduleAbsolute<TState>(TState state, long dueTime, Func<IScheduler, TState, IDisposable> action)
         {
             if (dueTime <= Clock)
+            {
                 dueTime = Clock + 1;
+            }
 
             return base.ScheduleAbsolute<TState>(state, dueTime, action);
         }
@@ -75,7 +77,9 @@ namespace Microsoft.Reactive.Testing
         public ITestableObserver<T> Start<T>(Func<IObservable<T>> create, long created, long subscribed, long disposed)
         {
             if (create == null)
+            {
                 throw new ArgumentNullException(nameof(create));
+            }
 
             var source = default(IObservable<T>);
             var subscription = default(IDisposable);
@@ -102,7 +106,9 @@ namespace Microsoft.Reactive.Testing
         public ITestableObserver<T> Start<T>(Func<IObservable<T>> create, long disposed)
         {
             if (create == null)
+            {
                 throw new ArgumentNullException(nameof(create));
+            }
 
             return Start(create, ReactiveTest.Created, ReactiveTest.Subscribed, disposed);
         }
@@ -117,7 +123,9 @@ namespace Microsoft.Reactive.Testing
         public ITestableObserver<T> Start<T>(Func<IObservable<T>> create)
         {
             if (create == null)
+            {
                 throw new ArgumentNullException(nameof(create));
+            }
 
             return Start(create, ReactiveTest.Created, ReactiveTest.Subscribed, ReactiveTest.Disposed);
         }
@@ -132,7 +140,9 @@ namespace Microsoft.Reactive.Testing
         public ITestableObservable<T> CreateHotObservable<T>(params Recorded<Notification<T>>[] messages)
         {
             if (messages == null)
+            {
                 throw new ArgumentNullException(nameof(messages));
+            }
 
             return new HotObservable<T>(this, messages);
         }
@@ -147,7 +157,9 @@ namespace Microsoft.Reactive.Testing
         public ITestableObservable<T> CreateColdObservable<T>(params Recorded<Notification<T>>[] messages)
         {
             if (messages == null)
+            {
                 throw new ArgumentNullException(nameof(messages));
+            }
 
             return new ColdObservable<T>(this, messages);
         }

+ 0 - 2
Rx.NET/Source/src/System.Reactive.Observable.Aliases/Observable.Aliases.cs

@@ -5,9 +5,7 @@
 #pragma warning disable 1591
 
 using System.Collections.Generic;
-using System.Reactive.Concurrency;
 using System.Reactive.Linq;
-using System.Reactive;
 using System.Reactive.Threading.Tasks; // needed for doc comments
 using System.Threading;
 using System.Threading.Tasks;

+ 0 - 7
Rx.NET/Source/src/System.Reactive.Observable.Aliases/Qbservable.Aliases.Generated.cs

@@ -5,18 +5,11 @@
 
 #pragma warning disable 1591
 
-using System;
-using System.Reactive.Concurrency;
 using System.Collections.Generic;
 using System.Diagnostics.CodeAnalysis;
-using System.Reactive.Joins;
-using System.Linq;
 using System.Linq.Expressions;
-using System.Reflection;
 using System.Threading;
 using System.Threading.Tasks;
-using System.Reactive;
-using System.Reactive.Subjects;
 
 namespace System.Reactive.Linq
 {

+ 1 - 4
Rx.NET/Source/src/System.Reactive/AnonymousObservable.cs

@@ -21,10 +21,7 @@ namespace System.Reactive
         /// <exception cref="ArgumentNullException"><paramref name="subscribe"/> is <c>null</c>.</exception>
         public AnonymousObservable(Func<IObserver<T>, IDisposable> subscribe)
         {
-            if (subscribe == null)
-                throw new ArgumentNullException(nameof(subscribe));
-
-            _subscribe = subscribe;
+            _subscribe = subscribe ?? throw new ArgumentNullException(nameof(subscribe));
         }
 
         /// <summary>

+ 3 - 10
Rx.NET/Source/src/System.Reactive/AnonymousObserver.cs

@@ -23,16 +23,9 @@ namespace System.Reactive
         /// <exception cref="ArgumentNullException"><paramref name="onNext"/> or <paramref name="onError"/> or <paramref name="onCompleted"/> is <c>null</c>.</exception>
         public AnonymousObserver(Action<T> onNext, Action<Exception> onError, Action onCompleted)
         {
-            if (onNext == null)
-                throw new ArgumentNullException(nameof(onNext));
-            if (onError == null)
-                throw new ArgumentNullException(nameof(onError));
-            if (onCompleted == null)
-                throw new ArgumentNullException(nameof(onCompleted));
-
-            _onNext = onNext;
-            _onError = onError;
-            _onCompleted = onCompleted;
+            _onNext = onNext ?? throw new ArgumentNullException(nameof(onNext));
+            _onError = onError ?? throw new ArgumentNullException(nameof(onError));
+            _onCompleted = onCompleted ?? throw new ArgumentNullException(nameof(onCompleted));
         }
 
         /// <summary>

+ 2 - 1
Rx.NET/Source/src/System.Reactive/AnonymousSafeObserver.cs

@@ -2,7 +2,6 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System.Reactive.Disposables;
 using System.Threading;
 
 namespace System.Reactive
@@ -47,7 +46,9 @@ namespace System.Reactive
                 finally
                 {
                     if (!__noError)
+                    {
                         Dispose();
+                    }
                 }
             }
         }

+ 6 - 2
Rx.NET/Source/src/System.Reactive/Concurrency/AsyncLock.cs

@@ -13,7 +13,7 @@ namespace System.Reactive.Concurrency
     {
         private bool isAcquired = false;
         private bool hasFaulted = false;
-        private object guard = new object();
+        private readonly object guard = new object();
         private Queue<(Action<Delegate, object> action, Delegate @delegate, object state)> queue;
 
         /// <summary>
@@ -26,7 +26,9 @@ namespace System.Reactive.Concurrency
         public void Wait(Action action)
         {
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             Wait(action, closureAction => closureAction());
         }
@@ -44,13 +46,15 @@ namespace System.Reactive.Concurrency
         internal void Wait<TState>(TState state, Action<TState> action)
         {
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             Wait(state, action, (actionObject, stateObject) => ((Action<TState>)actionObject)((TState)stateObject));
         }
 
         private void Wait(object state, Delegate @delegate, Action<Delegate, object> action)
-        { 
+        {
             // allow one thread to update the state
             lock (guard)
             {

+ 5 - 1
Rx.NET/Source/src/System.Reactive/Concurrency/CatchScheduler.cs

@@ -77,7 +77,7 @@ namespace System.Reactive.Concurrency
             public IDisposable ScheduleLongRunning<TState>(TState state, Action<TState, ICancelable> action)
             {
                 return _scheduler.ScheduleLongRunning(
-                    (scheduler: this, action, state), 
+                    (scheduler: this, action, state),
                     (tuple, cancel) =>
                     {
                         try
@@ -124,7 +124,9 @@ namespace System.Reactive.Concurrency
                     // take effect.
                     //
                     if (_failed)
+                    {
                         return default;
+                    }
 
                     try
                     {
@@ -135,7 +137,9 @@ namespace System.Reactive.Concurrency
                         _failed = true;
 
                         if (!_catchScheduler._handler(exception))
+                        {
                             throw;
+                        }
 
                         Disposable.TryDispose(ref _cancel);
                         return default;

+ 7 - 4
Rx.NET/Source/src/System.Reactive/Concurrency/ConcurrencyAbstractionLayerImpl.cs

@@ -33,7 +33,9 @@ namespace System.Reactive.Concurrency
         public IDisposable StartPeriodicTimer(Action action, TimeSpan period)
         {
             if (period < TimeSpan.Zero)
+            {
                 throw new ArgumentOutOfRangeException(nameof(period));
+            }
 
             //
             // The contract for periodic scheduling in Rx is that specifying TimeSpan.Zero as the period causes the scheduler to 
@@ -74,7 +76,8 @@ namespace System.Reactive.Concurrency
                 var item = (WorkItem)itemObject;
 
                 item.Action(item.State);
-            }) { IsBackground = true }.Start(new WorkItem(action, state));
+            })
+            { IsBackground = true }.Start(new WorkItem(action, state));
         }
 
         private static TimeSpan Normalize(TimeSpan dueTime) => dueTime < TimeSpan.Zero ? TimeSpan.Zero : dueTime;
@@ -168,7 +171,7 @@ namespace System.Reactive.Concurrency
 
             private static void Tick(object state)
             {
-                var timer = (Timer) state;
+                var timer = (Timer)state;
 
                 try
                 {
@@ -238,7 +241,7 @@ namespace System.Reactive.Concurrency
             public FastPeriodicTimer(Action action)
             {
                 _action = action;
-                
+
                 new Thread(_ => Loop(_))
                 {
                     Name = "Rx-FastPeriodicTimer",
@@ -246,7 +249,7 @@ namespace System.Reactive.Concurrency
                 }
                 .Start(this);
             }
-            
+
             private static void Loop(object threadParam)
             {
                 var timer = (FastPeriodicTimer)threadParam;

+ 4 - 2
Rx.NET/Source/src/System.Reactive/Concurrency/CurrentThreadScheduler.cs

@@ -3,8 +3,6 @@
 // See the LICENSE file in the project root for more information. 
 
 using System.ComponentModel;
-using System.Threading;
-using System.Reactive.Disposables;
 
 namespace System.Reactive.Concurrency
 {
@@ -46,7 +44,9 @@ namespace System.Reactive.Concurrency
             get
             {
                 if (s_clock == null)
+                {
                     s_clock = ConcurrencyAbstractionLayer.Current.StartStopwatch();
+                }
 
                 return s_clock.Elapsed;
             }
@@ -78,7 +78,9 @@ namespace System.Reactive.Concurrency
         public override IDisposable Schedule<TState>(TState state, TimeSpan dueTime, Func<IScheduler, TState, IDisposable> action)
         {
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             var queue = default(SchedulerQueue<TimeSpan>);
 

+ 14 - 1
Rx.NET/Source/src/System.Reactive/Concurrency/DefaultScheduler.cs

@@ -35,7 +35,9 @@ namespace System.Reactive.Concurrency
         public override IDisposable Schedule<TState>(TState state, Func<IScheduler, TState, IDisposable> action)
         {
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             var workItem = new UserWorkItem<TState>(this, state, action);
 
@@ -58,11 +60,15 @@ namespace System.Reactive.Concurrency
         public override IDisposable Schedule<TState>(TState state, TimeSpan dueTime, Func<IScheduler, TState, IDisposable> action)
         {
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             var dt = Scheduler.Normalize(dueTime);
             if (dt.Ticks == 0)
+            {
                 return Schedule(state, action);
+            }
 
             var workItem = new UserWorkItem<TState>(this, state, action);
 
@@ -87,9 +93,14 @@ namespace System.Reactive.Concurrency
         public IDisposable SchedulePeriodic<TState>(TState state, TimeSpan period, Func<TState, TState> action)
         {
             if (period < TimeSpan.Zero)
+            {
                 throw new ArgumentOutOfRangeException(nameof(period));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return new PeriodicallyScheduledWorkItem<TState>(state, period, action);
         }
@@ -105,7 +116,7 @@ namespace System.Reactive.Concurrency
             {
                 _state = state;
                 _action = action;
-                
+
                 _cancel = s_cal.StartPeriodicTimer(Tick, period);
             }
 
@@ -186,7 +197,9 @@ namespace System.Reactive.Concurrency
             public IDisposable ScheduleLongRunning<TState>(TState state, Action<TState, ICancelable> action)
             {
                 if (action == null)
+                {
                     throw new ArgumentNullException(nameof(action));
+                }
 
                 return new LongScheduledWorkItem<TState>(state, action);
             }

+ 15 - 5
Rx.NET/Source/src/System.Reactive/Concurrency/EventLoopScheduler.cs

@@ -94,13 +94,11 @@ namespace System.Reactive.Concurrency
         /// <exception cref="ArgumentNullException"><paramref name="threadFactory"/> is <c>null</c>.</exception>
         public EventLoopScheduler(Func<ThreadStart, Thread> threadFactory)
         {
-            if (threadFactory == null)
-                throw new ArgumentNullException(nameof(threadFactory));
 #else
         internal EventLoopScheduler(Func<ThreadStart, Thread> threadFactory)
         {
 #endif
-            _threadFactory = threadFactory;
+            _threadFactory = threadFactory ?? throw new ArgumentNullException(nameof(threadFactory));
             _stopwatch = ConcurrencyAbstractionLayer.Current.StartStopwatch();
 
             _gate = new object();
@@ -144,7 +142,9 @@ namespace System.Reactive.Concurrency
         public override IDisposable Schedule<TState>(TState state, TimeSpan dueTime, Func<IScheduler, TState, IDisposable> action)
         {
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             var due = _stopwatch.Elapsed + dueTime;
             var si = new ScheduledItem<TimeSpan, TState>(this, state, action, due);
@@ -152,7 +152,9 @@ namespace System.Reactive.Concurrency
             lock (_gate)
             {
                 if (_disposed)
+                {
                     throw new ObjectDisposedException("");
+                }
 
                 if (dueTime <= TimeSpan.Zero)
                 {
@@ -185,9 +187,14 @@ namespace System.Reactive.Concurrency
         public IDisposable SchedulePeriodic<TState>(TState state, TimeSpan period, Func<TState, TState> action)
         {
             if (period < TimeSpan.Zero)
+            {
                 throw new ArgumentOutOfRangeException(nameof(period));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return new PeriodicallyScheduledWorkItem<TState>(this, state, period, action);
         }
@@ -298,7 +305,10 @@ namespace System.Reactive.Concurrency
                     // Bug fix that ensures the number of calls to Release never greatly exceeds the number of calls to Wait.
                     // See work item #37: https://rx.codeplex.com/workitem/37
                     //
-                    while (_evt.CurrentCount > 0) _evt.Wait();
+                    while (_evt.CurrentCount > 0)
+                    {
+                        _evt.Wait();
+                    }
 
                     //
                     // The event could have been set by a call to Dispose. This takes priority over anything else. We quit the
@@ -306,7 +316,7 @@ namespace System.Reactive.Concurrency
                     //
                     if (_disposed)
                     {
-                        ((IDisposable)_evt).Dispose();
+                        _evt.Dispose();
                         return;
                     }
 

+ 2 - 1
Rx.NET/Source/src/System.Reactive/Concurrency/HistoricalScheduler.cs

@@ -3,7 +3,6 @@
 // See the LICENSE file in the project root for more information. 
 
 using System.Collections.Generic;
-using System.Reactive.Disposables;
 
 namespace System.Reactive.Concurrency
 {
@@ -135,7 +134,9 @@ namespace System.Reactive.Concurrency
         public override IDisposable ScheduleAbsolute<TState>(TState state, DateTimeOffset dueTime, Func<IScheduler, TState, IDisposable> action)
         {
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             var si = default(ScheduledItem<DateTimeOffset, TState>);
 

+ 8 - 0
Rx.NET/Source/src/System.Reactive/Concurrency/ImmediateScheduler.cs

@@ -34,7 +34,9 @@ namespace System.Reactive.Concurrency
         public override IDisposable Schedule<TState>(TState state, Func<IScheduler, TState, IDisposable> action)
         {
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return action(new AsyncLockScheduler(), state);
         }
@@ -51,7 +53,9 @@ namespace System.Reactive.Concurrency
         public override IDisposable Schedule<TState>(TState state, TimeSpan dueTime, Func<IScheduler, TState, IDisposable> action)
         {
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             var dt = Scheduler.Normalize(dueTime);
             if (dt.Ticks > 0)
@@ -69,7 +73,9 @@ namespace System.Reactive.Concurrency
             public override IDisposable Schedule<TState>(TState state, Func<IScheduler, TState, IDisposable> action)
             {
                 if (action == null)
+                {
                     throw new ArgumentNullException(nameof(action));
+                }
 
                 var m = new SingleAssignmentDisposable();
 
@@ -94,7 +100,9 @@ namespace System.Reactive.Concurrency
             public override IDisposable Schedule<TState>(TState state, TimeSpan dueTime, Func<IScheduler, TState, IDisposable> action)
             {
                 if (action == null)
+                {
                     throw new ArgumentNullException(nameof(action));
+                }
 
                 if (dueTime.Ticks <= 0)
                 {

+ 6 - 0
Rx.NET/Source/src/System.Reactive/Concurrency/LocalScheduler.TimerQueue.cs

@@ -302,7 +302,9 @@ namespace System.Reactive.Concurrency
             lock (s_gate) */
             {
                 if (s_longTerm.Count == 0)
+                {
                     return;
+                }
 
                 //
                 // To avoid setting the timer all over again for the first work item if it hasn't changed,
@@ -310,7 +312,9 @@ namespace System.Reactive.Concurrency
                 //
                 var next = s_longTerm.Peek();
                 if (next == s_nextLongTermWorkItem)
+                {
                     return;
+                }
 
                 //
                 // We need to arrive early in order to accommodate for potential drift. The relative amount
@@ -350,7 +354,9 @@ namespace System.Reactive.Concurrency
 
                     var due = Scheduler.Normalize(next.DueTime - next.Scheduler.Now);
                     if (due >= SHORTTERM)
+                    {
                         break;
+                    }
 
                     var item = s_longTerm.Dequeue();
                     item.Scheduler.ScheduleShortTermWork(item);

+ 10 - 0
Rx.NET/Source/src/System.Reactive/Concurrency/LocalScheduler.cs

@@ -25,7 +25,9 @@ namespace System.Reactive.Concurrency
         public virtual IDisposable Schedule<TState>(TState state, Func<IScheduler, TState, IDisposable> action)
         {
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return Schedule(state, TimeSpan.Zero, action);
         }
@@ -52,7 +54,9 @@ namespace System.Reactive.Concurrency
         public virtual IDisposable Schedule<TState>(TState state, DateTimeOffset dueTime, Func<IScheduler, TState, IDisposable> action)
         {
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return Enqueue(state, dueTime, action);
         }
@@ -79,11 +83,17 @@ namespace System.Reactive.Concurrency
         protected virtual object GetService(Type serviceType)
         {
             if (serviceType == typeof(IStopwatchProvider))
+            {
                 return this as IStopwatchProvider;
+            }
             else if (serviceType == typeof(ISchedulerLongRunning))
+            {
                 return this as ISchedulerLongRunning;
+            }
             else if (serviceType == typeof(ISchedulerPeriodic))
+            {
                 return this as ISchedulerPeriodic;
+            }
 
             return null;
         }

+ 19 - 8
Rx.NET/Source/src/System.Reactive/Concurrency/NewThreadScheduler.cs

@@ -12,7 +12,7 @@ namespace System.Reactive.Concurrency
     /// </summary>
     public sealed class NewThreadScheduler : LocalScheduler, ISchedulerLongRunning, ISchedulerPeriodic
     {
-        internal static readonly Lazy<NewThreadScheduler> s_instance = new Lazy<NewThreadScheduler>(() => new NewThreadScheduler());
+        internal static readonly Lazy<NewThreadScheduler> Instance = new Lazy<NewThreadScheduler>(() => new NewThreadScheduler());
 
         private readonly Func<ThreadStart, Thread> _threadFactory;
 
@@ -27,7 +27,7 @@ namespace System.Reactive.Concurrency
         /// <summary>
         /// Gets an instance of this scheduler that uses the default Thread constructor.
         /// </summary>
-        public static NewThreadScheduler Default => s_instance.Value;
+        public static NewThreadScheduler Default => Instance.Value;
 
 #if !NO_THREAD
         /// <summary>
@@ -37,13 +37,11 @@ namespace System.Reactive.Concurrency
         /// <exception cref="ArgumentNullException"><paramref name="threadFactory"/> is <c>null</c>.</exception>
         public NewThreadScheduler(Func<ThreadStart, Thread> threadFactory)
         {
-            if (threadFactory == null)
-                throw new ArgumentNullException(nameof(threadFactory));
 #else
         private NewThreadScheduler(Func<ThreadStart, Thread> threadFactory)
         {
 #endif
-            _threadFactory = threadFactory;
+            _threadFactory = threadFactory ?? throw new ArgumentNullException(nameof(threadFactory));
         }
 
         /// <summary>
@@ -58,10 +56,14 @@ namespace System.Reactive.Concurrency
         public override IDisposable Schedule<TState>(TState state, TimeSpan dueTime, Func<IScheduler, TState, IDisposable> action)
         {
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
-            var scheduler = new EventLoopScheduler(_threadFactory);
-            scheduler.ExitIfEmpty = true;
+            var scheduler = new EventLoopScheduler(_threadFactory)
+            {
+                ExitIfEmpty = true
+            };
             return scheduler.Schedule(state, dueTime, action);
         }
 
@@ -76,7 +78,9 @@ namespace System.Reactive.Concurrency
         public IDisposable ScheduleLongRunning<TState>(TState state, Action<TState, ICancelable> action)
         {
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             var d = new BooleanDisposable();
 
@@ -108,9 +112,14 @@ namespace System.Reactive.Concurrency
         public IDisposable SchedulePeriodic<TState>(TState state, TimeSpan period, Func<TState, TState> action)
         {
             if (period < TimeSpan.Zero)
+            {
                 throw new ArgumentOutOfRangeException(nameof(period));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             var periodic = new Periodic<TState>(state, period, action);
 
@@ -152,7 +161,9 @@ namespace System.Reactive.Concurrency
                     lock (_cancel)
                     {
                         if (Monitor.Wait(_cancel, timeout))
+                        {
                             return;
+                        }
                     }
 
                     _state = _action(_state);
@@ -185,4 +196,4 @@ namespace System.Reactive.Concurrency
             return new StopwatchImpl();
         }
     }
-}
+}

+ 4 - 12
Rx.NET/Source/src/System.Reactive/Concurrency/ScheduledItem.cs

@@ -25,11 +25,8 @@ namespace System.Reactive.Concurrency
         /// <exception cref="ArgumentNullException"><paramref name="comparer"/> is <c>null</c>.</exception>
         protected ScheduledItem(TAbsolute dueTime, IComparer<TAbsolute> comparer)
         {
-            if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
-
             DueTime = dueTime;
-            _comparer = comparer;
+            _comparer = comparer ?? throw new ArgumentNullException(nameof(comparer));
         }
 
         /// <summary>
@@ -65,7 +62,7 @@ namespace System.Reactive.Concurrency
         public int CompareTo(ScheduledItem<TAbsolute> other)
         {
             // MSDN: By definition, any object compares greater than null, and two null references compare equal to each other.
-            if (ReferenceEquals(other, null))
+            if (other is null)
             {
                 return 1;
             }
@@ -186,14 +183,9 @@ namespace System.Reactive.Concurrency
         public ScheduledItem(IScheduler scheduler, TValue state, Func<IScheduler, TValue, IDisposable> action, TAbsolute dueTime, IComparer<TAbsolute> comparer)
             : base(dueTime, comparer)
         {
-            if (scheduler == null)
-                throw new ArgumentNullException(nameof(scheduler));
-            if (action == null)
-                throw new ArgumentNullException(nameof(action));
-
-            _scheduler = scheduler;
+            _scheduler = scheduler ?? throw new ArgumentNullException(nameof(scheduler));
             _state = state;
-            _action = action;
+            _action = action ?? throw new ArgumentNullException(nameof(action));
         }
 
         /// <summary>

+ 75 - 2
Rx.NET/Source/src/System.Reactive/Concurrency/Scheduler.Async.cs

@@ -20,7 +20,9 @@ namespace System.Reactive.Concurrency
         public static SchedulerOperation Yield(this IScheduler scheduler)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return new SchedulerOperation(a => scheduler.Schedule(a), scheduler.GetCancellationToken());
         }
@@ -36,7 +38,9 @@ namespace System.Reactive.Concurrency
         public static SchedulerOperation Yield(this IScheduler scheduler, CancellationToken cancellationToken)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return new SchedulerOperation(a => scheduler.Schedule(a), cancellationToken);
         }
@@ -52,7 +56,9 @@ namespace System.Reactive.Concurrency
         public static SchedulerOperation Sleep(this IScheduler scheduler, TimeSpan dueTime)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return new SchedulerOperation(a => scheduler.Schedule(dueTime, a), scheduler.GetCancellationToken());
         }
@@ -69,7 +75,9 @@ namespace System.Reactive.Concurrency
         public static SchedulerOperation Sleep(this IScheduler scheduler, TimeSpan dueTime, CancellationToken cancellationToken)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return new SchedulerOperation(a => scheduler.Schedule(dueTime, a), cancellationToken);
         }
@@ -85,7 +93,9 @@ namespace System.Reactive.Concurrency
         public static SchedulerOperation Sleep(this IScheduler scheduler, DateTimeOffset dueTime)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return new SchedulerOperation(a => scheduler.Schedule(dueTime, a), scheduler.GetCancellationToken());
         }
@@ -102,7 +112,9 @@ namespace System.Reactive.Concurrency
         public static SchedulerOperation Sleep(this IScheduler scheduler, DateTimeOffset dueTime, CancellationToken cancellationToken)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return new SchedulerOperation(a => scheduler.Schedule(dueTime, a), cancellationToken);
         }
@@ -119,9 +131,14 @@ namespace System.Reactive.Concurrency
         public static IDisposable ScheduleAsync<TState>(this IScheduler scheduler, TState state, Func<IScheduler, TState, CancellationToken, Task> action)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return ScheduleAsync_<TState>(scheduler, state, action);
         }
@@ -138,9 +155,14 @@ namespace System.Reactive.Concurrency
         public static IDisposable ScheduleAsync<TState>(this IScheduler scheduler, TState state, Func<IScheduler, TState, CancellationToken, Task<IDisposable>> action)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return ScheduleAsync_<TState>(scheduler, state, action);
         }
@@ -155,9 +177,14 @@ namespace System.Reactive.Concurrency
         public static IDisposable ScheduleAsync(this IScheduler scheduler, Func<IScheduler, CancellationToken, Task> action)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return ScheduleAsync_(scheduler, action, (self, closureAction, ct) => closureAction(self, ct));
         }
@@ -172,9 +199,14 @@ namespace System.Reactive.Concurrency
         public static IDisposable ScheduleAsync(this IScheduler scheduler, Func<IScheduler, CancellationToken, Task<IDisposable>> action)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return ScheduleAsync_(scheduler, action, (self, closureAction, ct) => closureAction(self, ct));
         }
@@ -192,9 +224,14 @@ namespace System.Reactive.Concurrency
         public static IDisposable ScheduleAsync<TState>(this IScheduler scheduler, TState state, TimeSpan dueTime, Func<IScheduler, TState, CancellationToken, Task> action)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return ScheduleAsync_(scheduler, state, dueTime, action);
         }
@@ -212,9 +249,14 @@ namespace System.Reactive.Concurrency
         public static IDisposable ScheduleAsync<TState>(this IScheduler scheduler, TState state, TimeSpan dueTime, Func<IScheduler, TState, CancellationToken, Task<IDisposable>> action)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return ScheduleAsync_(scheduler, state, dueTime, action);
         }
@@ -230,9 +272,14 @@ namespace System.Reactive.Concurrency
         public static IDisposable ScheduleAsync(this IScheduler scheduler, TimeSpan dueTime, Func<IScheduler, CancellationToken, Task> action)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return ScheduleAsync_(scheduler, action, dueTime, (self, closureAction, ct) => closureAction(self, ct));
         }
@@ -248,9 +295,14 @@ namespace System.Reactive.Concurrency
         public static IDisposable ScheduleAsync(this IScheduler scheduler, TimeSpan dueTime, Func<IScheduler, CancellationToken, Task<IDisposable>> action)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return ScheduleAsync_(scheduler, action, dueTime, (self, closureAction, ct) => closureAction(self, ct));
         }
@@ -268,9 +320,14 @@ namespace System.Reactive.Concurrency
         public static IDisposable ScheduleAsync<TState>(this IScheduler scheduler, TState state, DateTimeOffset dueTime, Func<IScheduler, TState, CancellationToken, Task> action)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return ScheduleAsync_(scheduler, state, dueTime, action);
         }
@@ -288,9 +345,14 @@ namespace System.Reactive.Concurrency
         public static IDisposable ScheduleAsync<TState>(this IScheduler scheduler, TState state, DateTimeOffset dueTime, Func<IScheduler, TState, CancellationToken, Task<IDisposable>> action)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return ScheduleAsync_(scheduler, state, dueTime, action);
         }
@@ -306,9 +368,14 @@ namespace System.Reactive.Concurrency
         public static IDisposable ScheduleAsync(this IScheduler scheduler, DateTimeOffset dueTime, Func<IScheduler, CancellationToken, Task> action)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return ScheduleAsync_(scheduler, action, dueTime, (self, closureAction, ct) => closureAction(self, ct));
         }
@@ -324,9 +391,14 @@ namespace System.Reactive.Concurrency
         public static IDisposable ScheduleAsync(this IScheduler scheduler, DateTimeOffset dueTime, Func<IScheduler, CancellationToken, Task<IDisposable>> action)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return ScheduleAsync_(scheduler, action, dueTime, (self, closureAction, ct) => closureAction(self, ct));
         }
@@ -369,7 +441,9 @@ namespace System.Reactive.Concurrency
             action(new CancelableScheduler(self, c.Token), s, c.Token).ContinueWith(t =>
             {
                 if (t.IsCanceled)
+                {
                     return;
+                }
 
                 if (t.Exception != null)
                 {
@@ -389,8 +463,7 @@ namespace System.Reactive.Concurrency
 
         private static CancellationToken GetCancellationToken(this IScheduler scheduler)
         {
-            var cs = scheduler as CancelableScheduler;
-            return cs != null ? cs.Token : CancellationToken.None;
+            return scheduler is CancelableScheduler cs ? cs.Token : CancellationToken.None;
         }
 
         private sealed class CancelableScheduler : IScheduler

+ 46 - 17
Rx.NET/Source/src/System.Reactive/Concurrency/Scheduler.Recursive.cs

@@ -2,7 +2,6 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System.Collections.Generic;
 using System.Reactive.Disposables;
 
 namespace System.Reactive.Concurrency
@@ -19,9 +18,14 @@ namespace System.Reactive.Concurrency
         public static IDisposable Schedule(this IScheduler scheduler, Action<Action> action)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return scheduler.Schedule(action, (_action, self) => _action(() => self(_action)));
         }
@@ -38,9 +42,14 @@ namespace System.Reactive.Concurrency
         public static IDisposable Schedule<TState>(this IScheduler scheduler, TState state, Action<TState, Action<TState>> action)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return scheduler.Schedule((state, action), (s, p) => InvokeRec1(s, p));
         }
@@ -63,9 +72,14 @@ namespace System.Reactive.Concurrency
         public static IDisposable Schedule(this IScheduler scheduler, TimeSpan dueTime, Action<Action<TimeSpan>> action)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return scheduler.Schedule(action, dueTime, (_action, self) => _action(dt => self(_action, dt)));
         }
@@ -83,9 +97,14 @@ namespace System.Reactive.Concurrency
         public static IDisposable Schedule<TState>(this IScheduler scheduler, TState state, TimeSpan dueTime, Action<TState, Action<TState, TimeSpan>> action)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return scheduler.Schedule((state, action), dueTime, (s, p) => InvokeRec2(s, p));
         }
@@ -108,9 +127,14 @@ namespace System.Reactive.Concurrency
         public static IDisposable Schedule(this IScheduler scheduler, DateTimeOffset dueTime, Action<Action<DateTimeOffset>> action)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return scheduler.Schedule(action, dueTime, (_action, self) => _action(dt => self(_action, dt)));
         }
@@ -128,9 +152,14 @@ namespace System.Reactive.Concurrency
         public static IDisposable Schedule<TState>(this IScheduler scheduler, TState state, DateTimeOffset dueTime, Action<TState, Action<TState, DateTimeOffset>> action)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return scheduler.Schedule((state, action), dueTime, (s, p) => InvokeRec3(s, p));
         }
@@ -142,7 +171,7 @@ namespace System.Reactive.Concurrency
             return recursiveInvoker;
         }
 
-        abstract class InvokeRecBaseState<TState> : IDisposable
+        private abstract class InvokeRecBaseState<TState> : IDisposable
         {
             protected readonly IScheduler scheduler;
 
@@ -161,11 +190,10 @@ namespace System.Reactive.Concurrency
 
         }
 
-        sealed class InvokeRec1State<TState> : InvokeRecBaseState<TState>
+        private sealed class InvokeRec1State<TState> : InvokeRecBaseState<TState>
         {
-            readonly Action<TState, Action<TState>> action;
-
-            readonly Action<TState> recurseCallback;
+            private readonly Action<TState, Action<TState>> action;
+            private readonly Action<TState> recurseCallback;
 
             public InvokeRec1State(IScheduler scheduler, Action<TState, Action<TState>> action) : base(scheduler)
             {
@@ -177,7 +205,8 @@ namespace System.Reactive.Concurrency
             {
                 var sad = new SingleAssignmentDisposable();
                 group.Add(sad);
-                sad.Disposable = scheduler.Schedule((state, sad, @this: this), (_, nextState) => {
+                sad.Disposable = scheduler.Schedule((state, sad, @this: this), (_, nextState) =>
+                {
                     [email protected](nextState.sad);
                     [email protected](nextState.state);
                     return Disposable.Empty;
@@ -190,11 +219,10 @@ namespace System.Reactive.Concurrency
             }
         }
 
-        sealed class InvokeRec2State<TState> : InvokeRecBaseState<TState>
+        private sealed class InvokeRec2State<TState> : InvokeRecBaseState<TState>
         {
-            readonly Action<TState, Action<TState, TimeSpan>> action;
-
-            readonly Action<TState, TimeSpan> recurseCallback;
+            private readonly Action<TState, Action<TState, TimeSpan>> action;
+            private readonly Action<TState, TimeSpan> recurseCallback;
 
             public InvokeRec2State(IScheduler scheduler, Action<TState, Action<TState, TimeSpan>> action) : base(scheduler)
             {
@@ -206,7 +234,8 @@ namespace System.Reactive.Concurrency
             {
                 var sad = new SingleAssignmentDisposable();
                 group.Add(sad);
-                sad.Disposable = scheduler.Schedule((state, sad, @this: this), time, (_, nextState) => {
+                sad.Disposable = scheduler.Schedule((state, sad, @this: this), time, (_, nextState) =>
+                {
                     [email protected](nextState.sad);
                     [email protected](nextState.state);
                     return Disposable.Empty;
@@ -219,11 +248,10 @@ namespace System.Reactive.Concurrency
             }
         }
 
-        sealed class InvokeRec3State<TState> : InvokeRecBaseState<TState>
+        private sealed class InvokeRec3State<TState> : InvokeRecBaseState<TState>
         {
-            readonly Action<TState, Action<TState, DateTimeOffset>> action;
-
-            readonly Action<TState, DateTimeOffset> recurseCallback;
+            private readonly Action<TState, Action<TState, DateTimeOffset>> action;
+            private readonly Action<TState, DateTimeOffset> recurseCallback;
 
             public InvokeRec3State(IScheduler scheduler, Action<TState, Action<TState, DateTimeOffset>> action) : base(scheduler)
             {
@@ -235,7 +263,8 @@ namespace System.Reactive.Concurrency
             {
                 var sad = new SingleAssignmentDisposable();
                 group.Add(sad);
-                sad.Disposable = scheduler.Schedule((state, sad, @this: this), dtOffset, (_, nextState) => {
+                sad.Disposable = scheduler.Schedule((state, sad, @this: this), dtOffset, (_, nextState) =>
+                {
                     [email protected](nextState.sad);
                     [email protected](nextState.state);
                     return Disposable.Empty;

+ 28 - 0
Rx.NET/Source/src/System.Reactive/Concurrency/Scheduler.Services.Emulation.cs

@@ -28,11 +28,19 @@ namespace System.Reactive.Concurrency
         public static IDisposable SchedulePeriodic<TState>(this IScheduler scheduler, TState state, TimeSpan period, Func<TState, TState> action)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
+
             if (period < TimeSpan.Zero)
+            {
                 throw new ArgumentOutOfRangeException(nameof(period));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return SchedulePeriodic_(scheduler, state, period, action);
         }
@@ -54,11 +62,19 @@ namespace System.Reactive.Concurrency
         public static IDisposable SchedulePeriodic<TState>(this IScheduler scheduler, TState state, TimeSpan period, Action<TState> action)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
+
             if (period < TimeSpan.Zero)
+            {
                 throw new ArgumentOutOfRangeException(nameof(period));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return SchedulePeriodic_(scheduler, (state, action), period, t => { t.action(t.state); return t; });
         }
@@ -78,11 +94,19 @@ namespace System.Reactive.Concurrency
         public static IDisposable SchedulePeriodic(this IScheduler scheduler, TimeSpan period, Action action)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
+
             if (period < TimeSpan.Zero)
+            {
                 throw new ArgumentOutOfRangeException(nameof(period));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return SchedulePeriodic_(scheduler, action, period, a => { a(); return a; });
         }
@@ -99,7 +123,9 @@ namespace System.Reactive.Concurrency
         public static IStopwatch StartStopwatch(this IScheduler scheduler)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             //
             // All schedulers deriving from LocalScheduler will automatically pick up this
@@ -576,7 +602,9 @@ namespace System.Reactive.Concurrency
                         // safely bail out, delegating work to the catch-up tail calls.
                         //
                         if (Interlocked.Increment(ref _pendingTickCount) == 1)
+                        {
                             goto case DISPATCH_START;
+                        }
 
                         break;
 

+ 36 - 1
Rx.NET/Source/src/System.Reactive/Concurrency/Scheduler.Simple.cs

@@ -18,9 +18,14 @@ namespace System.Reactive.Concurrency
         public static IDisposable Schedule(this IScheduler scheduler, Action action)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             // Surprisingly, passing the method group of Invoke will create a fresh
             // delegate each time although it's static, while an anonymous
@@ -44,12 +49,17 @@ namespace System.Reactive.Concurrency
         internal static IDisposable ScheduleAction<TState>(this IScheduler scheduler, TState state, Action<TState> action)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return scheduler.Schedule(
-                (action, state), 
+                (action, state),
                 (_, tuple) =>
                 {
                     tuple.action(tuple.state);
@@ -68,9 +78,14 @@ namespace System.Reactive.Concurrency
         public static IDisposable Schedule(this IScheduler scheduler, TimeSpan dueTime, Action action)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             // See note above.
             return scheduler.Schedule(action, dueTime, (s, a) => Invoke(s, a));
@@ -88,9 +103,14 @@ namespace System.Reactive.Concurrency
         internal static IDisposable ScheduleAction<TState>(this IScheduler scheduler, TState state, TimeSpan dueTime, Action<TState> action)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             // See note above.
             return scheduler.Schedule((state, action), dueTime, (s, tuple) => Invoke(s, tuple));
@@ -107,9 +127,14 @@ namespace System.Reactive.Concurrency
         public static IDisposable Schedule(this IScheduler scheduler, DateTimeOffset dueTime, Action action)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             // See note above.
             return scheduler.Schedule(action, dueTime, (s, a) => Invoke(s, a));
@@ -127,9 +152,14 @@ namespace System.Reactive.Concurrency
         internal static IDisposable ScheduleAction<TState>(this IScheduler scheduler, TState state, DateTimeOffset dueTime, Action<TState> action)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             // See note above.
             return scheduler.Schedule((state, action), dueTime, (s, tuple) => Invoke(s, tuple));
@@ -145,9 +175,14 @@ namespace System.Reactive.Concurrency
         public static IDisposable ScheduleLongRunning(this ISchedulerLongRunning scheduler, Action<ICancelable> action)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return scheduler.ScheduleLongRunning(action, (a, c) => a(c));
         }

+ 12 - 0
Rx.NET/Source/src/System.Reactive/Concurrency/Scheduler.Wrappers.cs

@@ -15,7 +15,9 @@ namespace System.Reactive.Concurrency
         public static IScheduler DisableOptimizations(this IScheduler scheduler)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return new DisableOptimizationsScheduler(scheduler);
         }
@@ -30,9 +32,14 @@ namespace System.Reactive.Concurrency
         public static IScheduler DisableOptimizations(this IScheduler scheduler, params Type[] optimizationInterfaces)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
+
             if (optimizationInterfaces == null)
+            {
                 throw new ArgumentNullException(nameof(optimizationInterfaces));
+            }
 
             return new DisableOptimizationsScheduler(scheduler, optimizationInterfaces);
         }
@@ -49,9 +56,14 @@ namespace System.Reactive.Concurrency
             where TException : Exception
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
+
             if (handler == null)
+            {
                 throw new ArgumentNullException(nameof(handler));
+            }
 
             return new CatchScheduler<TException>(scheduler, handler);
         }

+ 4 - 1
Rx.NET/Source/src/System.Reactive/Concurrency/Scheduler.cs

@@ -2,8 +2,8 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System.Reactive.PlatformServices;
 using System.Globalization;
+using System.Reactive.PlatformServices;
 
 namespace System.Reactive.Concurrency
 {
@@ -90,7 +90,10 @@ namespace System.Reactive.Concurrency
             var res = PlatformEnlightenmentProvider.Current.GetService<IScheduler>(name);
 #pragma warning restore CS0618 // Type or member is obsolete
             if (res == null)
+            {
                 throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, Strings_Core.CANT_OBTAIN_SCHEDULER, name));
+            }
+
             return res;
         }
     }

+ 4 - 0
Rx.NET/Source/src/System.Reactive/Concurrency/SchedulerOperation.cs

@@ -89,10 +89,14 @@ namespace System.Reactive.Concurrency
         public void OnCompleted(Action continuation)
         {
             if (continuation == null)
+            {
                 throw new ArgumentNullException(nameof(continuation));
+            }
 
             if (_continuation != null)
+            {
                 throw new InvalidOperationException(Strings_Core.SCHEDULER_OPERATION_ALREADY_AWAITED);
+            }
 
             if (_postBackToOriginalContext)
             {

+ 2 - 0
Rx.NET/Source/src/System.Reactive/Concurrency/SchedulerQueue.cs

@@ -31,7 +31,9 @@ namespace System.Reactive.Concurrency
         public SchedulerQueue(int capacity)
         {
             if (capacity < 0)
+            {
                 throw new ArgumentOutOfRangeException(nameof(capacity));
+            }
 
             _queue = new PriorityQueue<ScheduledItem<TAbsolute>>(capacity);
         }

+ 10 - 0
Rx.NET/Source/src/System.Reactive/Concurrency/SchedulerWrapper.cs

@@ -28,7 +28,9 @@ namespace System.Reactive.Concurrency
         public IDisposable Schedule<TState>(TState state, Func<IScheduler, TState, IDisposable> action)
         {
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return _scheduler.Schedule(state, Wrap(action));
         }
@@ -36,7 +38,9 @@ namespace System.Reactive.Concurrency
         public IDisposable Schedule<TState>(TState state, TimeSpan dueTime, Func<IScheduler, TState, IDisposable> action)
         {
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return _scheduler.Schedule(state, dueTime, Wrap(action));
         }
@@ -44,7 +48,9 @@ namespace System.Reactive.Concurrency
         public IDisposable Schedule<TState>(TState state, DateTimeOffset dueTime, Func<IScheduler, TState, IDisposable> action)
         {
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return _scheduler.Schedule(state, dueTime, Wrap(action));
         }
@@ -65,10 +71,14 @@ namespace System.Reactive.Concurrency
         {
             var serviceProvider = _scheduler as IServiceProvider;
             if (serviceProvider == null)
+            {
                 return null;
+            }
 
             if (TryGetService(serviceProvider, serviceType, out var result))
+            {
                 return result;
+            }
 
             return serviceProvider.GetService(serviceType);
         }

+ 34 - 8
Rx.NET/Source/src/System.Reactive/Concurrency/Synchronization.cs

@@ -31,14 +31,19 @@ namespace System.Reactive.Concurrency
         public static IObservable<TSource> SubscribeOn<TSource>(IObservable<TSource> source, IScheduler scheduler)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return new SubscribeOnObservable<TSource>(source, scheduler);
         }
 
-        sealed class SubscribeOnObservable<TSource> : ObservableBase<TSource>
+        private sealed class SubscribeOnObservable<TSource> : ObservableBase<TSource>
         {
             private sealed class Subscription : IDisposable
             {
@@ -47,7 +52,7 @@ namespace System.Reactive.Concurrency
                 public Subscription(IObservable<TSource> source, IScheduler scheduler, IObserver<TSource> observer)
                 {
                     Disposable.TrySetSingle(
-                        ref _cancel, 
+                        ref _cancel,
                         scheduler.Schedule(
                             (@this: this, source, observer),
                             (closureScheduler, state) =>
@@ -63,8 +68,8 @@ namespace System.Reactive.Concurrency
                 }
             }
 
-            readonly IObservable<TSource> source;
-            readonly IScheduler scheduler;
+            private readonly IObservable<TSource> source;
+            private readonly IScheduler scheduler;
 
             public SubscribeOnObservable(IObservable<TSource> source, IScheduler scheduler)
             {
@@ -93,21 +98,25 @@ namespace System.Reactive.Concurrency
         public static IObservable<TSource> SubscribeOn<TSource>(IObservable<TSource> source, SynchronizationContext context)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (context == null)
+            {
                 throw new ArgumentNullException(nameof(context));
+            }
 
             return new SubscribeOnCtxObservable<TSource>(source, context);
         }
 
-        sealed class SubscribeOnCtxObservable<TSource> : ObservableBase<TSource>
+        private sealed class SubscribeOnCtxObservable<TSource> : ObservableBase<TSource>
         {
             private sealed class Subscription : IDisposable
             {
                 private readonly IObservable<TSource> _source;
                 private readonly IObserver<TSource> _observer;
                 private readonly SynchronizationContext _context;
-
                 private IDisposable _cancel;
 
                 public Subscription(IObservable<TSource> source, SynchronizationContext context, IObserver<TSource> observer)
@@ -133,8 +142,8 @@ namespace System.Reactive.Concurrency
                 }
             }
 
-            readonly IObservable<TSource> _source;
-            readonly SynchronizationContext _context;
+            private readonly IObservable<TSource> _source;
+            private readonly SynchronizationContext _context;
 
             public SubscribeOnCtxObservable(IObservable<TSource> source, SynchronizationContext context)
             {
@@ -163,9 +172,14 @@ namespace System.Reactive.Concurrency
         public static IObservable<TSource> ObserveOn<TSource>(IObservable<TSource> source, IScheduler scheduler)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return new ObserveOn<TSource>.Scheduler(source, scheduler);
         }
@@ -181,9 +195,14 @@ namespace System.Reactive.Concurrency
         public static IObservable<TSource> ObserveOn<TSource>(IObservable<TSource> source, SynchronizationContext context)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (context == null)
+            {
                 throw new ArgumentNullException(nameof(context));
+            }
 
             return new ObserveOn<TSource>.Context(source, context);
         }
@@ -202,7 +221,9 @@ namespace System.Reactive.Concurrency
         public static IObservable<TSource> Synchronize<TSource>(IObservable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return new Synchronize<TSource>(source);
         }
@@ -218,9 +239,14 @@ namespace System.Reactive.Concurrency
         public static IObservable<TSource> Synchronize<TSource>(IObservable<TSource> source, object gate)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (gate == null)
+            {
                 throw new ArgumentNullException(nameof(gate));
+            }
 
             return new Synchronize<TSource>(source, gate);
         }

+ 6 - 8
Rx.NET/Source/src/System.Reactive/Concurrency/SynchronizationContextScheduler.cs

@@ -22,10 +22,7 @@ namespace System.Reactive.Concurrency
         /// <exception cref="ArgumentNullException"><paramref name="context"/> is <c>null</c>.</exception>
         public SynchronizationContextScheduler(SynchronizationContext context)
         {
-            if (context == null)
-                throw new ArgumentNullException(nameof(context));
-
-            _context = context;
+            _context = context ?? throw new ArgumentNullException(nameof(context));
             _alwaysPost = true;
         }
 
@@ -37,10 +34,7 @@ namespace System.Reactive.Concurrency
         /// <exception cref="ArgumentNullException"><paramref name="context"/> is <c>null</c>.</exception>
         public SynchronizationContextScheduler(SynchronizationContext context, bool alwaysPost)
         {
-            if (context == null)
-                throw new ArgumentNullException(nameof(context));
-
-            _context = context;
+            _context = context ?? throw new ArgumentNullException(nameof(context));
             _alwaysPost = alwaysPost;
         }
 
@@ -55,7 +49,9 @@ namespace System.Reactive.Concurrency
         public override IDisposable Schedule<TState>(TState state, Func<IScheduler, TState, IDisposable> action)
         {
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             if (!_alwaysPost && _context == SynchronizationContext.Current)
             {
@@ -87,7 +83,9 @@ namespace System.Reactive.Concurrency
         public override IDisposable Schedule<TState>(TState state, TimeSpan dueTime, Func<IScheduler, TState, IDisposable> action)
         {
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             var dt = Scheduler.Normalize(dueTime);
             if (dt.Ticks == 0)

+ 12 - 6
Rx.NET/Source/src/System.Reactive/Concurrency/TaskPoolScheduler.cs

@@ -126,7 +126,7 @@ namespace System.Reactive.Concurrency
                 scheduler.taskFactory.StartNew(
                     @thisObject =>
                     {
-                        var @this = (LongScheduledWorkItem<TState>) thisObject;
+                        var @this = (LongScheduledWorkItem<TState>)thisObject;
 
                         //
                         // Notice we don't check _cancel.IsDisposed. The contract for ISchedulerLongRunning
@@ -157,10 +157,7 @@ namespace System.Reactive.Concurrency
         /// <exception cref="ArgumentNullException"><paramref name="taskFactory"/> is <c>null</c>.</exception>
         public TaskPoolScheduler(TaskFactory taskFactory)
         {
-            if (taskFactory == null)
-                throw new ArgumentNullException(nameof(taskFactory));
-
-            this.taskFactory = taskFactory;
+            this.taskFactory = taskFactory ?? throw new ArgumentNullException(nameof(taskFactory));
         }
 
         /// <summary>
@@ -179,7 +176,9 @@ namespace System.Reactive.Concurrency
         public override IDisposable Schedule<TState>(TState state, Func<IScheduler, TState, IDisposable> action)
         {
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return new ScheduledWorkItem<TState>(this, state, action);
         }
@@ -196,7 +195,9 @@ namespace System.Reactive.Concurrency
         public override IDisposable Schedule<TState>(TState state, TimeSpan dueTime, Func<IScheduler, TState, IDisposable> action)
         {
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             var dt = Scheduler.Normalize(dueTime);
             if (dt.Ticks == 0)
@@ -252,9 +253,14 @@ namespace System.Reactive.Concurrency
         public IDisposable SchedulePeriodic<TState>(TState state, TimeSpan period, Func<TState, TState> action)
         {
             if (period < TimeSpan.Zero)
+            {
                 throw new ArgumentOutOfRangeException(nameof(period));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return new PeriodicallyScheduledWorkItem<TState>(state, period, action, taskFactory);
         }
@@ -300,7 +306,7 @@ namespace System.Reactive.Concurrency
                     },
                     this,
                     CancellationToken.None,
-                    TaskContinuationOptions.ExecuteSynchronously | TaskContinuationOptions.OnlyOnRanToCompletion, 
+                    TaskContinuationOptions.ExecuteSynchronously | TaskContinuationOptions.OnlyOnRanToCompletion,
                     _taskFactory.Scheduler
                 );
             }

+ 1 - 1
Rx.NET/Source/src/System.Reactive/Concurrency/Thread.Stub.cs

@@ -27,6 +27,6 @@ namespace System.Reactive.Concurrency
         private void Run() => _start();
     }
 
-    delegate void ThreadStart();
+    internal delegate void ThreadStart();
 }
 #endif

+ 12 - 1
Rx.NET/Source/src/System.Reactive/Concurrency/ThreadPoolScheduler.cs

@@ -38,12 +38,14 @@ namespace System.Reactive.Concurrency
         public override IDisposable Schedule<TState>(TState state, Func<IScheduler, TState, IDisposable> action)
         {
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             var workItem = new UserWorkItem<TState>(this, state, action);
 
             ThreadPool.QueueUserWorkItem(
-                closureWorkItem => ((UserWorkItem<TState>)closureWorkItem).Run(), 
+                closureWorkItem => ((UserWorkItem<TState>)closureWorkItem).Run(),
                 workItem);
 
             return workItem;
@@ -61,7 +63,9 @@ namespace System.Reactive.Concurrency
         public override IDisposable Schedule<TState>(TState state, TimeSpan dueTime, Func<IScheduler, TState, IDisposable> action)
         {
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             var dt = Scheduler.Normalize(dueTime);
             if (dt.Ticks == 0)
@@ -91,7 +95,9 @@ namespace System.Reactive.Concurrency
         public IDisposable ScheduleLongRunning<TState>(TState state, Action<TState, ICancelable> action)
         {
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return s_newBackgroundThread.Value.ScheduleLongRunning(state, action);
         }
@@ -123,9 +129,14 @@ namespace System.Reactive.Concurrency
         public IDisposable SchedulePeriodic<TState>(TState state, TimeSpan period, Func<TState, TState> action)
         {
             if (period < TimeSpan.Zero)
+            {
                 throw new ArgumentOutOfRangeException(nameof(period));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             if (period == TimeSpan.Zero)
             {

+ 10 - 0
Rx.NET/Source/src/System.Reactive/Concurrency/VirtualTimeScheduler.Extensions.cs

@@ -25,9 +25,14 @@ namespace System.Reactive.Concurrency
             where TAbsolute : IComparable<TAbsolute>
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             // As stated in Scheduler.Simple.cs,
             // an anonymous delegate will allow delegate caching.
@@ -50,9 +55,14 @@ namespace System.Reactive.Concurrency
             where TAbsolute : IComparable<TAbsolute>
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
+
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return scheduler.ScheduleAbsolute(action, dueTime, (s, a) => Invoke(s, a));
         }

+ 24 - 6
Rx.NET/Source/src/System.Reactive/Concurrency/VirtualTimeScheduler.cs

@@ -4,7 +4,6 @@
 
 using System.Collections.Generic;
 using System.Globalization;
-using System.Reactive.Disposables;
 
 namespace System.Reactive.Concurrency
 {
@@ -20,7 +19,7 @@ namespace System.Reactive.Concurrency
         /// Creates a new virtual time scheduler with the default value of TAbsolute as the initial clock value.
         /// </summary>
         protected VirtualTimeSchedulerBase()
-            : this(default(TAbsolute), Comparer<TAbsolute>.Default)
+            : this(default, Comparer<TAbsolute>.Default)
         {
         }
 
@@ -32,11 +31,8 @@ namespace System.Reactive.Concurrency
         /// <exception cref="ArgumentNullException"><paramref name="comparer"/> is <c>null</c>.</exception>
         protected VirtualTimeSchedulerBase(TAbsolute initialClock, IComparer<TAbsolute> comparer)
         {
-            if (comparer == null)
-                throw new ArgumentNullException(nameof(comparer));
-
             Clock = initialClock;
-            Comparer = comparer;
+            Comparer = comparer ?? throw new ArgumentNullException(nameof(comparer));
         }
 
         /// <summary>
@@ -92,7 +88,9 @@ namespace System.Reactive.Concurrency
         public IDisposable ScheduleRelative<TState>(TState state, TRelative dueTime, Func<IScheduler, TState, IDisposable> action)
         {
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             var runAt = Add(Clock, dueTime);
 
@@ -110,7 +108,9 @@ namespace System.Reactive.Concurrency
         public IDisposable Schedule<TState>(TState state, Func<IScheduler, TState, IDisposable> action)
         {
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return ScheduleAbsolute(state, Clock, action);
         }
@@ -127,7 +127,9 @@ namespace System.Reactive.Concurrency
         public IDisposable Schedule<TState>(TState state, TimeSpan dueTime, Func<IScheduler, TState, IDisposable> action)
         {
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return ScheduleRelative(state, ToRelative(dueTime), action);
         }
@@ -144,7 +146,9 @@ namespace System.Reactive.Concurrency
         public IDisposable Schedule<TState>(TState state, DateTimeOffset dueTime, Func<IScheduler, TState, IDisposable> action)
         {
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             return ScheduleRelative(state, ToRelative(dueTime - Now), action);
         }
@@ -195,10 +199,14 @@ namespace System.Reactive.Concurrency
         {
             var dueToClock = Comparer.Compare(time, Clock);
             if (dueToClock < 0)
+            {
                 throw new ArgumentOutOfRangeException(nameof(time));
+            }
 
             if (dueToClock == 0)
+            {
                 return;
+            }
 
             if (!IsEnabled)
             {
@@ -241,10 +249,14 @@ namespace System.Reactive.Concurrency
 
             var dueToClock = Comparer.Compare(dt, Clock);
             if (dueToClock < 0)
+            {
                 throw new ArgumentOutOfRangeException(nameof(time));
+            }
 
             if (dueToClock == 0)
+            {
                 return;
+            }
 
             if (!IsEnabled)
             {
@@ -267,7 +279,9 @@ namespace System.Reactive.Concurrency
 
             var dueToClock = Comparer.Compare(dt, Clock);
             if (dueToClock < 0)
+            {
                 throw new ArgumentOutOfRangeException(nameof(time));
+            }
 
             Clock = dt;
         }
@@ -305,7 +319,9 @@ namespace System.Reactive.Concurrency
         protected virtual object GetService(Type serviceType)
         {
             if (serviceType == typeof(IStopwatchProvider))
+            {
                 return this as IStopwatchProvider;
+            }
 
             return null;
         }
@@ -399,7 +415,9 @@ namespace System.Reactive.Concurrency
         public override IDisposable ScheduleAbsolute<TState>(TState state, TAbsolute dueTime, Func<IScheduler, TState, IDisposable> action)
         {
             if (action == null)
+            {
                 throw new ArgumentNullException(nameof(action));
+            }
 
             var si = default(ScheduledItem<TAbsolute, TState>);
 

+ 1 - 4
Rx.NET/Source/src/System.Reactive/Disposables/CancellationDisposable.cs

@@ -20,10 +20,7 @@ namespace System.Reactive.Disposables
         /// <exception cref="ArgumentNullException"><paramref name="cts"/> is <c>null</c>.</exception>
         public CancellationDisposable(CancellationTokenSource cts)
         {
-            if (cts == null)
-                throw new ArgumentNullException(nameof(cts));
-
-            _cts = cts;
+            _cts = cts ?? throw new ArgumentNullException(nameof(cts));
         }
 
         /// <summary>

+ 19 - 7
Rx.NET/Source/src/System.Reactive/Disposables/CompositeDisposable.cs

@@ -4,7 +4,6 @@
 
 using System.Collections;
 using System.Collections.Generic;
-using System.Linq;
 using System.Threading;
 
 namespace System.Reactive.Disposables
@@ -16,7 +15,6 @@ namespace System.Reactive.Disposables
     public sealed class CompositeDisposable : ICollection<IDisposable>, ICancelable
     {
         private readonly object _gate = new object();
-
         private bool _disposed;
         private List<IDisposable> _disposables;
         private int _count;
@@ -42,7 +40,9 @@ namespace System.Reactive.Disposables
         public CompositeDisposable(int capacity)
         {
             if (capacity < 0)
+            {
                 throw new ArgumentOutOfRangeException(nameof(capacity));
+            }
 
             _disposables = new List<IDisposable>(capacity);
         }
@@ -72,7 +72,9 @@ namespace System.Reactive.Disposables
         public CompositeDisposable(IEnumerable<IDisposable> disposables)
         {
             if (disposables == null)
+            {
                 throw new ArgumentNullException(nameof(disposables));
+            }
 
             // If the disposables is a collection, get its size
             // and use it as a capacity hint for the copy.
@@ -126,7 +128,9 @@ namespace System.Reactive.Disposables
         public void Add(IDisposable item)
         {
             if (item == null)
+            {
                 throw new ArgumentNullException(nameof(item));
+            }
 
             lock (_gate)
             {
@@ -153,7 +157,9 @@ namespace System.Reactive.Disposables
         public bool Remove(IDisposable item)
         {
             if (item == null)
+            {
                 throw new ArgumentNullException(nameof(item));
+            }
 
             lock (_gate)
             {
@@ -278,7 +284,9 @@ namespace System.Reactive.Disposables
         public bool Contains(IDisposable item)
         {
             if (item == null)
+            {
                 throw new ArgumentNullException(nameof(item));
+            }
 
             lock (_gate)
             {
@@ -300,9 +308,14 @@ namespace System.Reactive.Disposables
         public void CopyTo(IDisposable[] array, int arrayIndex)
         {
             if (array == null)
+            {
                 throw new ArgumentNullException(nameof(array));
+            }
+
             if (arrayIndex < 0 || arrayIndex >= array.Length)
+            {
                 throw new ArgumentOutOfRangeException(nameof(arrayIndex));
+            }
 
             lock (_gate)
             {
@@ -367,17 +380,16 @@ namespace System.Reactive.Disposables
         /// An empty enumerator for the <see cref="GetEnumerator"/>
         /// method to avoid allocation on disposed or empty composites.
         /// </summary>
-        static readonly CompositeEnumerator EMPTY_ENUMERATOR =
+        private static readonly CompositeEnumerator EMPTY_ENUMERATOR =
             new CompositeEnumerator(new IDisposable[0]);
 
         /// <summary>
         /// An enumerator for an array of disposables.
         /// </summary>
-        sealed class CompositeEnumerator : IEnumerator<IDisposable>
+        private sealed class CompositeEnumerator : IEnumerator<IDisposable>
         {
-            readonly IDisposable[] disposables;
-
-            int index;
+            private readonly IDisposable[] disposables;
+            private int index;
 
             public CompositeEnumerator(IDisposable[] disposables)
             {

+ 3 - 3
Rx.NET/Source/src/System.Reactive/Disposables/ContextDisposable.cs

@@ -22,12 +22,12 @@ namespace System.Reactive.Disposables
         /// <exception cref="ArgumentNullException"><paramref name="context"/> or <paramref name="disposable"/> is null.</exception>
         public ContextDisposable(SynchronizationContext context, IDisposable disposable)
         {
-            if (context == null)
-                throw new ArgumentNullException(nameof(context));
             if (disposable == null)
+            {
                 throw new ArgumentNullException(nameof(disposable));
+            }
 
-            Context = context;
+            Context = context ?? throw new ArgumentNullException(nameof(context));
             Disposable.SetSingle(ref _disposable, disposable);
         }
 

+ 15 - 1
Rx.NET/Source/src/System.Reactive/Disposables/Disposable.cs

@@ -55,7 +55,9 @@ namespace System.Reactive.Disposables
         public static IDisposable Create(Action dispose)
         {
             if (dispose == null)
+            {
                 throw new ArgumentNullException(nameof(dispose));
+            }
 
             return new AnonymousDisposable(dispose);
         }
@@ -70,7 +72,9 @@ namespace System.Reactive.Disposables
         public static IDisposable Create<TState>(TState state, Action<TState> dispose)
         {
             if (dispose == null)
+            {
                 throw new ArgumentNullException(nameof(dispose));
+            }
 
             return new AnonymousDisposable<TState>(state, dispose);
         }
@@ -83,7 +87,7 @@ namespace System.Reactive.Disposables
         {
             var current = Volatile.Read(ref fieldRef);
 
-            return current == BooleanDisposable.True 
+            return current == BooleanDisposable.True
                 ? null
                 : current;
         }
@@ -113,7 +117,9 @@ namespace System.Reactive.Disposables
             var result = TrySetSingle(ref fieldRef, value);
 
             if (result == TrySetSingleResult.AlreadyAssigned)
+            {
                 throw new InvalidOperationException(Strings_Core.DISPOSABLE_ALREADY_ASSIGNED);
+            }
 
             return result == TrySetSingleResult.Success;
         }
@@ -126,10 +132,14 @@ namespace System.Reactive.Disposables
         {
             var old = Interlocked.CompareExchange(ref fieldRef, value, null);
             if (old == null)
+            {
                 return TrySetSingleResult.Success;
+            }
 
             if (old != BooleanDisposable.True)
+            {
                 return TrySetSingleResult.AlreadyAssigned;
+            }
 
             value?.Dispose();
             return TrySetSingleResult.Disposed;
@@ -220,7 +230,9 @@ namespace System.Reactive.Disposables
             var old = Interlocked.Exchange(ref fieldRef, BooleanDisposable.True);
 
             if (old == BooleanDisposable.True)
+            {
                 return false;
+            }
 
             old?.Dispose();
             return true;
@@ -231,7 +243,9 @@ namespace System.Reactive.Disposables
             var old = Interlocked.Exchange(ref fieldRef, BooleanDisposable.True);
 
             if (old == BooleanDisposable.True)
+            {
                 return false;
+            }
 
             disposeAction(old, state);
             return true;

+ 0 - 1
Rx.NET/Source/src/System.Reactive/Disposables/MultipleAssignmentDisposable.cs

@@ -2,7 +2,6 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System.Threading;
 
 namespace System.Reactive.Disposables
 {

+ 7 - 6
Rx.NET/Source/src/System.Reactive/Disposables/RefCountDisposable.cs

@@ -37,10 +37,7 @@ namespace System.Reactive.Disposables
         /// <exception cref="ArgumentNullException"><paramref name="disposable"/> is null.</exception>
         public RefCountDisposable(IDisposable disposable, bool throwWhenDisposed)
         {
-            if (disposable == null)
-                throw new ArgumentNullException(nameof(disposable));
-
-            _disposable = disposable;
+            _disposable = disposable ?? throw new ArgumentNullException(nameof(disposable));
             _count = 0;
             _throwWhenDisposed = throwWhenDisposed;
         }
@@ -67,7 +64,9 @@ namespace System.Reactive.Disposables
                 if (cnt == int.MinValue)
                 {
                     if (_throwWhenDisposed)
+                    {
                         throw new ObjectDisposedException("RefCountDisposable");
+                    }
 
                     return Disposable.Empty;
                 }
@@ -114,7 +113,8 @@ namespace System.Reactive.Disposables
 
                 var b = Interlocked.CompareExchange(ref _count, u, cnt);
 
-                if (b == cnt) {
+                if (b == cnt)
+                {
                     // if there were 0 active disposables, there can't be any more after
                     // the CAS so we can dispose the underlying disposable
                     if (active == 0)
@@ -147,7 +147,8 @@ namespace System.Reactive.Disposables
 
                 var b = Interlocked.CompareExchange(ref _count, u, cnt);
 
-                if (b == cnt) {
+                if (b == cnt)
+                {
                     // if after the CAS there was zero active disposables and
                     // the main has been also marked for disposing,
                     // it is safe to dispose the underlying disposable

+ 3 - 4
Rx.NET/Source/src/System.Reactive/Disposables/ScheduledDisposable.cs

@@ -3,7 +3,6 @@
 // See the LICENSE file in the project root for more information. 
 
 using System.Reactive.Concurrency;
-using System.Threading;
 
 namespace System.Reactive.Disposables
 {
@@ -22,12 +21,12 @@ namespace System.Reactive.Disposables
         /// <exception cref="ArgumentNullException"><paramref name="scheduler"/> or <paramref name="disposable"/> is null.</exception>
         public ScheduledDisposable(IScheduler scheduler, IDisposable disposable)
         {
-            if (scheduler == null)
-                throw new ArgumentNullException(nameof(scheduler));
             if (disposable == null)
+            {
                 throw new ArgumentNullException(nameof(disposable));
+            }
 
-            Scheduler = scheduler;
+            Scheduler = scheduler ?? throw new ArgumentNullException(nameof(scheduler));
             Disposables.Disposable.SetSingle(ref _disposable, disposable);
         }
 

+ 0 - 1
Rx.NET/Source/src/System.Reactive/Disposables/SerialDisposable.cs

@@ -2,7 +2,6 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System.Threading;
 
 namespace System.Reactive.Disposables
 {

+ 0 - 1
Rx.NET/Source/src/System.Reactive/Disposables/SingleAssignmentDisposable.cs

@@ -2,7 +2,6 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System.Threading;
 
 namespace System.Reactive.Disposables
 {

+ 11 - 0
Rx.NET/Source/src/System.Reactive/Disposables/StableCompositeDisposable.cs

@@ -21,9 +21,14 @@ namespace System.Reactive.Disposables
         public static ICancelable Create(IDisposable disposable1, IDisposable disposable2)
         {
             if (disposable1 == null)
+            {
                 throw new ArgumentNullException(nameof(disposable1));
+            }
+
             if (disposable2 == null)
+            {
                 throw new ArgumentNullException(nameof(disposable2));
+            }
 
             return new Binary(disposable1, disposable2);
         }
@@ -36,7 +41,9 @@ namespace System.Reactive.Disposables
         public static ICancelable Create(params IDisposable[] disposables)
         {
             if (disposables == null)
+            {
                 throw new ArgumentNullException(nameof(disposables));
+            }
 
             return new NAry(disposables);
         }
@@ -49,7 +56,9 @@ namespace System.Reactive.Disposables
         public static ICancelable Create(IEnumerable<IDisposable> disposables)
         {
             if (disposables == null)
+            {
                 throw new ArgumentNullException(nameof(disposables));
+            }
 
             return new NAry(disposables);
         }
@@ -104,7 +113,9 @@ namespace System.Reactive.Disposables
                 // Doing this on the list to avoid duplicate enumeration of disposables.
                 //
                 if (_disposables.Contains(null))
+                {
                     throw new ArgumentException(Strings_Core.DISPOSABLES_CANT_CONTAIN_NULL, nameof(disposables));
+                }
             }
 
             public override bool IsDisposed => _disposables == null;

+ 6 - 1
Rx.NET/Source/src/System.Reactive/EventPattern.cs

@@ -58,10 +58,15 @@ namespace System.Reactive
         /// <returns><c>true</c> if both <see cref="EventPattern{TSender, TEventArgs}"/> objects represent the same event; otherwise, <c>false</c>.</returns>
         public bool Equals(EventPattern<TSender, TEventArgs> other)
         {
-            if (ReferenceEquals(null, other))
+            if (other is null)
+            {
                 return false;
+            }
+
             if (ReferenceEquals(this, other))
+            {
                 return true;
+            }
 
             return EqualityComparer<TSender>.Default.Equals(Sender, other.Sender) && EqualityComparer<TEventArgs>.Default.Equals(EventArgs, other.EventArgs);
         }

+ 9 - 7
Rx.NET/Source/src/System.Reactive/EventPatternSourceBase.cs

@@ -27,13 +27,8 @@ namespace System.Reactive
         /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="invokeHandler"/> is <c>null</c>.</exception>
         protected EventPatternSourceBase(IObservable<EventPattern<TSender, TEventArgs>> source, Action<Action<TSender, TEventArgs>, /*object,*/ EventPattern<TSender, TEventArgs>> invokeHandler)
         {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-            if (invokeHandler == null)
-                throw new ArgumentNullException(nameof(invokeHandler));
-
-            _source = source;
-            _invokeHandler = invokeHandler;
+            _source = source ?? throw new ArgumentNullException(nameof(source));
+            _invokeHandler = invokeHandler ?? throw new ArgumentNullException(nameof(invokeHandler));
             _subscriptions = new Dictionary<Delegate, Stack<IDisposable>>();
         }
 
@@ -46,9 +41,14 @@ namespace System.Reactive
         protected void Add(Delegate handler, Action<TSender, TEventArgs> invoke)
         {
             if (handler == null)
+            {
                 throw new ArgumentNullException(nameof(handler));
+            }
+
             if (invoke == null)
+            {
                 throw new ArgumentNullException(nameof(invoke));
+            }
 
             var gate = new object();
             var isAdded = false;
@@ -110,7 +110,9 @@ namespace System.Reactive
         protected void Remove(Delegate handler)
         {
             if (handler == null)
+            {
                 throw new ArgumentNullException(nameof(handler));
+            }
 
             var d = default(IDisposable);
 

+ 1 - 1
Rx.NET/Source/src/System.Reactive/ExperimentalAttribute.cs

@@ -7,7 +7,7 @@ namespace System.Reactive
     /// <summary>
     /// Marks the program elements that are experimental. This class cannot be inherited.
     /// </summary>
-    [Experimental, AttributeUsage(AttributeTargets.All, AllowMultiple=false, Inherited=true)]
+    [Experimental, AttributeUsage(AttributeTargets.All, AllowMultiple = false, Inherited = true)]
     public sealed class ExperimentalAttribute : Attribute
     {
     }

+ 3 - 3
Rx.NET/Source/src/System.Reactive/Internal/Constants.cs

@@ -10,11 +10,11 @@ namespace System.Reactive
     {
         private const string OBSOLETE_REFACTORING = "This property is no longer supported due to refactoring of the API surface and elimination of platform-specific dependencies.";
 
-        public const string OBSOLETE_SCHEDULER_NEWTHREAD  = OBSOLETE_REFACTORING + " Please use NewThreadScheduler.Default to obtain an instance of this scheduler type.";
-        public const string OBSOLETE_SCHEDULER_TASKPOOL   = OBSOLETE_REFACTORING + " Please use TaskPoolScheduler.Default to obtain an instance of this scheduler type.";
+        public const string OBSOLETE_SCHEDULER_NEWTHREAD = OBSOLETE_REFACTORING + " Please use NewThreadScheduler.Default to obtain an instance of this scheduler type.";
+        public const string OBSOLETE_SCHEDULER_TASKPOOL = OBSOLETE_REFACTORING + " Please use TaskPoolScheduler.Default to obtain an instance of this scheduler type.";
         public const string OBSOLETE_SCHEDULER_THREADPOOL = OBSOLETE_REFACTORING + " Consider using Scheduler.Default to obtain the platform's most appropriate pool-based scheduler. In order to access a specific pool-based scheduler, please add a reference to the System.Reactive.PlatformServices assembly for your target platform and use the appropriate scheduler in the System.Reactive.Concurrency namespace.";
 
-        public const string OBSOLETE_SCHEDULEREQUIRED     = "This instance property is no longer supported. Use CurrentThreadScheduler.IsScheduleRequired instead.";
+        public const string OBSOLETE_SCHEDULEREQUIRED = "This instance property is no longer supported. Use CurrentThreadScheduler.IsScheduleRequired instead.";
     }
 
     // We can't make those based on the Strings_*.resx file, because the ObsoleteAttribute needs a compile-time constant.

+ 4 - 2
Rx.NET/Source/src/System.Reactive/Internal/CurrentPlatformEnlightenmentProvider.cs

@@ -88,8 +88,10 @@ namespace System.Reactive.PlatformServices
 #else
                     var ifType = t;
 #endif
-                    var asm = new AssemblyName(ifType.Assembly.FullName);
-                    asm.Name = "System.Reactive";
+                    var asm = new AssemblyName(ifType.Assembly.FullName)
+                    {
+                        Name = "System.Reactive"
+                    };
                     var name = "System.Reactive.Linq.QueryDebugger, " + asm.FullName;
 
                     var dbg = Type.GetType(name, false);

+ 11 - 1
Rx.NET/Source/src/System.Reactive/Internal/Either.Generic.cs

@@ -13,7 +13,7 @@ namespace System.Reactive
         {
         }
 
-        public static Either<TLeft, TRight> CreateLeft(TLeft value) =>  new Left(value);
+        public static Either<TLeft, TRight> CreateLeft(TLeft value) => new Left(value);
 
         public static Either<TLeft, TRight> CreateRight(TRight value) => new Right(value);
 
@@ -36,9 +36,14 @@ namespace System.Reactive
             public bool Equals(Left other)
             {
                 if (other == this)
+                {
                     return true;
+                }
+
                 if (other == null)
+                {
                     return false;
+                }
 
                 return EqualityComparer<TLeft>.Default.Equals(Value, other.Value);
             }
@@ -69,9 +74,14 @@ namespace System.Reactive
             public bool Equals(Right other)
             {
                 if (other == this)
+                {
                     return true;
+                }
+
                 if (other == null)
+                {
                     return false;
+                }
 
                 return EqualityComparer<TRight>.Default.Equals(Value, other.Value);
             }

+ 5 - 6
Rx.NET/Source/src/System.Reactive/Internal/ExceptionHelper.cs

@@ -2,11 +2,8 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System;
 using System.Collections.Generic;
-using System.Text;
 using System.Threading;
-using System.Linq;
 
 namespace System.Reactive
 {
@@ -81,8 +78,10 @@ namespace System.Reactive
                 else
                 if (current is AggregateException a)
                 {
-                    var list = new List<Exception>(a.InnerExceptions);
-                    list.Add(ex);
+                    var list = new List<Exception>(a.InnerExceptions)
+                    {
+                        ex
+                    };
                     b = new AggregateException(list);
                 }
                 else
@@ -99,7 +98,7 @@ namespace System.Reactive
         /// <summary>
         /// The class indicating a terminal state as an Exception type.
         /// </summary>
-        sealed class TerminatedException : Exception
+        private sealed class TerminatedException : Exception
         {
             internal TerminatedException() : base("No further exceptions")
             {

+ 0 - 3
Rx.NET/Source/src/System.Reactive/Internal/HalfSerializer.cs

@@ -2,9 +2,6 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System;
-using System.Collections.Generic;
-using System.Text;
 using System.Threading;
 
 namespace System.Reactive

+ 4 - 0
Rx.NET/Source/src/System.Reactive/Internal/Helpers.cs

@@ -11,10 +11,14 @@ namespace System.Reactive
         public static int? GetLength<T>(IEnumerable<T> source)
         {
             if (source is T[] array)
+            {
                 return array.Length;
+            }
 
             if (source is IList<T> list)
+            {
                 return list.Count;
+            }
 
             return null;
         }

+ 2 - 0
Rx.NET/Source/src/System.Reactive/Internal/Lookup.cs

@@ -38,7 +38,9 @@ namespace System.Reactive
             {
 
                 if (!_dictionary.TryGetValue(key, out var list))
+                {
                     return Enumerable.Empty<E>();
+                }
 
                 return Hide(list);
             }

+ 2 - 5
Rx.NET/Source/src/System.Reactive/Internal/PlatformEnlightenmentProvider.cs

@@ -52,12 +52,9 @@ namespace System.Reactive.PlatformServices
 
             set
             {
-                if (value == null)
-                    throw new ArgumentNullException(nameof(value));
-
-                s_current = value;
+                s_current = value ?? throw new ArgumentNullException(nameof(value));
             }
-            
+
         }
 
         private static IPlatformEnlightenmentProvider CreatePlatformProvider() => new CurrentPlatformEnlightenmentProvider();

+ 21 - 2
Rx.NET/Source/src/System.Reactive/Internal/PriorityQueue.cs

@@ -2,7 +2,6 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System.Threading;
 using System.Collections.Generic;
 
 namespace System.Reactive
@@ -32,10 +31,15 @@ namespace System.Reactive
         private int Percolate(int index)
         {
             if (index >= _size || index < 0)
+            {
                 return index;
+            }
+
             var parent = (index - 1) / 2;
             if (parent < 0 || parent == index)
+            {
                 return index;
+            }
 
             if (IsHigherPriority(index, parent))
             {
@@ -51,16 +55,24 @@ namespace System.Reactive
         private void Heapify(int index)
         {
             if (index >= _size || index < 0)
+            {
                 return;
+            }
 
             var left = 2 * index + 1;
             var right = 2 * index + 2;
             var first = index;
 
             if (left < _size && IsHigherPriority(left, first))
+            {
                 first = left;
+            }
+
             if (right < _size && IsHigherPriority(right, first))
+            {
                 first = right;
+            }
+
             if (first != index)
             {
                 var temp = _items[index];
@@ -75,7 +87,9 @@ namespace System.Reactive
         public T Peek()
         {
             if (_size == 0)
+            {
                 throw new InvalidOperationException(Strings_Core.HEAP_EMPTY);
+            }
 
             return _items[0].Value;
         }
@@ -83,10 +97,12 @@ namespace System.Reactive
         private void RemoveAt(int index)
         {
             _items[index] = _items[--_size];
-            _items[_size] = default(IndexedItem);
+            _items[_size] = default;
 
             if (Percolate(index) == index)
+            {
                 Heapify(index);
+            }
 
             if (_size < _items.Length / 4)
             {
@@ -140,7 +156,10 @@ namespace System.Reactive
             {
                 var c = Value.CompareTo(other.Value);
                 if (c == 0)
+                {
                     c = Id.CompareTo(other.Id);
+                }
+
                 return c;
             }
         }

+ 5 - 2
Rx.NET/Source/src/System.Reactive/Internal/Producer.cs

@@ -4,7 +4,6 @@
 
 using System.Reactive.Concurrency;
 using System.Reactive.Disposables;
-using System.Threading;
 
 namespace System.Reactive
 {
@@ -31,7 +30,9 @@ namespace System.Reactive
         public IDisposable Subscribe(IObserver<TSource> observer)
         {
             if (observer == null)
+            {
                 throw new ArgumentNullException(nameof(observer));
+            }
 
             return SubscribeRaw(observer, enableSafeguard: true);
         }
@@ -53,7 +54,7 @@ namespace System.Reactive
             if (CurrentThreadScheduler.IsScheduleRequired)
             {
                 var runAssignable = new SingleAssignmentDisposable();
-                
+
                 CurrentThreadScheduler.Instance.ScheduleAction(
                     (@this: this, runAssignable, observer),
                     tuple => tuple.runAssignable.Disposable = [email protected](tuple.observer));
@@ -89,7 +90,9 @@ namespace System.Reactive
         public IDisposable Subscribe(IObserver<TTarget> observer)
         {
             if (observer == null)
+            {
                 throw new ArgumentNullException(nameof(observer));
+            }
 
             return SubscribeRaw(observer, enableSafeguard: true);
         }

+ 23 - 0
Rx.NET/Source/src/System.Reactive/Internal/ReflectionUtils.cs

@@ -40,30 +40,43 @@ namespace System.Reactive
             {
                 e = targetType.GetEventEx(eventName, true);
                 if (e == null)
+                {
                     throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Strings_Linq.COULD_NOT_FIND_STATIC_EVENT, eventName, targetType.FullName));
+                }
             }
             else
             {
                 e = targetType.GetEventEx(eventName, false);
                 if (e == null)
+                {
                     throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Strings_Linq.COULD_NOT_FIND_INSTANCE_EVENT, eventName, targetType.FullName));
+                }
             }
 
             addMethod = e.GetAddMethod();
             removeMethod = e.GetRemoveMethod();
 
             if (addMethod == null)
+            {
                 throw new InvalidOperationException(Strings_Linq.EVENT_MISSING_ADD_METHOD);
+            }
+
             if (removeMethod == null)
+            {
                 throw new InvalidOperationException(Strings_Linq.EVENT_MISSING_REMOVE_METHOD);
+            }
 
             var psa = addMethod.GetParameters();
             if (psa.Length != 1)
+            {
                 throw new InvalidOperationException(Strings_Linq.EVENT_ADD_METHOD_SHOULD_TAKE_ONE_PARAMETER);
+            }
 
             var psr = removeMethod.GetParameters();
             if (psr.Length != 1)
+            {
                 throw new InvalidOperationException(Strings_Linq.EVENT_REMOVE_METHOD_SHOULD_TAKE_ONE_PARAMETER);
+            }
 
             isWinRT = false;
 
@@ -74,7 +87,9 @@ namespace System.Reactive
 
                 var pet = psr[0];
                 if (pet.ParameterType != typeof(EventRegistrationToken))
+                {
                     throw new InvalidOperationException(Strings_Linq.EVENT_WINRT_REMOVE_METHOD_SHOULD_TAKE_ERT);
+                }
             }
 #endif
 
@@ -85,16 +100,24 @@ namespace System.Reactive
             var parameters = invokeMethod.GetParameters();
 
             if (parameters.Length != 2)
+            {
                 throw new InvalidOperationException(Strings_Linq.EVENT_PATTERN_REQUIRES_TWO_PARAMETERS);
+            }
 
             if (!typeof(TSender).IsAssignableFrom(parameters[0].ParameterType))
+            {
                 throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Strings_Linq.EVENT_SENDER_NOT_ASSIGNABLE, typeof(TSender).FullName));
+            }
 
             if (!typeof(TEventArgs).IsAssignableFrom(parameters[1].ParameterType))
+            {
                 throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Strings_Linq.EVENT_ARGS_NOT_ASSIGNABLE, typeof(TEventArgs).FullName));
+            }
 
             if (invokeMethod.ReturnType != typeof(void))
+            {
                 throw new InvalidOperationException(Strings_Linq.EVENT_MUST_RETURN_VOID);
+            }
         }
 
         public static EventInfo GetEventEx(this Type type, string name, bool isStatic)

+ 3 - 1
Rx.NET/Source/src/System.Reactive/Internal/SafeObserver.cs

@@ -69,7 +69,7 @@ namespace System.Reactive
         }
 
         private IDisposable _disposable;
-        
+
         public abstract void OnNext(TSource value);
 
         public abstract void OnError(Exception error);
@@ -89,7 +89,9 @@ namespace System.Reactive
         protected virtual void Dispose(bool disposing)
         {
             if (disposing)
+            {
                 Disposable.TryDispose(ref _disposable);
+            }
         }
     }
 }

+ 47 - 29
Rx.NET/Source/src/System.Reactive/Internal/ScheduledObserver.cs

@@ -2,7 +2,6 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System.Collections.Generic;
 using System.Reactive.Concurrency;
 using System.Reactive.Disposables;
 using System.Threading;
@@ -14,17 +13,15 @@ namespace System.Reactive
 
     internal class ScheduledObserver<T> : ObserverBase<T>, IScheduledObserver<T>
     {
-        private volatile int _state = 0;
+        private int _state = 0;
         private const int STOPPED = 0;
         private const int RUNNING = 1;
         private const int PENDING = 2;
         private const int FAULTED = 9;
-
         private readonly ConcurrentQueue<T> _queue = new ConcurrentQueue<T>();
-        private volatile bool _failed;
-        private volatile Exception _error;
-        private volatile bool _completed;
-
+        private bool _failed;
+        private Exception _error;
+        private bool _completed;
         private readonly IObserver<T> _observer;
         private readonly IScheduler _scheduler;
         private readonly ISchedulerLongRunning _longRunning;
@@ -43,9 +40,9 @@ namespace System.Reactive
             }
         }
 
-        sealed class SemaphoreSlimRelease : IDisposable
+        private sealed class SemaphoreSlimRelease : IDisposable
         {
-            SemaphoreSlim _dispatcherEvent;
+            private SemaphoreSlim _dispatcherEvent;
 
             public SemaphoreSlimRelease(SemaphoreSlim dispatcherEvent)
             {
@@ -90,7 +87,9 @@ namespace System.Reactive
                 _dispatcherEvent.Wait();
 
                 if (cancel.IsDisposed)
+                {
                     return;
+                }
 
                 var next = default(T);
                 while (_queue.TryDequeue(out next))
@@ -103,7 +102,9 @@ namespace System.Reactive
                     {
                         var nop = default(T);
                         while (_queue.TryDequeue(out nop))
+                        {
                             ;
+                        }
 
                         throw;
                     }
@@ -111,7 +112,9 @@ namespace System.Reactive
                     _dispatcherEvent.Wait();
 
                     if (cancel.IsDisposed)
+                    {
                         return;
+                    }
                 }
 
                 if (_failed)
@@ -144,7 +147,9 @@ namespace System.Reactive
                 EnsureDispatcher();
             }
             else
+            {
                 EnsureActiveSlow();
+            }
         }
 
         private void EnsureActiveSlow()
@@ -161,7 +166,9 @@ namespace System.Reactive
                 }
 
                 if (old == FAULTED)
+                {
                     return;
+                }
 
                 // If we find the consumer loop running, we transition to PENDING to handle
                 // the case where the queue is seen empty by the consumer, making it transition
@@ -187,7 +194,9 @@ namespace System.Reactive
                 // this state.
                 //
                 if (old == PENDING || old == RUNNING && Interlocked.CompareExchange(ref _state, PENDING, RUNNING) == RUNNING)
+                {
                     break;
+                }
             }
 
             if (isOwner)
@@ -218,7 +227,9 @@ namespace System.Reactive
                     //      _observer.OnError(...)                     // Lost an OnNext
                     //
                     if (!_queue.IsEmpty)
+                    {
                         continue;
+                    }
 
                     Interlocked.Exchange(ref _state, STOPPED);
                     _observer.OnError(_error);
@@ -243,7 +254,9 @@ namespace System.Reactive
                     //      _observer.OnCompleted()                    // Lost an OnNext
                     //
                     if (!_queue.IsEmpty)
+                    {
                         continue;
+                    }
 
                     Interlocked.Exchange(ref _state, STOPPED);
                     _observer.OnCompleted();
@@ -253,7 +266,9 @@ namespace System.Reactive
 
                 var old = Interlocked.CompareExchange(ref _state, STOPPED, RUNNING);
                 if (old == RUNNING || old == FAULTED)
+                {
                     return;
+                }
 
                 Debug.Assert(old == PENDING);
 
@@ -274,7 +289,9 @@ namespace System.Reactive
 
                 var nop = default(T);
                 while (_queue.TryDequeue(out nop))
+                {
                     ;
+                }
 
                 throw;
             }
@@ -366,45 +383,43 @@ namespace System.Reactive
     /// <typeparam name="T">The element type of the sequence.</typeparam>
     internal sealed class ObserveOnObserverNew<T> : IObserver<T>, IDisposable
     {
-        readonly IObserver<T> downstream;
-
-        readonly IScheduler scheduler;
+        private readonly IObserver<T> downstream;
+        private readonly IScheduler scheduler;
 
         /// <summary>
         /// If not null, the <see cref="scheduler"/> supports
         /// long running tasks.
         /// </summary>
-        readonly ISchedulerLongRunning longRunning;
-
-        readonly ConcurrentQueue<T> queue;
-
+        private readonly ISchedulerLongRunning longRunning;
+        private readonly ConcurrentQueue<T> queue;
         private IDisposable _run;
 
         /// <summary>
         /// The current task representing a running drain operation.
         /// </summary>
-        IDisposable task;
+        private IDisposable task;
 
         /// <summary>
         /// Indicates the work-in-progress state of this operator,
         /// zero means no work is currently being done.
         /// </summary>
-        int wip;
+        private int wip;
 
         /// <summary>
         /// If true, the upstream has issued OnCompleted.
         /// </summary>
-        bool done;
+        private bool done;
+
         /// <summary>
         /// If <see cref="done"/> is true and this is non-null, the upstream
         /// failed with an OnError.
         /// </summary>
-        Exception error;
+        private Exception error;
 
         /// <summary>
         /// Indicates a dispose has been requested.
         /// </summary>
-        bool disposed;
+        private bool disposed;
 
         public ObserveOnObserverNew(IScheduler scheduler, IObserver<T> downstream)
         {
@@ -431,10 +446,13 @@ namespace System.Reactive
         /// Remove remaining elements from the queue upon
         /// cancellation or failure.
         /// </summary>
-        void Clear()
+        private void Clear()
         {
             var q = queue;
-            while (q.TryDequeue(out var _)) ;
+            while (q.TryDequeue(out var _))
+            {
+                ;
+            }
         }
 
         public void OnCompleted()
@@ -460,7 +478,7 @@ namespace System.Reactive
         /// Submit the drain task via the appropriate scheduler if
         /// there is no drain currently running (wip > 0).
         /// </summary>
-        void Schedule()
+        private void Schedule()
         {
             if (Interlocked.Increment(ref wip) == 1)
             {
@@ -495,7 +513,7 @@ namespace System.Reactive
         /// Avoids creating a delegate that captures <code>this</code>
         /// whenever the signals have to be drained.
         /// </summary>
-        static readonly Action<ObserveOnObserverNew<T>, ICancelable> DRAIN_LONG_RUNNING =
+        private static readonly Action<ObserveOnObserverNew<T>, ICancelable> DRAIN_LONG_RUNNING =
             (self, cancel) => self.DrainLongRunning();
 
         /// <summary>
@@ -503,7 +521,7 @@ namespace System.Reactive
         /// Avoids creating a delegate that captures <code>this</code>
         /// whenever the signals have to be drained.
         /// </summary>
-        static readonly Func<IScheduler, ObserveOnObserverNew<T>, IDisposable> DRAIN_SHORT_RUNNING =
+        private static readonly Func<IScheduler, ObserveOnObserverNew<T>, IDisposable> DRAIN_SHORT_RUNNING =
             (scheduler, self) => self.DrainShortRunning(scheduler);
 
         /// <summary>
@@ -512,7 +530,7 @@ namespace System.Reactive
         /// </summary>
         /// <param name="recursiveScheduler">The scheduler to use for scheduling the next signal emission if necessary.</param>
         /// <returns>The IDisposable of the recursively scheduled task or an empty disposable.</returns>
-        IDisposable DrainShortRunning(IScheduler recursiveScheduler)
+        private IDisposable DrainShortRunning(IScheduler recursiveScheduler)
         {
             DrainStep(queue, downstream, false);
 
@@ -534,7 +552,7 @@ namespace System.Reactive
         /// <param name="delayError">Should the errors be delayed until all
         /// queued items have been emitted to the downstream?</param>
         /// <returns>True if the drain loop should stop.</returns>
-        bool DrainStep(ConcurrentQueue<T> q, IObserver<T> downstream, bool delayError)
+        private bool DrainStep(ConcurrentQueue<T> q, IObserver<T> downstream, bool delayError)
         {
             // Check if the operator has been disposed
             if (Volatile.Read(ref disposed))
@@ -602,7 +620,7 @@ namespace System.Reactive
         /// as this is executing a long-running scheduler so
         /// it can occupy that thread as long as it needs to.
         /// </summary>
-        void DrainLongRunning()
+        private void DrainLongRunning()
         {
             var missed = 1;
 

+ 0 - 1
Rx.NET/Source/src/System.Reactive/Internal/Sink.cs

@@ -3,7 +3,6 @@
 // See the LICENSE file in the project root for more information. 
 
 using System.Reactive.Disposables;
-using System.Threading;
 
 namespace System.Reactive
 {

+ 1 - 1
Rx.NET/Source/src/System.Reactive/Internal/Stubs.cs

@@ -26,5 +26,5 @@ namespace System.Reactive
 #endif
     }
 #endif
-    }
+}
 

+ 14 - 14
Rx.NET/Source/src/System.Reactive/Internal/TailRecursiveSink.cs

@@ -3,7 +3,6 @@
 // See the LICENSE file in the project root for more information. 
 
 using System.Collections.Generic;
-using System.Reactive.Concurrency;
 using System.Reactive.Disposables;
 using System.Threading;
 
@@ -16,18 +15,17 @@ namespace System.Reactive
         {
         }
 
-        bool _isDisposed;
-
-        int _trampoline;
-
-        IDisposable _currentSubscription;
-
-        Stack<IEnumerator<IObservable<TSource>>> _stack = new Stack<IEnumerator<IObservable<TSource>>>();
+        private bool _isDisposed;
+        private int _trampoline;
+        private IDisposable _currentSubscription;
+        private Stack<IEnumerator<IObservable<TSource>>> _stack = new Stack<IEnumerator<IObservable<TSource>>>();
 
         public void Run(IEnumerable<IObservable<TSource>> sources)
         {
             if (!TryGetEnumerator(sources, out var current))
+            {
                 return;
+            }
 
             _stack.Push(current);
 
@@ -43,7 +41,7 @@ namespace System.Reactive
             base.Dispose(disposing);
         }
 
-        void Drain()
+        private void Drain()
         {
             if (Interlocked.Increment(ref _trampoline) != 1)
             {
@@ -134,7 +132,7 @@ namespace System.Reactive
                                     // Since this drain loop is the only one to use Ready, this should
                                     // be unambiguous
                                     var u = Interlocked.CompareExchange(ref _currentSubscription, d, sad);
-                                    
+
                                     // sequence disposed or completed synchronously
                                     if (u != sad)
                                     {
@@ -144,7 +142,7 @@ namespace System.Reactive
                                             continue;
                                         }
                                     }
-                                }   
+                                }
                                 else
                                 {
                                     continue;
@@ -172,7 +170,7 @@ namespace System.Reactive
             }
         }
 
-        void DisposeAll()
+        private void DisposeAll()
         {
             Volatile.Write(ref _isDisposed, true);
             // the disposing of currentSubscription is deferred to drain due to some ObservableExTest.Iterate_Complete()
@@ -183,7 +181,9 @@ namespace System.Reactive
         protected void Recurse()
         {
             if (Disposable.TrySetSerial(ref _currentSubscription, null))
+            {
                 Drain();
+            }
         }
 
         protected abstract IEnumerable<IObservable<TSource>> Extract(IObservable<TSource> source);
@@ -220,7 +220,7 @@ namespace System.Reactive
     /// <summary>
     /// Holds onto a singleton IDisposable indicating a ready state.
     /// </summary>
-    static class ReadyToken
+    internal static class ReadyToken
     {
         /// <summary>
         /// This indicates the operation has been prepared and ready for
@@ -228,7 +228,7 @@ namespace System.Reactive
         /// </summary>
         internal static readonly IDisposable Ready = new ReadyDisposable();
 
-        sealed class ReadyDisposable : IDisposable
+        private sealed class ReadyDisposable : IDisposable
         {
             public void Dispose()
             {

+ 51 - 18
Rx.NET/Source/src/System.Reactive/Joins/ActivePlan.cs

@@ -8,7 +8,7 @@ namespace System.Reactive.Joins
 {
     internal abstract class ActivePlan
     {
-        Dictionary<IJoinObserver, IJoinObserver> joinObservers = new Dictionary<IJoinObserver, IJoinObserver>();
+        private Dictionary<IJoinObserver, IJoinObserver> joinObservers = new Dictionary<IJoinObserver, IJoinObserver>();
 
         internal abstract void Match();
 
@@ -23,7 +23,9 @@ namespace System.Reactive.Joins
         protected void Dequeue()
         {
             foreach (var joinObserver in joinObservers.Values)
+            {
                 joinObserver.Dequeue();
+            }
         }
     }
 
@@ -48,7 +50,9 @@ namespace System.Reactive.Joins
                 var n1 = first.Queue.Peek();
 
                 if (n1.Kind == NotificationKind.OnCompleted)
+                {
                     onCompleted();
+                }
                 else
                 {
                     Dequeue();
@@ -84,9 +88,11 @@ namespace System.Reactive.Joins
                 var n1 = first.Queue.Peek();
                 var n2 = second.Queue.Peek();
 
-                if (   n1.Kind == NotificationKind.OnCompleted
+                if (n1.Kind == NotificationKind.OnCompleted
                     || n2.Kind == NotificationKind.OnCompleted)
+                {
                     onCompleted();
+                }
                 else
                 {
                     Dequeue();
@@ -128,10 +134,12 @@ namespace System.Reactive.Joins
                 var n2 = second.Queue.Peek();
                 var n3 = third.Queue.Peek();
 
-                if (   n1.Kind == NotificationKind.OnCompleted
+                if (n1.Kind == NotificationKind.OnCompleted
                     || n2.Kind == NotificationKind.OnCompleted
                     || n3.Kind == NotificationKind.OnCompleted)
+                {
                     onCompleted();
+                }
                 else
                 {
                     Dequeue();
@@ -179,11 +187,13 @@ namespace System.Reactive.Joins
                 var n3 = third.Queue.Peek();
                 var n4 = fourth.Queue.Peek();
 
-                if (   n1.Kind == NotificationKind.OnCompleted
+                if (n1.Kind == NotificationKind.OnCompleted
                     || n2.Kind == NotificationKind.OnCompleted
                     || n3.Kind == NotificationKind.OnCompleted
                     || n4.Kind == NotificationKind.OnCompleted)
+                {
                     onCompleted();
+                }
                 else
                 {
                     Dequeue();
@@ -238,12 +248,14 @@ namespace System.Reactive.Joins
                 var n4 = fourth.Queue.Peek();
                 var n5 = fifth.Queue.Peek();
 
-                if (   n1.Kind == NotificationKind.OnCompleted
+                if (n1.Kind == NotificationKind.OnCompleted
                     || n2.Kind == NotificationKind.OnCompleted
                     || n3.Kind == NotificationKind.OnCompleted
                     || n4.Kind == NotificationKind.OnCompleted
                     || n5.Kind == NotificationKind.OnCompleted)
+                {
                     onCompleted();
+                }
                 else
                 {
                     Dequeue();
@@ -270,7 +282,7 @@ namespace System.Reactive.Joins
         private readonly JoinObserver<T6> sixth;
 
         internal ActivePlan(JoinObserver<T1> first, JoinObserver<T2> second, JoinObserver<T3> third,
-            JoinObserver<T4> fourth, JoinObserver<T5> fifth, JoinObserver<T6> sixth, 
+            JoinObserver<T4> fourth, JoinObserver<T5> fifth, JoinObserver<T6> sixth,
             Action<T1, T2, T3, T4, T5, T6> onNext, Action onCompleted)
         {
             this.onNext = onNext;
@@ -305,13 +317,15 @@ namespace System.Reactive.Joins
                 var n5 = fifth.Queue.Peek();
                 var n6 = sixth.Queue.Peek();
 
-                if (   n1.Kind == NotificationKind.OnCompleted
+                if (n1.Kind == NotificationKind.OnCompleted
                     || n2.Kind == NotificationKind.OnCompleted
                     || n3.Kind == NotificationKind.OnCompleted
                     || n4.Kind == NotificationKind.OnCompleted
                     || n5.Kind == NotificationKind.OnCompleted
                     || n6.Kind == NotificationKind.OnCompleted)
+                {
                     onCompleted();
+                }
                 else
                 {
                     Dequeue();
@@ -379,14 +393,16 @@ namespace System.Reactive.Joins
                 var n6 = sixth.Queue.Peek();
                 var n7 = seventh.Queue.Peek();
 
-                if (   n1.Kind == NotificationKind.OnCompleted
+                if (n1.Kind == NotificationKind.OnCompleted
                     || n2.Kind == NotificationKind.OnCompleted
                     || n3.Kind == NotificationKind.OnCompleted
                     || n4.Kind == NotificationKind.OnCompleted
                     || n5.Kind == NotificationKind.OnCompleted
                     || n6.Kind == NotificationKind.OnCompleted
                     || n7.Kind == NotificationKind.OnCompleted)
+                {
                     onCompleted();
+                }
                 else
                 {
                     Dequeue();
@@ -461,7 +477,7 @@ namespace System.Reactive.Joins
                 var n7 = seventh.Queue.Peek();
                 var n8 = eighth.Queue.Peek();
 
-                if (   n1.Kind == NotificationKind.OnCompleted
+                if (n1.Kind == NotificationKind.OnCompleted
                     || n2.Kind == NotificationKind.OnCompleted
                     || n3.Kind == NotificationKind.OnCompleted
                     || n4.Kind == NotificationKind.OnCompleted
@@ -470,7 +486,9 @@ namespace System.Reactive.Joins
                     || n7.Kind == NotificationKind.OnCompleted
                     || n8.Kind == NotificationKind.OnCompleted
                     )
+                {
                     onCompleted();
+                }
                 else
                 {
                     Dequeue();
@@ -552,7 +570,7 @@ namespace System.Reactive.Joins
                 var n8 = eighth.Queue.Peek();
                 var n9 = ninth.Queue.Peek();
 
-                if (   n1.Kind == NotificationKind.OnCompleted
+                if (n1.Kind == NotificationKind.OnCompleted
                     || n2.Kind == NotificationKind.OnCompleted
                     || n3.Kind == NotificationKind.OnCompleted
                     || n4.Kind == NotificationKind.OnCompleted
@@ -562,7 +580,9 @@ namespace System.Reactive.Joins
                     || n8.Kind == NotificationKind.OnCompleted
                     || n9.Kind == NotificationKind.OnCompleted
                     )
+                {
                     onCompleted();
+                }
                 else
                 {
                     Dequeue();
@@ -650,7 +670,7 @@ namespace System.Reactive.Joins
                 var n9 = ninth.Queue.Peek();
                 var n10 = tenth.Queue.Peek();
 
-                if (   n1.Kind == NotificationKind.OnCompleted
+                if (n1.Kind == NotificationKind.OnCompleted
                     || n2.Kind == NotificationKind.OnCompleted
                     || n3.Kind == NotificationKind.OnCompleted
                     || n4.Kind == NotificationKind.OnCompleted
@@ -661,7 +681,9 @@ namespace System.Reactive.Joins
                     || n9.Kind == NotificationKind.OnCompleted
                     || n10.Kind == NotificationKind.OnCompleted
                     )
+                {
                     onCompleted();
+                }
                 else
                 {
                     Dequeue();
@@ -755,7 +777,7 @@ namespace System.Reactive.Joins
                 var n10 = tenth.Queue.Peek();
                 var n11 = eleventh.Queue.Peek();
 
-                if (   n1.Kind == NotificationKind.OnCompleted
+                if (n1.Kind == NotificationKind.OnCompleted
                     || n2.Kind == NotificationKind.OnCompleted
                     || n3.Kind == NotificationKind.OnCompleted
                     || n4.Kind == NotificationKind.OnCompleted
@@ -767,7 +789,9 @@ namespace System.Reactive.Joins
                     || n10.Kind == NotificationKind.OnCompleted
                     || n11.Kind == NotificationKind.OnCompleted
                     )
+                {
                     onCompleted();
+                }
                 else
                 {
                     Dequeue();
@@ -868,7 +892,7 @@ namespace System.Reactive.Joins
                 var n11 = eleventh.Queue.Peek();
                 var n12 = twelfth.Queue.Peek();
 
-                if (   n1.Kind == NotificationKind.OnCompleted
+                if (n1.Kind == NotificationKind.OnCompleted
                     || n2.Kind == NotificationKind.OnCompleted
                     || n3.Kind == NotificationKind.OnCompleted
                     || n4.Kind == NotificationKind.OnCompleted
@@ -881,7 +905,9 @@ namespace System.Reactive.Joins
                     || n11.Kind == NotificationKind.OnCompleted
                     || n12.Kind == NotificationKind.OnCompleted
                     )
+                {
                     onCompleted();
+                }
                 else
                 {
                     Dequeue();
@@ -988,7 +1014,7 @@ namespace System.Reactive.Joins
                 var n12 = twelfth.Queue.Peek();
                 var n13 = thirteenth.Queue.Peek();
 
-                if (   n1.Kind == NotificationKind.OnCompleted
+                if (n1.Kind == NotificationKind.OnCompleted
                     || n2.Kind == NotificationKind.OnCompleted
                     || n3.Kind == NotificationKind.OnCompleted
                     || n4.Kind == NotificationKind.OnCompleted
@@ -1002,7 +1028,9 @@ namespace System.Reactive.Joins
                     || n12.Kind == NotificationKind.OnCompleted
                     || n13.Kind == NotificationKind.OnCompleted
                     )
+                {
                     onCompleted();
+                }
                 else
                 {
                     Dequeue();
@@ -1115,7 +1143,7 @@ namespace System.Reactive.Joins
                 var n13 = thirteenth.Queue.Peek();
                 var n14 = fourteenth.Queue.Peek();
 
-                if (   n1.Kind == NotificationKind.OnCompleted
+                if (n1.Kind == NotificationKind.OnCompleted
                     || n2.Kind == NotificationKind.OnCompleted
                     || n3.Kind == NotificationKind.OnCompleted
                     || n4.Kind == NotificationKind.OnCompleted
@@ -1130,7 +1158,9 @@ namespace System.Reactive.Joins
                     || n13.Kind == NotificationKind.OnCompleted
                     || n14.Kind == NotificationKind.OnCompleted
                     )
+                {
                     onCompleted();
+                }
                 else
                 {
                     Dequeue();
@@ -1250,7 +1280,7 @@ namespace System.Reactive.Joins
                 var n14 = fourteenth.Queue.Peek();
                 var n15 = fifteenth.Queue.Peek();
 
-                if (   n1.Kind == NotificationKind.OnCompleted
+                if (n1.Kind == NotificationKind.OnCompleted
                     || n2.Kind == NotificationKind.OnCompleted
                     || n3.Kind == NotificationKind.OnCompleted
                     || n4.Kind == NotificationKind.OnCompleted
@@ -1266,7 +1296,9 @@ namespace System.Reactive.Joins
                     || n14.Kind == NotificationKind.OnCompleted
                     || n15.Kind == NotificationKind.OnCompleted
                     )
+                {
                     onCompleted();
+                }
                 else
                 {
                     Dequeue();
@@ -1291,7 +1323,6 @@ namespace System.Reactive.Joins
         }
     }
 
-
     internal class ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> : ActivePlan
     {
         private readonly Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> onNext;
@@ -1393,7 +1424,7 @@ namespace System.Reactive.Joins
                 var n15 = fifteenth.Queue.Peek();
                 var n16 = sixteenth.Queue.Peek();
 
-                if (   n1.Kind == NotificationKind.OnCompleted
+                if (n1.Kind == NotificationKind.OnCompleted
                     || n2.Kind == NotificationKind.OnCompleted
                     || n3.Kind == NotificationKind.OnCompleted
                     || n4.Kind == NotificationKind.OnCompleted
@@ -1410,7 +1441,9 @@ namespace System.Reactive.Joins
                     || n15.Kind == NotificationKind.OnCompleted
                     || n16.Kind == NotificationKind.OnCompleted
                     )
+                {
                     onCompleted();
+                }
                 else
                 {
                     Dequeue();

+ 6 - 0
Rx.NET/Source/src/System.Reactive/Joins/JoinObserver.cs

@@ -62,7 +62,9 @@ namespace System.Reactive.Joins
 
                     Queue.Enqueue(notification);
                     foreach (var activePlan in _activePlans.ToArray()) // Working on a copy since _activePlans might change while iterating.
+                    {
                         activePlan.Match();
+                    }
                 }
             }
         }
@@ -79,7 +81,9 @@ namespace System.Reactive.Joins
         {
             _activePlans.Remove(activePlan);
             if (_activePlans.Count == 0)
+            {
                 Dispose();
+            }
         }
 
         protected override void Dispose(bool disposing)
@@ -89,7 +93,9 @@ namespace System.Reactive.Joins
             if (!_isDisposed)
             {
                 if (disposing)
+                {
                     Disposable.TryDispose(ref _subscription);
+                }
 
                 _isDisposed = true;
             }

+ 60 - 0
Rx.NET/Source/src/System.Reactive/Joins/Pattern.cs

@@ -41,7 +41,9 @@ namespace System.Reactive.Joins
         public Plan<TResult> Then<TResult>(Func<TSource1, TResult> selector)
         {
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return new Plan<TSource1, TResult>(this, selector);
         }
@@ -74,7 +76,9 @@ namespace System.Reactive.Joins
         public Pattern<TSource1, TSource2, TSource3> And<TSource3>(IObservable<TSource3> other)
         {
             if (other == null)
+            {
                 throw new ArgumentNullException(nameof(other));
+            }
 
             return new Pattern<TSource1, TSource2, TSource3>(First, Second, other);
         }
@@ -89,7 +93,9 @@ namespace System.Reactive.Joins
         public Plan<TResult> Then<TResult>(Func<TSource1, TSource2, TResult> selector)
         {
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return new Plan<TSource1, TSource2, TResult>(this, selector);
         }
@@ -125,7 +131,9 @@ namespace System.Reactive.Joins
         public Pattern<TSource1, TSource2, TSource3, TSource4> And<TSource4>(IObservable<TSource4> other)
         {
             if (other == null)
+            {
                 throw new ArgumentNullException(nameof(other));
+            }
 
             return new Pattern<TSource1, TSource2, TSource3, TSource4>(First, Second, Third, other);
         }
@@ -140,7 +148,9 @@ namespace System.Reactive.Joins
         public Plan<TResult> Then<TResult>(Func<TSource1, TSource2, TSource3, TResult> selector)
         {
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return new Plan<TSource1, TSource2, TSource3, TResult>(this, selector);
         }
@@ -179,7 +189,9 @@ namespace System.Reactive.Joins
         public Pattern<TSource1, TSource2, TSource3, TSource4, TSource5> And<TSource5>(IObservable<TSource5> other)
         {
             if (other == null)
+            {
                 throw new ArgumentNullException(nameof(other));
+            }
 
             return new Pattern<TSource1, TSource2, TSource3, TSource4, TSource5>(First, Second, Third, Fourth, other);
         }
@@ -194,7 +206,9 @@ namespace System.Reactive.Joins
         public Plan<TResult> Then<TResult>(Func<TSource1, TSource2, TSource3, TSource4, TResult> selector)
         {
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return new Plan<TSource1, TSource2, TSource3, TSource4, TResult>(this, selector);
         }
@@ -236,7 +250,9 @@ namespace System.Reactive.Joins
         public Pattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6> And<TSource6>(IObservable<TSource6> other)
         {
             if (other == null)
+            {
                 throw new ArgumentNullException(nameof(other));
+            }
 
             return new Pattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6>(First, Second, Third, Fourth, Fifth, other);
         }
@@ -251,7 +267,9 @@ namespace System.Reactive.Joins
         public Plan<TResult> Then<TResult>(Func<TSource1, TSource2, TSource3, TSource4, TSource5, TResult> selector)
         {
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return new Plan<TSource1, TSource2, TSource3, TSource4, TSource5, TResult>(this, selector);
         }
@@ -296,7 +314,9 @@ namespace System.Reactive.Joins
         public Pattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7> And<TSource7>(IObservable<TSource7> other)
         {
             if (other == null)
+            {
                 throw new ArgumentNullException(nameof(other));
+            }
 
             return new Pattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7>(First, Second, Third, Fourth, Fifth, Sixth, other);
         }
@@ -311,7 +331,9 @@ namespace System.Reactive.Joins
         public Plan<TResult> Then<TResult>(Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TResult> selector)
         {
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return new Plan<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TResult>(this, selector);
         }
@@ -359,7 +381,9 @@ namespace System.Reactive.Joins
         public Pattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8> And<TSource8>(IObservable<TSource8> other)
         {
             if (other == null)
+            {
                 throw new ArgumentNullException(nameof(other));
+            }
 
             return new Pattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8>(First, Second, Third, Fourth, Fifth, Sixth, Seventh, other);
         }
@@ -374,7 +398,9 @@ namespace System.Reactive.Joins
         public Plan<TResult> Then<TResult>(Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TResult> selector)
         {
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return new Plan<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TResult>(this, selector);
         }
@@ -425,7 +451,9 @@ namespace System.Reactive.Joins
         public Pattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9> And<TSource9>(IObservable<TSource9> other)
         {
             if (other == null)
+            {
                 throw new ArgumentNullException(nameof(other));
+            }
 
             return new Pattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9>(First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, other);
         }
@@ -440,7 +468,9 @@ namespace System.Reactive.Joins
         public Plan<TResult> Then<TResult>(Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TResult> selector)
         {
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return new Plan<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TResult>(this, selector);
         }
@@ -494,7 +524,9 @@ namespace System.Reactive.Joins
         public Pattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10> And<TSource10>(IObservable<TSource10> other)
         {
             if (other == null)
+            {
                 throw new ArgumentNullException(nameof(other));
+            }
 
             return new Pattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10>(First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth, other);
         }
@@ -509,7 +541,9 @@ namespace System.Reactive.Joins
         public Plan<TResult> Then<TResult>(Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TResult> selector)
         {
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return new Plan<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TResult>(this, selector);
         }
@@ -566,7 +600,9 @@ namespace System.Reactive.Joins
         public Pattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11> And<TSource11>(IObservable<TSource11> other)
         {
             if (other == null)
+            {
                 throw new ArgumentNullException(nameof(other));
+            }
 
             return new Pattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11>(First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth, Tenth, other);
         }
@@ -581,7 +617,9 @@ namespace System.Reactive.Joins
         public Plan<TResult> Then<TResult>(Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TResult> selector)
         {
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return new Plan<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TResult>(this, selector);
         }
@@ -641,7 +679,9 @@ namespace System.Reactive.Joins
         public Pattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12> And<TSource12>(IObservable<TSource12> other)
         {
             if (other == null)
+            {
                 throw new ArgumentNullException(nameof(other));
+            }
 
             return new Pattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12>(First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth, Tenth, Eleventh, other);
         }
@@ -656,7 +696,9 @@ namespace System.Reactive.Joins
         public Plan<TResult> Then<TResult>(Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TResult> selector)
         {
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return new Plan<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TResult>(this, selector);
         }
@@ -719,7 +761,9 @@ namespace System.Reactive.Joins
         public Pattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13> And<TSource13>(IObservable<TSource13> other)
         {
             if (other == null)
+            {
                 throw new ArgumentNullException(nameof(other));
+            }
 
             return new Pattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13>(First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth, Tenth, Eleventh, Twelfth, other);
         }
@@ -734,7 +778,9 @@ namespace System.Reactive.Joins
         public Plan<TResult> Then<TResult>(Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TResult> selector)
         {
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return new Plan<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TResult>(this, selector);
         }
@@ -800,7 +846,9 @@ namespace System.Reactive.Joins
         public Pattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14> And<TSource14>(IObservable<TSource14> other)
         {
             if (other == null)
+            {
                 throw new ArgumentNullException(nameof(other));
+            }
 
             return new Pattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14>(First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth, Tenth, Eleventh, Twelfth, Thirteenth, other);
         }
@@ -815,7 +863,9 @@ namespace System.Reactive.Joins
         public Plan<TResult> Then<TResult>(Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TResult> selector)
         {
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return new Plan<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TResult>(this, selector);
         }
@@ -884,7 +934,9 @@ namespace System.Reactive.Joins
         public Pattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TSource15> And<TSource15>(IObservable<TSource15> other)
         {
             if (other == null)
+            {
                 throw new ArgumentNullException(nameof(other));
+            }
 
             return new Pattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TSource15>(First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth, Tenth, Eleventh, Twelfth, Thirteenth, Fourteenth, other);
         }
@@ -899,7 +951,9 @@ namespace System.Reactive.Joins
         public Plan<TResult> Then<TResult>(Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TResult> selector)
         {
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return new Plan<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TResult>(this, selector);
         }
@@ -971,7 +1025,9 @@ namespace System.Reactive.Joins
         public Pattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TSource15, TSource16> And<TSource16>(IObservable<TSource16> other)
         {
             if (other == null)
+            {
                 throw new ArgumentNullException(nameof(other));
+            }
 
             return new Pattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TSource15, TSource16>(First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth, Tenth, Eleventh, Twelfth, Thirteenth, Fourteenth, Fifteenth, other);
         }
@@ -986,7 +1042,9 @@ namespace System.Reactive.Joins
         public Plan<TResult> Then<TResult>(Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TSource15, TResult> selector)
         {
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return new Plan<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TSource15, TResult>(this, selector);
         }
@@ -1061,7 +1119,9 @@ namespace System.Reactive.Joins
         public Plan<TResult> Then<TResult>(Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TSource15, TSource16, TResult> selector)
         {
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return new Plan<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TSource15, TSource16, TResult>(this, selector);
         }

+ 871 - 871
Rx.NET/Source/src/System.Reactive/Joins/Plan.cs

@@ -294,875 +294,875 @@ namespace System.Reactive.Joins
         }
     }
 
-   internal class Plan<T1, T2, T3, T4, T5, T6, TResult> : Plan<TResult>
-   {
-       internal Pattern<T1, T2, T3, T4, T5, T6> Expression { get; private set; }
-
-       internal Func<T1, T2, T3, T4, T5, T6, TResult> Selector { get; private set; }
-
-       internal Plan(Pattern<T1, T2, T3, T4, T5, T6> expression,
-                     Func<T1, T2, T3, T4, T5, T6, TResult> selector)
-       {
-           Expression = expression;
-           Selector = selector;
-       }
-
-       internal override ActivePlan Activate(Dictionary<object, IJoinObserver> externalSubscriptions,
-                                             IObserver<TResult> observer, Action<ActivePlan> deactivate)
-       {
-           var onError = new Action<Exception>(observer.OnError);
-           var firstJoinObserver = CreateObserver(externalSubscriptions, Expression.First, onError);
-           var secondJoinObserver = CreateObserver(externalSubscriptions, Expression.Second, onError);
-           var thirdJoinObserver = CreateObserver(externalSubscriptions, Expression.Third, onError);
-           var fourthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourth, onError);
-           var fifthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fifth, onError);
-           var sixthJoinObserver = CreateObserver(externalSubscriptions, Expression.Sixth, onError);
-           var activePlan = default(ActivePlan<T1, T2, T3, T4, T5, T6>);
-
-           activePlan = new ActivePlan<T1, T2, T3, T4, T5, T6>(firstJoinObserver, secondJoinObserver, thirdJoinObserver,
-               fourthJoinObserver, fifthJoinObserver, sixthJoinObserver,
-               (first, second, third, fourth, fifth, sixth) =>
-               {
-                   var result = default(TResult);
-                   try
-                   {
-                       result = Selector(first, second, third, fourth, fifth, sixth);
-                   }
-                   catch (Exception exception)
-                   {
-                       observer.OnError(exception);
-                       return;
-                   }
-                   observer.OnNext(result);
-               },
-               () =>
-               {
-                   firstJoinObserver.RemoveActivePlan(activePlan);
-                   secondJoinObserver.RemoveActivePlan(activePlan);
-                   thirdJoinObserver.RemoveActivePlan(activePlan);
-                   fourthJoinObserver.RemoveActivePlan(activePlan);
-                   fifthJoinObserver.RemoveActivePlan(activePlan);
-                   sixthJoinObserver.RemoveActivePlan(activePlan);
-                   deactivate(activePlan);
-               });
-
-           firstJoinObserver.AddActivePlan(activePlan);
-           secondJoinObserver.AddActivePlan(activePlan);
-           thirdJoinObserver.AddActivePlan(activePlan);
-           fourthJoinObserver.AddActivePlan(activePlan);
-           fifthJoinObserver.AddActivePlan(activePlan);
-           sixthJoinObserver.AddActivePlan(activePlan);
-           return activePlan;
-       }
-   }
-
-   internal class Plan<T1, T2, T3, T4, T5, T6, T7, TResult> : Plan<TResult>
-   {
-       internal Pattern<T1, T2, T3, T4, T5, T6, T7> Expression { get; private set; }
-
-       internal Func<T1, T2, T3, T4, T5, T6, T7, TResult> Selector { get; private set; }
-
-       internal Plan(Pattern<T1, T2, T3, T4, T5, T6, T7> expression,
-                     Func<T1, T2, T3, T4, T5, T6, T7, TResult> selector)
-       {
-           Expression = expression;
-           Selector = selector;
-       }
-
-       internal override ActivePlan Activate(Dictionary<object, IJoinObserver> externalSubscriptions,
-                                             IObserver<TResult> observer, Action<ActivePlan> deactivate)
-       {
-           var onError = new Action<Exception>(observer.OnError);
-           var firstJoinObserver = CreateObserver(externalSubscriptions, Expression.First, onError);
-           var secondJoinObserver = CreateObserver(externalSubscriptions, Expression.Second, onError);
-           var thirdJoinObserver = CreateObserver(externalSubscriptions, Expression.Third, onError);
-           var fourthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourth, onError);
-           var fifthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fifth, onError);
-           var sixthJoinObserver = CreateObserver(externalSubscriptions, Expression.Sixth, onError);
-           var seventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Seventh, onError);
-           var activePlan = default(ActivePlan<T1, T2, T3, T4, T5, T6, T7>);
-
-           activePlan = new ActivePlan<T1, T2, T3, T4, T5, T6, T7>(firstJoinObserver, secondJoinObserver, thirdJoinObserver,
-               fourthJoinObserver, fifthJoinObserver, sixthJoinObserver, seventhJoinObserver,
-               (first, second, third, fourth, fifth, sixth, seventh) =>
-               {
-                   var result = default(TResult);
-                   try
-                   {
-                       result = Selector(first, second, third, fourth, fifth, sixth, seventh);
-                   }
-                   catch (Exception exception)
-                   {
-                       observer.OnError(exception);
-                       return;
-                   }
-                   observer.OnNext(result);
-               },
-               () =>
-               {
-                   firstJoinObserver.RemoveActivePlan(activePlan);
-                   secondJoinObserver.RemoveActivePlan(activePlan);
-                   thirdJoinObserver.RemoveActivePlan(activePlan);
-                   fourthJoinObserver.RemoveActivePlan(activePlan);
-                   fifthJoinObserver.RemoveActivePlan(activePlan);
-                   sixthJoinObserver.RemoveActivePlan(activePlan);
-                   seventhJoinObserver.RemoveActivePlan(activePlan);
-                   deactivate(activePlan);
-               });
-
-           firstJoinObserver.AddActivePlan(activePlan);
-           secondJoinObserver.AddActivePlan(activePlan);
-           thirdJoinObserver.AddActivePlan(activePlan);
-           fourthJoinObserver.AddActivePlan(activePlan);
-           fifthJoinObserver.AddActivePlan(activePlan);
-           sixthJoinObserver.AddActivePlan(activePlan);
-           seventhJoinObserver.AddActivePlan(activePlan);
-           return activePlan;
-       }
-   }
-
-   internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, TResult> : Plan<TResult>
-   {
-       internal Pattern<T1, T2, T3, T4, T5, T6, T7, T8> Expression { get; private set; }
-
-       internal Func<T1, T2, T3, T4, T5, T6, T7, T8, TResult> Selector { get; private set; }
-
-       internal Plan(Pattern<T1, T2, T3, T4, T5, T6, T7, T8> expression,
-                     Func<T1, T2, T3, T4, T5, T6, T7, T8, TResult> selector)
-       {
-           Expression = expression;
-           Selector = selector;
-       }
-
-       internal override ActivePlan Activate(Dictionary<object, IJoinObserver> externalSubscriptions,
-                                             IObserver<TResult> observer, Action<ActivePlan> deactivate)
-       {
-           var onError = new Action<Exception>(observer.OnError);
-           var firstJoinObserver = CreateObserver(externalSubscriptions, Expression.First, onError);
-           var secondJoinObserver = CreateObserver(externalSubscriptions, Expression.Second, onError);
-           var thirdJoinObserver = CreateObserver(externalSubscriptions, Expression.Third, onError);
-           var fourthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourth, onError);
-           var fifthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fifth, onError);
-           var sixthJoinObserver = CreateObserver(externalSubscriptions, Expression.Sixth, onError);
-           var seventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Seventh, onError);
-           var eighthJoinObserver = CreateObserver(externalSubscriptions, Expression.Eighth, onError);
-           var activePlan = default(ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8>);
-
-           activePlan = new ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8>(firstJoinObserver, secondJoinObserver, thirdJoinObserver,
-               fourthJoinObserver, fifthJoinObserver, sixthJoinObserver, seventhJoinObserver, eighthJoinObserver,
-               (first, second, third, fourth, fifth, sixth, seventh, eighth) =>
-               {
-                   var result = default(TResult);
-                   try
-                   {
-                       result = Selector(first, second, third, fourth, fifth, sixth, seventh, eighth);
-                   }
-                   catch (Exception exception)
-                   {
-                       observer.OnError(exception);
-                       return;
-                   }
-                   observer.OnNext(result);
-               },
-               () =>
-               {
-                   firstJoinObserver.RemoveActivePlan(activePlan);
-                   secondJoinObserver.RemoveActivePlan(activePlan);
-                   thirdJoinObserver.RemoveActivePlan(activePlan);
-                   fourthJoinObserver.RemoveActivePlan(activePlan);
-                   fifthJoinObserver.RemoveActivePlan(activePlan);
-                   sixthJoinObserver.RemoveActivePlan(activePlan);
-                   seventhJoinObserver.RemoveActivePlan(activePlan);
-                   eighthJoinObserver.RemoveActivePlan(activePlan);
-                   deactivate(activePlan);
-               });
-
-           firstJoinObserver.AddActivePlan(activePlan);
-           secondJoinObserver.AddActivePlan(activePlan);
-           thirdJoinObserver.AddActivePlan(activePlan);
-           fourthJoinObserver.AddActivePlan(activePlan);
-           fifthJoinObserver.AddActivePlan(activePlan);
-           sixthJoinObserver.AddActivePlan(activePlan);
-           seventhJoinObserver.AddActivePlan(activePlan);
-           eighthJoinObserver.AddActivePlan(activePlan);
-           return activePlan;
-       }
-   }
-
-   internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult> : Plan<TResult>
-   {
-       internal Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9> Expression { get; private set; }
-
-       internal Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult> Selector { get; private set; }
-
-       internal Plan(Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9> expression,
-                     Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult> selector)
-       {
-           Expression = expression;
-           Selector = selector;
-       }
-
-       internal override ActivePlan Activate(Dictionary<object, IJoinObserver> externalSubscriptions,
-                                             IObserver<TResult> observer, Action<ActivePlan> deactivate)
-       {
-           var onError = new Action<Exception>(observer.OnError);
-           var firstJoinObserver = CreateObserver(externalSubscriptions, Expression.First, onError);
-           var secondJoinObserver = CreateObserver(externalSubscriptions, Expression.Second, onError);
-           var thirdJoinObserver = CreateObserver(externalSubscriptions, Expression.Third, onError);
-           var fourthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourth, onError);
-           var fifthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fifth, onError);
-           var sixthJoinObserver = CreateObserver(externalSubscriptions, Expression.Sixth, onError);
-           var seventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Seventh, onError);
-           var eighthJoinObserver = CreateObserver(externalSubscriptions, Expression.Eighth, onError);
-           var ninthJoinObserver = CreateObserver(externalSubscriptions, Expression.Ninth, onError);
-           var activePlan = default(ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9>);
-
-           activePlan = new ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9>(firstJoinObserver, secondJoinObserver, thirdJoinObserver,
-               fourthJoinObserver, fifthJoinObserver, sixthJoinObserver, seventhJoinObserver, eighthJoinObserver, ninthJoinObserver,
-               (first, second, third, fourth, fifth, sixth, seventh, eighth, ninth) =>
-               {
-                   var result = default(TResult);
-                   try
-                   {
-                       result = Selector(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth);
-                   }
-                   catch (Exception exception)
-                   {
-                       observer.OnError(exception);
-                       return;
-                   }
-                   observer.OnNext(result);
-               },
-               () =>
-               {
-                   firstJoinObserver.RemoveActivePlan(activePlan);
-                   secondJoinObserver.RemoveActivePlan(activePlan);
-                   thirdJoinObserver.RemoveActivePlan(activePlan);
-                   fourthJoinObserver.RemoveActivePlan(activePlan);
-                   fifthJoinObserver.RemoveActivePlan(activePlan);
-                   sixthJoinObserver.RemoveActivePlan(activePlan);
-                   seventhJoinObserver.RemoveActivePlan(activePlan);
-                   eighthJoinObserver.RemoveActivePlan(activePlan);
-                   ninthJoinObserver.RemoveActivePlan(activePlan);
-                   deactivate(activePlan);
-               });
-
-           firstJoinObserver.AddActivePlan(activePlan);
-           secondJoinObserver.AddActivePlan(activePlan);
-           thirdJoinObserver.AddActivePlan(activePlan);
-           fourthJoinObserver.AddActivePlan(activePlan);
-           fifthJoinObserver.AddActivePlan(activePlan);
-           sixthJoinObserver.AddActivePlan(activePlan);
-           seventhJoinObserver.AddActivePlan(activePlan);
-           eighthJoinObserver.AddActivePlan(activePlan);
-           ninthJoinObserver.AddActivePlan(activePlan);
-           return activePlan;
-       }
-   }
-
-   internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult> : Plan<TResult>
-   {
-       internal Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> Expression { get; private set; }
-
-       internal Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult> Selector { get; private set; }
-
-       internal Plan(Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> expression,
-                     Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult> selector)
-       {
-           Expression = expression;
-           Selector = selector;
-       }
-
-       internal override ActivePlan Activate(Dictionary<object, IJoinObserver> externalSubscriptions,
-                                             IObserver<TResult> observer, Action<ActivePlan> deactivate)
-       {
-           var onError = new Action<Exception>(observer.OnError);
-           var firstJoinObserver = CreateObserver(externalSubscriptions, Expression.First, onError);
-           var secondJoinObserver = CreateObserver(externalSubscriptions, Expression.Second, onError);
-           var thirdJoinObserver = CreateObserver(externalSubscriptions, Expression.Third, onError);
-           var fourthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourth, onError);
-           var fifthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fifth, onError);
-           var sixthJoinObserver = CreateObserver(externalSubscriptions, Expression.Sixth, onError);
-           var seventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Seventh, onError);
-           var eighthJoinObserver = CreateObserver(externalSubscriptions, Expression.Eighth, onError);
-           var ninthJoinObserver = CreateObserver(externalSubscriptions, Expression.Ninth, onError);
-           var tenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Tenth, onError);
-           var activePlan = default(ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>);
-
-           activePlan = new ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(firstJoinObserver, secondJoinObserver, thirdJoinObserver,
-               fourthJoinObserver, fifthJoinObserver, sixthJoinObserver, seventhJoinObserver, eighthJoinObserver, ninthJoinObserver, tenthJoinObserver, 
-               (first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth) =>
-               {
-                   var result = default(TResult);
-                   try
-                   {
-                       result = Selector(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth);
-                   }
-                   catch (Exception exception)
-                   {
-                       observer.OnError(exception);
-                       return;
-                   }
-                   observer.OnNext(result);
-               },
-               () =>
-               {
-                   firstJoinObserver.RemoveActivePlan(activePlan);
-                   secondJoinObserver.RemoveActivePlan(activePlan);
-                   thirdJoinObserver.RemoveActivePlan(activePlan);
-                   fourthJoinObserver.RemoveActivePlan(activePlan);
-                   fifthJoinObserver.RemoveActivePlan(activePlan);
-                   sixthJoinObserver.RemoveActivePlan(activePlan);
-                   seventhJoinObserver.RemoveActivePlan(activePlan);
-                   eighthJoinObserver.RemoveActivePlan(activePlan);
-                   ninthJoinObserver.RemoveActivePlan(activePlan);
-                   tenthJoinObserver.RemoveActivePlan(activePlan);
-                   deactivate(activePlan);
-               });
-
-           firstJoinObserver.AddActivePlan(activePlan);
-           secondJoinObserver.AddActivePlan(activePlan);
-           thirdJoinObserver.AddActivePlan(activePlan);
-           fourthJoinObserver.AddActivePlan(activePlan);
-           fifthJoinObserver.AddActivePlan(activePlan);
-           sixthJoinObserver.AddActivePlan(activePlan);
-           seventhJoinObserver.AddActivePlan(activePlan);
-           eighthJoinObserver.AddActivePlan(activePlan);
-           ninthJoinObserver.AddActivePlan(activePlan);
-           tenthJoinObserver.AddActivePlan(activePlan);
-           return activePlan;
-       }
-   }
-
-   internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult> : Plan<TResult>
-   {
-       internal Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Expression { get; private set; }
-
-       internal Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult> Selector { get; private set; }
-
-       internal Plan(Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> expression,
-                     Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult> selector)
-       {
-           Expression = expression;
-           Selector = selector;
-       }
-
-       internal override ActivePlan Activate(Dictionary<object, IJoinObserver> externalSubscriptions,
-                                             IObserver<TResult> observer, Action<ActivePlan> deactivate)
-       {
-           var onError = new Action<Exception>(observer.OnError);
-           var firstJoinObserver = CreateObserver(externalSubscriptions, Expression.First, onError);
-           var secondJoinObserver = CreateObserver(externalSubscriptions, Expression.Second, onError);
-           var thirdJoinObserver = CreateObserver(externalSubscriptions, Expression.Third, onError);
-           var fourthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourth, onError);
-           var fifthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fifth, onError);
-           var sixthJoinObserver = CreateObserver(externalSubscriptions, Expression.Sixth, onError);
-           var seventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Seventh, onError);
-           var eighthJoinObserver = CreateObserver(externalSubscriptions, Expression.Eighth, onError);
-           var ninthJoinObserver = CreateObserver(externalSubscriptions, Expression.Ninth, onError);
-           var tenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Tenth, onError);
-           var eleventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Eleventh, onError);
-
-           var activePlan = default(ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>);
-
-           activePlan = new ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(firstJoinObserver, secondJoinObserver, thirdJoinObserver,
-               fourthJoinObserver, fifthJoinObserver, sixthJoinObserver, seventhJoinObserver, eighthJoinObserver, ninthJoinObserver, tenthJoinObserver,eleventhJoinObserver,
-               (first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh) =>
-               {
-                   var result = default(TResult);
-                   try
-                   {
-                       result = Selector(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh);
-                   }
-                   catch (Exception exception)
-                   {
-                       observer.OnError(exception);
-                       return;
-                   }
-                   observer.OnNext(result);
-               },
-               () =>
-               {
-                   firstJoinObserver.RemoveActivePlan(activePlan);
-                   secondJoinObserver.RemoveActivePlan(activePlan);
-                   thirdJoinObserver.RemoveActivePlan(activePlan);
-                   fourthJoinObserver.RemoveActivePlan(activePlan);
-                   fifthJoinObserver.RemoveActivePlan(activePlan);
-                   sixthJoinObserver.RemoveActivePlan(activePlan);
-                   seventhJoinObserver.RemoveActivePlan(activePlan);
-                   eighthJoinObserver.RemoveActivePlan(activePlan);
-                   ninthJoinObserver.RemoveActivePlan(activePlan);
-                   tenthJoinObserver.RemoveActivePlan(activePlan);
-                   eleventhJoinObserver.RemoveActivePlan(activePlan);
-                   deactivate(activePlan);
-               });
-
-           firstJoinObserver.AddActivePlan(activePlan);
-           secondJoinObserver.AddActivePlan(activePlan);
-           thirdJoinObserver.AddActivePlan(activePlan);
-           fourthJoinObserver.AddActivePlan(activePlan);
-           fifthJoinObserver.AddActivePlan(activePlan);
-           sixthJoinObserver.AddActivePlan(activePlan);
-           seventhJoinObserver.AddActivePlan(activePlan);
-           eighthJoinObserver.AddActivePlan(activePlan);
-           ninthJoinObserver.AddActivePlan(activePlan);
-           tenthJoinObserver.AddActivePlan(activePlan);
-           eleventhJoinObserver.AddActivePlan(activePlan);
-           return activePlan;
-       }
-   }
-
-   internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult> : Plan<TResult>
-   {
-       internal Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Expression { get; private set; }
-
-       internal Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult> Selector { get; private set; }
-
-       internal Plan(Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> expression,
-                     Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult> selector)
-       {
-           Expression = expression;
-           Selector = selector;
-       }
-
-       internal override ActivePlan Activate(Dictionary<object, IJoinObserver> externalSubscriptions,
-                                             IObserver<TResult> observer, Action<ActivePlan> deactivate)
-       {
-           var onError = new Action<Exception>(observer.OnError);
-           var firstJoinObserver = CreateObserver(externalSubscriptions, Expression.First, onError);
-           var secondJoinObserver = CreateObserver(externalSubscriptions, Expression.Second, onError);
-           var thirdJoinObserver = CreateObserver(externalSubscriptions, Expression.Third, onError);
-           var fourthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourth, onError);
-           var fifthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fifth, onError);
-           var sixthJoinObserver = CreateObserver(externalSubscriptions, Expression.Sixth, onError);
-           var seventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Seventh, onError);
-           var eighthJoinObserver = CreateObserver(externalSubscriptions, Expression.Eighth, onError);
-           var ninthJoinObserver = CreateObserver(externalSubscriptions, Expression.Ninth, onError);
-           var tenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Tenth, onError);
-           var eleventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Eleventh, onError);
-           var twelfthJoinObserver = CreateObserver(externalSubscriptions, Expression.Twelfth, onError);
-
-           var activePlan = default(ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>);
-
-           activePlan = new ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(firstJoinObserver, secondJoinObserver, thirdJoinObserver,
-               fourthJoinObserver, fifthJoinObserver, sixthJoinObserver, seventhJoinObserver, eighthJoinObserver, ninthJoinObserver, tenthJoinObserver, eleventhJoinObserver,
-               twelfthJoinObserver,
-               (first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth) =>
-               {
-                   var result = default(TResult);
-                   try
-                   {
-                       result = Selector(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth);
-                   }
-                   catch (Exception exception)
-                   {
-                       observer.OnError(exception);
-                       return;
-                   }
-                   observer.OnNext(result);
-               },
-               () =>
-               {
-                   firstJoinObserver.RemoveActivePlan(activePlan);
-                   secondJoinObserver.RemoveActivePlan(activePlan);
-                   thirdJoinObserver.RemoveActivePlan(activePlan);
-                   fourthJoinObserver.RemoveActivePlan(activePlan);
-                   fifthJoinObserver.RemoveActivePlan(activePlan);
-                   sixthJoinObserver.RemoveActivePlan(activePlan);
-                   seventhJoinObserver.RemoveActivePlan(activePlan);
-                   eighthJoinObserver.RemoveActivePlan(activePlan);
-                   ninthJoinObserver.RemoveActivePlan(activePlan);
-                   tenthJoinObserver.RemoveActivePlan(activePlan);
-                   eleventhJoinObserver.RemoveActivePlan(activePlan);
-                   twelfthJoinObserver.RemoveActivePlan(activePlan);
-                   deactivate(activePlan);
-               });
-
-           firstJoinObserver.AddActivePlan(activePlan);
-           secondJoinObserver.AddActivePlan(activePlan);
-           thirdJoinObserver.AddActivePlan(activePlan);
-           fourthJoinObserver.AddActivePlan(activePlan);
-           fifthJoinObserver.AddActivePlan(activePlan);
-           sixthJoinObserver.AddActivePlan(activePlan);
-           seventhJoinObserver.AddActivePlan(activePlan);
-           eighthJoinObserver.AddActivePlan(activePlan);
-           ninthJoinObserver.AddActivePlan(activePlan);
-           tenthJoinObserver.AddActivePlan(activePlan);
-           eleventhJoinObserver.AddActivePlan(activePlan);
-           twelfthJoinObserver.AddActivePlan(activePlan);
-           return activePlan;
-       }
-   }
-
-
-   internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TResult> : Plan<TResult>
-   {
-       internal Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> Expression { get; private set; }
-
-       internal Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TResult> Selector { get; private set; }
-
-       internal Plan(Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> expression,
-                     Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TResult> selector)
-       {
-           Expression = expression;
-           Selector = selector;
-       }
-
-       internal override ActivePlan Activate(Dictionary<object, IJoinObserver> externalSubscriptions,
-                                             IObserver<TResult> observer, Action<ActivePlan> deactivate)
-       {
-           var onError = new Action<Exception>(observer.OnError);
-           var firstJoinObserver = CreateObserver(externalSubscriptions, Expression.First, onError);
-           var secondJoinObserver = CreateObserver(externalSubscriptions, Expression.Second, onError);
-           var thirdJoinObserver = CreateObserver(externalSubscriptions, Expression.Third, onError);
-           var fourthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourth, onError);
-           var fifthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fifth, onError);
-           var sixthJoinObserver = CreateObserver(externalSubscriptions, Expression.Sixth, onError);
-           var seventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Seventh, onError);
-           var eighthJoinObserver = CreateObserver(externalSubscriptions, Expression.Eighth, onError);
-           var ninthJoinObserver = CreateObserver(externalSubscriptions, Expression.Ninth, onError);
-           var tenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Tenth, onError);
-           var eleventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Eleventh, onError);
-           var twelfthJoinObserver = CreateObserver(externalSubscriptions, Expression.Twelfth, onError);
-           var thirteenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Thirteenth, onError);
-
-           var activePlan = default(ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>);
-
-           activePlan = new ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(firstJoinObserver, secondJoinObserver, thirdJoinObserver,
-               fourthJoinObserver, fifthJoinObserver, sixthJoinObserver, seventhJoinObserver, eighthJoinObserver, ninthJoinObserver, tenthJoinObserver, eleventhJoinObserver,
-               twelfthJoinObserver, thirteenthJoinObserver,
-               (first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth) =>
-               {
-                   var result = default(TResult);
-                   try
-                   {
-                       result = Selector(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth);
-                   }
-                   catch (Exception exception)
-                   {
-                       observer.OnError(exception);
-                       return;
-                   }
-                   observer.OnNext(result);
-               },
-               () =>
-               {
-                   firstJoinObserver.RemoveActivePlan(activePlan);
-                   secondJoinObserver.RemoveActivePlan(activePlan);
-                   thirdJoinObserver.RemoveActivePlan(activePlan);
-                   fourthJoinObserver.RemoveActivePlan(activePlan);
-                   fifthJoinObserver.RemoveActivePlan(activePlan);
-                   sixthJoinObserver.RemoveActivePlan(activePlan);
-                   seventhJoinObserver.RemoveActivePlan(activePlan);
-                   eighthJoinObserver.RemoveActivePlan(activePlan);
-                   ninthJoinObserver.RemoveActivePlan(activePlan);
-                   tenthJoinObserver.RemoveActivePlan(activePlan);
-                   eleventhJoinObserver.RemoveActivePlan(activePlan);
-                   twelfthJoinObserver.RemoveActivePlan(activePlan);
-                   thirteenthJoinObserver.RemoveActivePlan(activePlan);
-                   deactivate(activePlan);
-               });
-
-           firstJoinObserver.AddActivePlan(activePlan);
-           secondJoinObserver.AddActivePlan(activePlan);
-           thirdJoinObserver.AddActivePlan(activePlan);
-           fourthJoinObserver.AddActivePlan(activePlan);
-           fifthJoinObserver.AddActivePlan(activePlan);
-           sixthJoinObserver.AddActivePlan(activePlan);
-           seventhJoinObserver.AddActivePlan(activePlan);
-           eighthJoinObserver.AddActivePlan(activePlan);
-           ninthJoinObserver.AddActivePlan(activePlan);
-           tenthJoinObserver.AddActivePlan(activePlan);
-           eleventhJoinObserver.AddActivePlan(activePlan);
-           twelfthJoinObserver.AddActivePlan(activePlan);
-           thirteenthJoinObserver.AddActivePlan(activePlan);
-           return activePlan;
-       }
-   }
-
-
-   internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TResult> : Plan<TResult>
-   {
-       internal Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> Expression { get; private set; }
-
-       internal Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TResult> Selector { get; private set; }
-
-       internal Plan(Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> expression,
-                     Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TResult> selector)
-       {
-           Expression = expression;
-           Selector = selector;
-       }
-
-       internal override ActivePlan Activate(Dictionary<object, IJoinObserver> externalSubscriptions,
-                                             IObserver<TResult> observer, Action<ActivePlan> deactivate)
-       {
-           var onError = new Action<Exception>(observer.OnError);
-           var firstJoinObserver = CreateObserver(externalSubscriptions, Expression.First, onError);
-           var secondJoinObserver = CreateObserver(externalSubscriptions, Expression.Second, onError);
-           var thirdJoinObserver = CreateObserver(externalSubscriptions, Expression.Third, onError);
-           var fourthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourth, onError);
-           var fifthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fifth, onError);
-           var sixthJoinObserver = CreateObserver(externalSubscriptions, Expression.Sixth, onError);
-           var seventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Seventh, onError);
-           var eighthJoinObserver = CreateObserver(externalSubscriptions, Expression.Eighth, onError);
-           var ninthJoinObserver = CreateObserver(externalSubscriptions, Expression.Ninth, onError);
-           var tenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Tenth, onError);
-           var eleventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Eleventh, onError);
-           var twelfthJoinObserver = CreateObserver(externalSubscriptions, Expression.Twelfth, onError);
-           var thirteenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Thirteenth, onError);
-           var fourteenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourteenth, onError);
-
-           var activePlan = default(ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>);
-
-           activePlan = new ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(
-               firstJoinObserver, secondJoinObserver, thirdJoinObserver,
-               fourthJoinObserver, fifthJoinObserver, sixthJoinObserver, 
-               seventhJoinObserver, eighthJoinObserver, ninthJoinObserver, 
-               tenthJoinObserver, eleventhJoinObserver,
-               twelfthJoinObserver, thirteenthJoinObserver,
-               fourteenthJoinObserver,
-               (first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth, fourteenth) =>
-               {
-                   var result = default(TResult);
-                   try
-                   {
-                       result = Selector(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth, fourteenth);
-                   }
-                   catch (Exception exception)
-                   {
-                       observer.OnError(exception);
-                       return;
-                   }
-                   observer.OnNext(result);
-               },
-               () =>
-               {
-                   firstJoinObserver.RemoveActivePlan(activePlan);
-                   secondJoinObserver.RemoveActivePlan(activePlan);
-                   thirdJoinObserver.RemoveActivePlan(activePlan);
-                   fourthJoinObserver.RemoveActivePlan(activePlan);
-                   fifthJoinObserver.RemoveActivePlan(activePlan);
-                   sixthJoinObserver.RemoveActivePlan(activePlan);
-                   seventhJoinObserver.RemoveActivePlan(activePlan);
-                   eighthJoinObserver.RemoveActivePlan(activePlan);
-                   ninthJoinObserver.RemoveActivePlan(activePlan);
-                   tenthJoinObserver.RemoveActivePlan(activePlan);
-                   eleventhJoinObserver.RemoveActivePlan(activePlan);
-                   twelfthJoinObserver.RemoveActivePlan(activePlan);
-                   thirteenthJoinObserver.RemoveActivePlan(activePlan);
-                   fourteenthJoinObserver.RemoveActivePlan(activePlan);
-                   deactivate(activePlan);
-               });
-
-           firstJoinObserver.AddActivePlan(activePlan);
-           secondJoinObserver.AddActivePlan(activePlan);
-           thirdJoinObserver.AddActivePlan(activePlan);
-           fourthJoinObserver.AddActivePlan(activePlan);
-           fifthJoinObserver.AddActivePlan(activePlan);
-           sixthJoinObserver.AddActivePlan(activePlan);
-           seventhJoinObserver.AddActivePlan(activePlan);
-           eighthJoinObserver.AddActivePlan(activePlan);
-           ninthJoinObserver.AddActivePlan(activePlan);
-           tenthJoinObserver.AddActivePlan(activePlan);
-           eleventhJoinObserver.AddActivePlan(activePlan);
-           twelfthJoinObserver.AddActivePlan(activePlan);
-           thirteenthJoinObserver.AddActivePlan(activePlan);
-           fourteenthJoinObserver.AddActivePlan(activePlan);
-           return activePlan;
-       }
-   }
-
-   internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TResult> : Plan<TResult>
-   {
-       internal Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> Expression { get; private set; }
-
-       internal Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TResult> Selector { get; private set; }
-
-       internal Plan(Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> expression,
-                     Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TResult> selector)
-       {
-           Expression = expression;
-           Selector = selector;
-       }
-
-       internal override ActivePlan Activate(Dictionary<object, IJoinObserver> externalSubscriptions,
-                                             IObserver<TResult> observer, Action<ActivePlan> deactivate)
-       {
-           var onError = new Action<Exception>(observer.OnError);
-           var firstJoinObserver = CreateObserver(externalSubscriptions, Expression.First, onError);
-           var secondJoinObserver = CreateObserver(externalSubscriptions, Expression.Second, onError);
-           var thirdJoinObserver = CreateObserver(externalSubscriptions, Expression.Third, onError);
-           var fourthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourth, onError);
-           var fifthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fifth, onError);
-           var sixthJoinObserver = CreateObserver(externalSubscriptions, Expression.Sixth, onError);
-           var seventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Seventh, onError);
-           var eighthJoinObserver = CreateObserver(externalSubscriptions, Expression.Eighth, onError);
-           var ninthJoinObserver = CreateObserver(externalSubscriptions, Expression.Ninth, onError);
-           var tenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Tenth, onError);
-           var eleventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Eleventh, onError);
-           var twelfthJoinObserver = CreateObserver(externalSubscriptions, Expression.Twelfth, onError);
-           var thirteenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Thirteenth, onError);
-           var fourteenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourteenth, onError);
-           var fifteenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fifteenth, onError);
-
-           var activePlan = default(ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>);
-
-           activePlan = new ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(
-               firstJoinObserver, secondJoinObserver, thirdJoinObserver,
-               fourthJoinObserver, fifthJoinObserver, sixthJoinObserver,
-               seventhJoinObserver, eighthJoinObserver, ninthJoinObserver,
-               tenthJoinObserver, eleventhJoinObserver,
-               twelfthJoinObserver, thirteenthJoinObserver,
-               fourteenthJoinObserver, fifteenthJoinObserver,
-               (first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth, fourteenth, fifteenth) =>
-               {
-                   var result = default(TResult);
-                   try
-                   {
-                       result = Selector(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth, fourteenth, fifteenth);
-                   }
-                   catch (Exception exception)
-                   {
-                       observer.OnError(exception);
-                       return;
-                   }
-                   observer.OnNext(result);
-               },
-               () =>
-               {
-                   firstJoinObserver.RemoveActivePlan(activePlan);
-                   secondJoinObserver.RemoveActivePlan(activePlan);
-                   thirdJoinObserver.RemoveActivePlan(activePlan);
-                   fourthJoinObserver.RemoveActivePlan(activePlan);
-                   fifthJoinObserver.RemoveActivePlan(activePlan);
-                   sixthJoinObserver.RemoveActivePlan(activePlan);
-                   seventhJoinObserver.RemoveActivePlan(activePlan);
-                   eighthJoinObserver.RemoveActivePlan(activePlan);
-                   ninthJoinObserver.RemoveActivePlan(activePlan);
-                   tenthJoinObserver.RemoveActivePlan(activePlan);
-                   eleventhJoinObserver.RemoveActivePlan(activePlan);
-                   twelfthJoinObserver.RemoveActivePlan(activePlan);
-                   thirteenthJoinObserver.RemoveActivePlan(activePlan);
-                   fourteenthJoinObserver.RemoveActivePlan(activePlan);
-                   fifteenthJoinObserver.RemoveActivePlan(activePlan);
-                   deactivate(activePlan);
-               });
-
-           firstJoinObserver.AddActivePlan(activePlan);
-           secondJoinObserver.AddActivePlan(activePlan);
-           thirdJoinObserver.AddActivePlan(activePlan);
-           fourthJoinObserver.AddActivePlan(activePlan);
-           fifthJoinObserver.AddActivePlan(activePlan);
-           sixthJoinObserver.AddActivePlan(activePlan);
-           seventhJoinObserver.AddActivePlan(activePlan);
-           eighthJoinObserver.AddActivePlan(activePlan);
-           ninthJoinObserver.AddActivePlan(activePlan);
-           tenthJoinObserver.AddActivePlan(activePlan);
-           eleventhJoinObserver.AddActivePlan(activePlan);
-           twelfthJoinObserver.AddActivePlan(activePlan);
-           thirteenthJoinObserver.AddActivePlan(activePlan);
-           fourteenthJoinObserver.AddActivePlan(activePlan);
-           fifteenthJoinObserver.AddActivePlan(activePlan);
-           return activePlan;
-       }
-   }
-   internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TResult> : Plan<TResult>
-   {
-       internal Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> Expression { get; private set; }
-
-       internal Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TResult> Selector { get; private set; }
-
-       internal Plan(Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> expression,
-                     Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TResult> selector)
-       {
-           Expression = expression;
-           Selector = selector;
-       }
-
-       internal override ActivePlan Activate(Dictionary<object, IJoinObserver> externalSubscriptions,
-                                             IObserver<TResult> observer, Action<ActivePlan> deactivate)
-       {
-           var onError = new Action<Exception>(observer.OnError);
-           var firstJoinObserver = CreateObserver(externalSubscriptions, Expression.First, onError);
-           var secondJoinObserver = CreateObserver(externalSubscriptions, Expression.Second, onError);
-           var thirdJoinObserver = CreateObserver(externalSubscriptions, Expression.Third, onError);
-           var fourthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourth, onError);
-           var fifthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fifth, onError);
-           var sixthJoinObserver = CreateObserver(externalSubscriptions, Expression.Sixth, onError);
-           var seventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Seventh, onError);
-           var eighthJoinObserver = CreateObserver(externalSubscriptions, Expression.Eighth, onError);
-           var ninthJoinObserver = CreateObserver(externalSubscriptions, Expression.Ninth, onError);
-           var tenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Tenth, onError);
-           var eleventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Eleventh, onError);
-           var twelfthJoinObserver = CreateObserver(externalSubscriptions, Expression.Twelfth, onError);
-           var thirteenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Thirteenth, onError);
-           var fourteenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourteenth, onError);
-           var fifteenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fifteenth, onError);
-           var sixteenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Sixteenth, onError);
-
-           var activePlan = default(ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>);
-
-           activePlan = new ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(
-               firstJoinObserver, secondJoinObserver, thirdJoinObserver,
-               fourthJoinObserver, fifthJoinObserver, sixthJoinObserver,
-               seventhJoinObserver, eighthJoinObserver, ninthJoinObserver,
-               tenthJoinObserver, eleventhJoinObserver,
-               twelfthJoinObserver, thirteenthJoinObserver,
-               fourteenthJoinObserver, fifteenthJoinObserver,
-               sixteenthJoinObserver,
-               (first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth, fourteenth, fifteenth, sixteenth) =>
-               {
-                   var result = default(TResult);
-                   try
-                   {
-                       result = Selector(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth, fourteenth, fifteenth, sixteenth);
-                   }
-                   catch (Exception exception)
-                   {
-                       observer.OnError(exception);
-                       return;
-                   }
-                   observer.OnNext(result);
-               },
-               () =>
-               {
-                   firstJoinObserver.RemoveActivePlan(activePlan);
-                   secondJoinObserver.RemoveActivePlan(activePlan);
-                   thirdJoinObserver.RemoveActivePlan(activePlan);
-                   fourthJoinObserver.RemoveActivePlan(activePlan);
-                   fifthJoinObserver.RemoveActivePlan(activePlan);
-                   sixthJoinObserver.RemoveActivePlan(activePlan);
-                   seventhJoinObserver.RemoveActivePlan(activePlan);
-                   eighthJoinObserver.RemoveActivePlan(activePlan);
-                   ninthJoinObserver.RemoveActivePlan(activePlan);
-                   tenthJoinObserver.RemoveActivePlan(activePlan);
-                   eleventhJoinObserver.RemoveActivePlan(activePlan);
-                   twelfthJoinObserver.RemoveActivePlan(activePlan);
-                   thirteenthJoinObserver.RemoveActivePlan(activePlan);
-                   fourteenthJoinObserver.RemoveActivePlan(activePlan);
-                   fifteenthJoinObserver.RemoveActivePlan(activePlan);
-                   sixteenthJoinObserver.RemoveActivePlan(activePlan);
-                   deactivate(activePlan);
-               });
-
-           firstJoinObserver.AddActivePlan(activePlan);
-           secondJoinObserver.AddActivePlan(activePlan);
-           thirdJoinObserver.AddActivePlan(activePlan);
-           fourthJoinObserver.AddActivePlan(activePlan);
-           fifthJoinObserver.AddActivePlan(activePlan);
-           sixthJoinObserver.AddActivePlan(activePlan);
-           seventhJoinObserver.AddActivePlan(activePlan);
-           eighthJoinObserver.AddActivePlan(activePlan);
-           ninthJoinObserver.AddActivePlan(activePlan);
-           tenthJoinObserver.AddActivePlan(activePlan);
-           eleventhJoinObserver.AddActivePlan(activePlan);
-           twelfthJoinObserver.AddActivePlan(activePlan);
-           thirteenthJoinObserver.AddActivePlan(activePlan);
-           fourteenthJoinObserver.AddActivePlan(activePlan);
-           fifteenthJoinObserver.AddActivePlan(activePlan);
-           sixteenthJoinObserver.AddActivePlan(activePlan);
-           return activePlan;
-       }
-   }
+    internal class Plan<T1, T2, T3, T4, T5, T6, TResult> : Plan<TResult>
+    {
+        internal Pattern<T1, T2, T3, T4, T5, T6> Expression { get; private set; }
+
+        internal Func<T1, T2, T3, T4, T5, T6, TResult> Selector { get; private set; }
+
+        internal Plan(Pattern<T1, T2, T3, T4, T5, T6> expression,
+                      Func<T1, T2, T3, T4, T5, T6, TResult> selector)
+        {
+            Expression = expression;
+            Selector = selector;
+        }
+
+        internal override ActivePlan Activate(Dictionary<object, IJoinObserver> externalSubscriptions,
+                                              IObserver<TResult> observer, Action<ActivePlan> deactivate)
+        {
+            var onError = new Action<Exception>(observer.OnError);
+            var firstJoinObserver = CreateObserver(externalSubscriptions, Expression.First, onError);
+            var secondJoinObserver = CreateObserver(externalSubscriptions, Expression.Second, onError);
+            var thirdJoinObserver = CreateObserver(externalSubscriptions, Expression.Third, onError);
+            var fourthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourth, onError);
+            var fifthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fifth, onError);
+            var sixthJoinObserver = CreateObserver(externalSubscriptions, Expression.Sixth, onError);
+            var activePlan = default(ActivePlan<T1, T2, T3, T4, T5, T6>);
+
+            activePlan = new ActivePlan<T1, T2, T3, T4, T5, T6>(firstJoinObserver, secondJoinObserver, thirdJoinObserver,
+                fourthJoinObserver, fifthJoinObserver, sixthJoinObserver,
+                (first, second, third, fourth, fifth, sixth) =>
+                {
+                    var result = default(TResult);
+                    try
+                    {
+                        result = Selector(first, second, third, fourth, fifth, sixth);
+                    }
+                    catch (Exception exception)
+                    {
+                        observer.OnError(exception);
+                        return;
+                    }
+                    observer.OnNext(result);
+                },
+                () =>
+                {
+                    firstJoinObserver.RemoveActivePlan(activePlan);
+                    secondJoinObserver.RemoveActivePlan(activePlan);
+                    thirdJoinObserver.RemoveActivePlan(activePlan);
+                    fourthJoinObserver.RemoveActivePlan(activePlan);
+                    fifthJoinObserver.RemoveActivePlan(activePlan);
+                    sixthJoinObserver.RemoveActivePlan(activePlan);
+                    deactivate(activePlan);
+                });
+
+            firstJoinObserver.AddActivePlan(activePlan);
+            secondJoinObserver.AddActivePlan(activePlan);
+            thirdJoinObserver.AddActivePlan(activePlan);
+            fourthJoinObserver.AddActivePlan(activePlan);
+            fifthJoinObserver.AddActivePlan(activePlan);
+            sixthJoinObserver.AddActivePlan(activePlan);
+            return activePlan;
+        }
+    }
+
+    internal class Plan<T1, T2, T3, T4, T5, T6, T7, TResult> : Plan<TResult>
+    {
+        internal Pattern<T1, T2, T3, T4, T5, T6, T7> Expression { get; private set; }
+
+        internal Func<T1, T2, T3, T4, T5, T6, T7, TResult> Selector { get; private set; }
+
+        internal Plan(Pattern<T1, T2, T3, T4, T5, T6, T7> expression,
+                      Func<T1, T2, T3, T4, T5, T6, T7, TResult> selector)
+        {
+            Expression = expression;
+            Selector = selector;
+        }
+
+        internal override ActivePlan Activate(Dictionary<object, IJoinObserver> externalSubscriptions,
+                                              IObserver<TResult> observer, Action<ActivePlan> deactivate)
+        {
+            var onError = new Action<Exception>(observer.OnError);
+            var firstJoinObserver = CreateObserver(externalSubscriptions, Expression.First, onError);
+            var secondJoinObserver = CreateObserver(externalSubscriptions, Expression.Second, onError);
+            var thirdJoinObserver = CreateObserver(externalSubscriptions, Expression.Third, onError);
+            var fourthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourth, onError);
+            var fifthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fifth, onError);
+            var sixthJoinObserver = CreateObserver(externalSubscriptions, Expression.Sixth, onError);
+            var seventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Seventh, onError);
+            var activePlan = default(ActivePlan<T1, T2, T3, T4, T5, T6, T7>);
+
+            activePlan = new ActivePlan<T1, T2, T3, T4, T5, T6, T7>(firstJoinObserver, secondJoinObserver, thirdJoinObserver,
+                fourthJoinObserver, fifthJoinObserver, sixthJoinObserver, seventhJoinObserver,
+                (first, second, third, fourth, fifth, sixth, seventh) =>
+                {
+                    var result = default(TResult);
+                    try
+                    {
+                        result = Selector(first, second, third, fourth, fifth, sixth, seventh);
+                    }
+                    catch (Exception exception)
+                    {
+                        observer.OnError(exception);
+                        return;
+                    }
+                    observer.OnNext(result);
+                },
+                () =>
+                {
+                    firstJoinObserver.RemoveActivePlan(activePlan);
+                    secondJoinObserver.RemoveActivePlan(activePlan);
+                    thirdJoinObserver.RemoveActivePlan(activePlan);
+                    fourthJoinObserver.RemoveActivePlan(activePlan);
+                    fifthJoinObserver.RemoveActivePlan(activePlan);
+                    sixthJoinObserver.RemoveActivePlan(activePlan);
+                    seventhJoinObserver.RemoveActivePlan(activePlan);
+                    deactivate(activePlan);
+                });
+
+            firstJoinObserver.AddActivePlan(activePlan);
+            secondJoinObserver.AddActivePlan(activePlan);
+            thirdJoinObserver.AddActivePlan(activePlan);
+            fourthJoinObserver.AddActivePlan(activePlan);
+            fifthJoinObserver.AddActivePlan(activePlan);
+            sixthJoinObserver.AddActivePlan(activePlan);
+            seventhJoinObserver.AddActivePlan(activePlan);
+            return activePlan;
+        }
+    }
+
+    internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, TResult> : Plan<TResult>
+    {
+        internal Pattern<T1, T2, T3, T4, T5, T6, T7, T8> Expression { get; private set; }
+
+        internal Func<T1, T2, T3, T4, T5, T6, T7, T8, TResult> Selector { get; private set; }
+
+        internal Plan(Pattern<T1, T2, T3, T4, T5, T6, T7, T8> expression,
+                      Func<T1, T2, T3, T4, T5, T6, T7, T8, TResult> selector)
+        {
+            Expression = expression;
+            Selector = selector;
+        }
+
+        internal override ActivePlan Activate(Dictionary<object, IJoinObserver> externalSubscriptions,
+                                              IObserver<TResult> observer, Action<ActivePlan> deactivate)
+        {
+            var onError = new Action<Exception>(observer.OnError);
+            var firstJoinObserver = CreateObserver(externalSubscriptions, Expression.First, onError);
+            var secondJoinObserver = CreateObserver(externalSubscriptions, Expression.Second, onError);
+            var thirdJoinObserver = CreateObserver(externalSubscriptions, Expression.Third, onError);
+            var fourthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourth, onError);
+            var fifthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fifth, onError);
+            var sixthJoinObserver = CreateObserver(externalSubscriptions, Expression.Sixth, onError);
+            var seventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Seventh, onError);
+            var eighthJoinObserver = CreateObserver(externalSubscriptions, Expression.Eighth, onError);
+            var activePlan = default(ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8>);
+
+            activePlan = new ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8>(firstJoinObserver, secondJoinObserver, thirdJoinObserver,
+                fourthJoinObserver, fifthJoinObserver, sixthJoinObserver, seventhJoinObserver, eighthJoinObserver,
+                (first, second, third, fourth, fifth, sixth, seventh, eighth) =>
+                {
+                    var result = default(TResult);
+                    try
+                    {
+                        result = Selector(first, second, third, fourth, fifth, sixth, seventh, eighth);
+                    }
+                    catch (Exception exception)
+                    {
+                        observer.OnError(exception);
+                        return;
+                    }
+                    observer.OnNext(result);
+                },
+                () =>
+                {
+                    firstJoinObserver.RemoveActivePlan(activePlan);
+                    secondJoinObserver.RemoveActivePlan(activePlan);
+                    thirdJoinObserver.RemoveActivePlan(activePlan);
+                    fourthJoinObserver.RemoveActivePlan(activePlan);
+                    fifthJoinObserver.RemoveActivePlan(activePlan);
+                    sixthJoinObserver.RemoveActivePlan(activePlan);
+                    seventhJoinObserver.RemoveActivePlan(activePlan);
+                    eighthJoinObserver.RemoveActivePlan(activePlan);
+                    deactivate(activePlan);
+                });
+
+            firstJoinObserver.AddActivePlan(activePlan);
+            secondJoinObserver.AddActivePlan(activePlan);
+            thirdJoinObserver.AddActivePlan(activePlan);
+            fourthJoinObserver.AddActivePlan(activePlan);
+            fifthJoinObserver.AddActivePlan(activePlan);
+            sixthJoinObserver.AddActivePlan(activePlan);
+            seventhJoinObserver.AddActivePlan(activePlan);
+            eighthJoinObserver.AddActivePlan(activePlan);
+            return activePlan;
+        }
+    }
+
+    internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult> : Plan<TResult>
+    {
+        internal Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9> Expression { get; private set; }
+
+        internal Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult> Selector { get; private set; }
+
+        internal Plan(Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9> expression,
+                      Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult> selector)
+        {
+            Expression = expression;
+            Selector = selector;
+        }
+
+        internal override ActivePlan Activate(Dictionary<object, IJoinObserver> externalSubscriptions,
+                                              IObserver<TResult> observer, Action<ActivePlan> deactivate)
+        {
+            var onError = new Action<Exception>(observer.OnError);
+            var firstJoinObserver = CreateObserver(externalSubscriptions, Expression.First, onError);
+            var secondJoinObserver = CreateObserver(externalSubscriptions, Expression.Second, onError);
+            var thirdJoinObserver = CreateObserver(externalSubscriptions, Expression.Third, onError);
+            var fourthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourth, onError);
+            var fifthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fifth, onError);
+            var sixthJoinObserver = CreateObserver(externalSubscriptions, Expression.Sixth, onError);
+            var seventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Seventh, onError);
+            var eighthJoinObserver = CreateObserver(externalSubscriptions, Expression.Eighth, onError);
+            var ninthJoinObserver = CreateObserver(externalSubscriptions, Expression.Ninth, onError);
+            var activePlan = default(ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9>);
+
+            activePlan = new ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9>(firstJoinObserver, secondJoinObserver, thirdJoinObserver,
+                fourthJoinObserver, fifthJoinObserver, sixthJoinObserver, seventhJoinObserver, eighthJoinObserver, ninthJoinObserver,
+                (first, second, third, fourth, fifth, sixth, seventh, eighth, ninth) =>
+                {
+                    var result = default(TResult);
+                    try
+                    {
+                        result = Selector(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth);
+                    }
+                    catch (Exception exception)
+                    {
+                        observer.OnError(exception);
+                        return;
+                    }
+                    observer.OnNext(result);
+                },
+                () =>
+                {
+                    firstJoinObserver.RemoveActivePlan(activePlan);
+                    secondJoinObserver.RemoveActivePlan(activePlan);
+                    thirdJoinObserver.RemoveActivePlan(activePlan);
+                    fourthJoinObserver.RemoveActivePlan(activePlan);
+                    fifthJoinObserver.RemoveActivePlan(activePlan);
+                    sixthJoinObserver.RemoveActivePlan(activePlan);
+                    seventhJoinObserver.RemoveActivePlan(activePlan);
+                    eighthJoinObserver.RemoveActivePlan(activePlan);
+                    ninthJoinObserver.RemoveActivePlan(activePlan);
+                    deactivate(activePlan);
+                });
+
+            firstJoinObserver.AddActivePlan(activePlan);
+            secondJoinObserver.AddActivePlan(activePlan);
+            thirdJoinObserver.AddActivePlan(activePlan);
+            fourthJoinObserver.AddActivePlan(activePlan);
+            fifthJoinObserver.AddActivePlan(activePlan);
+            sixthJoinObserver.AddActivePlan(activePlan);
+            seventhJoinObserver.AddActivePlan(activePlan);
+            eighthJoinObserver.AddActivePlan(activePlan);
+            ninthJoinObserver.AddActivePlan(activePlan);
+            return activePlan;
+        }
+    }
+
+    internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult> : Plan<TResult>
+    {
+        internal Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> Expression { get; private set; }
+
+        internal Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult> Selector { get; private set; }
+
+        internal Plan(Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> expression,
+                      Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult> selector)
+        {
+            Expression = expression;
+            Selector = selector;
+        }
+
+        internal override ActivePlan Activate(Dictionary<object, IJoinObserver> externalSubscriptions,
+                                              IObserver<TResult> observer, Action<ActivePlan> deactivate)
+        {
+            var onError = new Action<Exception>(observer.OnError);
+            var firstJoinObserver = CreateObserver(externalSubscriptions, Expression.First, onError);
+            var secondJoinObserver = CreateObserver(externalSubscriptions, Expression.Second, onError);
+            var thirdJoinObserver = CreateObserver(externalSubscriptions, Expression.Third, onError);
+            var fourthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourth, onError);
+            var fifthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fifth, onError);
+            var sixthJoinObserver = CreateObserver(externalSubscriptions, Expression.Sixth, onError);
+            var seventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Seventh, onError);
+            var eighthJoinObserver = CreateObserver(externalSubscriptions, Expression.Eighth, onError);
+            var ninthJoinObserver = CreateObserver(externalSubscriptions, Expression.Ninth, onError);
+            var tenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Tenth, onError);
+            var activePlan = default(ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>);
+
+            activePlan = new ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(firstJoinObserver, secondJoinObserver, thirdJoinObserver,
+                fourthJoinObserver, fifthJoinObserver, sixthJoinObserver, seventhJoinObserver, eighthJoinObserver, ninthJoinObserver, tenthJoinObserver,
+                (first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth) =>
+                {
+                    var result = default(TResult);
+                    try
+                    {
+                        result = Selector(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth);
+                    }
+                    catch (Exception exception)
+                    {
+                        observer.OnError(exception);
+                        return;
+                    }
+                    observer.OnNext(result);
+                },
+                () =>
+                {
+                    firstJoinObserver.RemoveActivePlan(activePlan);
+                    secondJoinObserver.RemoveActivePlan(activePlan);
+                    thirdJoinObserver.RemoveActivePlan(activePlan);
+                    fourthJoinObserver.RemoveActivePlan(activePlan);
+                    fifthJoinObserver.RemoveActivePlan(activePlan);
+                    sixthJoinObserver.RemoveActivePlan(activePlan);
+                    seventhJoinObserver.RemoveActivePlan(activePlan);
+                    eighthJoinObserver.RemoveActivePlan(activePlan);
+                    ninthJoinObserver.RemoveActivePlan(activePlan);
+                    tenthJoinObserver.RemoveActivePlan(activePlan);
+                    deactivate(activePlan);
+                });
+
+            firstJoinObserver.AddActivePlan(activePlan);
+            secondJoinObserver.AddActivePlan(activePlan);
+            thirdJoinObserver.AddActivePlan(activePlan);
+            fourthJoinObserver.AddActivePlan(activePlan);
+            fifthJoinObserver.AddActivePlan(activePlan);
+            sixthJoinObserver.AddActivePlan(activePlan);
+            seventhJoinObserver.AddActivePlan(activePlan);
+            eighthJoinObserver.AddActivePlan(activePlan);
+            ninthJoinObserver.AddActivePlan(activePlan);
+            tenthJoinObserver.AddActivePlan(activePlan);
+            return activePlan;
+        }
+    }
+
+    internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult> : Plan<TResult>
+    {
+        internal Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Expression { get; private set; }
+
+        internal Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult> Selector { get; private set; }
+
+        internal Plan(Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> expression,
+                      Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult> selector)
+        {
+            Expression = expression;
+            Selector = selector;
+        }
+
+        internal override ActivePlan Activate(Dictionary<object, IJoinObserver> externalSubscriptions,
+                                              IObserver<TResult> observer, Action<ActivePlan> deactivate)
+        {
+            var onError = new Action<Exception>(observer.OnError);
+            var firstJoinObserver = CreateObserver(externalSubscriptions, Expression.First, onError);
+            var secondJoinObserver = CreateObserver(externalSubscriptions, Expression.Second, onError);
+            var thirdJoinObserver = CreateObserver(externalSubscriptions, Expression.Third, onError);
+            var fourthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourth, onError);
+            var fifthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fifth, onError);
+            var sixthJoinObserver = CreateObserver(externalSubscriptions, Expression.Sixth, onError);
+            var seventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Seventh, onError);
+            var eighthJoinObserver = CreateObserver(externalSubscriptions, Expression.Eighth, onError);
+            var ninthJoinObserver = CreateObserver(externalSubscriptions, Expression.Ninth, onError);
+            var tenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Tenth, onError);
+            var eleventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Eleventh, onError);
+
+            var activePlan = default(ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>);
+
+            activePlan = new ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(firstJoinObserver, secondJoinObserver, thirdJoinObserver,
+                fourthJoinObserver, fifthJoinObserver, sixthJoinObserver, seventhJoinObserver, eighthJoinObserver, ninthJoinObserver, tenthJoinObserver, eleventhJoinObserver,
+                (first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh) =>
+                {
+                    var result = default(TResult);
+                    try
+                    {
+                        result = Selector(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh);
+                    }
+                    catch (Exception exception)
+                    {
+                        observer.OnError(exception);
+                        return;
+                    }
+                    observer.OnNext(result);
+                },
+                () =>
+                {
+                    firstJoinObserver.RemoveActivePlan(activePlan);
+                    secondJoinObserver.RemoveActivePlan(activePlan);
+                    thirdJoinObserver.RemoveActivePlan(activePlan);
+                    fourthJoinObserver.RemoveActivePlan(activePlan);
+                    fifthJoinObserver.RemoveActivePlan(activePlan);
+                    sixthJoinObserver.RemoveActivePlan(activePlan);
+                    seventhJoinObserver.RemoveActivePlan(activePlan);
+                    eighthJoinObserver.RemoveActivePlan(activePlan);
+                    ninthJoinObserver.RemoveActivePlan(activePlan);
+                    tenthJoinObserver.RemoveActivePlan(activePlan);
+                    eleventhJoinObserver.RemoveActivePlan(activePlan);
+                    deactivate(activePlan);
+                });
+
+            firstJoinObserver.AddActivePlan(activePlan);
+            secondJoinObserver.AddActivePlan(activePlan);
+            thirdJoinObserver.AddActivePlan(activePlan);
+            fourthJoinObserver.AddActivePlan(activePlan);
+            fifthJoinObserver.AddActivePlan(activePlan);
+            sixthJoinObserver.AddActivePlan(activePlan);
+            seventhJoinObserver.AddActivePlan(activePlan);
+            eighthJoinObserver.AddActivePlan(activePlan);
+            ninthJoinObserver.AddActivePlan(activePlan);
+            tenthJoinObserver.AddActivePlan(activePlan);
+            eleventhJoinObserver.AddActivePlan(activePlan);
+            return activePlan;
+        }
+    }
+
+    internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult> : Plan<TResult>
+    {
+        internal Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Expression { get; private set; }
+
+        internal Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult> Selector { get; private set; }
+
+        internal Plan(Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> expression,
+                      Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult> selector)
+        {
+            Expression = expression;
+            Selector = selector;
+        }
+
+        internal override ActivePlan Activate(Dictionary<object, IJoinObserver> externalSubscriptions,
+                                              IObserver<TResult> observer, Action<ActivePlan> deactivate)
+        {
+            var onError = new Action<Exception>(observer.OnError);
+            var firstJoinObserver = CreateObserver(externalSubscriptions, Expression.First, onError);
+            var secondJoinObserver = CreateObserver(externalSubscriptions, Expression.Second, onError);
+            var thirdJoinObserver = CreateObserver(externalSubscriptions, Expression.Third, onError);
+            var fourthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourth, onError);
+            var fifthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fifth, onError);
+            var sixthJoinObserver = CreateObserver(externalSubscriptions, Expression.Sixth, onError);
+            var seventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Seventh, onError);
+            var eighthJoinObserver = CreateObserver(externalSubscriptions, Expression.Eighth, onError);
+            var ninthJoinObserver = CreateObserver(externalSubscriptions, Expression.Ninth, onError);
+            var tenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Tenth, onError);
+            var eleventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Eleventh, onError);
+            var twelfthJoinObserver = CreateObserver(externalSubscriptions, Expression.Twelfth, onError);
+
+            var activePlan = default(ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>);
+
+            activePlan = new ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(firstJoinObserver, secondJoinObserver, thirdJoinObserver,
+                fourthJoinObserver, fifthJoinObserver, sixthJoinObserver, seventhJoinObserver, eighthJoinObserver, ninthJoinObserver, tenthJoinObserver, eleventhJoinObserver,
+                twelfthJoinObserver,
+                (first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth) =>
+                {
+                    var result = default(TResult);
+                    try
+                    {
+                        result = Selector(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth);
+                    }
+                    catch (Exception exception)
+                    {
+                        observer.OnError(exception);
+                        return;
+                    }
+                    observer.OnNext(result);
+                },
+                () =>
+                {
+                    firstJoinObserver.RemoveActivePlan(activePlan);
+                    secondJoinObserver.RemoveActivePlan(activePlan);
+                    thirdJoinObserver.RemoveActivePlan(activePlan);
+                    fourthJoinObserver.RemoveActivePlan(activePlan);
+                    fifthJoinObserver.RemoveActivePlan(activePlan);
+                    sixthJoinObserver.RemoveActivePlan(activePlan);
+                    seventhJoinObserver.RemoveActivePlan(activePlan);
+                    eighthJoinObserver.RemoveActivePlan(activePlan);
+                    ninthJoinObserver.RemoveActivePlan(activePlan);
+                    tenthJoinObserver.RemoveActivePlan(activePlan);
+                    eleventhJoinObserver.RemoveActivePlan(activePlan);
+                    twelfthJoinObserver.RemoveActivePlan(activePlan);
+                    deactivate(activePlan);
+                });
+
+            firstJoinObserver.AddActivePlan(activePlan);
+            secondJoinObserver.AddActivePlan(activePlan);
+            thirdJoinObserver.AddActivePlan(activePlan);
+            fourthJoinObserver.AddActivePlan(activePlan);
+            fifthJoinObserver.AddActivePlan(activePlan);
+            sixthJoinObserver.AddActivePlan(activePlan);
+            seventhJoinObserver.AddActivePlan(activePlan);
+            eighthJoinObserver.AddActivePlan(activePlan);
+            ninthJoinObserver.AddActivePlan(activePlan);
+            tenthJoinObserver.AddActivePlan(activePlan);
+            eleventhJoinObserver.AddActivePlan(activePlan);
+            twelfthJoinObserver.AddActivePlan(activePlan);
+            return activePlan;
+        }
+    }
+
+
+    internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TResult> : Plan<TResult>
+    {
+        internal Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> Expression { get; private set; }
+
+        internal Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TResult> Selector { get; private set; }
+
+        internal Plan(Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> expression,
+                      Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TResult> selector)
+        {
+            Expression = expression;
+            Selector = selector;
+        }
+
+        internal override ActivePlan Activate(Dictionary<object, IJoinObserver> externalSubscriptions,
+                                              IObserver<TResult> observer, Action<ActivePlan> deactivate)
+        {
+            var onError = new Action<Exception>(observer.OnError);
+            var firstJoinObserver = CreateObserver(externalSubscriptions, Expression.First, onError);
+            var secondJoinObserver = CreateObserver(externalSubscriptions, Expression.Second, onError);
+            var thirdJoinObserver = CreateObserver(externalSubscriptions, Expression.Third, onError);
+            var fourthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourth, onError);
+            var fifthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fifth, onError);
+            var sixthJoinObserver = CreateObserver(externalSubscriptions, Expression.Sixth, onError);
+            var seventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Seventh, onError);
+            var eighthJoinObserver = CreateObserver(externalSubscriptions, Expression.Eighth, onError);
+            var ninthJoinObserver = CreateObserver(externalSubscriptions, Expression.Ninth, onError);
+            var tenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Tenth, onError);
+            var eleventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Eleventh, onError);
+            var twelfthJoinObserver = CreateObserver(externalSubscriptions, Expression.Twelfth, onError);
+            var thirteenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Thirteenth, onError);
+
+            var activePlan = default(ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>);
+
+            activePlan = new ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(firstJoinObserver, secondJoinObserver, thirdJoinObserver,
+                fourthJoinObserver, fifthJoinObserver, sixthJoinObserver, seventhJoinObserver, eighthJoinObserver, ninthJoinObserver, tenthJoinObserver, eleventhJoinObserver,
+                twelfthJoinObserver, thirteenthJoinObserver,
+                (first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth) =>
+                {
+                    var result = default(TResult);
+                    try
+                    {
+                        result = Selector(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth);
+                    }
+                    catch (Exception exception)
+                    {
+                        observer.OnError(exception);
+                        return;
+                    }
+                    observer.OnNext(result);
+                },
+                () =>
+                {
+                    firstJoinObserver.RemoveActivePlan(activePlan);
+                    secondJoinObserver.RemoveActivePlan(activePlan);
+                    thirdJoinObserver.RemoveActivePlan(activePlan);
+                    fourthJoinObserver.RemoveActivePlan(activePlan);
+                    fifthJoinObserver.RemoveActivePlan(activePlan);
+                    sixthJoinObserver.RemoveActivePlan(activePlan);
+                    seventhJoinObserver.RemoveActivePlan(activePlan);
+                    eighthJoinObserver.RemoveActivePlan(activePlan);
+                    ninthJoinObserver.RemoveActivePlan(activePlan);
+                    tenthJoinObserver.RemoveActivePlan(activePlan);
+                    eleventhJoinObserver.RemoveActivePlan(activePlan);
+                    twelfthJoinObserver.RemoveActivePlan(activePlan);
+                    thirteenthJoinObserver.RemoveActivePlan(activePlan);
+                    deactivate(activePlan);
+                });
+
+            firstJoinObserver.AddActivePlan(activePlan);
+            secondJoinObserver.AddActivePlan(activePlan);
+            thirdJoinObserver.AddActivePlan(activePlan);
+            fourthJoinObserver.AddActivePlan(activePlan);
+            fifthJoinObserver.AddActivePlan(activePlan);
+            sixthJoinObserver.AddActivePlan(activePlan);
+            seventhJoinObserver.AddActivePlan(activePlan);
+            eighthJoinObserver.AddActivePlan(activePlan);
+            ninthJoinObserver.AddActivePlan(activePlan);
+            tenthJoinObserver.AddActivePlan(activePlan);
+            eleventhJoinObserver.AddActivePlan(activePlan);
+            twelfthJoinObserver.AddActivePlan(activePlan);
+            thirteenthJoinObserver.AddActivePlan(activePlan);
+            return activePlan;
+        }
+    }
+
+
+    internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TResult> : Plan<TResult>
+    {
+        internal Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> Expression { get; private set; }
+
+        internal Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TResult> Selector { get; private set; }
+
+        internal Plan(Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> expression,
+                      Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TResult> selector)
+        {
+            Expression = expression;
+            Selector = selector;
+        }
+
+        internal override ActivePlan Activate(Dictionary<object, IJoinObserver> externalSubscriptions,
+                                              IObserver<TResult> observer, Action<ActivePlan> deactivate)
+        {
+            var onError = new Action<Exception>(observer.OnError);
+            var firstJoinObserver = CreateObserver(externalSubscriptions, Expression.First, onError);
+            var secondJoinObserver = CreateObserver(externalSubscriptions, Expression.Second, onError);
+            var thirdJoinObserver = CreateObserver(externalSubscriptions, Expression.Third, onError);
+            var fourthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourth, onError);
+            var fifthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fifth, onError);
+            var sixthJoinObserver = CreateObserver(externalSubscriptions, Expression.Sixth, onError);
+            var seventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Seventh, onError);
+            var eighthJoinObserver = CreateObserver(externalSubscriptions, Expression.Eighth, onError);
+            var ninthJoinObserver = CreateObserver(externalSubscriptions, Expression.Ninth, onError);
+            var tenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Tenth, onError);
+            var eleventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Eleventh, onError);
+            var twelfthJoinObserver = CreateObserver(externalSubscriptions, Expression.Twelfth, onError);
+            var thirteenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Thirteenth, onError);
+            var fourteenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourteenth, onError);
+
+            var activePlan = default(ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>);
+
+            activePlan = new ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(
+                firstJoinObserver, secondJoinObserver, thirdJoinObserver,
+                fourthJoinObserver, fifthJoinObserver, sixthJoinObserver,
+                seventhJoinObserver, eighthJoinObserver, ninthJoinObserver,
+                tenthJoinObserver, eleventhJoinObserver,
+                twelfthJoinObserver, thirteenthJoinObserver,
+                fourteenthJoinObserver,
+                (first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth, fourteenth) =>
+                {
+                    var result = default(TResult);
+                    try
+                    {
+                        result = Selector(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth, fourteenth);
+                    }
+                    catch (Exception exception)
+                    {
+                        observer.OnError(exception);
+                        return;
+                    }
+                    observer.OnNext(result);
+                },
+                () =>
+                {
+                    firstJoinObserver.RemoveActivePlan(activePlan);
+                    secondJoinObserver.RemoveActivePlan(activePlan);
+                    thirdJoinObserver.RemoveActivePlan(activePlan);
+                    fourthJoinObserver.RemoveActivePlan(activePlan);
+                    fifthJoinObserver.RemoveActivePlan(activePlan);
+                    sixthJoinObserver.RemoveActivePlan(activePlan);
+                    seventhJoinObserver.RemoveActivePlan(activePlan);
+                    eighthJoinObserver.RemoveActivePlan(activePlan);
+                    ninthJoinObserver.RemoveActivePlan(activePlan);
+                    tenthJoinObserver.RemoveActivePlan(activePlan);
+                    eleventhJoinObserver.RemoveActivePlan(activePlan);
+                    twelfthJoinObserver.RemoveActivePlan(activePlan);
+                    thirteenthJoinObserver.RemoveActivePlan(activePlan);
+                    fourteenthJoinObserver.RemoveActivePlan(activePlan);
+                    deactivate(activePlan);
+                });
+
+            firstJoinObserver.AddActivePlan(activePlan);
+            secondJoinObserver.AddActivePlan(activePlan);
+            thirdJoinObserver.AddActivePlan(activePlan);
+            fourthJoinObserver.AddActivePlan(activePlan);
+            fifthJoinObserver.AddActivePlan(activePlan);
+            sixthJoinObserver.AddActivePlan(activePlan);
+            seventhJoinObserver.AddActivePlan(activePlan);
+            eighthJoinObserver.AddActivePlan(activePlan);
+            ninthJoinObserver.AddActivePlan(activePlan);
+            tenthJoinObserver.AddActivePlan(activePlan);
+            eleventhJoinObserver.AddActivePlan(activePlan);
+            twelfthJoinObserver.AddActivePlan(activePlan);
+            thirteenthJoinObserver.AddActivePlan(activePlan);
+            fourteenthJoinObserver.AddActivePlan(activePlan);
+            return activePlan;
+        }
+    }
+
+    internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TResult> : Plan<TResult>
+    {
+        internal Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> Expression { get; private set; }
+
+        internal Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TResult> Selector { get; private set; }
+
+        internal Plan(Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> expression,
+                      Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TResult> selector)
+        {
+            Expression = expression;
+            Selector = selector;
+        }
+
+        internal override ActivePlan Activate(Dictionary<object, IJoinObserver> externalSubscriptions,
+                                              IObserver<TResult> observer, Action<ActivePlan> deactivate)
+        {
+            var onError = new Action<Exception>(observer.OnError);
+            var firstJoinObserver = CreateObserver(externalSubscriptions, Expression.First, onError);
+            var secondJoinObserver = CreateObserver(externalSubscriptions, Expression.Second, onError);
+            var thirdJoinObserver = CreateObserver(externalSubscriptions, Expression.Third, onError);
+            var fourthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourth, onError);
+            var fifthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fifth, onError);
+            var sixthJoinObserver = CreateObserver(externalSubscriptions, Expression.Sixth, onError);
+            var seventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Seventh, onError);
+            var eighthJoinObserver = CreateObserver(externalSubscriptions, Expression.Eighth, onError);
+            var ninthJoinObserver = CreateObserver(externalSubscriptions, Expression.Ninth, onError);
+            var tenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Tenth, onError);
+            var eleventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Eleventh, onError);
+            var twelfthJoinObserver = CreateObserver(externalSubscriptions, Expression.Twelfth, onError);
+            var thirteenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Thirteenth, onError);
+            var fourteenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourteenth, onError);
+            var fifteenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fifteenth, onError);
+
+            var activePlan = default(ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>);
+
+            activePlan = new ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(
+                firstJoinObserver, secondJoinObserver, thirdJoinObserver,
+                fourthJoinObserver, fifthJoinObserver, sixthJoinObserver,
+                seventhJoinObserver, eighthJoinObserver, ninthJoinObserver,
+                tenthJoinObserver, eleventhJoinObserver,
+                twelfthJoinObserver, thirteenthJoinObserver,
+                fourteenthJoinObserver, fifteenthJoinObserver,
+                (first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth, fourteenth, fifteenth) =>
+                {
+                    var result = default(TResult);
+                    try
+                    {
+                        result = Selector(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth, fourteenth, fifteenth);
+                    }
+                    catch (Exception exception)
+                    {
+                        observer.OnError(exception);
+                        return;
+                    }
+                    observer.OnNext(result);
+                },
+                () =>
+                {
+                    firstJoinObserver.RemoveActivePlan(activePlan);
+                    secondJoinObserver.RemoveActivePlan(activePlan);
+                    thirdJoinObserver.RemoveActivePlan(activePlan);
+                    fourthJoinObserver.RemoveActivePlan(activePlan);
+                    fifthJoinObserver.RemoveActivePlan(activePlan);
+                    sixthJoinObserver.RemoveActivePlan(activePlan);
+                    seventhJoinObserver.RemoveActivePlan(activePlan);
+                    eighthJoinObserver.RemoveActivePlan(activePlan);
+                    ninthJoinObserver.RemoveActivePlan(activePlan);
+                    tenthJoinObserver.RemoveActivePlan(activePlan);
+                    eleventhJoinObserver.RemoveActivePlan(activePlan);
+                    twelfthJoinObserver.RemoveActivePlan(activePlan);
+                    thirteenthJoinObserver.RemoveActivePlan(activePlan);
+                    fourteenthJoinObserver.RemoveActivePlan(activePlan);
+                    fifteenthJoinObserver.RemoveActivePlan(activePlan);
+                    deactivate(activePlan);
+                });
+
+            firstJoinObserver.AddActivePlan(activePlan);
+            secondJoinObserver.AddActivePlan(activePlan);
+            thirdJoinObserver.AddActivePlan(activePlan);
+            fourthJoinObserver.AddActivePlan(activePlan);
+            fifthJoinObserver.AddActivePlan(activePlan);
+            sixthJoinObserver.AddActivePlan(activePlan);
+            seventhJoinObserver.AddActivePlan(activePlan);
+            eighthJoinObserver.AddActivePlan(activePlan);
+            ninthJoinObserver.AddActivePlan(activePlan);
+            tenthJoinObserver.AddActivePlan(activePlan);
+            eleventhJoinObserver.AddActivePlan(activePlan);
+            twelfthJoinObserver.AddActivePlan(activePlan);
+            thirteenthJoinObserver.AddActivePlan(activePlan);
+            fourteenthJoinObserver.AddActivePlan(activePlan);
+            fifteenthJoinObserver.AddActivePlan(activePlan);
+            return activePlan;
+        }
+    }
+    internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TResult> : Plan<TResult>
+    {
+        internal Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> Expression { get; private set; }
+
+        internal Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TResult> Selector { get; private set; }
+
+        internal Plan(Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> expression,
+                      Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TResult> selector)
+        {
+            Expression = expression;
+            Selector = selector;
+        }
+
+        internal override ActivePlan Activate(Dictionary<object, IJoinObserver> externalSubscriptions,
+                                              IObserver<TResult> observer, Action<ActivePlan> deactivate)
+        {
+            var onError = new Action<Exception>(observer.OnError);
+            var firstJoinObserver = CreateObserver(externalSubscriptions, Expression.First, onError);
+            var secondJoinObserver = CreateObserver(externalSubscriptions, Expression.Second, onError);
+            var thirdJoinObserver = CreateObserver(externalSubscriptions, Expression.Third, onError);
+            var fourthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourth, onError);
+            var fifthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fifth, onError);
+            var sixthJoinObserver = CreateObserver(externalSubscriptions, Expression.Sixth, onError);
+            var seventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Seventh, onError);
+            var eighthJoinObserver = CreateObserver(externalSubscriptions, Expression.Eighth, onError);
+            var ninthJoinObserver = CreateObserver(externalSubscriptions, Expression.Ninth, onError);
+            var tenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Tenth, onError);
+            var eleventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Eleventh, onError);
+            var twelfthJoinObserver = CreateObserver(externalSubscriptions, Expression.Twelfth, onError);
+            var thirteenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Thirteenth, onError);
+            var fourteenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourteenth, onError);
+            var fifteenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fifteenth, onError);
+            var sixteenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Sixteenth, onError);
+
+            var activePlan = default(ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>);
+
+            activePlan = new ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(
+                firstJoinObserver, secondJoinObserver, thirdJoinObserver,
+                fourthJoinObserver, fifthJoinObserver, sixthJoinObserver,
+                seventhJoinObserver, eighthJoinObserver, ninthJoinObserver,
+                tenthJoinObserver, eleventhJoinObserver,
+                twelfthJoinObserver, thirteenthJoinObserver,
+                fourteenthJoinObserver, fifteenthJoinObserver,
+                sixteenthJoinObserver,
+                (first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth, fourteenth, fifteenth, sixteenth) =>
+                {
+                    var result = default(TResult);
+                    try
+                    {
+                        result = Selector(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth, fourteenth, fifteenth, sixteenth);
+                    }
+                    catch (Exception exception)
+                    {
+                        observer.OnError(exception);
+                        return;
+                    }
+                    observer.OnNext(result);
+                },
+                () =>
+                {
+                    firstJoinObserver.RemoveActivePlan(activePlan);
+                    secondJoinObserver.RemoveActivePlan(activePlan);
+                    thirdJoinObserver.RemoveActivePlan(activePlan);
+                    fourthJoinObserver.RemoveActivePlan(activePlan);
+                    fifthJoinObserver.RemoveActivePlan(activePlan);
+                    sixthJoinObserver.RemoveActivePlan(activePlan);
+                    seventhJoinObserver.RemoveActivePlan(activePlan);
+                    eighthJoinObserver.RemoveActivePlan(activePlan);
+                    ninthJoinObserver.RemoveActivePlan(activePlan);
+                    tenthJoinObserver.RemoveActivePlan(activePlan);
+                    eleventhJoinObserver.RemoveActivePlan(activePlan);
+                    twelfthJoinObserver.RemoveActivePlan(activePlan);
+                    thirteenthJoinObserver.RemoveActivePlan(activePlan);
+                    fourteenthJoinObserver.RemoveActivePlan(activePlan);
+                    fifteenthJoinObserver.RemoveActivePlan(activePlan);
+                    sixteenthJoinObserver.RemoveActivePlan(activePlan);
+                    deactivate(activePlan);
+                });
+
+            firstJoinObserver.AddActivePlan(activePlan);
+            secondJoinObserver.AddActivePlan(activePlan);
+            thirdJoinObserver.AddActivePlan(activePlan);
+            fourthJoinObserver.AddActivePlan(activePlan);
+            fifthJoinObserver.AddActivePlan(activePlan);
+            sixthJoinObserver.AddActivePlan(activePlan);
+            seventhJoinObserver.AddActivePlan(activePlan);
+            eighthJoinObserver.AddActivePlan(activePlan);
+            ninthJoinObserver.AddActivePlan(activePlan);
+            tenthJoinObserver.AddActivePlan(activePlan);
+            eleventhJoinObserver.AddActivePlan(activePlan);
+            twelfthJoinObserver.AddActivePlan(activePlan);
+            thirteenthJoinObserver.AddActivePlan(activePlan);
+            fourteenthJoinObserver.AddActivePlan(activePlan);
+            fifteenthJoinObserver.AddActivePlan(activePlan);
+            sixteenthJoinObserver.AddActivePlan(activePlan);
+            return activePlan;
+        }
+    }
 }

+ 58 - 0
Rx.NET/Source/src/System.Reactive/Joins/QueryablePattern.cs

@@ -55,7 +55,9 @@ namespace System.Reactive.Joins
         public QueryablePattern<TSource1, TSource2, TSource3> And<TSource3>(IObservable<TSource3> other)
         {
             if (other == null)
+            {
                 throw new ArgumentNullException(nameof(other));
+            }
 
             var t = typeof(QueryablePattern<TSource1, TSource2>);
             var m = t.GetMethod(nameof(And)).MakeGenericMethod(typeof(TSource3));
@@ -79,7 +81,9 @@ namespace System.Reactive.Joins
         public QueryablePlan<TResult> Then<TResult>(Expression<Func<TSource1, TSource2, TResult>> selector)
         {
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             var t = typeof(QueryablePattern<TSource1, TSource2>);
             var m = t.GetMethod(nameof(Then)).MakeGenericMethod(typeof(TResult));
@@ -118,7 +122,9 @@ namespace System.Reactive.Joins
         public QueryablePattern<TSource1, TSource2, TSource3, TSource4> And<TSource4>(IObservable<TSource4> other)
         {
             if (other == null)
+            {
                 throw new ArgumentNullException(nameof(other));
+            }
 
             var t = typeof(QueryablePattern<TSource1, TSource2, TSource3>);
             var m = t.GetMethod(nameof(And)).MakeGenericMethod(typeof(TSource4));
@@ -142,7 +148,9 @@ namespace System.Reactive.Joins
         public QueryablePlan<TResult> Then<TResult>(Expression<Func<TSource1, TSource2, TSource3, TResult>> selector)
         {
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             var t = typeof(QueryablePattern<TSource1, TSource2, TSource3>);
             var m = t.GetMethod(nameof(Then)).MakeGenericMethod(typeof(TResult));
@@ -182,7 +190,9 @@ namespace System.Reactive.Joins
         public QueryablePattern<TSource1, TSource2, TSource3, TSource4, TSource5> And<TSource5>(IObservable<TSource5> other)
         {
             if (other == null)
+            {
                 throw new ArgumentNullException(nameof(other));
+            }
 
             var t = typeof(QueryablePattern<TSource1, TSource2, TSource3, TSource4>);
             var m = t.GetMethod(nameof(And)).MakeGenericMethod(typeof(TSource5));
@@ -206,7 +216,9 @@ namespace System.Reactive.Joins
         public QueryablePlan<TResult> Then<TResult>(Expression<Func<TSource1, TSource2, TSource3, TSource4, TResult>> selector)
         {
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             var t = typeof(QueryablePattern<TSource1, TSource2, TSource3, TSource4>);
             var m = t.GetMethod(nameof(Then)).MakeGenericMethod(typeof(TResult));
@@ -247,7 +259,9 @@ namespace System.Reactive.Joins
         public QueryablePattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6> And<TSource6>(IObservable<TSource6> other)
         {
             if (other == null)
+            {
                 throw new ArgumentNullException(nameof(other));
+            }
 
             var t = typeof(QueryablePattern<TSource1, TSource2, TSource3, TSource4, TSource5>);
             var m = t.GetMethod(nameof(And)).MakeGenericMethod(typeof(TSource6));
@@ -271,7 +285,9 @@ namespace System.Reactive.Joins
         public QueryablePlan<TResult> Then<TResult>(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TResult>> selector)
         {
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             var t = typeof(QueryablePattern<TSource1, TSource2, TSource3, TSource4, TSource5>);
             var m = t.GetMethod(nameof(Then)).MakeGenericMethod(typeof(TResult));
@@ -313,7 +329,9 @@ namespace System.Reactive.Joins
         public QueryablePattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7> And<TSource7>(IObservable<TSource7> other)
         {
             if (other == null)
+            {
                 throw new ArgumentNullException(nameof(other));
+            }
 
             var t = typeof(QueryablePattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6>);
             var m = t.GetMethod(nameof(And)).MakeGenericMethod(typeof(TSource7));
@@ -337,7 +355,9 @@ namespace System.Reactive.Joins
         public QueryablePlan<TResult> Then<TResult>(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TResult>> selector)
         {
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             var t = typeof(QueryablePattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6>);
             var m = t.GetMethod(nameof(Then)).MakeGenericMethod(typeof(TResult));
@@ -380,7 +400,9 @@ namespace System.Reactive.Joins
         public QueryablePattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8> And<TSource8>(IObservable<TSource8> other)
         {
             if (other == null)
+            {
                 throw new ArgumentNullException(nameof(other));
+            }
 
             var t = typeof(QueryablePattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7>);
             var m = t.GetMethod(nameof(And)).MakeGenericMethod(typeof(TSource8));
@@ -404,7 +426,9 @@ namespace System.Reactive.Joins
         public QueryablePlan<TResult> Then<TResult>(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TResult>> selector)
         {
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             var t = typeof(QueryablePattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7>);
             var m = t.GetMethod(nameof(Then)).MakeGenericMethod(typeof(TResult));
@@ -448,7 +472,9 @@ namespace System.Reactive.Joins
         public QueryablePattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9> And<TSource9>(IObservable<TSource9> other)
         {
             if (other == null)
+            {
                 throw new ArgumentNullException(nameof(other));
+            }
 
             var t = typeof(QueryablePattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8>);
             var m = t.GetMethod(nameof(And)).MakeGenericMethod(typeof(TSource9));
@@ -472,7 +498,9 @@ namespace System.Reactive.Joins
         public QueryablePlan<TResult> Then<TResult>(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TResult>> selector)
         {
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             var t = typeof(QueryablePattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8>);
             var m = t.GetMethod(nameof(Then)).MakeGenericMethod(typeof(TResult));
@@ -517,7 +545,9 @@ namespace System.Reactive.Joins
         public QueryablePattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10> And<TSource10>(IObservable<TSource10> other)
         {
             if (other == null)
+            {
                 throw new ArgumentNullException(nameof(other));
+            }
 
             var t = typeof(QueryablePattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9>);
             var m = t.GetMethod(nameof(And)).MakeGenericMethod(typeof(TSource10));
@@ -541,7 +571,9 @@ namespace System.Reactive.Joins
         public QueryablePlan<TResult> Then<TResult>(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TResult>> selector)
         {
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             var t = typeof(QueryablePattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9>);
             var m = t.GetMethod(nameof(Then)).MakeGenericMethod(typeof(TResult));
@@ -587,7 +619,9 @@ namespace System.Reactive.Joins
         public QueryablePattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11> And<TSource11>(IObservable<TSource11> other)
         {
             if (other == null)
+            {
                 throw new ArgumentNullException(nameof(other));
+            }
 
             var t = typeof(QueryablePattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10>);
             var m = t.GetMethod(nameof(And)).MakeGenericMethod(typeof(TSource11));
@@ -611,7 +645,9 @@ namespace System.Reactive.Joins
         public QueryablePlan<TResult> Then<TResult>(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TResult>> selector)
         {
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             var t = typeof(QueryablePattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10>);
             var m = t.GetMethod(nameof(Then)).MakeGenericMethod(typeof(TResult));
@@ -658,7 +694,9 @@ namespace System.Reactive.Joins
         public QueryablePattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12> And<TSource12>(IObservable<TSource12> other)
         {
             if (other == null)
+            {
                 throw new ArgumentNullException(nameof(other));
+            }
 
             var t = typeof(QueryablePattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11>);
             var m = t.GetMethod(nameof(And)).MakeGenericMethod(typeof(TSource12));
@@ -682,7 +720,9 @@ namespace System.Reactive.Joins
         public QueryablePlan<TResult> Then<TResult>(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TResult>> selector)
         {
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             var t = typeof(QueryablePattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11>);
             var m = t.GetMethod(nameof(Then)).MakeGenericMethod(typeof(TResult));
@@ -730,7 +770,9 @@ namespace System.Reactive.Joins
         public QueryablePattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13> And<TSource13>(IObservable<TSource13> other)
         {
             if (other == null)
+            {
                 throw new ArgumentNullException(nameof(other));
+            }
 
             var t = typeof(QueryablePattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12>);
             var m = t.GetMethod(nameof(And)).MakeGenericMethod(typeof(TSource13));
@@ -754,7 +796,9 @@ namespace System.Reactive.Joins
         public QueryablePlan<TResult> Then<TResult>(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TResult>> selector)
         {
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             var t = typeof(QueryablePattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12>);
             var m = t.GetMethod(nameof(Then)).MakeGenericMethod(typeof(TResult));
@@ -803,7 +847,9 @@ namespace System.Reactive.Joins
         public QueryablePattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14> And<TSource14>(IObservable<TSource14> other)
         {
             if (other == null)
+            {
                 throw new ArgumentNullException(nameof(other));
+            }
 
             var t = typeof(QueryablePattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13>);
             var m = t.GetMethod(nameof(And)).MakeGenericMethod(typeof(TSource14));
@@ -827,7 +873,9 @@ namespace System.Reactive.Joins
         public QueryablePlan<TResult> Then<TResult>(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TResult>> selector)
         {
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             var t = typeof(QueryablePattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13>);
             var m = t.GetMethod(nameof(Then)).MakeGenericMethod(typeof(TResult));
@@ -877,7 +925,9 @@ namespace System.Reactive.Joins
         public QueryablePattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TSource15> And<TSource15>(IObservable<TSource15> other)
         {
             if (other == null)
+            {
                 throw new ArgumentNullException(nameof(other));
+            }
 
             var t = typeof(QueryablePattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14>);
             var m = t.GetMethod(nameof(And)).MakeGenericMethod(typeof(TSource15));
@@ -901,7 +951,9 @@ namespace System.Reactive.Joins
         public QueryablePlan<TResult> Then<TResult>(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TResult>> selector)
         {
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             var t = typeof(QueryablePattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14>);
             var m = t.GetMethod(nameof(Then)).MakeGenericMethod(typeof(TResult));
@@ -952,7 +1004,9 @@ namespace System.Reactive.Joins
         public QueryablePattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TSource15, TSource16> And<TSource16>(IObservable<TSource16> other)
         {
             if (other == null)
+            {
                 throw new ArgumentNullException(nameof(other));
+            }
 
             var t = typeof(QueryablePattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TSource15>);
             var m = t.GetMethod(nameof(And)).MakeGenericMethod(typeof(TSource16));
@@ -976,7 +1030,9 @@ namespace System.Reactive.Joins
         public QueryablePlan<TResult> Then<TResult>(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TSource15, TResult>> selector)
         {
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             var t = typeof(QueryablePattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TSource15>);
             var m = t.GetMethod(nameof(Then)).MakeGenericMethod(typeof(TResult));
@@ -1028,7 +1084,9 @@ namespace System.Reactive.Joins
         public QueryablePlan<TResult> Then<TResult>(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TSource15, TSource16, TResult>> selector)
         {
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             var t = typeof(QueryablePattern<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TSource15, TSource16>);
             var m = t.GetMethod(nameof(Then)).MakeGenericMethod(typeof(TResult));

+ 0 - 1
Rx.NET/Source/src/System.Reactive/Linq/LocalQueryMethodImplementationTypeAttribute.cs

@@ -2,7 +2,6 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System;
 using System.ComponentModel;
 
 namespace System.Reactive.Linq

文件差异内容过多而无法显示
+ 287 - 0
Rx.NET/Source/src/System.Reactive/Linq/Observable.Aggregates.cs


文件差异内容过多而无法显示
+ 306 - 0
Rx.NET/Source/src/System.Reactive/Linq/Observable.Async.cs


+ 9 - 2
Rx.NET/Source/src/System.Reactive/Linq/Observable.Awaiter.cs

@@ -2,9 +2,8 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System.Threading;
-using System.Reactive.Disposables;
 using System.Reactive.Subjects;
+using System.Threading;
 
 namespace System.Reactive.Linq
 {
@@ -21,7 +20,9 @@ namespace System.Reactive.Linq
         public static AsyncSubject<TSource> GetAwaiter<TSource>(this IObservable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return s_impl.GetAwaiter<TSource>(source);
         }
@@ -37,7 +38,9 @@ namespace System.Reactive.Linq
         public static AsyncSubject<TSource> GetAwaiter<TSource>(this IConnectableObservable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return s_impl.GetAwaiter<TSource>(source);
         }
@@ -54,7 +57,9 @@ namespace System.Reactive.Linq
         public static AsyncSubject<TSource> RunAsync<TSource>(this IObservable<TSource> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return s_impl.RunAsync<TSource>(source, cancellationToken);
         }
@@ -71,7 +76,9 @@ namespace System.Reactive.Linq
         public static AsyncSubject<TSource> RunAsync<TSource>(this IConnectableObservable<TSource> source, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return s_impl.RunAsync<TSource>(source, cancellationToken);
         }

+ 177 - 1
Rx.NET/Source/src/System.Reactive/Linq/Observable.Binding.cs

@@ -7,7 +7,7 @@ using System.Reactive.Subjects;
 
 namespace System.Reactive.Linq
 {
-	public static partial class Observable
+    public static partial class Observable
     {
         #region + Multicast +
 
@@ -25,9 +25,14 @@ namespace System.Reactive.Linq
         public static IConnectableObservable<TResult> Multicast<TSource, TResult>(this IObservable<TSource> source, ISubject<TSource, TResult> subject)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (subject == null)
+            {
                 throw new ArgumentNullException(nameof(subject));
+            }
 
             return s_impl.Multicast<TSource, TResult>(source, subject);
         }
@@ -48,11 +53,19 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> Multicast<TSource, TIntermediate, TResult>(this IObservable<TSource> source, Func<ISubject<TSource, TIntermediate>> subjectSelector, Func<IObservable<TIntermediate>, IObservable<TResult>> selector)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (subjectSelector == null)
+            {
                 throw new ArgumentNullException(nameof(subjectSelector));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return s_impl.Multicast<TSource, TIntermediate, TResult>(source, subjectSelector, selector);
         }
@@ -74,7 +87,9 @@ namespace System.Reactive.Linq
         public static IConnectableObservable<TSource> Publish<TSource>(this IObservable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return s_impl.Publish<TSource>(source);
         }
@@ -93,9 +108,14 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> Publish<TSource, TResult>(this IObservable<TSource> source, Func<IObservable<TSource>, IObservable<TResult>> selector)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return s_impl.Publish<TSource, TResult>(source, selector);
         }
@@ -114,7 +134,9 @@ namespace System.Reactive.Linq
         public static IConnectableObservable<TSource> Publish<TSource>(this IObservable<TSource> source, TSource initialValue)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return s_impl.Publish<TSource>(source, initialValue);
         }
@@ -134,9 +156,14 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> Publish<TSource, TResult>(this IObservable<TSource> source, Func<IObservable<TSource>, IObservable<TResult>> selector, TSource initialValue)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return s_impl.Publish<TSource, TResult>(source, selector, initialValue);
         }
@@ -158,7 +185,9 @@ namespace System.Reactive.Linq
         public static IConnectableObservable<TSource> PublishLast<TSource>(this IObservable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return s_impl.PublishLast<TSource>(source);
         }
@@ -177,9 +206,14 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> PublishLast<TSource, TResult>(this IObservable<TSource> source, Func<IObservable<TSource>, IObservable<TResult>> selector)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return s_impl.PublishLast<TSource, TResult>(source, selector);
         }
@@ -198,7 +232,9 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> RefCount<TSource>(this IConnectableObservable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return s_impl.RefCount<TSource>(source);
         }
@@ -214,10 +250,14 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> RefCount<TSource>(this IConnectableObservable<TSource> source, TimeSpan disconnectDelay)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException("source");
+            }
 
             if (disconnectDelay < TimeSpan.Zero)
+            {
                 throw new ArgumentException("disconnectDelay");
+            }
 
             return s_impl.RefCount<TSource>(source, disconnectDelay);
         }
@@ -234,13 +274,19 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> RefCount<TSource>(this IConnectableObservable<TSource> source, TimeSpan disconnectDelay, IScheduler scheduler)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException("source");
+            }
 
             if (scheduler == null)
+            {
                 throw new ArgumentNullException("scheduler");
+            }
 
             if (disconnectDelay < TimeSpan.Zero)
+            {
                 throw new ArgumentException("disconnectDelay");
+            }
 
             return s_impl.RefCount<TSource>(source, disconnectDelay, scheduler);
         }
@@ -262,7 +308,9 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> AutoConnect<TSource>(this IConnectableObservable<TSource> source, int minObservers = 1, Action<IDisposable> onConnect = null)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return s_impl.AutoConnect(source, minObservers, onConnect);
         }
@@ -284,7 +332,9 @@ namespace System.Reactive.Linq
         public static IConnectableObservable<TSource> Replay<TSource>(this IObservable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return s_impl.Replay<TSource>(source);
         }
@@ -303,9 +353,14 @@ namespace System.Reactive.Linq
         public static IConnectableObservable<TSource> Replay<TSource>(this IObservable<TSource> source, IScheduler scheduler)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return s_impl.Replay<TSource>(source, scheduler);
         }
@@ -324,9 +379,14 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> Replay<TSource, TResult>(this IObservable<TSource> source, Func<IObservable<TSource>, IObservable<TResult>> selector)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return s_impl.Replay<TSource, TResult>(source, selector);
         }
@@ -346,11 +406,19 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> Replay<TSource, TResult>(this IObservable<TSource> source, Func<IObservable<TSource>, IObservable<TResult>> selector, IScheduler scheduler)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
+
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return s_impl.Replay<TSource, TResult>(source, selector, scheduler);
         }
@@ -370,9 +438,14 @@ namespace System.Reactive.Linq
         public static IConnectableObservable<TSource> Replay<TSource>(this IObservable<TSource> source, TimeSpan window)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (window < TimeSpan.Zero)
+            {
                 throw new ArgumentOutOfRangeException(nameof(window));
+            }
 
             return s_impl.Replay<TSource>(source, window);
         }
@@ -393,11 +466,19 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> Replay<TSource, TResult>(this IObservable<TSource> source, Func<IObservable<TSource>, IObservable<TResult>> selector, TimeSpan window)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
+
             if (window < TimeSpan.Zero)
+            {
                 throw new ArgumentOutOfRangeException(nameof(window));
+            }
 
             return s_impl.Replay<TSource, TResult>(source, selector, window);
         }
@@ -418,11 +499,19 @@ namespace System.Reactive.Linq
         public static IConnectableObservable<TSource> Replay<TSource>(this IObservable<TSource> source, TimeSpan window, IScheduler scheduler)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (window < TimeSpan.Zero)
+            {
                 throw new ArgumentOutOfRangeException(nameof(window));
+            }
+
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return s_impl.Replay<TSource>(source, window, scheduler);
         }
@@ -444,13 +533,24 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> Replay<TSource, TResult>(this IObservable<TSource> source, Func<IObservable<TSource>, IObservable<TResult>> selector, TimeSpan window, IScheduler scheduler)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
+
             if (window < TimeSpan.Zero)
+            {
                 throw new ArgumentOutOfRangeException(nameof(window));
+            }
+
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return s_impl.Replay<TSource, TResult>(source, selector, window, scheduler);
         }
@@ -471,11 +571,19 @@ namespace System.Reactive.Linq
         public static IConnectableObservable<TSource> Replay<TSource>(this IObservable<TSource> source, int bufferSize, IScheduler scheduler)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (bufferSize < 0)
+            {
                 throw new ArgumentOutOfRangeException(nameof(bufferSize));
+            }
+
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return s_impl.Replay<TSource>(source, bufferSize, scheduler);
         }
@@ -497,13 +605,24 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> Replay<TSource, TResult>(this IObservable<TSource> source, Func<IObservable<TSource>, IObservable<TResult>> selector, int bufferSize, IScheduler scheduler)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
+
             if (bufferSize < 0)
+            {
                 throw new ArgumentOutOfRangeException(nameof(bufferSize));
+            }
+
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return s_impl.Replay<TSource, TResult>(source, selector, bufferSize, scheduler);
         }
@@ -523,9 +642,14 @@ namespace System.Reactive.Linq
         public static IConnectableObservable<TSource> Replay<TSource>(this IObservable<TSource> source, int bufferSize)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (bufferSize < 0)
+            {
                 throw new ArgumentOutOfRangeException(nameof(bufferSize));
+            }
 
             return s_impl.Replay<TSource>(source, bufferSize);
         }
@@ -546,11 +670,19 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> Replay<TSource, TResult>(this IObservable<TSource> source, Func<IObservable<TSource>, IObservable<TResult>> selector, int bufferSize)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
+
             if (bufferSize < 0)
+            {
                 throw new ArgumentOutOfRangeException(nameof(bufferSize));
+            }
 
             return s_impl.Replay<TSource, TResult>(source, selector, bufferSize);
         }
@@ -572,11 +704,19 @@ namespace System.Reactive.Linq
         public static IConnectableObservable<TSource> Replay<TSource>(this IObservable<TSource> source, int bufferSize, TimeSpan window)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (bufferSize < 0)
+            {
                 throw new ArgumentOutOfRangeException(nameof(bufferSize));
+            }
+
             if (window < TimeSpan.Zero)
+            {
                 throw new ArgumentOutOfRangeException(nameof(window));
+            }
 
             return s_impl.Replay<TSource>(source, bufferSize, window);
         }
@@ -599,13 +739,24 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> Replay<TSource, TResult>(this IObservable<TSource> source, Func<IObservable<TSource>, IObservable<TResult>> selector, int bufferSize, TimeSpan window)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
+
             if (bufferSize < 0)
+            {
                 throw new ArgumentOutOfRangeException(nameof(bufferSize));
+            }
+
             if (window < TimeSpan.Zero)
+            {
                 throw new ArgumentOutOfRangeException(nameof(window));
+            }
 
             return s_impl.Replay<TSource, TResult>(source, selector, bufferSize, window);
         }
@@ -628,13 +779,24 @@ namespace System.Reactive.Linq
         public static IConnectableObservable<TSource> Replay<TSource>(this IObservable<TSource> source, int bufferSize, TimeSpan window, IScheduler scheduler)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (bufferSize < 0)
+            {
                 throw new ArgumentOutOfRangeException(nameof(bufferSize));
+            }
+
             if (window < TimeSpan.Zero)
+            {
                 throw new ArgumentOutOfRangeException(nameof(window));
+            }
+
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return s_impl.Replay<TSource>(source, bufferSize, window, scheduler);
         }
@@ -658,15 +820,29 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> Replay<TSource, TResult>(this IObservable<TSource> source, Func<IObservable<TSource>, IObservable<TResult>> selector, int bufferSize, TimeSpan window, IScheduler scheduler)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
+
             if (bufferSize < 0)
+            {
                 throw new ArgumentOutOfRangeException(nameof(bufferSize));
+            }
+
             if (window < TimeSpan.Zero)
+            {
                 throw new ArgumentOutOfRangeException(nameof(window));
+            }
+
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return s_impl.Replay<TSource, TResult>(source, selector, bufferSize, window, scheduler);
         }

+ 83 - 0
Rx.NET/Source/src/System.Reactive/Linq/Observable.Blocking.cs

@@ -20,7 +20,9 @@ namespace System.Reactive.Linq
         public static IEnumerable<IList<TSource>> Chunkify<TSource>(this IObservable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return s_impl.Chunkify<TSource>(source);
         }
@@ -42,11 +44,19 @@ namespace System.Reactive.Linq
         public static IEnumerable<TResult> Collect<TSource, TResult>(this IObservable<TSource> source, Func<TResult> newCollector, Func<TResult, TSource, TResult> merge)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (newCollector == null)
+            {
                 throw new ArgumentNullException(nameof(newCollector));
+            }
+
             if (merge == null)
+            {
                 throw new ArgumentNullException(nameof(merge));
+            }
 
             return s_impl.Collect<TSource, TResult>(source, newCollector, merge);
         }
@@ -65,13 +75,24 @@ namespace System.Reactive.Linq
         public static IEnumerable<TResult> Collect<TSource, TResult>(this IObservable<TSource> source, Func<TResult> getInitialCollector, Func<TResult, TSource, TResult> merge, Func<TResult, TResult> getNewCollector)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (getInitialCollector == null)
+            {
                 throw new ArgumentNullException(nameof(getInitialCollector));
+            }
+
             if (merge == null)
+            {
                 throw new ArgumentNullException(nameof(merge));
+            }
+
             if (getNewCollector == null)
+            {
                 throw new ArgumentNullException(nameof(getNewCollector));
+            }
 
             return s_impl.Collect<TSource, TResult>(source, getInitialCollector, merge, getNewCollector);
         }
@@ -95,7 +116,9 @@ namespace System.Reactive.Linq
         public static TSource First<TSource>(this IObservable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return s_impl.First<TSource>(source);
         }
@@ -116,9 +139,14 @@ namespace System.Reactive.Linq
         public static TSource First<TSource>(this IObservable<TSource> source, Func<TSource, bool> predicate)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (predicate == null)
+            {
                 throw new ArgumentNullException(nameof(predicate));
+            }
 
             return s_impl.First<TSource>(source, predicate);
         }
@@ -141,7 +169,9 @@ namespace System.Reactive.Linq
         public static TSource FirstOrDefault<TSource>(this IObservable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return s_impl.FirstOrDefault<TSource>(source);
         }
@@ -161,9 +191,14 @@ namespace System.Reactive.Linq
         public static TSource FirstOrDefault<TSource>(this IObservable<TSource> source, Func<TSource, bool> predicate)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (predicate == null)
+            {
                 throw new ArgumentNullException(nameof(predicate));
+            }
 
             return s_impl.FirstOrDefault<TSource>(source, predicate);
         }
@@ -186,9 +221,14 @@ namespace System.Reactive.Linq
         public static void ForEach<TSource>(this IObservable<TSource> source, Action<TSource> onNext)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (onNext == null)
+            {
                 throw new ArgumentNullException(nameof(onNext));
+            }
 
             s_impl.ForEach<TSource>(source, onNext);
         }
@@ -207,9 +247,14 @@ namespace System.Reactive.Linq
         public static void ForEach<TSource>(this IObservable<TSource> source, Action<TSource, int> onNext)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (onNext == null)
+            {
                 throw new ArgumentNullException(nameof(onNext));
+            }
 
             s_impl.ForEach<TSource>(source, onNext);
         }
@@ -228,7 +273,9 @@ namespace System.Reactive.Linq
         public static IEnumerator<TSource> GetEnumerator<TSource>(this IObservable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return s_impl.GetEnumerator<TSource>(source);
         }
@@ -252,7 +299,9 @@ namespace System.Reactive.Linq
         public static TSource Last<TSource>(this IObservable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return s_impl.Last<TSource>(source);
         }
@@ -273,9 +322,14 @@ namespace System.Reactive.Linq
         public static TSource Last<TSource>(this IObservable<TSource> source, Func<TSource, bool> predicate)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (predicate == null)
+            {
                 throw new ArgumentNullException(nameof(predicate));
+            }
 
             return s_impl.Last<TSource>(source, predicate);
         }
@@ -298,7 +352,9 @@ namespace System.Reactive.Linq
         public static TSource LastOrDefault<TSource>(this IObservable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return s_impl.LastOrDefault<TSource>(source);
         }
@@ -318,9 +374,14 @@ namespace System.Reactive.Linq
         public static TSource LastOrDefault<TSource>(this IObservable<TSource> source, Func<TSource, bool> predicate)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (predicate == null)
+            {
                 throw new ArgumentNullException(nameof(predicate));
+            }
 
             return s_impl.LastOrDefault<TSource>(source, predicate);
         }
@@ -339,7 +400,9 @@ namespace System.Reactive.Linq
         public static IEnumerable<TSource> Latest<TSource>(this IObservable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return s_impl.Latest<TSource>(source);
         }
@@ -360,7 +423,9 @@ namespace System.Reactive.Linq
         public static IEnumerable<TSource> MostRecent<TSource>(this IObservable<TSource> source, TSource initialValue)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return s_impl.MostRecent<TSource>(source, initialValue);
         }
@@ -380,7 +445,9 @@ namespace System.Reactive.Linq
         public static IEnumerable<TSource> Next<TSource>(this IObservable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return s_impl.Next<TSource>(source);
         }
@@ -404,7 +471,9 @@ namespace System.Reactive.Linq
         public static TSource Single<TSource>(this IObservable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return s_impl.Single<TSource>(source);
         }
@@ -425,9 +494,14 @@ namespace System.Reactive.Linq
         public static TSource Single<TSource>(this IObservable<TSource> source, Func<TSource, bool> predicate)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (predicate == null)
+            {
                 throw new ArgumentNullException(nameof(predicate));
+            }
 
             return s_impl.Single<TSource>(source, predicate);
         }
@@ -451,7 +525,9 @@ namespace System.Reactive.Linq
         public static TSource SingleOrDefault<TSource>(this IObservable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return s_impl.SingleOrDefault<TSource>(source);
         }
@@ -472,9 +548,14 @@ namespace System.Reactive.Linq
         public static TSource SingleOrDefault<TSource>(this IObservable<TSource> source, Func<TSource, bool> predicate)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (predicate == null)
+            {
                 throw new ArgumentNullException(nameof(predicate));
+            }
 
             return s_impl.SingleOrDefault<TSource>(source, predicate);
         }
@@ -495,7 +576,9 @@ namespace System.Reactive.Linq
         public static TSource Wait<TSource>(this IObservable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return s_impl.Wait<TSource>(source);
         }

+ 27 - 0
Rx.NET/Source/src/System.Reactive/Linq/Observable.Concurrency.cs

@@ -26,9 +26,14 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> ObserveOn<TSource>(this IObservable<TSource> source, IScheduler scheduler)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return s_impl.ObserveOn<TSource>(source, scheduler);
         }
@@ -48,9 +53,14 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> ObserveOn<TSource>(this IObservable<TSource> source, SynchronizationContext context)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (context == null)
+            {
                 throw new ArgumentNullException(nameof(context));
+            }
 
             return s_impl.ObserveOn<TSource>(source, context);
         }
@@ -75,9 +85,14 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> SubscribeOn<TSource>(this IObservable<TSource> source, IScheduler scheduler)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return s_impl.SubscribeOn<TSource>(source, scheduler);
         }
@@ -98,9 +113,14 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> SubscribeOn<TSource>(this IObservable<TSource> source, SynchronizationContext context)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (context == null)
+            {
                 throw new ArgumentNullException(nameof(context));
+            }
 
             return s_impl.SubscribeOn<TSource>(source, context);
         }
@@ -124,7 +144,9 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> Synchronize<TSource>(this IObservable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return s_impl.Synchronize<TSource>(source);
         }
@@ -141,9 +163,14 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> Synchronize<TSource>(this IObservable<TSource> source, object gate)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (gate == null)
+            {
                 throw new ArgumentNullException(nameof(gate));
+            }
 
             return s_impl.Synchronize<TSource>(source, gate);
         }

+ 28 - 0
Rx.NET/Source/src/System.Reactive/Linq/Observable.Conversions.cs

@@ -22,9 +22,14 @@ namespace System.Reactive.Linq
         public static IDisposable Subscribe<TSource>(this IEnumerable<TSource> source, IObserver<TSource> observer)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (observer == null)
+            {
                 throw new ArgumentNullException(nameof(observer));
+            }
 
             return s_impl.Subscribe<TSource>(source, observer);
         }
@@ -41,11 +46,19 @@ namespace System.Reactive.Linq
         public static IDisposable Subscribe<TSource>(this IEnumerable<TSource> source, IObserver<TSource> observer, IScheduler scheduler)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (observer == null)
+            {
                 throw new ArgumentNullException(nameof(observer));
+            }
+
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return s_impl.Subscribe<TSource>(source, observer, scheduler);
         }
@@ -64,7 +77,9 @@ namespace System.Reactive.Linq
         public static IEnumerable<TSource> ToEnumerable<TSource>(this IObservable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return s_impl.ToEnumerable<TSource>(source);
         }
@@ -82,7 +97,9 @@ namespace System.Reactive.Linq
         public static IEventSource<Unit> ToEvent(this IObservable<Unit> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return s_impl.ToEvent(source);
         }
@@ -97,7 +114,9 @@ namespace System.Reactive.Linq
         public static IEventSource<TSource> ToEvent<TSource>(this IObservable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return s_impl.ToEvent<TSource>(source);
         }
@@ -116,7 +135,9 @@ namespace System.Reactive.Linq
         public static IEventPatternSource<TEventArgs> ToEventPattern<TEventArgs>(this IObservable<EventPattern<TEventArgs>> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return s_impl.ToEventPattern<TEventArgs>(source);
         }
@@ -135,7 +156,9 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> ToObservable<TSource>(this IEnumerable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return s_impl.ToObservable<TSource>(source);
         }
@@ -151,9 +174,14 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> ToObservable<TSource>(this IEnumerable<TSource> source, IScheduler scheduler)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return s_impl.ToObservable<TSource>(source, scheduler);
         }

+ 86 - 1
Rx.NET/Source/src/System.Reactive/Linq/Observable.Creation.cs

@@ -2,7 +2,6 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System.Collections.Generic;
 using System.Reactive.Concurrency;
 using System.Threading;
 using System.Threading.Tasks;
@@ -28,7 +27,9 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> Create<TResult>(Func<IObserver<TResult>, IDisposable> subscribe)
         {
             if (subscribe == null)
+            {
                 throw new ArgumentNullException(nameof(subscribe));
+            }
 
             return s_impl.Create<TResult>(subscribe);
         }
@@ -48,7 +49,9 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> Create<TResult>(Func<IObserver<TResult>, Action> subscribe)
         {
             if (subscribe == null)
+            {
                 throw new ArgumentNullException(nameof(subscribe));
+            }
 
             return s_impl.Create<TResult>(subscribe);
         }
@@ -70,7 +73,9 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> Create<TResult>(Func<IObserver<TResult>, CancellationToken, Task> subscribeAsync)
         {
             if (subscribeAsync == null)
+            {
                 throw new ArgumentNullException(nameof(subscribeAsync));
+            }
 
             return s_impl.Create<TResult>(subscribeAsync);
         }
@@ -86,7 +91,9 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> Create<TResult>(Func<IObserver<TResult>, Task> subscribeAsync)
         {
             if (subscribeAsync == null)
+            {
                 throw new ArgumentNullException(nameof(subscribeAsync));
+            }
 
             return s_impl.Create<TResult>(subscribeAsync);
         }
@@ -104,7 +111,9 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> Create<TResult>(Func<IObserver<TResult>, CancellationToken, Task<IDisposable>> subscribeAsync)
         {
             if (subscribeAsync == null)
+            {
                 throw new ArgumentNullException(nameof(subscribeAsync));
+            }
 
             return s_impl.Create<TResult>(subscribeAsync);
         }
@@ -120,7 +129,9 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> Create<TResult>(Func<IObserver<TResult>, Task<IDisposable>> subscribeAsync)
         {
             if (subscribeAsync == null)
+            {
                 throw new ArgumentNullException(nameof(subscribeAsync));
+            }
 
             return s_impl.Create<TResult>(subscribeAsync);
         }
@@ -138,7 +149,9 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> Create<TResult>(Func<IObserver<TResult>, CancellationToken, Task<Action>> subscribeAsync)
         {
             if (subscribeAsync == null)
+            {
                 throw new ArgumentNullException(nameof(subscribeAsync));
+            }
 
             return s_impl.Create<TResult>(subscribeAsync);
         }
@@ -154,7 +167,9 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> Create<TResult>(Func<IObserver<TResult>, Task<Action>> subscribeAsync)
         {
             if (subscribeAsync == null)
+            {
                 throw new ArgumentNullException(nameof(subscribeAsync));
+            }
 
             return s_impl.Create<TResult>(subscribeAsync);
         }
@@ -173,7 +188,9 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> Defer<TResult>(Func<IObservable<TResult>> observableFactory)
         {
             if (observableFactory == null)
+            {
                 throw new ArgumentNullException(nameof(observableFactory));
+            }
 
             return s_impl.Defer<TResult>(observableFactory);
         }
@@ -193,7 +210,9 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> Defer<TResult>(Func<Task<IObservable<TResult>>> observableFactoryAsync)
         {
             if (observableFactoryAsync == null)
+            {
                 throw new ArgumentNullException(nameof(observableFactoryAsync));
+            }
 
             return s_impl.Defer<TResult>(observableFactoryAsync);
         }
@@ -211,7 +230,9 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> DeferAsync<TResult>(Func<CancellationToken, Task<IObservable<TResult>>> observableFactoryAsync)
         {
             if (observableFactoryAsync == null)
+            {
                 throw new ArgumentNullException(nameof(observableFactoryAsync));
+            }
 
             return s_impl.Defer<TResult>(observableFactoryAsync);
         }
@@ -251,7 +272,9 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> Empty<TResult>(IScheduler scheduler)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return s_impl.Empty<TResult>(scheduler);
         }
@@ -267,7 +290,9 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> Empty<TResult>(IScheduler scheduler, TResult witness)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return s_impl.Empty<TResult>(scheduler); // Pure inference - no specialized target method.
         }
@@ -290,11 +315,19 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> Generate<TState, TResult>(TState initialState, Func<TState, bool> condition, Func<TState, TState> iterate, Func<TState, TResult> resultSelector)
         {
             if (condition == null)
+            {
                 throw new ArgumentNullException(nameof(condition));
+            }
+
             if (iterate == null)
+            {
                 throw new ArgumentNullException(nameof(iterate));
+            }
+
             if (resultSelector == null)
+            {
                 throw new ArgumentNullException(nameof(resultSelector));
+            }
 
             return s_impl.Generate<TState, TResult>(initialState, condition, iterate, resultSelector);
         }
@@ -314,13 +347,24 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> Generate<TState, TResult>(TState initialState, Func<TState, bool> condition, Func<TState, TState> iterate, Func<TState, TResult> resultSelector, IScheduler scheduler)
         {
             if (condition == null)
+            {
                 throw new ArgumentNullException(nameof(condition));
+            }
+
             if (iterate == null)
+            {
                 throw new ArgumentNullException(nameof(iterate));
+            }
+
             if (resultSelector == null)
+            {
                 throw new ArgumentNullException(nameof(resultSelector));
+            }
+
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return s_impl.Generate<TState, TResult>(initialState, condition, iterate, resultSelector, scheduler);
         }
@@ -365,7 +409,9 @@ namespace System.Reactive.Linq
         {
             var max = ((long)start) + count - 1;
             if (count < 0 || max > int.MaxValue)
+            {
                 throw new ArgumentOutOfRangeException(nameof(count));
+            }
 
             return s_impl.Range(start, count);
         }
@@ -383,10 +429,14 @@ namespace System.Reactive.Linq
         {
             var max = ((long)start) + count - 1;
             if (count < 0 || max > int.MaxValue)
+            {
                 throw new ArgumentOutOfRangeException(nameof(count));
+            }
 
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return s_impl.Range(start, count, scheduler);
         }
@@ -417,7 +467,9 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> Repeat<TResult>(TResult value, IScheduler scheduler)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return s_impl.Repeat<TResult>(value, scheduler);
         }
@@ -433,7 +485,9 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> Repeat<TResult>(TResult value, int repeatCount)
         {
             if (repeatCount < 0)
+            {
                 throw new ArgumentOutOfRangeException(nameof(repeatCount));
+            }
 
             return s_impl.Repeat<TResult>(value, repeatCount);
         }
@@ -451,9 +505,14 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> Repeat<TResult>(TResult value, int repeatCount, IScheduler scheduler)
         {
             if (repeatCount < 0)
+            {
                 throw new ArgumentOutOfRangeException(nameof(repeatCount));
+            }
+
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return s_impl.Repeat<TResult>(value, repeatCount, scheduler);
         }
@@ -484,7 +543,9 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> Return<TResult>(TResult value, IScheduler scheduler)
         {
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return s_impl.Return<TResult>(value, scheduler);
         }
@@ -503,7 +564,9 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> Throw<TResult>(Exception exception)
         {
             if (exception == null)
+            {
                 throw new ArgumentNullException(nameof(exception));
+            }
 
             return s_impl.Throw<TResult>(exception);
         }
@@ -519,7 +582,9 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> Throw<TResult>(Exception exception, TResult witness)
         {
             if (exception == null)
+            {
                 throw new ArgumentNullException(nameof(exception));
+            }
 
             return s_impl.Throw<TResult>(exception); // Pure inference - no specialized target method.
         }
@@ -535,9 +600,14 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> Throw<TResult>(Exception exception, IScheduler scheduler)
         {
             if (exception == null)
+            {
                 throw new ArgumentNullException(nameof(exception));
+            }
+
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return s_impl.Throw<TResult>(exception, scheduler);
         }
@@ -554,9 +624,14 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> Throw<TResult>(Exception exception, IScheduler scheduler, TResult witness)
         {
             if (exception == null)
+            {
                 throw new ArgumentNullException(nameof(exception));
+            }
+
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return s_impl.Throw<TResult>(exception, scheduler); // Pure inference - no specialized target method.
         }
@@ -577,9 +652,14 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> Using<TResult, TResource>(Func<TResource> resourceFactory, Func<TResource, IObservable<TResult>> observableFactory) where TResource : IDisposable
         {
             if (resourceFactory == null)
+            {
                 throw new ArgumentNullException(nameof(resourceFactory));
+            }
+
             if (observableFactory == null)
+            {
                 throw new ArgumentNullException(nameof(observableFactory));
+            }
 
             return s_impl.Using<TResult, TResource>(resourceFactory, observableFactory);
         }
@@ -603,9 +683,14 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> Using<TResult, TResource>(Func<CancellationToken, Task<TResource>> resourceFactoryAsync, Func<TResource, CancellationToken, Task<IObservable<TResult>>> observableFactoryAsync) where TResource : IDisposable
         {
             if (resourceFactoryAsync == null)
+            {
                 throw new ArgumentNullException(nameof(resourceFactoryAsync));
+            }
+
             if (observableFactoryAsync == null)
+            {
                 throw new ArgumentNullException(nameof(observableFactoryAsync));
+            }
 
             return s_impl.Using<TResult, TResource>(resourceFactoryAsync, observableFactoryAsync);
         }

+ 208 - 1
Rx.NET/Source/src/System.Reactive/Linq/Observable.Events.cs

@@ -47,9 +47,14 @@ namespace System.Reactive.Linq
         public static IObservable<EventPattern<object>> FromEventPattern(Action<EventHandler> addHandler, Action<EventHandler> removeHandler)
         {
             if (addHandler == null)
+            {
                 throw new ArgumentNullException(nameof(addHandler));
+            }
+
             if (removeHandler == null)
+            {
                 throw new ArgumentNullException(nameof(removeHandler));
+            }
 
             return s_impl.FromEventPattern(addHandler, removeHandler);
         }
@@ -83,11 +88,19 @@ namespace System.Reactive.Linq
         public static IObservable<EventPattern<object>> FromEventPattern(Action<EventHandler> addHandler, Action<EventHandler> removeHandler, IScheduler scheduler)
         {
             if (addHandler == null)
+            {
                 throw new ArgumentNullException(nameof(addHandler));
+            }
+
             if (removeHandler == null)
+            {
                 throw new ArgumentNullException(nameof(removeHandler));
+            }
+
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return s_impl.FromEventPattern(addHandler, removeHandler, scheduler);
         }
@@ -130,9 +143,14 @@ namespace System.Reactive.Linq
         public static IObservable<EventPattern<TEventArgs>> FromEventPattern<TDelegate, TEventArgs>(Action<TDelegate> addHandler, Action<TDelegate> removeHandler)
         {
             if (addHandler == null)
+            {
                 throw new ArgumentNullException(nameof(addHandler));
+            }
+
             if (removeHandler == null)
+            {
                 throw new ArgumentNullException(nameof(removeHandler));
+            }
 
             return s_impl.FromEventPattern<TDelegate, TEventArgs>(addHandler, removeHandler);
         }
@@ -168,11 +186,19 @@ namespace System.Reactive.Linq
         public static IObservable<EventPattern<TEventArgs>> FromEventPattern<TDelegate, TEventArgs>(Action<TDelegate> addHandler, Action<TDelegate> removeHandler, IScheduler scheduler)
         {
             if (addHandler == null)
+            {
                 throw new ArgumentNullException(nameof(addHandler));
+            }
+
             if (removeHandler == null)
+            {
                 throw new ArgumentNullException(nameof(removeHandler));
+            }
+
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return s_impl.FromEventPattern<TDelegate, TEventArgs>(addHandler, removeHandler, scheduler);
         }
@@ -212,11 +238,19 @@ namespace System.Reactive.Linq
         public static IObservable<EventPattern<TEventArgs>> FromEventPattern<TDelegate, TEventArgs>(Func<EventHandler<TEventArgs>, TDelegate> conversion, Action<TDelegate> addHandler, Action<TDelegate> removeHandler)
         {
             if (conversion == null)
+            {
                 throw new ArgumentNullException(nameof(conversion));
+            }
+
             if (addHandler == null)
+            {
                 throw new ArgumentNullException(nameof(addHandler));
+            }
+
             if (removeHandler == null)
+            {
                 throw new ArgumentNullException(nameof(removeHandler));
+            }
 
             return s_impl.FromEventPattern<TDelegate, TEventArgs>(conversion, addHandler, removeHandler);
         }
@@ -253,13 +287,24 @@ namespace System.Reactive.Linq
         public static IObservable<EventPattern<TEventArgs>> FromEventPattern<TDelegate, TEventArgs>(Func<EventHandler<TEventArgs>, TDelegate> conversion, Action<TDelegate> addHandler, Action<TDelegate> removeHandler, IScheduler scheduler)
         {
             if (conversion == null)
+            {
                 throw new ArgumentNullException(nameof(conversion));
+            }
+
             if (addHandler == null)
+            {
                 throw new ArgumentNullException(nameof(addHandler));
+            }
+
             if (removeHandler == null)
+            {
                 throw new ArgumentNullException(nameof(removeHandler));
+            }
+
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return s_impl.FromEventPattern<TDelegate, TEventArgs>(conversion, addHandler, removeHandler, scheduler);
         }
@@ -299,9 +344,14 @@ namespace System.Reactive.Linq
         public static IObservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TDelegate, TSender, TEventArgs>(Action<TDelegate> addHandler, Action<TDelegate> removeHandler)
         {
             if (addHandler == null)
+            {
                 throw new ArgumentNullException(nameof(addHandler));
+            }
+
             if (removeHandler == null)
+            {
                 throw new ArgumentNullException(nameof(removeHandler));
+            }
 
             return s_impl.FromEventPattern<TDelegate, TSender, TEventArgs>(addHandler, removeHandler);
         }
@@ -338,11 +388,19 @@ namespace System.Reactive.Linq
         public static IObservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TDelegate, TSender, TEventArgs>(Action<TDelegate> addHandler, Action<TDelegate> removeHandler, IScheduler scheduler)
         {
             if (addHandler == null)
+            {
                 throw new ArgumentNullException(nameof(addHandler));
+            }
+
             if (removeHandler == null)
+            {
                 throw new ArgumentNullException(nameof(removeHandler));
+            }
+
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return s_impl.FromEventPattern<TDelegate, TSender, TEventArgs>(addHandler, removeHandler, scheduler);
         }
@@ -383,9 +441,14 @@ namespace System.Reactive.Linq
         public static IObservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(Action<EventHandler<TEventArgs>> addHandler, Action<EventHandler<TEventArgs>> removeHandler)
         {
             if (addHandler == null)
+            {
                 throw new ArgumentNullException(nameof(addHandler));
+            }
+
             if (removeHandler == null)
+            {
                 throw new ArgumentNullException(nameof(removeHandler));
+            }
 
             return s_impl.FromEventPattern<TEventArgs>(addHandler, removeHandler);
         }
@@ -419,11 +482,19 @@ namespace System.Reactive.Linq
         public static IObservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(Action<EventHandler<TEventArgs>> addHandler, Action<EventHandler<TEventArgs>> removeHandler, IScheduler scheduler)
         {
             if (addHandler == null)
+            {
                 throw new ArgumentNullException(nameof(addHandler));
+            }
+
             if (removeHandler == null)
+            {
                 throw new ArgumentNullException(nameof(removeHandler));
+            }
+
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return s_impl.FromEventPattern<TEventArgs>(addHandler, removeHandler, scheduler);
         }
@@ -470,9 +541,14 @@ namespace System.Reactive.Linq
         public static IObservable<EventPattern<object>> FromEventPattern(object target, string eventName)
         {
             if (target == null)
+            {
                 throw new ArgumentNullException(nameof(target));
+            }
+
             if (eventName == null)
+            {
                 throw new ArgumentNullException(nameof(eventName));
+            }
 
             return s_impl.FromEventPattern(target, eventName);
         }
@@ -508,12 +584,20 @@ namespace System.Reactive.Linq
         public static IObservable<EventPattern<object>> FromEventPattern(object target, string eventName, IScheduler scheduler)
         {
             if (target == null)
+            {
                 throw new ArgumentNullException(nameof(target));
+            }
+
             if (eventName == null)
+            {
                 throw new ArgumentNullException(nameof(eventName));
+            }
+
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
-            
+            }
+
             return s_impl.FromEventPattern(target, eventName, scheduler);
         }
 
@@ -552,9 +636,14 @@ namespace System.Reactive.Linq
         public static IObservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(object target, string eventName)
         {
             if (target == null)
+            {
                 throw new ArgumentNullException(nameof(target));
+            }
+
             if (eventName == null)
+            {
                 throw new ArgumentNullException(nameof(eventName));
+            }
 
             return s_impl.FromEventPattern<TEventArgs>(target, eventName);
         }
@@ -591,11 +680,19 @@ namespace System.Reactive.Linq
         public static IObservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(object target, string eventName, IScheduler scheduler)
         {
             if (target == null)
+            {
                 throw new ArgumentNullException(nameof(target));
+            }
+
             if (eventName == null)
+            {
                 throw new ArgumentNullException(nameof(eventName));
+            }
+
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return s_impl.FromEventPattern<TEventArgs>(target, eventName, scheduler);
         }
@@ -636,9 +733,14 @@ namespace System.Reactive.Linq
         public static IObservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(object target, string eventName)
         {
             if (target == null)
+            {
                 throw new ArgumentNullException(nameof(target));
+            }
+
             if (eventName == null)
+            {
                 throw new ArgumentNullException(nameof(eventName));
+            }
 
             return s_impl.FromEventPattern<TSender, TEventArgs>(target, eventName);
         }
@@ -676,11 +778,19 @@ namespace System.Reactive.Linq
         public static IObservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(object target, string eventName, IScheduler scheduler)
         {
             if (target == null)
+            {
                 throw new ArgumentNullException(nameof(target));
+            }
+
             if (eventName == null)
+            {
                 throw new ArgumentNullException(nameof(eventName));
+            }
+
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return s_impl.FromEventPattern<TSender, TEventArgs>(target, eventName, scheduler);
         }
@@ -723,9 +833,14 @@ namespace System.Reactive.Linq
         public static IObservable<EventPattern<object>> FromEventPattern(Type type, string eventName)
         {
             if (type == null)
+            {
                 throw new ArgumentNullException(nameof(type));
+            }
+
             if (eventName == null)
+            {
                 throw new ArgumentNullException(nameof(eventName));
+            }
 
             return s_impl.FromEventPattern(type, eventName);
         }
@@ -761,11 +876,19 @@ namespace System.Reactive.Linq
         public static IObservable<EventPattern<object>> FromEventPattern(Type type, string eventName, IScheduler scheduler)
         {
             if (type == null)
+            {
                 throw new ArgumentNullException(nameof(type));
+            }
+
             if (eventName == null)
+            {
                 throw new ArgumentNullException(nameof(eventName));
+            }
+
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return s_impl.FromEventPattern(type, eventName, scheduler);
         }
@@ -805,9 +928,14 @@ namespace System.Reactive.Linq
         public static IObservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(Type type, string eventName)
         {
             if (type == null)
+            {
                 throw new ArgumentNullException(nameof(type));
+            }
+
             if (eventName == null)
+            {
                 throw new ArgumentNullException(nameof(eventName));
+            }
 
             return s_impl.FromEventPattern<TEventArgs>(type, eventName);
         }
@@ -844,11 +972,19 @@ namespace System.Reactive.Linq
         public static IObservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(Type type, string eventName, IScheduler scheduler)
         {
             if (type == null)
+            {
                 throw new ArgumentNullException(nameof(type));
+            }
+
             if (eventName == null)
+            {
                 throw new ArgumentNullException(nameof(eventName));
+            }
+
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return s_impl.FromEventPattern<TEventArgs>(type, eventName, scheduler);
         }
@@ -889,9 +1025,14 @@ namespace System.Reactive.Linq
         public static IObservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(Type type, string eventName)
         {
             if (type == null)
+            {
                 throw new ArgumentNullException(nameof(type));
+            }
+
             if (eventName == null)
+            {
                 throw new ArgumentNullException(nameof(eventName));
+            }
 
             return s_impl.FromEventPattern<TSender, TEventArgs>(type, eventName);
         }
@@ -929,11 +1070,19 @@ namespace System.Reactive.Linq
         public static IObservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(Type type, string eventName, IScheduler scheduler)
         {
             if (type == null)
+            {
                 throw new ArgumentNullException(nameof(type));
+            }
+
             if (eventName == null)
+            {
                 throw new ArgumentNullException(nameof(eventName));
+            }
+
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return s_impl.FromEventPattern<TSender, TEventArgs>(type, eventName, scheduler);
         }
@@ -982,11 +1131,19 @@ namespace System.Reactive.Linq
         public static IObservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(Func<Action<TEventArgs>, TDelegate> conversion, Action<TDelegate> addHandler, Action<TDelegate> removeHandler)
         {
             if (conversion == null)
+            {
                 throw new ArgumentNullException(nameof(conversion));
+            }
+
             if (addHandler == null)
+            {
                 throw new ArgumentNullException(nameof(addHandler));
+            }
+
             if (removeHandler == null)
+            {
                 throw new ArgumentNullException(nameof(removeHandler));
+            }
 
             return s_impl.FromEvent<TDelegate, TEventArgs>(conversion, addHandler, removeHandler);
         }
@@ -1022,13 +1179,24 @@ namespace System.Reactive.Linq
         public static IObservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(Func<Action<TEventArgs>, TDelegate> conversion, Action<TDelegate> addHandler, Action<TDelegate> removeHandler, IScheduler scheduler)
         {
             if (conversion == null)
+            {
                 throw new ArgumentNullException(nameof(conversion));
+            }
+
             if (addHandler == null)
+            {
                 throw new ArgumentNullException(nameof(addHandler));
+            }
+
             if (removeHandler == null)
+            {
                 throw new ArgumentNullException(nameof(removeHandler));
+            }
+
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return s_impl.FromEvent<TDelegate, TEventArgs>(conversion, addHandler, removeHandler, scheduler);
         }
@@ -1066,9 +1234,14 @@ namespace System.Reactive.Linq
         public static IObservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(Action<TDelegate> addHandler, Action<TDelegate> removeHandler)
         {
             if (addHandler == null)
+            {
                 throw new ArgumentNullException(nameof(addHandler));
+            }
+
             if (removeHandler == null)
+            {
                 throw new ArgumentNullException(nameof(removeHandler));
+            }
 
             return s_impl.FromEvent<TDelegate, TEventArgs>(addHandler, removeHandler);
         }
@@ -1103,11 +1276,19 @@ namespace System.Reactive.Linq
         public static IObservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(Action<TDelegate> addHandler, Action<TDelegate> removeHandler, IScheduler scheduler)
         {
             if (addHandler == null)
+            {
                 throw new ArgumentNullException(nameof(addHandler));
+            }
+
             if (removeHandler == null)
+            {
                 throw new ArgumentNullException(nameof(removeHandler));
+            }
+
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return s_impl.FromEvent<TDelegate, TEventArgs>(addHandler, removeHandler, scheduler);
         }
@@ -1148,9 +1329,14 @@ namespace System.Reactive.Linq
         public static IObservable<TEventArgs> FromEvent<TEventArgs>(Action<Action<TEventArgs>> addHandler, Action<Action<TEventArgs>> removeHandler)
         {
             if (addHandler == null)
+            {
                 throw new ArgumentNullException(nameof(addHandler));
+            }
+
             if (removeHandler == null)
+            {
                 throw new ArgumentNullException(nameof(removeHandler));
+            }
 
             return s_impl.FromEvent<TEventArgs>(addHandler, removeHandler);
         }
@@ -1184,11 +1370,19 @@ namespace System.Reactive.Linq
         public static IObservable<TEventArgs> FromEvent<TEventArgs>(Action<Action<TEventArgs>> addHandler, Action<Action<TEventArgs>> removeHandler, IScheduler scheduler)
         {
             if (addHandler == null)
+            {
                 throw new ArgumentNullException(nameof(addHandler));
+            }
+
             if (removeHandler == null)
+            {
                 throw new ArgumentNullException(nameof(removeHandler));
+            }
+
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return s_impl.FromEvent<TEventArgs>(addHandler, removeHandler, scheduler);
         }
@@ -1228,9 +1422,14 @@ namespace System.Reactive.Linq
         public static IObservable<Unit> FromEvent(Action<Action> addHandler, Action<Action> removeHandler)
         {
             if (addHandler == null)
+            {
                 throw new ArgumentNullException(nameof(addHandler));
+            }
+
             if (removeHandler == null)
+            {
                 throw new ArgumentNullException(nameof(removeHandler));
+            }
 
             return s_impl.FromEvent(addHandler, removeHandler);
         }
@@ -1263,11 +1462,19 @@ namespace System.Reactive.Linq
         public static IObservable<Unit> FromEvent(Action<Action> addHandler, Action<Action> removeHandler, IScheduler scheduler)
         {
             if (addHandler == null)
+            {
                 throw new ArgumentNullException(nameof(addHandler));
+            }
+
             if (removeHandler == null)
+            {
                 throw new ArgumentNullException(nameof(removeHandler));
+            }
+
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return s_impl.FromEvent(addHandler, removeHandler, scheduler);
         }

+ 77 - 0
Rx.NET/Source/src/System.Reactive/Linq/Observable.Imperative.cs

@@ -25,9 +25,14 @@ namespace System.Reactive.Linq
         public static Task ForEachAsync<TSource>(this IObservable<TSource> source, Action<TSource> onNext)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (onNext == null)
+            {
                 throw new ArgumentNullException(nameof(onNext));
+            }
 
             return s_impl.ForEachAsync<TSource>(source, onNext);
         }
@@ -46,9 +51,14 @@ namespace System.Reactive.Linq
         public static Task ForEachAsync<TSource>(this IObservable<TSource> source, Action<TSource> onNext, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (onNext == null)
+            {
                 throw new ArgumentNullException(nameof(onNext));
+            }
 
             return s_impl.ForEachAsync<TSource>(source, onNext, cancellationToken);
         }
@@ -65,9 +75,14 @@ namespace System.Reactive.Linq
         public static Task ForEachAsync<TSource>(this IObservable<TSource> source, Action<TSource, int> onNext)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (onNext == null)
+            {
                 throw new ArgumentNullException(nameof(onNext));
+            }
 
             return s_impl.ForEachAsync<TSource>(source, onNext);
         }
@@ -86,9 +101,14 @@ namespace System.Reactive.Linq
         public static Task ForEachAsync<TSource>(this IObservable<TSource> source, Action<TSource, int> onNext, CancellationToken cancellationToken)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (onNext == null)
+            {
                 throw new ArgumentNullException(nameof(onNext));
+            }
 
             return s_impl.ForEachAsync<TSource>(source, onNext, cancellationToken);
         }
@@ -110,11 +130,19 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> Case<TValue, TResult>(Func<TValue> selector, IDictionary<TValue, IObservable<TResult>> sources, IObservable<TResult> defaultSource)
         {
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
+
             if (sources == null)
+            {
                 throw new ArgumentNullException(nameof(sources));
+            }
+
             if (defaultSource == null)
+            {
                 throw new ArgumentNullException(nameof(defaultSource));
+            }
 
             return s_impl.Case<TValue, TResult>(selector, sources, defaultSource);
         }
@@ -132,11 +160,19 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> Case<TValue, TResult>(Func<TValue> selector, IDictionary<TValue, IObservable<TResult>> sources, IScheduler scheduler)
         {
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
+
             if (sources == null)
+            {
                 throw new ArgumentNullException(nameof(sources));
+            }
+
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return s_impl.Case<TValue, TResult>(selector, sources, scheduler);
         }
@@ -153,9 +189,14 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> Case<TValue, TResult>(Func<TValue> selector, IDictionary<TValue, IObservable<TResult>> sources)
         {
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
+
             if (sources == null)
+            {
                 throw new ArgumentNullException(nameof(sources));
+            }
 
             return s_impl.Case<TValue, TResult>(selector, sources);
         }
@@ -175,9 +216,14 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> DoWhile<TSource>(this IObservable<TSource> source, Func<bool> condition)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (condition == null)
+            {
                 throw new ArgumentNullException(nameof(condition));
+            }
 
             return s_impl.DoWhile<TSource>(source, condition);
         }
@@ -198,9 +244,14 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> For<TSource, TResult>(IEnumerable<TSource> source, Func<TSource, IObservable<TResult>> resultSelector)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (resultSelector == null)
+            {
                 throw new ArgumentNullException(nameof(resultSelector));
+            }
 
             return s_impl.For<TSource, TResult>(source, resultSelector);
         }
@@ -221,11 +272,19 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> If<TResult>(Func<bool> condition, IObservable<TResult> thenSource, IObservable<TResult> elseSource)
         {
             if (condition == null)
+            {
                 throw new ArgumentNullException(nameof(condition));
+            }
+
             if (thenSource == null)
+            {
                 throw new ArgumentNullException(nameof(thenSource));
+            }
+
             if (elseSource == null)
+            {
                 throw new ArgumentNullException(nameof(elseSource));
+            }
 
             return s_impl.If<TResult>(condition, thenSource, elseSource);
         }
@@ -241,9 +300,14 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> If<TResult>(Func<bool> condition, IObservable<TResult> thenSource)
         {
             if (condition == null)
+            {
                 throw new ArgumentNullException(nameof(condition));
+            }
+
             if (thenSource == null)
+            {
                 throw new ArgumentNullException(nameof(thenSource));
+            }
 
             return s_impl.If<TResult>(condition, thenSource);
         }
@@ -260,11 +324,19 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> If<TResult>(Func<bool> condition, IObservable<TResult> thenSource, IScheduler scheduler)
         {
             if (condition == null)
+            {
                 throw new ArgumentNullException(nameof(condition));
+            }
+
             if (thenSource == null)
+            {
                 throw new ArgumentNullException(nameof(thenSource));
+            }
+
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return s_impl.If<TResult>(condition, thenSource, scheduler);
         }
@@ -284,9 +356,14 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> While<TSource>(Func<bool> condition, IObservable<TSource> source)
         {
             if (condition == null)
+            {
                 throw new ArgumentNullException(nameof(condition));
+            }
+
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return s_impl.While<TSource>(condition, source);
         }

+ 15 - 2
Rx.NET/Source/src/System.Reactive/Linq/Observable.Joins.cs

@@ -3,12 +3,11 @@
 // See the LICENSE file in the project root for more information. 
 
 using System.Collections.Generic;
-using System.Reactive.Disposables;
 using System.Reactive.Joins;
 
 namespace System.Reactive.Linq
 {
-	public static partial class Observable
+    public static partial class Observable
     {
         #region And
 
@@ -24,9 +23,14 @@ namespace System.Reactive.Linq
         public static Pattern<TLeft, TRight> And<TLeft, TRight>(this IObservable<TLeft> left, IObservable<TRight> right)
         {
             if (left == null)
+            {
                 throw new ArgumentNullException(nameof(left));
+            }
+
             if (right == null)
+            {
                 throw new ArgumentNullException(nameof(right));
+            }
 
             return s_impl.And<TLeft, TRight>(left, right);
         }
@@ -47,9 +51,14 @@ namespace System.Reactive.Linq
         public static Plan<TResult> Then<TSource, TResult>(this IObservable<TSource> source, Func<TSource, TResult> selector)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (selector == null)
+            {
                 throw new ArgumentNullException(nameof(selector));
+            }
 
             return s_impl.Then<TSource, TResult>(source, selector);
         }
@@ -68,7 +77,9 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> When<TResult>(params Plan<TResult>[] plans)
         {
             if (plans == null)
+            {
                 throw new ArgumentNullException(nameof(plans));
+            }
 
             return s_impl.When<TResult>(plans);
         }
@@ -83,7 +94,9 @@ namespace System.Reactive.Linq
         public static IObservable<TResult> When<TResult>(this IEnumerable<Plan<TResult>> plans)
         {
             if (plans == null)
+            {
                 throw new ArgumentNullException(nameof(plans));
+            }
 
             return s_impl.When<TResult>(plans);
         }

文件差异内容过多而无法显示
+ 490 - 0
Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.cs


+ 4 - 0
Rx.NET/Source/src/System.Reactive/Linq/Observable.Queryable.cs

@@ -18,7 +18,9 @@ namespace System.Reactive.Linq
             get
             {
                 if (s_provider == null)
+                {
                     s_provider = new ObservableQueryProvider();
+                }
 
                 return s_provider;
             }
@@ -34,7 +36,9 @@ namespace System.Reactive.Linq
         public static IQbservable<TSource> AsQbservable<TSource>(this IObservable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return new ObservableQuery<TSource>(source);
         }

+ 193 - 0
Rx.NET/Source/src/System.Reactive/Linq/Observable.Single.cs

@@ -22,7 +22,9 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> Append<TSource>(this IObservable<TSource> source, TSource value)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return s_impl.Append<TSource>(source, value);
         }
@@ -39,9 +41,14 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> Append<TSource>(this IObservable<TSource> source, TSource value, IScheduler scheduler)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return s_impl.Append<TSource>(source, value, scheduler);
         }
@@ -60,7 +67,9 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> AsObservable<TSource>(this IObservable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return s_impl.AsObservable<TSource>(source);
         }
@@ -81,9 +90,14 @@ namespace System.Reactive.Linq
         public static IObservable<IList<TSource>> Buffer<TSource>(this IObservable<TSource> source, int count)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (count <= 0)
+            {
                 throw new ArgumentOutOfRangeException(nameof(count));
+            }
 
             return s_impl.Buffer<TSource>(source, count);
         }
@@ -101,11 +115,19 @@ namespace System.Reactive.Linq
         public static IObservable<IList<TSource>> Buffer<TSource>(this IObservable<TSource> source, int count, int skip)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (count <= 0)
+            {
                 throw new ArgumentOutOfRangeException(nameof(count));
+            }
+
             if (skip <= 0)
+            {
                 throw new ArgumentOutOfRangeException(nameof(skip));
+            }
 
             return s_impl.Buffer<TSource>(source, count, skip);
         }
@@ -124,7 +146,9 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> Dematerialize<TSource>(this IObservable<Notification<TSource>> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return s_impl.Dematerialize<TSource>(source);
         }
@@ -143,7 +167,9 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> DistinctUntilChanged<TSource>(this IObservable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return s_impl.DistinctUntilChanged<TSource>(source);
         }
@@ -159,9 +185,14 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> DistinctUntilChanged<TSource>(this IObservable<TSource> source, IEqualityComparer<TSource> comparer)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (comparer == null)
+            {
                 throw new ArgumentNullException(nameof(comparer));
+            }
 
             return s_impl.DistinctUntilChanged<TSource>(source, comparer);
         }
@@ -178,9 +209,14 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> DistinctUntilChanged<TSource, TKey>(this IObservable<TSource> source, Func<TSource, TKey> keySelector)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
 
             return s_impl.DistinctUntilChanged<TSource, TKey>(source, keySelector);
         }
@@ -198,11 +234,19 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> DistinctUntilChanged<TSource, TKey>(this IObservable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (keySelector == null)
+            {
                 throw new ArgumentNullException(nameof(keySelector));
+            }
+
             if (comparer == null)
+            {
                 throw new ArgumentNullException(nameof(comparer));
+            }
 
             return s_impl.DistinctUntilChanged<TSource, TKey>(source, keySelector, comparer);
         }
@@ -223,9 +267,14 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> Do<TSource>(this IObservable<TSource> source, Action<TSource> onNext)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (onNext == null)
+            {
                 throw new ArgumentNullException(nameof(onNext));
+            }
 
             return s_impl.Do<TSource>(source, onNext);
         }
@@ -243,11 +292,19 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> Do<TSource>(this IObservable<TSource> source, Action<TSource> onNext, Action onCompleted)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (onNext == null)
+            {
                 throw new ArgumentNullException(nameof(onNext));
+            }
+
             if (onCompleted == null)
+            {
                 throw new ArgumentNullException(nameof(onCompleted));
+            }
 
             return s_impl.Do<TSource>(source, onNext, onCompleted);
         }
@@ -265,11 +322,19 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> Do<TSource>(this IObservable<TSource> source, Action<TSource> onNext, Action<Exception> onError)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (onNext == null)
+            {
                 throw new ArgumentNullException(nameof(onNext));
+            }
+
             if (onError == null)
+            {
                 throw new ArgumentNullException(nameof(onError));
+            }
 
             return s_impl.Do<TSource>(source, onNext, onError);
         }
@@ -288,13 +353,24 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> Do<TSource>(this IObservable<TSource> source, Action<TSource> onNext, Action<Exception> onError, Action onCompleted)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (onNext == null)
+            {
                 throw new ArgumentNullException(nameof(onNext));
+            }
+
             if (onError == null)
+            {
                 throw new ArgumentNullException(nameof(onError));
+            }
+
             if (onCompleted == null)
+            {
                 throw new ArgumentNullException(nameof(onCompleted));
+            }
 
             return s_impl.Do<TSource>(source, onNext, onError, onCompleted);
         }
@@ -311,9 +387,14 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> Do<TSource>(this IObservable<TSource> source, IObserver<TSource> observer)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (observer == null)
+            {
                 throw new ArgumentNullException(nameof(observer));
+            }
 
             return s_impl.Do<TSource>(source, observer);
         }
@@ -333,9 +414,14 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> Finally<TSource>(this IObservable<TSource> source, Action finallyAction)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (finallyAction == null)
+            {
                 throw new ArgumentNullException(nameof(finallyAction));
+            }
 
             return s_impl.Finally<TSource>(source, finallyAction);
         }
@@ -354,7 +440,9 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> IgnoreElements<TSource>(this IObservable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return s_impl.IgnoreElements<TSource>(source);
         }
@@ -373,7 +461,9 @@ namespace System.Reactive.Linq
         public static IObservable<Notification<TSource>> Materialize<TSource>(this IObservable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return s_impl.Materialize<TSource>(source);
         }
@@ -393,7 +483,9 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> Prepend<TSource>(this IObservable<TSource> source, TSource value)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return s_impl.Prepend<TSource>(source, value);
         }
@@ -410,9 +502,14 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> Prepend<TSource>(this IObservable<TSource> source, TSource value, IScheduler scheduler)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return s_impl.Prepend<TSource>(source, value, scheduler);
         }
@@ -430,7 +527,9 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> Repeat<TSource>(this IObservable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return s_impl.Repeat<TSource>(source);
         }
@@ -447,9 +546,14 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> Repeat<TSource>(this IObservable<TSource> source, int repeatCount)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (repeatCount < 0)
+            {
                 throw new ArgumentOutOfRangeException(nameof(repeatCount));
+            }
 
             return s_impl.Repeat<TSource>(source, repeatCount);
         }
@@ -471,9 +575,14 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> RepeatWhen<TSource, TSignal>(this IObservable<TSource> source, Func<IObservable<object>, IObservable<TSignal>> handler)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (handler == null)
+            {
                 throw new ArgumentNullException(nameof(handler));
+            }
 
             return s_impl.RepeatWhen(source, handler);
         }
@@ -493,7 +602,9 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> Retry<TSource>(this IObservable<TSource> source)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
 
             return s_impl.Retry<TSource>(source);
         }
@@ -510,9 +621,14 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> Retry<TSource>(this IObservable<TSource> source, int retryCount)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (retryCount < 0)
+            {
                 throw new ArgumentOutOfRangeException(nameof(retryCount));
+            }
 
             return s_impl.Retry<TSource>(source, retryCount);
         }
@@ -534,9 +650,14 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> RetryWhen<TSource, TSignal>(this IObservable<TSource> source, Func<IObservable<Exception>, IObservable<TSignal>> handler)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (handler == null)
+            {
                 throw new ArgumentNullException(nameof(handler));
+            }
 
             return s_impl.RetryWhen(source, handler);
         }
@@ -560,9 +681,14 @@ namespace System.Reactive.Linq
         public static IObservable<TAccumulate> Scan<TSource, TAccumulate>(this IObservable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> accumulator)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (accumulator == null)
+            {
                 throw new ArgumentNullException(nameof(accumulator));
+            }
 
             return s_impl.Scan<TSource, TAccumulate>(source, seed, accumulator);
         }
@@ -579,9 +705,14 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> Scan<TSource>(this IObservable<TSource> source, Func<TSource, TSource, TSource> accumulator)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (accumulator == null)
+            {
                 throw new ArgumentNullException(nameof(accumulator));
+            }
 
             return s_impl.Scan<TSource>(source, accumulator);
         }
@@ -606,9 +737,14 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> SkipLast<TSource>(this IObservable<TSource> source, int count)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (count < 0)
+            {
                 throw new ArgumentOutOfRangeException(nameof(count));
+            }
 
             return s_impl.SkipLast<TSource>(source, count);
         }
@@ -628,9 +764,14 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> StartWith<TSource>(this IObservable<TSource> source, params TSource[] values)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (values == null)
+            {
                 throw new ArgumentNullException(nameof(values));
+            }
 
             return s_impl.StartWith<TSource>(source, values);
         }
@@ -646,9 +787,14 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> StartWith<TSource>(this IObservable<TSource> source, IEnumerable<TSource> values)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (values == null)
+            {
                 throw new ArgumentNullException(nameof(values));
+            }
 
             return s_impl.StartWith<TSource>(source, values);
         }
@@ -665,11 +811,19 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> StartWith<TSource>(this IObservable<TSource> source, IScheduler scheduler, params TSource[] values)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
+
             if (values == null)
+            {
                 throw new ArgumentNullException(nameof(values));
+            }
 
             return s_impl.StartWith<TSource>(source, scheduler, values);
         }
@@ -691,11 +845,19 @@ namespace System.Reactive.Linq
             //
 
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
+
             if (values == null)
+            {
                 throw new ArgumentNullException(nameof(values));
+            }
 
             return s_impl.StartWith<TSource>(source, scheduler, values);
         }
@@ -720,9 +882,14 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> TakeLast<TSource>(this IObservable<TSource> source, int count)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (count < 0)
+            {
                 throw new ArgumentOutOfRangeException(nameof(count));
+            }
 
             return s_impl.TakeLast<TSource>(source, count);
         }
@@ -744,11 +911,19 @@ namespace System.Reactive.Linq
         public static IObservable<TSource> TakeLast<TSource>(this IObservable<TSource> source, int count, IScheduler scheduler)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (count < 0)
+            {
                 throw new ArgumentOutOfRangeException(nameof(count));
+            }
+
             if (scheduler == null)
+            {
                 throw new ArgumentNullException(nameof(scheduler));
+            }
 
             return s_impl.TakeLast<TSource>(source, count, scheduler);
         }
@@ -773,9 +948,14 @@ namespace System.Reactive.Linq
         public static IObservable<IList<TSource>> TakeLastBuffer<TSource>(this IObservable<TSource> source, int count)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (count < 0)
+            {
                 throw new ArgumentOutOfRangeException(nameof(count));
+            }
 
             return s_impl.TakeLastBuffer<TSource>(source, count);
         }
@@ -796,9 +976,14 @@ namespace System.Reactive.Linq
         public static IObservable<IObservable<TSource>> Window<TSource>(this IObservable<TSource> source, int count)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (count <= 0)
+            {
                 throw new ArgumentOutOfRangeException(nameof(count));
+            }
 
             return s_impl.Window<TSource>(source, count);
         }
@@ -816,11 +1001,19 @@ namespace System.Reactive.Linq
         public static IObservable<IObservable<TSource>> Window<TSource>(this IObservable<TSource> source, int count, int skip)
         {
             if (source == null)
+            {
                 throw new ArgumentNullException(nameof(source));
+            }
+
             if (count <= 0)
+            {
                 throw new ArgumentOutOfRangeException(nameof(count));
+            }
+
             if (skip <= 0)
+            {
                 throw new ArgumentOutOfRangeException(nameof(skip));
+            }
 
             return s_impl.Window<TSource>(source, count, skip);
         }

文件差异内容过多而无法显示
+ 401 - 0
Rx.NET/Source/src/System.Reactive/Linq/Observable.StandardSequenceOperators.cs


文件差异内容过多而无法显示
+ 378 - 0
Rx.NET/Source/src/System.Reactive/Linq/Observable.Time.cs


+ 3 - 3
Rx.NET/Source/src/System.Reactive/Linq/Observable/Aggregate.cs

@@ -29,7 +29,7 @@ namespace System.Reactive.Linq.ObservableImpl
                 : base(observer)
             {
                 _accumulator = accumulator;
-                _accumulation = default(TSource);
+                _accumulation = default;
                 _hasAccumulation = false;
             }
 
@@ -85,7 +85,7 @@ namespace System.Reactive.Linq.ObservableImpl
 
         protected override void Run(_ sink) => sink.Run(_source);
 
-        internal sealed class _ : Sink<TSource, TAccumulate> 
+        internal sealed class _ : Sink<TSource, TAccumulate>
         {
             private readonly Func<TAccumulate, TSource, TAccumulate> _accumulator;
             private TAccumulate _accumulation;
@@ -141,7 +141,7 @@ namespace System.Reactive.Linq.ObservableImpl
 
         protected override void Run(_ sink) => sink.Run(_source);
 
-        internal sealed class _ : Sink<TSource, TResult> 
+        internal sealed class _ : Sink<TSource, TResult>
         {
             private readonly Func<TAccumulate, TSource, TAccumulate> _accumulator;
             private readonly Func<TAccumulate, TResult> _resultSelector;

+ 2 - 2
Rx.NET/Source/src/System.Reactive/Linq/Observable/All.cs

@@ -19,7 +19,7 @@ namespace System.Reactive.Linq.ObservableImpl
 
         protected override void Run(_ sink) => sink.Run(_source);
 
-        internal sealed class _ : Sink<TSource, bool> 
+        internal sealed class _ : Sink<TSource, bool>
         {
             private readonly Func<TSource, bool> _predicate;
 
@@ -48,7 +48,7 @@ namespace System.Reactive.Linq.ObservableImpl
                     ForwardOnCompleted();
                 }
             }
-            
+
             public override void OnCompleted()
             {
                 ForwardOnNext(true);

+ 9 - 14
Rx.NET/Source/src/System.Reactive/Linq/Observable/Amb.cs

@@ -24,11 +24,9 @@ namespace System.Reactive.Linq.ObservableImpl
 
         internal sealed class AmbCoordinator : IDisposable
         {
-            readonly AmbObserver leftObserver;
-
-            readonly AmbObserver rightObserver;
-
-            int winner;
+            private readonly AmbObserver leftObserver;
+            private readonly AmbObserver rightObserver;
+            private int winner;
 
             public AmbCoordinator(IObserver<TSource> observer)
             {
@@ -69,21 +67,18 @@ namespace System.Reactive.Linq.ObservableImpl
                 return false;
             }
 
-            sealed class AmbObserver : IObserver<TSource>, IDisposable
+            private sealed class AmbObserver : IObserver<TSource>, IDisposable
             {
-                readonly IObserver<TSource> downstream;
-
-                readonly AmbCoordinator parent;
-
-                readonly bool isLeft;
-
-                IDisposable upstream;
+                private readonly IObserver<TSource> downstream;
+                private readonly AmbCoordinator parent;
+                private readonly bool isLeft;
+                private IDisposable upstream;
 
                 /// <summary>
                 /// If true, this observer won the race and now can emit
                 /// on a fast path.
                 /// </summary>
-                bool iwon;
+                private bool iwon;
 
                 public AmbObserver(IObserver<TSource> downstream, AmbCoordinator parent, bool isLeft)
                 {

部分文件因为文件数量过多而无法显示