Pārlūkot izejas kodu

Merge pull request #736 from danielcweber/RemoveCodeRedundancies

Remove code redundancies as suggested by ReSharper.
Daniel C. Weber 7 gadi atpakaļ
vecāks
revīzija
907ef165c3
36 mainītis faili ar 125 papildinājumiem un 188 dzēšanām
  1. 0 3
      Rx.NET/Source/src/AssemblyInfo.cs
  2. 2 4
      Rx.NET/Source/src/System.Reactive/Concurrency/ConcurrencyAbstractionLayerImpl.cs
  3. 5 3
      Rx.NET/Source/src/System.Reactive/Concurrency/LocalScheduler.cs
  4. 10 11
      Rx.NET/Source/src/System.Reactive/Concurrency/Scheduler.Services.Emulation.cs
  5. 1 1
      Rx.NET/Source/src/System.Reactive/Concurrency/Scheduler.Services.cs
  6. 1 3
      Rx.NET/Source/src/System.Reactive/Concurrency/Synchronization.Synchronize.cs
  7. 2 4
      Rx.NET/Source/src/System.Reactive/Concurrency/ThreadPoolScheduler.cs
  8. 1 1
      Rx.NET/Source/src/System.Reactive/Concurrency/VirtualTimeScheduler.cs
  9. 1 1
      Rx.NET/Source/src/System.Reactive/ExperimentalAttribute.cs
  10. 2 4
      Rx.NET/Source/src/System.Reactive/Internal/SafeObserver.cs
  11. 1 1
      Rx.NET/Source/src/System.Reactive/Internal/ScheduledObserver.cs
  12. 27 31
      Rx.NET/Source/src/System.Reactive/Internal/TailRecursiveSink.cs
  13. 5 7
      Rx.NET/Source/src/System.Reactive/Linq/GroupedObservable.cs
  14. 1 1
      Rx.NET/Source/src/System.Reactive/Linq/LocalQueryMethodImplementationTypeAttribute.cs
  15. 15 21
      Rx.NET/Source/src/System.Reactive/Linq/Observable/AppendPrepend.cs
  16. 0 6
      Rx.NET/Source/src/System.Reactive/Linq/Observable/CombineLatest.cs
  17. 1 1
      Rx.NET/Source/src/System.Reactive/Linq/Observable/FromEventPattern.cs
  18. 3 5
      Rx.NET/Source/src/System.Reactive/Linq/Observable/PushToPullAdapter.cs
  19. 2 4
      Rx.NET/Source/src/System.Reactive/Linq/Observable/Skip.cs
  20. 2 4
      Rx.NET/Source/src/System.Reactive/Linq/Observable/SkipUntil.cs
  21. 4 8
      Rx.NET/Source/src/System.Reactive/Linq/Observable/Take.cs
  22. 4 8
      Rx.NET/Source/src/System.Reactive/Linq/Observable/TakeLast.cs
  23. 2 4
      Rx.NET/Source/src/System.Reactive/Linq/Observable/TakeUntil.cs
  24. 0 5
      Rx.NET/Source/src/System.Reactive/Linq/Observable/Zip.cs
  25. 6 10
      Rx.NET/Source/src/System.Reactive/Linq/QueryLanguage.Async.cs
  26. 2 4
      Rx.NET/Source/src/System.Reactive/Linq/QueryLanguage.Events.cs
  27. 2 1
      Rx.NET/Source/src/System.Reactive/Linq/QueryLanguage.Single.cs
  28. 1 2
      Rx.NET/Source/src/System.Reactive/Notification.cs
  29. 0 1
      Rx.NET/Source/src/System.Reactive/ObservableBase.cs
  30. 4 5
      Rx.NET/Source/src/System.Reactive/ObservableQuery.cs
  31. 2 4
      Rx.NET/Source/src/System.Reactive/Observer.Extensions.cs
  32. 5 7
      Rx.NET/Source/src/System.Reactive/Runtime/CompilerServices/TaskObservableMethodBuilder.cs
  33. 5 6
      Rx.NET/Source/src/System.Reactive/Subjects/BehaviorSubject.cs
  34. 2 1
      Rx.NET/Source/src/System.Reactive/Subjects/ReplaySubject.cs
  35. 2 4
      Rx.NET/Source/src/System.Reactive/Threading/Tasks/TaskObservableExtensions.cs
  36. 2 2
      Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.Core.approved.txt

