Oren Novotny пре 8 година
родитељ
комит
2de07f26b5
23 измењених фајлова са 37 додато и 69 уклоњено
  1. 1 1
      Rx.NET/Source/src/Microsoft.Reactive.Testing/MockObserver.cs
  2. 2 2
      Rx.NET/Source/src/System.Reactive/Concurrency/ConcurrencyAbstractionLayerImpl.cs
  3. 1 2
      Rx.NET/Source/src/System.Reactive/Concurrency/SchedulerWrapper.cs
  4. 2 4
      Rx.NET/Source/src/System.Reactive/Internal/Lookup.cs
  5. 1 1
      Rx.NET/Source/src/System.Reactive/Internal/Producer.cs
  6. 2 4
      Rx.NET/Source/src/System.Reactive/Internal/SystemClock.cs
  7. 2 4
      Rx.NET/Source/src/System.Reactive/Internal/TailRecursiveSink.cs
  8. 2 3
      Rx.NET/Source/src/System.Reactive/Joins/Plan.cs
  9. 1 2
      Rx.NET/Source/src/System.Reactive/Linq/Observable/Case.cs
  10. 1 2
      Rx.NET/Source/src/System.Reactive/Linq/Observable/GroupByUntil.cs
  11. 1 2
      Rx.NET/Source/src/System.Reactive/Linq/Observable/PushToPullAdapter.cs
  12. 2 2
      Rx.NET/Source/src/System.Reactive/Linq/Observable/Timeout.cs
  13. 1 5
      Rx.NET/Source/src/System.Reactive/Linq/QueryLanguage.Events.cs
  14. 1 1
      Rx.NET/Source/src/System.Reactive/Subjects/AsyncSubject.cs
  15. 1 1
      Rx.NET/Source/src/System.Reactive/TimeInterval.cs
  16. 1 1
      Rx.NET/Source/src/System.Reactive/Timestamped.cs
  17. 1 1
      Rx.NET/Source/tests/Tests.System.Reactive/MockEnumerable.cs
  18. 2 6
      Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/DefaultSchedulerTest.cs
  19. 1 2
      Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/SchedulerTest.cs
  20. 2 7
      Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/ThreadPoolSchedulerTest.cs
  21. 6 12
      Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Subjects/BehaviorSubjectTest.cs
  22. 1 2
      Rx.NET/Source/tests/Tests.System.Reactive/Tests/MySubject.cs
  23. 2 2
      Rx.NET/Source/tests/Tests.System.Reactive/Tests/PrivateTypesTest.cs

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

@@ -19,7 +19,7 @@ namespace Microsoft.Reactive.Testing
                 throw new ArgumentNullException(nameof(scheduler));
 
             this.scheduler = scheduler;
-            this.messages = new List<Recorded<Notification<T>>>();
+            messages = new List<Recorded<Notification<T>>>();
         }
 
         public void OnNext(T value)

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

@@ -147,7 +147,7 @@ namespace System.Reactive.Concurrency
                     // Rooting of the timer happens through the this.Tick delegate's target object,
                     // which is the current instance and has a field to store the Timer instance.
                     //
-                    _timer = new System.Threading.Timer(this.Tick, state, dueTime, TimeSpan.FromMilliseconds(System.Threading.Timeout.Infinite));
+                    _timer = new System.Threading.Timer(Tick, state, dueTime, TimeSpan.FromMilliseconds(System.Threading.Timeout.Infinite));
                 }
             }
 
@@ -192,7 +192,7 @@ namespace System.Reactive.Concurrency
                 // Rooting of the timer happens through the this.Tick delegate's target object,
                 // which is the current instance and has a field to store the Timer instance.
                 //
-                _timer = new System.Threading.Timer(this.Tick, null, period, period);
+                _timer = new System.Threading.Timer(Tick, null, period, period);
             }
 
             private void Tick(object state) => _action();

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

@@ -67,8 +67,7 @@ namespace System.Reactive.Concurrency
             if (serviceProvider == null)
                 return null;
 
-            var result = default(object);
-            if (TryGetService(serviceProvider, serviceType, out result))
+            if (TryGetService(serviceProvider, serviceType, out var result))
                 return result;
 
             return serviceProvider.GetService(serviceType);

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

