From de52350d27cb64797a57b436dda56cffaf1029c3 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 13 Apr 2017 12:33:12 -0700 Subject: [PATCH] Removing checks for absence of SynchronizationContext. --- .../Concurrency/Synchronization.ObserveOn.cs | 9 +-------- .../src/System.Reactive/Concurrency/Synchronization.cs | 4 ---- .../Concurrency/SynchronizationContextScheduler.cs | 2 -- .../src/System.Reactive/Disposables/ContextDisposable.cs | 2 -- .../Internal/SynchronizationContextExtensions.cs | 2 -- Rx.NET/Source/src/System.Reactive/Linq/IQueryLanguage.cs | 6 ++---- .../src/System.Reactive/Linq/Observable.Concurrency.cs | 4 ---- .../src/System.Reactive/Linq/Observable/ObserveOn.cs | 9 +-------- .../System.Reactive/Linq/QueryLanguage.Concurrency.cs | 4 ---- Rx.NET/Source/src/System.Reactive/Observer.Extensions.cs | 4 +--- 10 files changed, 5 insertions(+), 41 deletions(-) diff --git a/Rx.NET/Source/src/System.Reactive/Concurrency/Synchronization.ObserveOn.cs b/Rx.NET/Source/src/System.Reactive/Concurrency/Synchronization.ObserveOn.cs index f76a0d006..8dd2b0f79 100644 --- a/Rx.NET/Source/src/System.Reactive/Concurrency/Synchronization.ObserveOn.cs +++ b/Rx.NET/Source/src/System.Reactive/Concurrency/Synchronization.ObserveOn.cs @@ -14,6 +14,7 @@ class ObserveOn : Producer { private readonly IObservable _source; private readonly IScheduler _scheduler; + private readonly SynchronizationContext _context; public ObserveOn(IObservable source, IScheduler scheduler) { @@ -21,20 +22,15 @@ public ObserveOn(IObservable source, IScheduler scheduler) _scheduler = scheduler; } -#if !NO_SYNCCTX - private readonly SynchronizationContext _context; - public ObserveOn(IObservable source, SynchronizationContext context) { _source = source; _context = context; } -#endif [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Justification = "Visibility restricted to friend assemblies. Those should be correct by inspection.")] protected override IDisposable Run(IObserver observer, IDisposable cancel, Action setSink) { -#if !NO_SYNCCTX if (_context != null) { var sink = new ObserveOnSink(this, observer, cancel); @@ -42,7 +38,6 @@ protected override IDisposable Run(IObserver observer, IDisposable canc return sink.Run(); } else -#endif { var sink = new ObserveOnObserver(_scheduler, observer, cancel); setSink(sink); @@ -50,7 +45,6 @@ protected override IDisposable Run(IObserver observer, IDisposable canc } } -#if !NO_SYNCCTX class ObserveOnSink : Sink, IObserver { private readonly ObserveOn _parent; @@ -113,7 +107,6 @@ private void OnCompletedPosted(object ignored) base.Dispose(); } } -#endif } } #endif \ No newline at end of file diff --git a/Rx.NET/Source/src/System.Reactive/Concurrency/Synchronization.cs b/Rx.NET/Source/src/System.Reactive/Concurrency/Synchronization.cs index aedc2f557..ff6d3679a 100644 --- a/Rx.NET/Source/src/System.Reactive/Concurrency/Synchronization.cs +++ b/Rx.NET/Source/src/System.Reactive/Concurrency/Synchronization.cs @@ -51,7 +51,6 @@ public static IObservable SubscribeOn(IObservable sou }); } -#if !NO_SYNCCTX /// /// Wraps the source sequence in order to run its subscription and unsubscription logic on the specified synchronization context. /// @@ -82,7 +81,6 @@ public static IObservable SubscribeOn(IObservable sou return subscription; }); } -#endif #endregion @@ -110,7 +108,6 @@ public static IObservable ObserveOn(IObservable sourc #endif } -#if !NO_SYNCCTX /// /// Wraps the source sequence in order to run its observer callbacks on the specified synchronization context. /// @@ -153,7 +150,6 @@ public static IObservable ObserveOn(IObservable sourc }); #endif } -#endif #endregion diff --git a/Rx.NET/Source/src/System.Reactive/Concurrency/SynchronizationContextScheduler.cs b/Rx.NET/Source/src/System.Reactive/Concurrency/SynchronizationContextScheduler.cs index 2350b889a..d2717762e 100644 --- a/Rx.NET/Source/src/System.Reactive/Concurrency/SynchronizationContextScheduler.cs +++ b/Rx.NET/Source/src/System.Reactive/Concurrency/SynchronizationContextScheduler.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. -#if !NO_SYNCCTX using System.Reactive.Disposables; using System.Threading; @@ -98,4 +97,3 @@ public override IDisposable Schedule(TState state, TimeSpan dueTime, Fun } } } -#endif \ No newline at end of file diff --git a/Rx.NET/Source/src/System.Reactive/Disposables/ContextDisposable.cs b/Rx.NET/Source/src/System.Reactive/Disposables/ContextDisposable.cs index 8f5dcf351..9b640efa5 100644 --- a/Rx.NET/Source/src/System.Reactive/Disposables/ContextDisposable.cs +++ b/Rx.NET/Source/src/System.Reactive/Disposables/ContextDisposable.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. -#if !NO_SYNCCTX using System.Reactive.Concurrency; using System.Threading; @@ -63,4 +62,3 @@ public void Dispose() } } } -#endif \ No newline at end of file diff --git a/Rx.NET/Source/src/System.Reactive/Internal/SynchronizationContextExtensions.cs b/Rx.NET/Source/src/System.Reactive/Internal/SynchronizationContextExtensions.cs index b1654731c..c9f6ab87f 100644 --- a/Rx.NET/Source/src/System.Reactive/Internal/SynchronizationContextExtensions.cs +++ b/Rx.NET/Source/src/System.Reactive/Internal/SynchronizationContextExtensions.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. -#if !NO_SYNCCTX using System; using System.Collections.Generic; using System.Linq; @@ -54,4 +53,3 @@ public static void PostWithStartComplete(this SynchronizationContext context, Ac } } } -#endif \ No newline at end of file diff --git a/Rx.NET/Source/src/System.Reactive/Linq/IQueryLanguage.cs b/Rx.NET/Source/src/System.Reactive/Linq/IQueryLanguage.cs index 26d3a693c..2f31933ba 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/IQueryLanguage.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/IQueryLanguage.cs @@ -380,13 +380,11 @@ internal interface IQueryLanguage #region * Concurrency * IObservable ObserveOn(IObservable source, IScheduler scheduler); -#if !NO_SYNCCTX IObservable ObserveOn(IObservable source, SynchronizationContext context); -#endif + IObservable SubscribeOn(IObservable source, IScheduler scheduler); -#if !NO_SYNCCTX IObservable SubscribeOn(IObservable source, SynchronizationContext context); -#endif + IObservable Synchronize(IObservable source); IObservable Synchronize(IObservable source, object gate); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable.Concurrency.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable.Concurrency.cs index 066b53a39..55aaa5a4b 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable.Concurrency.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable.Concurrency.cs @@ -33,7 +33,6 @@ public static IObservable ObserveOn(this IObservable return s_impl.ObserveOn(source, scheduler); } -#if !NO_SYNCCTX /// /// Wraps the source sequence in order to run its observer callbacks on the specified synchronization context. /// @@ -55,7 +54,6 @@ public static IObservable ObserveOn(this IObservable return s_impl.ObserveOn(source, context); } -#endif #endregion @@ -84,7 +82,6 @@ public static IObservable SubscribeOn(this IObservable(source, scheduler); } -#if !NO_SYNCCTX /// /// Wraps the source sequence in order to run its subscription and unsubscription logic on the specified synchronization context. This operation is not commonly used; /// see the remarks section for more information on the distinction between SubscribeOn and ObserveOn. @@ -107,7 +104,6 @@ public static IObservable SubscribeOn(this IObservable(source, context); } -#endif #endregion diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/ObserveOn.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/ObserveOn.cs index a329aec88..4a713ea5a 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/ObserveOn.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/ObserveOn.cs @@ -13,6 +13,7 @@ class ObserveOn : Producer { private readonly IObservable _source; private readonly IScheduler _scheduler; + private readonly SynchronizationContext _context; public ObserveOn(IObservable source, IScheduler scheduler) { @@ -20,19 +21,14 @@ public ObserveOn(IObservable source, IScheduler scheduler) _scheduler = scheduler; } -#if !NO_SYNCCTX - private readonly SynchronizationContext _context; - public ObserveOn(IObservable source, SynchronizationContext context) { _source = source; _context = context; } -#endif protected override IDisposable Run(IObserver observer, IDisposable cancel, Action setSink) { -#if !NO_SYNCCTX if (_context != null) { var sink = new ObserveOnImpl(this, observer, cancel); @@ -40,7 +36,6 @@ protected override IDisposable Run(IObserver observer, IDisposable canc return _source.Subscribe(sink); } else -#endif { var sink = new ObserveOnObserver(_scheduler, observer, cancel); setSink(sink); @@ -48,7 +43,6 @@ protected override IDisposable Run(IObserver observer, IDisposable canc } } -#if !NO_SYNCCTX class ObserveOnImpl : Sink, IObserver { private readonly ObserveOn _parent; @@ -85,7 +79,6 @@ public void OnCompleted() }); } } -#endif } } #endif \ No newline at end of file diff --git a/Rx.NET/Source/src/System.Reactive/Linq/QueryLanguage.Concurrency.cs b/Rx.NET/Source/src/System.Reactive/Linq/QueryLanguage.Concurrency.cs index 39009ea6a..ffd869874 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/QueryLanguage.Concurrency.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/QueryLanguage.Concurrency.cs @@ -21,12 +21,10 @@ public virtual IObservable ObserveOn(IObservable sour return Synchronization.ObserveOn(source, scheduler); } -#if !NO_SYNCCTX public virtual IObservable ObserveOn(IObservable source, SynchronizationContext context) { return Synchronization.ObserveOn(source, context); } -#endif #endregion @@ -37,12 +35,10 @@ public virtual IObservable SubscribeOn(IObservable so return Synchronization.SubscribeOn(source, scheduler); } -#if !NO_SYNCCTX public virtual IObservable SubscribeOn(IObservable source, SynchronizationContext context) { return Synchronization.SubscribeOn(source, context); } -#endif #endregion diff --git a/Rx.NET/Source/src/System.Reactive/Observer.Extensions.cs b/Rx.NET/Source/src/System.Reactive/Observer.Extensions.cs index ce7dd1b48..8aaed6ba5 100644 --- a/Rx.NET/Source/src/System.Reactive/Observer.Extensions.cs +++ b/Rx.NET/Source/src/System.Reactive/Observer.Extensions.cs @@ -258,7 +258,6 @@ public static IObserver NotifyOn(this IObserver observer, IScheduler sc return new ObserveOnObserver(scheduler, observer, null); } -#if !NO_SYNCCTX /// /// Schedules the invocation of observer methods on the given synchonization context. /// @@ -276,8 +275,7 @@ public static IObserver NotifyOn(this IObserver observer, Synchronizati return new ObserveOnObserver(new SynchronizationContextScheduler(context), observer, null); } -#endif - + /// /// Converts an observer to a progress object. ///