+ 0 - 3
Rx.NET/Source/src/AssemblyInfo.cs

@@ -1,9 +1,6 @@
 using System;
 using System.Resources;
 using System.Runtime.InteropServices;
-using System.Security;
-
-
 
 [assembly: ComVisible(false)]
 [assembly: CLSCompliant(true)]

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

@@ -44,10 +44,8 @@ namespace System.Reactive.Concurrency
             {
                 return new FastPeriodicTimer(action);
             }
-            else
-            {
-                return new PeriodicTimer(action, period);
-            }
+
+            return new PeriodicTimer(action, period);
         }
 
         public IDisposable QueueUserWorkItem(Action<object> action, object state)

+ 5 - 3
Rx.NET/Source/src/System.Reactive/Concurrency/LocalScheduler.cs

@@ -84,13 +84,15 @@ namespace System.Reactive.Concurrency
         {
             if (serviceType == typeof(IStopwatchProvider))
             {
-                return this as IStopwatchProvider;
+                return this;
             }
-            else if (serviceType == typeof(ISchedulerLongRunning))
+
+            if (serviceType == typeof(ISchedulerLongRunning))
             {
                 return this as ISchedulerLongRunning;
             }
-            else if (serviceType == typeof(ISchedulerPeriodic))
+
+            if (serviceType == typeof(ISchedulerPeriodic))
             {
                 return this as ISchedulerPeriodic;
             }

+ 10 - 11
Rx.NET/Source/src/System.Reactive/Concurrency/Scheduler.Services.Emulation.cs

@@ -411,7 +411,8 @@ namespace System.Reactive.Concurrency
                             next = Normalize(_nextDue - (_stopwatch.Elapsed - _inactiveTime));
                             break;
                         }
-                        else if (_runState == DISPOSED)
+
+                        if (_runState == DISPOSED)
                         {
                             //
                             // In case the periodic job gets disposed but we are currently
@@ -422,16 +423,14 @@ namespace System.Reactive.Concurrency
                             //
                             return;
                         }
-                        else
-                        {
-                            //
-                            // This is the least common case where we got suspended and need
-                            // to block such that future reevaluations of the next due time
-                            // will pick up the cumulative inactive time delta.
-                            //
-                            Debug.Assert(_runState == SUSPENDED);
-                            shouldWaitForResume = true;
-                        }
+
+                        //
+                        // This is the least common case where we got suspended and need
+                        // to block such that future reevaluations of the next due time
+                        // will pick up the cumulative inactive time delta.
+                        //
+                        Debug.Assert(_runState == SUSPENDED);
+                        shouldWaitForResume = true;
                     }
 
                     //

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

@@ -10,7 +10,7 @@ namespace System.Reactive.Concurrency
     //
     public static partial class Scheduler
     {
-        internal static Type[] OPTIMIZATIONS = new Type[] {
+        internal static Type[] OPTIMIZATIONS = {
             typeof(ISchedulerLongRunning),
             typeof(IStopwatchProvider),
             typeof(ISchedulerPeriodic),

+ 1 - 3
Rx.NET/Source/src/System.Reactive/Concurrency/Synchronization.Synchronize.cs

@@ -27,14 +27,12 @@ namespace System.Reactive.Concurrency
 
         internal sealed class _ : IdentitySink<TSource>
         {
-            private readonly Synchronize<TSource> _parent;
             private readonly object _gate;
 
             public _(Synchronize<TSource> parent, IObserver<TSource> observer)
                 : base(observer)
             {
-                _parent = parent;
-                _gate = _parent._gate ?? new object();
+                _gate = parent._gate ?? new object();
             }
 
             public override void OnNext(TSource value)

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

@@ -141,10 +141,8 @@ namespace System.Reactive.Concurrency
             {
                 return new FastPeriodicTimer<TState>(state, action);
             }
-            else
-            {
-                return new PeriodicTimer<TState>(state, period, action);
-            }
+
+            return new PeriodicTimer<TState>(state, period, action);
         }
 
         private sealed class FastPeriodicTimer<TState> : IDisposable

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

@@ -320,7 +320,7 @@ namespace System.Reactive.Concurrency
         {
             if (serviceType == typeof(IStopwatchProvider))
             {
-                return this as IStopwatchProvider;
+                return this;
             }
 
             return null;

+ 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)]
     public sealed class ExperimentalAttribute : Attribute
     {
     }

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

@@ -62,10 +62,8 @@ namespace System.Reactive
             {
                 return a.MakeSafe();
             }
-            else
-            {
-                return new WrappingSafeObserver(observer);
-            }
+
+            return new WrappingSafeObserver(observer);
         }
 
         private IDisposable _disposable;

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

@@ -602,7 +602,7 @@ namespace System.Reactive
                 }
                 return true;
             }