@@ -19,9 +19,8 @@ namespace System.Reactive
 
         public void Add(K key, E element)
         {
-            var list = default(List<E>);
 
-            if (!_dictionary.TryGetValue(key, out list))
+            if (!_dictionary.TryGetValue(key, out var list))
             {
                 _dictionary[key] = list = new List<E>();
             }
@@ -37,9 +36,8 @@ namespace System.Reactive
         {
             get
             {
-                var list = default(List<E>);
 
-                if (!_dictionary.TryGetValue(key, out list))
+                if (!_dictionary.TryGetValue(key, out var list))
                     return Enumerable.Empty<E>();
 
                 return Hide(list);

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

@@ -79,7 +79,7 @@ namespace System.Reactive
 
         private IDisposable Run(IScheduler _, State x)
         {
-            x.subscription.Disposable = this.Run(x.observer, x.subscription, x.Assign);
+            x.subscription.Disposable = Run(x.observer, x.subscription, x.Assign);
             return Disposable.Empty;
         }
 

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

@@ -61,8 +61,7 @@ namespace System.Reactive.PlatformServices
             {
                 foreach (var entry in s_systemClockChanged)
                 {
-                    var scheduler = default(LocalScheduler);
-                    if (entry.TryGetTarget(out scheduler))
+                    if (entry.TryGetTarget(out var scheduler))
                     {
                         scheduler.SystemClockChanged(sender, e);
                     }
@@ -124,8 +123,7 @@ namespace System.Reactive.PlatformServices
 
                 foreach (var handler in s_systemClockChanged)
                 {
-                    var scheduler = default(LocalScheduler);
-                    if (!handler.TryGetTarget(out scheduler))
+                    if (!handler.TryGetTarget(out var scheduler))
                     {
                         if (remove == null)
                         {

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

@@ -30,8 +30,7 @@ namespace System.Reactive
             _stack = new Stack<IEnumerator<IObservable<TSource>>>();
             _length = new Stack<int?>();
 
-            var e = default(IEnumerator<IObservable<TSource>>);
-            if (!TryGetEnumerator(sources, out e))
+            if (!TryGetEnumerator(sources, out var e))
                 return Disposable.Empty;
 
             _stack.Push(e);
@@ -139,8 +138,7 @@ namespace System.Reactive
                     var nextSeq = Extract(next);
                     if (nextSeq != null)
                     {
-                        var nextEnumerator = default(IEnumerator<IObservable<TSource>>);
-                        if (!TryGetEnumerator(nextSeq, out nextEnumerator))
+                        if (!TryGetEnumerator(nextSeq, out var nextEnumerator))
                             return;
 
                         _stack.Push(nextEnumerator);

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

@@ -23,15 +23,14 @@ namespace System.Reactive.Joins
             Dictionary<object, IJoinObserver> externalSubscriptions, IObservable<TSource> observable, Action<Exception> onError)
         {
             var observer = default(JoinObserver<TSource>);
-            var nonGeneric = default(IJoinObserver);
-            if (!externalSubscriptions.TryGetValue(observable, out nonGeneric))
+            if (!externalSubscriptions.TryGetValue(observable, out var nonGeneric))
             {
                 observer = new JoinObserver<TSource>(observable, onError);
                 externalSubscriptions.Add(observable, observer);
             }
             else
             {
-                observer = (JoinObserver<TSource>) nonGeneric;
+                observer = (JoinObserver<TSource>)nonGeneric;
             }
             return observer;
         }

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

@@ -22,8 +22,7 @@ namespace System.Reactive.Linq.ObservableImpl
 
         public IObservable<TResult> Eval()
         {
-            var res = default(IObservable<TResult>);
-            if (_sources.TryGetValue(_selector(), out res))
+            if (_sources.TryGetValue(_selector(), out var res))
                 return res;
 
             return _defaultSource;

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

@@ -342,8 +342,7 @@ namespace System.Reactive.Linq.ObservableImpl
 
         public bool Remove(TKey key)
         {
-            var value = default(TValue);
-            return _map.TryRemove(key, out value);
+            return _map.TryRemove(key, out var value);
         }
     }
 }

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

@@ -51,8 +51,7 @@ namespace System.Reactive.Linq.ObservableImpl
         {
             if (!_done)
             {
-                var current = default(TResult);
-                if (TryMoveNext(out current))
+                if (TryMoveNext(out var current))
                 {
                     Current = current;
                     return true;

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

@@ -84,7 +84,7 @@ namespace System.Reactive.Linq.ObservableImpl
                     }
 
                     if (timerWins)
-                        _subscription.Disposable = _other.SubscribeSafe(this.GetForwarder());
+                        _subscription.Disposable = _other.SubscribeSafe(GetForwarder());
 
                     return Disposable.Empty;
                 }
@@ -214,7 +214,7 @@ namespace System.Reactive.Linq.ObservableImpl
                     }
 
                     if (timerWins)
-                        _subscription.Disposable = _other.SubscribeSafe(this.GetForwarder());
+                        _subscription.Disposable = _other.SubscribeSafe(GetForwarder());
                 }
 
                 public void OnNext(TSource value)

+ 1 - 5
Rx.NET/Source/src/System.Reactive/Linq/QueryLanguage.Events.cs

@@ -264,11 +264,7 @@ namespace System.Reactive.Linq
 
         private static IObservable<TResult> FromEventPattern_<TSender, TEventArgs, TResult>(Type targetType, object target, string eventName, Func<TSender, TEventArgs, TResult> getResult, IScheduler scheduler)
         {
-            var addMethod = default(MethodInfo);
-            var removeMethod = default(MethodInfo);
-            var delegateType = default(Type);
-            var isWinRT = default(bool);
-            ReflectionUtils.GetEventMethods<TSender, TEventArgs>(targetType, target, eventName, out addMethod, out removeMethod, out delegateType, out isWinRT);
+            ReflectionUtils.GetEventMethods<TSender, TEventArgs>(targetType, target, eventName, out var addMethod, out var removeMethod, out var delegateType, out var isWinRT);
 
 #if HAS_WINRT
             if (isWinRT)

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

@@ -291,7 +291,7 @@ namespace System.Reactive.Subjects
             //
             // [OK] Use of unsafe Subscribe: this type's Subscribe implementation is safe.
             //
-            this.Subscribe/*Unsafe*/(new AwaitObserver(continuation, originalContext));
+            Subscribe/*Unsafe*/(new AwaitObserver(continuation, originalContext));
         }
 
         private sealed class AwaitObserver : IObserver<T>

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

@@ -81,7 +81,7 @@ namespace System.Reactive
                 return false;
 
             var other = (TimeInterval<T>)obj;
-            return this.Equals(other);
+            return Equals(other);
         }
 
         /// <summary>

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

@@ -82,7 +82,7 @@ namespace System.Reactive
                 return false;
 
             var other = (Timestamped<T>)obj;
-            return this.Equals(other);
+            return Equals(other);
         }
 
         /// <summary>

+ 1 - 1
Rx.NET/Source/tests/Tests.System.Reactive/MockEnumerable.cs

@@ -23,7 +23,7 @@ namespace ReactiveTests
             if (underlyingEnumerable == null)
                 throw new ArgumentNullException(nameof(underlyingEnumerable));
 
-            this.Scheduler = scheduler;
+            Scheduler = scheduler;
             this.underlyingEnumerable = underlyingEnumerable;
         }
 

+ 2 - 6
Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/DefaultSchedulerTest.cs

@@ -97,9 +97,7 @@ namespace ReactiveTests.Tests
         [Fact]
         public void No_ThreadPool_Starvation_Dispose()
         {
-            var bwt = default(int);
-            var bio = default(int);
-            ThreadPool.GetAvailableThreads(out bwt, out bio);
+            ThreadPool.GetAvailableThreads(out var bwt, out var bio);
 
             var N = Environment.ProcessorCount * 2;
 
@@ -113,9 +111,7 @@ namespace ReactiveTests.Tests
                 f.Set();
             }
 
-            var ewt = default(int);
-            var eio = default(int);
-            ThreadPool.GetAvailableThreads(out ewt, out eio);
+            ThreadPool.GetAvailableThreads(out var ewt, out var eio);
 
             Assert.False(bwt - ewt >= N);
         }

+ 1 - 2
Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/SchedulerTest.cs

@@ -1046,8 +1046,7 @@ namespace ReactiveTests.Tests
 
             public object GetService(Type serviceType)
             {
-                var res = default(object);
-                if (_services.TryGetValue(serviceType, out res))
+                if (_services.TryGetValue(serviceType, out var res))
                     return res;
 
                 return null;

+ 2 - 7
Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/ThreadPoolSchedulerTest.cs

@@ -298,9 +298,7 @@ namespace ReactiveTests.Tests
         [Fact]
         public void No_ThreadPool_Starvation_Dispose()
         {
-            var bwt = default(int);
-            var bio = default(int);
-            ThreadPool.GetAvailableThreads(out bwt, out bio);
+            ThreadPool.GetAvailableThreads(out var bwt, out var bio);
 
             var N = Environment.ProcessorCount * 2;
 
@@ -313,10 +311,7 @@ namespace ReactiveTests.Tests
                 d.Dispose();
                 f.Set();
             }
-
-            var ewt = default(int);
-            var eio = default(int);
-            ThreadPool.GetAvailableThreads(out ewt, out eio);
+            ThreadPool.GetAvailableThreads(out var ewt, out var eio);
 
             Assert.False(bwt - ewt >= N);
         }

+ 6 - 12
Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Subjects/BehaviorSubjectTest.cs

@@ -450,8 +450,7 @@ namespace ReactiveTests.Tests
             var s = new BehaviorSubject<int>(42);
             Assert.Equal(42, s.Value);
 
-            var x = default(int);
-            Assert.True(s.TryGetValue(out x));
+            Assert.True(s.TryGetValue(out var x));
             Assert.Equal(42, x);
         }
 
@@ -461,8 +460,7 @@ namespace ReactiveTests.Tests
             var s = new BehaviorSubject<int>(42);
             Assert.Equal(42, s.Value);
 
-            var x = default(int);
-            Assert.True(s.TryGetValue(out x));
+            Assert.True(s.TryGetValue(out var x));
             Assert.Equal(42, x);
 
             s.OnNext(43);
@@ -478,8 +476,7 @@ namespace ReactiveTests.Tests
             var s = new BehaviorSubject<int>(42);
             Assert.Equal(42, s.Value);
 
-            var x = default(int);
-            Assert.True(s.TryGetValue(out x));
+            Assert.True(s.TryGetValue(out var x));
             Assert.Equal(42, x);
 
             s.OnNext(43);
@@ -501,8 +498,7 @@ namespace ReactiveTests.Tests
             var s = new BehaviorSubject<int>(42);
             Assert.Equal(42, s.Value);
 
-            var x = default(int);
-            Assert.True(s.TryGetValue(out x));
+            Assert.True(s.TryGetValue(out var x));
             Assert.Equal(42, x);
 
             s.OnNext(43);
@@ -545,8 +541,7 @@ namespace ReactiveTests.Tests
 
             ReactiveAssert.Throws<InvalidOperationException>(() =>
             {
-                var x = default(int);
-                s.TryGetValue(out x);
+                s.TryGetValue(out var x);
             });
         }
 