-            else
+            
             // the queue is empty and the upstream hasn't completed yet
             if (empty)
             {

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

@@ -109,44 +109,40 @@ namespace System.Reactive
                                     _stack.Push(nextEnumerator);
                                     continue;
                                 }
-                                else
-                                {
-                                    Volatile.Write(ref _isDisposed, true);
-                                    continue;
-                                }
+
+                                Volatile.Write(ref _isDisposed, true);
+                                continue;
                             }
-                            else
-                            {
-                                // we need an unique indicator for this as
-                                // Subscribe could return a Disposable.Empty or
-                                // a BooleanDisposable
-                                var sad = ReadyToken.Ready;
 
-                                // Swap in the Ready indicator so we know the sequence hasn't been disposed
-                                if (Disposable.TrySetSingle(ref _currentSubscription, sad) == TrySetSingleResult.Success)
-                                {
-                                    // subscribe to the source
-                                    var d = next.SubscribeSafe(this);
+                            // we need an unique indicator for this as
+                            // Subscribe could return a Disposable.Empty or
+                            // a BooleanDisposable
+                            var sad = ReadyToken.Ready;
 
-                                    // Try to swap in the returned disposable in place of the Ready indicator
-                                    // Since this drain loop is the only one to use Ready, this should
-                                    // be unambiguous
-                                    var u = Interlocked.CompareExchange(ref _currentSubscription, d, sad);
+                            // Swap in the Ready indicator so we know the sequence hasn't been disposed
+                            if (Disposable.TrySetSingle(ref _currentSubscription, sad) == TrySetSingleResult.Success)
+                            {
+                                // subscribe to the source
+                                var d = next.SubscribeSafe(this);
 
-                                    // sequence disposed or completed synchronously
-                                    if (u != sad)
+                                // Try to swap in the returned disposable in place of the Ready indicator
+                                // 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)
+                                {
+                                    d.Dispose();
+                                    if (u == BooleanDisposable.True)
                                     {
-                                        d.Dispose();
-                                        if (u == BooleanDisposable.True)
-                                        {
-                                            continue;
-                                        }
+                                        continue;
                                     }
                                 }
-                                else
-                                {
-                                    continue;
-                                }
+                            }
+                            else
+                            {
+                                continue;
                             }
                         }
                         else

+ 5 - 7
Rx.NET/Source/src/System.Reactive/Linq/GroupedObservable.cs

@@ -38,13 +38,11 @@ namespace System.Reactive.Linq
                 var subscription = _subject.Subscribe/*Unsafe*/(observer);
                 return StableCompositeDisposable.Create(release, subscription);
             }
-            else
-            {
-                //
-                // [OK] Use of unsafe Subscribe: called on a known subject implementation.
-                //
-                return _subject.Subscribe/*Unsafe*/(observer);
-            }
+
+            //
+            // [OK] Use of unsafe Subscribe: called on a known subject implementation.
+            //
+            return _subject.Subscribe/*Unsafe*/(observer);
         }
     }
 }

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

@@ -12,7 +12,7 @@ namespace System.Reactive.Linq
     /// target class type.
     /// </summary>
     [EditorBrowsable(EditorBrowsableState.Never)]
-    [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
+    [AttributeUsage(AttributeTargets.Class, Inherited = false)]
     public sealed class LocalQueryMethodImplementationTypeAttribute : Attribute
     {
         private readonly Type _targetType;

+ 15 - 21
Rx.NET/Source/src/System.Reactive/Linq/Observable/AppendPrepend.cs

@@ -41,11 +41,9 @@ namespace System.Reactive.Linq.ObservableImpl
                     return new AppendPrependMultiple<TSource>(_source,
                         null, new Node<TSource>(prev, value), Scheduler);
                 }
-                else
-                {
-                    return new AppendPrependMultiple<TSource>(_source,
-                        prev, new Node<TSource>(value), Scheduler);
-                }
+
+                return new AppendPrependMultiple<TSource>(_source,
+                    prev, new Node<TSource>(value), Scheduler);
             }
 
             public IAppendPrepend<TSource> Prepend(TSource value)
@@ -57,11 +55,9 @@ namespace System.Reactive.Linq.ObservableImpl
                     return new AppendPrependMultiple<TSource>(_source,
                         new Node<TSource>(value), prev, Scheduler);
                 }
-                else
-                {
-                    return new AppendPrependMultiple<TSource>(_source,
-                        new Node<TSource>(prev, value), null, Scheduler);
-                }
+
+                return new AppendPrependMultiple<TSource>(_source,
+                    new Node<TSource>(prev, value), null, Scheduler);
             }
 
             protected override _ CreateSink(IObserver<TSource> observer) => new _(this, observer);
@@ -239,17 +235,15 @@ namespace System.Reactive.Linq.ObservableImpl
                         //
                         return longRunning.ScheduleLongRunning(new State(null, this, array, continueWith), Loop);
                     }
-                    else
-                    {
-                        //
-                        // We never allow the scheduled work to be cancelled. Instead, the flag
-                        // is used to have LoopRec bail out and perform proper clean-up of the
-                        // enumerator.
-                        //
-                        var flag = new BooleanDisposable();
-                        _scheduler.Schedule(new State(flag, this, array, continueWith), LoopRec);
-                        return flag;
-                    }
+
+                    //
+                    // We never allow the scheduled work to be cancelled. Instead, the flag
+                    // is used to have LoopRec bail out and perform proper clean-up of the
+                    // enumerator.
+                    //
+                    var flag = new BooleanDisposable();
+                    _scheduler.Schedule(new State(flag, this, array, continueWith), LoopRec);
+                    return flag;
                 }
 
                 private struct State

+ 0 - 6
Rx.NET/Source/src/System.Reactive/Linq/Observable/CombineLatest.cs

@@ -108,7 +108,6 @@ namespace System.Reactive.Linq.ObservableImpl
                         else if (_other.Done)
                         {
                             _parent.ForwardOnCompleted();
-                            return;
                         }
                     }
                 }
@@ -130,7 +129,6 @@ namespace System.Reactive.Linq.ObservableImpl
                         if (_other.Done)
                         {
                             _parent.ForwardOnCompleted();
-                            return;
                         }
                         else
                         {
@@ -203,7 +201,6 @@ namespace System.Reactive.Linq.ObservableImpl
                         if (_other.Done)
                         {
                             _parent.ForwardOnCompleted();
-                            return;
                         }
                         else
                         {
@@ -323,7 +320,6 @@ namespace System.Reactive.Linq.ObservableImpl
             if (allDone)
             {
                 ForwardOnCompleted();
-                return;
             }
         }
     }
@@ -472,7 +468,6 @@ namespace System.Reactive.Linq.ObservableImpl
                     else if (_isDone.AllExcept(index))
                     {
                         ForwardOnCompleted();
-                        return;
                     }
                 }
             }
@@ -494,7 +489,6 @@ namespace System.Reactive.Linq.ObservableImpl
                     if (_isDone.All())
                     {
                         ForwardOnCompleted();
-                        return;
                     }
                     else
                     {

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

@@ -151,7 +151,7 @@ namespace System.Reactive.Linq.ObservableImpl
             private Action AddHandlerCoreWinRT(Delegate handler)
             {
                 var token = _addMethod.Invoke(_target, new object[] { handler });
-                return () => _removeMethod.Invoke(_target, new object[] { token });
+                return () => _removeMethod.Invoke(_target, new[] { token });
             }
 #endif
         }

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

@@ -50,11 +50,9 @@ namespace System.Reactive.Linq.ObservableImpl
                     Current = current;
                     return true;
                 }