@@ -563,8 +558,7 @@ namespace ReactiveTests.Tests
                 var ignored = s.Value;
             });
 
-            var x = default(int);
-            Assert.False(s.TryGetValue(out x));
+            Assert.False(s.TryGetValue(out var x));
         }
     }
 }

+ 1 - 2
Rx.NET/Source/tests/Tests.System.Reactive/Tests/MySubject.cs

@@ -24,8 +24,7 @@ namespace ReactiveTests.Tests
         {
             _observer.OnNext(value);
 
-            IDisposable disconnect;
-            if (_disposeOn.TryGetValue(value, out disconnect))
+            if (_disposeOn.TryGetValue(value, out var disconnect))
                 disconnect.Dispose();
         }
 

+ 2 - 2
Rx.NET/Source/tests/Tests.System.Reactive/Tests/PrivateTypesTest.cs

@@ -211,7 +211,7 @@ namespace ReactiveTests.Tests
             public bool Equals(Left other)
             {
                 var equ = _value.GetType().GetMethods().Where(m => m.Name == nameof(Equals) && m.GetParameters()[0].ParameterType != typeof(object)).Single();
-                return (bool)equ.Invoke(_value, new object[] { other == null ? null : other._value });
+                return (bool)equ.Invoke(_value, new object[] { other?._value });
             }
         }
 
@@ -233,7 +233,7 @@ namespace ReactiveTests.Tests
             public bool Equals(Right other)
             {
                 var equ = _value.GetType().GetMethods().Where(m => m.Name == nameof(Equals) && m.GetParameters()[0].ParameterType != typeof(object)).Single();
-                return (bool)equ.Invoke(_value, new object[] { other == null ? null : other._value });
+                return (bool)equ.Invoke(_value, new object[] { other?._value });
             }
         }
     }