-                else
-                {
-                    _done = true;
-                    Dispose();
-                }
+
+                _done = true;
+                Dispose();
             }
 
             return false;

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

@@ -88,10 +88,8 @@ namespace System.Reactive.Linq.ObservableImpl
                 {
                     return this;
                 }
-                else
-                {
-                    return new Time(_source, duration, _scheduler);
-                }
+
+                return new Time(_source, duration, _scheduler);
             }
 
             protected override _ CreateSink(IObserver<TSource> observer) => new _(observer);

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

@@ -147,10 +147,8 @@ namespace System.Reactive.Linq.ObservableImpl
             {
                 return this;
             }
-            else
-            {
-                return new SkipUntil<TSource>(_source, startTime, _scheduler);
-            }
+
+            return new SkipUntil<TSource>(_source, startTime, _scheduler);
         }
 
         protected override _ CreateSink(IObserver<TSource> observer) => new _(observer);

+ 4 - 8
Rx.NET/Source/src/System.Reactive/Linq/Observable/Take.cs

@@ -33,10 +33,8 @@ namespace System.Reactive.Linq.ObservableImpl
                 {
                     return this;
                 }
-                else
-                {
-                    return new Count(_source, count);
-                }
+
+                return new Count(_source, count);
             }
 
             protected override _ CreateSink(IObserver<TSource> observer) => new _(_count, observer);
@@ -97,10 +95,8 @@ namespace System.Reactive.Linq.ObservableImpl
                 {
                     return this;
                 }
-                else
-                {
-                    return new Time(_source, duration, _scheduler);
-                }
+
+                return new Time(_source, duration, _scheduler);
             }
 
             protected override _ CreateSink(IObserver<TSource> observer) => new _(observer);

+ 4 - 8
Rx.NET/Source/src/System.Reactive/Linq/Observable/TakeLast.cs

@@ -106,10 +106,8 @@ namespace System.Reactive.Linq.ObservableImpl
                             ForwardOnCompleted();
                             break;
                         }
-                        else
-                        {
-                            ForwardOnNext(_queue.Dequeue());
-                        }
+
+                        ForwardOnNext(_queue.Dequeue());
 
                         n--;
                     }
@@ -223,10 +221,8 @@ namespace System.Reactive.Linq.ObservableImpl
                             ForwardOnCompleted();
                             break;
                         }
-                        else
-                        {
-                            ForwardOnNext(_queue.Dequeue().Value);
-                        }
+
+                        ForwardOnNext(_queue.Dequeue().Value);
 
                         n--;
                     }

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

@@ -124,10 +124,8 @@ namespace System.Reactive.Linq.ObservableImpl
             {
                 return this;
             }
-            else
-            {
-                return new TakeUntil<TSource>(_source, endTime, _scheduler);
-            }
+
+            return new TakeUntil<TSource>(_source, endTime, _scheduler);
         }
 
         protected override _ CreateSink(IObserver<TSource> observer) => new _(observer);

+ 0 - 5
Rx.NET/Source/src/System.Reactive/Linq/Observable/Zip.cs

@@ -149,7 +149,6 @@ namespace System.Reactive.Linq.ObservableImpl
                             if (_other.Done)
                             {
                                 _parent.ForwardOnCompleted();
-                                return;
                             }
                             else
                             {
@@ -232,7 +231,6 @@ namespace System.Reactive.Linq.ObservableImpl
                             if (_other.Done)
                             {
                                 _parent.ForwardOnCompleted();
-                                return;
                             }
                             else
                             {
@@ -471,7 +469,6 @@ namespace System.Reactive.Linq.ObservableImpl
             if (allDone)
             {
                 ForwardOnCompleted();
-                return;
             }
         }
     }
@@ -642,7 +639,6 @@ namespace System.Reactive.Linq.ObservableImpl
                     else if (_isDone.AllExcept(index))
                     {
                         ForwardOnCompleted();
-                        return;
                     }
                 }
             }
@@ -664,7 +660,6 @@ namespace System.Reactive.Linq.ObservableImpl
                     if (_isDone.All())
                     {
                         ForwardOnCompleted();
-                        return;
                     }
                     else
                     {

+ 6 - 10
Rx.NET/Source/src/System.Reactive/Linq/QueryLanguage.Async.cs

@@ -684,10 +684,8 @@ namespace System.Reactive.Linq
             {
                 return task.ToObservable(scheduler);
             }
-            else
-            {
-                return task.ToObservable();
-            }
+            
+            return task.ToObservable();
         }
 
         public virtual IObservable<TSource> StartAsync<TSource>(Func<CancellationToken, Task<TSource>> functionAsync)
@@ -789,10 +787,8 @@ namespace System.Reactive.Linq
             {
                 return task.ToObservable(scheduler);
             }
-            else
-            {
-                return task.ToObservable();
-            }
+            
+            return task.ToObservable();
         }
 
         public virtual IObservable<Unit> StartAsync(Func<CancellationToken, Task> actionAsync)
@@ -929,7 +925,7 @@ namespace System.Reactive.Linq
 
         public virtual Func<T, IObservable<TResult>> ToAsync<T, TResult>(Func<T, TResult> function, IScheduler scheduler)
         {
-            return (first) =>
+            return first =>
             {
                 var subject = new AsyncSubject<TResult>();
                 scheduler.ScheduleAction((function, subject, first), state =>
@@ -1426,7 +1422,7 @@ namespace System.Reactive.Linq
 
         public virtual Func<TSource, IObservable<Unit>> ToAsync<TSource>(Action<TSource> action, IScheduler scheduler)
         {
-            return (first) =>
+            return first =>
             {
                 var subject = new AsyncSubject<Unit>();
                 scheduler.ScheduleAction((subject, action, first), state =>

+ 2 - 4
Rx.NET/Source/src/System.Reactive/Linq/QueryLanguage.Events.cs

@@ -368,10 +368,8 @@ namespace System.Reactive.Linq
             {
                 return new SynchronizationContextScheduler(context, false);
             }
-            else
-            {
-                return SchedulerDefaults.ConstantTimeOperations;
-            }
+
+            return SchedulerDefaults.ConstantTimeOperations;
         }
 
         #endregion

+ 2 - 1
Rx.NET/Source/src/System.Reactive/Linq/QueryLanguage.Single.cs

@@ -63,7 +63,8 @@ namespace System.Reactive.Linq
             {
                 return new Buffer<TSource>.CountOverlap(source, count, skip);
             }
-            else if (count < skip)
+
+            if (count < skip)
             {
                 return new Buffer<TSource>.CountSkip(source, count, skip);
             }

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

@@ -6,7 +6,6 @@ using System.Collections.Generic;
 using System.Diagnostics;
 using System.Globalization;
 using System.Reactive.Concurrency;
-using System.Reactive.Disposables;
 
 #pragma warning disable 0659
 #pragma warning disable 0661
@@ -31,7 +30,7 @@ namespace System.Reactive
         /// <summary>
         /// Represents an OnCompleted notification.
         /// </summary>
-        OnCompleted,
+        OnCompleted
     }
 
     /// <summary>

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

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

+ 4 - 5
Rx.NET/Source/src/System.Reactive/ObservableQuery.cs

@@ -177,10 +177,8 @@ namespace System.Reactive
                     {
                         return Expression.Constant(source);
                     }
-                    else
-                    {
-                        return Visit(query.Expression);
-                    }
+
+                    return Visit(query.Expression);
                 }
 
                 return node;
@@ -208,7 +206,8 @@ namespace System.Reactive
                         var then = Expression.Call(pattern, "Then", method.GetGenericArguments(), arguments);
                         return then;
                     }
-                    else if (method.Name == "And")
+
+                    if (method.Name == "And")
                     {
                         //
                         // Retarget And to the corresponding pattern.

+ 2 - 4
Rx.NET/Source/src/System.Reactive/Observer.Extensions.cs

@@ -226,10 +226,8 @@ namespace System.Reactive
             {
                 return new AsyncLockObserver<T>(observer, new AsyncLock());
             }
-            else
-            {
-                return new SynchronizedObserver<T>(observer, new object());
-            }
+
+            return new SynchronizedObserver<T>(observer, new object());
         }
 
         /// <summary>

+ 5 - 7
Rx.NET/Source/src/System.Reactive/Runtime/CompilerServices/TaskObservableMethodBuilder.cs

@@ -5,7 +5,6 @@
 using System.Reactive;
 using System.Reactive.Concurrency;
 using System.Reactive.Disposables;
-using System.Reactive.Linq;
 using System.Reactive.Subjects;
 using System.Security;
 
@@ -296,16 +295,15 @@ namespace System.Runtime.CompilerServices
                 {
                     return _subject.Subscribe(observer);
                 }
-                else if (_exception != null)
+
+                if (_exception != null)
                 {
                     observer.OnError(_exception);
                     return Disposable.Empty;
                 }
-                else
-                {
-                    observer.OnNext(_result);
-                    return Disposable.Empty;
-                }
+
+                observer.OnNext(_result);
+                return Disposable.Empty;
             }
 
             /// <summary>

+ 5 - 6
Rx.NET/Source/src/System.Reactive/Subjects/BehaviorSubject.cs

@@ -118,15 +118,14 @@ namespace System.Reactive.Subjects
                     value = default;
                     return false;
                 }
-                else if (_exception != null)
+
+                if (_exception != null)
                 {
                     throw _exception;
                 }
-                else
-                {
-                    value = _value;
-                    return true;
-                }
+
+                value = _value;
+                return true;
             }
         }
 

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

@@ -880,7 +880,8 @@ namespace System.Reactive.Subjects
                             observer.OnError(error);
                             break;
                         }
-                        else if (done)
+
+                        if (done)
                         {
                             var observer = Done();
                             observer.OnCompleted();

+ 2 - 4
Rx.NET/Source/src/System.Reactive/Threading/Tasks/TaskObservableExtensions.cs

@@ -246,10 +246,8 @@ namespace System.Reactive.Threading.Tasks
             {
                 return subject.ObserveOn(scheduler);
             }
-            else
-            {
-                return subject.AsObservable();
-            }
+
+            return subject.AsObservable();
         }
 
         /// <summary>

+ 2 - 2
Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.Core.approved.txt

@@ -58,7 +58,7 @@ namespace System.Reactive
         protected void Add(System.Delegate handler, System.Action<TSender, TEventArgs> invoke) { }
         protected void Remove(System.Delegate handler) { }
     }
-    [System.AttributeUsageAttribute(System.AttributeTargets.Assembly | System.AttributeTargets.Module | System.AttributeTargets.Class | System.AttributeTargets.Struct | System.AttributeTargets.Enum | System.AttributeTargets.Constructor | System.AttributeTargets.Method | System.AttributeTargets.Property | System.AttributeTargets.Field | System.AttributeTargets.Event | System.AttributeTargets.Interface | System.AttributeTargets.Parameter | System.AttributeTargets.Delegate | System.AttributeTargets.ReturnValue | System.AttributeTargets.GenericParameter | System.AttributeTargets.All, AllowMultiple=false, Inherited=true)]
+    [System.AttributeUsageAttribute(System.AttributeTargets.Assembly | System.AttributeTargets.Module | System.AttributeTargets.Class | System.AttributeTargets.Struct | System.AttributeTargets.Enum | System.AttributeTargets.Constructor | System.AttributeTargets.Method | System.AttributeTargets.Property | System.AttributeTargets.Field | System.AttributeTargets.Event | System.AttributeTargets.Interface | System.AttributeTargets.Parameter | System.AttributeTargets.Delegate | System.AttributeTargets.ReturnValue | System.AttributeTargets.GenericParameter | System.AttributeTargets.All)]
     [System.Reactive.ExperimentalAttribute()]
     public sealed class ExperimentalAttribute : System.Attribute
     {
@@ -825,7 +825,7 @@ namespace System.Reactive.Linq
     {
         System.Reactive.Linq.IQbservable<TResult> CreateQuery<TResult>(System.Linq.Expressions.Expression expression);
     }
-    [System.AttributeUsageAttribute(System.AttributeTargets.Class | System.AttributeTargets.All, AllowMultiple=false, Inherited=false)]
+    [System.AttributeUsageAttribute(System.AttributeTargets.Class | System.AttributeTargets.All, Inherited=false)]
     public sealed class LocalQueryMethodImplementationTypeAttribute : System.Attribute
     {
         public LocalQueryMethodImplementationTypeAttribute(System.Type targetType) { }