ソースを参照

Merge pull request #740 from danielcweber/RemoveRedundanciesInSymbolDeclarations

Remove redundancies in symbol declarations
Daniel C. Weber 7 年 前
コミット
3af72770f9

+ 1 - 0
Rx.NET/Source/Directory.build.props

@@ -25,6 +25,7 @@
   </PropertyGroup>
   
   <ItemGroup Condition="'$(IsTestProject)' != 'true' and '$(SourceLinkEnabled)' != 'false'">
+    <PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.1" />
     <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta-62925-02" PrivateAssets="All"/>
   </ItemGroup>   
   

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

@@ -75,7 +75,6 @@ namespace System.Reactive.Concurrency
         /// Creates a new historical scheduler with the minimum value of <see cref="DateTimeOffset"/> as the initial clock value.
         /// </summary>
         public HistoricalScheduler()
-            : base()
         {
         }
 

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

@@ -333,7 +333,7 @@ namespace System.Reactive.Concurrency
                 var dueCapped = TimeSpan.FromTicks(Math.Min(dueEarly.Ticks, MAXSUPPORTEDTIMER.Ticks));
 
                 _nextLongTermWorkItem = next;
-                _nextLongTermTimer.Disposable = ConcurrencyAbstractionLayer.Current.StartTimer(_ => EvaluateLongTermQueue(_), null, dueCapped);
+                _nextLongTermTimer.Disposable = ConcurrencyAbstractionLayer.Current.StartTimer(_ => EvaluateLongTermQueue(), null, dueCapped);
             }
         }
 
@@ -341,8 +341,7 @@ namespace System.Reactive.Concurrency
         /// Evaluates the long term queue, transitioning short term work to the short term list,
         /// and adjusting the new long term processing timer accordingly.
         /// </summary>
-        /// <param name="state">Ignored.</param>
-        private static void EvaluateLongTermQueue(object state)
+        private static void EvaluateLongTermQueue()
         {
             lock (_staticGate)
             {
@@ -408,7 +407,7 @@ namespace System.Reactive.Concurrency
                     // method to create a new timer for the new first long term item.
                     //
                     _nextLongTermWorkItem = null;
-                    EvaluateLongTermQueue(null);
+                    EvaluateLongTermQueue();
                 }
             }
         }

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

@@ -171,7 +171,7 @@ namespace System.Reactive.Concurrency
             return recursiveInvoker;
         }
 
-        private abstract class InvokeRecBaseState<TState> : IDisposable
+        private abstract class InvokeRecBaseState : IDisposable
         {
             protected readonly IScheduler Scheduler;
 
@@ -190,7 +190,7 @@ namespace System.Reactive.Concurrency
 
         }
 
-        private sealed class InvokeRec1State<TState> : InvokeRecBaseState<TState>
+        private sealed class InvokeRec1State<TState> : InvokeRecBaseState
         {
             private readonly Action<TState, Action<TState>> _action;
             private readonly Action<TState> _recurseCallback;
@@ -219,7 +219,7 @@ namespace System.Reactive.Concurrency
             }
         }
 
-        private sealed class InvokeRec2State<TState> : InvokeRecBaseState<TState>
+        private sealed class InvokeRec2State<TState> : InvokeRecBaseState
         {
             private readonly Action<TState, Action<TState, TimeSpan>> _action;
             private readonly Action<TState, TimeSpan> _recurseCallback;
@@ -247,7 +247,7 @@ namespace System.Reactive.Concurrency
             }
         }
 
-        private sealed class InvokeRec3State<TState> : InvokeRecBaseState<TState>
+        private sealed class InvokeRec3State<TState> : InvokeRecBaseState
         {
             private readonly Action<TState, Action<TState, DateTimeOffset>> _action;
             private readonly Action<TState, DateTimeOffset> _recurseCallback;

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

@@ -363,7 +363,6 @@ namespace System.Reactive.Concurrency
         /// Creates a new virtual time scheduler with the default value of TAbsolute as the initial clock value.
         /// </summary>
         protected VirtualTimeScheduler()
-            : base()
         {
         }
 

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

@@ -100,10 +100,8 @@ namespace System.Reactive
                     }
                     catch
                     {
-                        var nop = default(T);
-                        while (_queue.TryDequeue(out nop))
+                        while (_queue.TryDequeue(out _))
                         {
-                            ;
                         }
 
                         throw;
@@ -287,10 +285,8 @@ namespace System.Reactive
             {
                 Interlocked.Exchange(ref _state, FAULTED);
 
-                var nop = default(T);
-                while (_queue.TryDequeue(out nop))
+                while (_queue.TryDequeue(out _))
                 {
-                    ;
                 }
 
                 throw;

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

@@ -123,7 +123,7 @@ namespace System.Reactive.PlatformServices
 
                 foreach (var handler in _systemClockChanged)
                 {
-                    if (!handler.TryGetTarget(out var scheduler))
+                    if (!handler.TryGetTarget(out _))
                     {
                         if (remove == null)
                         {

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

@@ -407,7 +407,7 @@ namespace System.Reactive.Linq
         /// <exception cref="ArgumentOutOfRangeException"><paramref name="count"/> is less than zero. -or- <paramref name="start"/> + <paramref name="count"/> - 1 is larger than <see cref="int.MaxValue"/>.</exception>
         public static IObservable<int> Range(int start, int count)
         {
-            var max = ((long)start) + count - 1;
+            var max = (long)start + count - 1;
             if (count < 0 || max > int.MaxValue)
             {
                 throw new ArgumentOutOfRangeException(nameof(count));
@@ -427,7 +427,7 @@ namespace System.Reactive.Linq
         /// <exception cref="ArgumentNullException"><paramref name="scheduler"/> is null.</exception>
         public static IObservable<int> Range(int start, int count, IScheduler scheduler)
         {
-            var max = ((long)start) + count - 1;
+            var max = (long)start + count - 1;
             if (count < 0 || max > int.MaxValue)
             {
                 throw new ArgumentOutOfRangeException(nameof(count));

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

@@ -52,8 +52,6 @@ namespace System.Reactive.Linq.ObservableImpl
 
     internal sealed class FirstBlocking<T> : BaseBlocking<T>
     {
-        internal FirstBlocking() : base() { }
-
         public override void OnCompleted()
         {
             Unblock();
@@ -86,8 +84,6 @@ namespace System.Reactive.Linq.ObservableImpl
 
     internal sealed class LastBlocking<T> : BaseBlocking<T>
     {
-        internal LastBlocking() : base() { }
-
         public override void OnCompleted()
         {
             Unblock();

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

@@ -350,7 +350,7 @@ namespace System.Reactive.Linq.ObservableImpl
 
         public bool Remove(TKey key)
         {
-            return _map.TryRemove(key, out var value);
+            return _map.TryRemove(key, out _);
         }
     }
 }

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

@@ -29,7 +29,7 @@ namespace System.Reactive.Linq.ObservableImpl
         protected abstract PushToPullSink<TSource, TResult> Run();
     }
 
-    internal abstract class PushToPullSink<TSource, TResult> : IObserver<TSource>, IEnumerator<TResult>, IDisposable
+    internal abstract class PushToPullSink<TSource, TResult> : IObserver<TSource>, IEnumerator<TResult>
     {
         private IDisposable _upstream;
 

+ 0 - 20
Rx.NET/Source/src/System.Reactive/Runtime/CompilerServices/AsyncMethodBuilderAttribute.cs

@@ -1,20 +0,0 @@
-// 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. 
-
-namespace System.Runtime.CompilerServices
-{
-    /// <summary>
-    /// Attribute to decorate a task-like type to specify a compatible asynchronous method builder.
-    /// </summary>
-    internal sealed class AsyncMethodBuilderAttribute : Attribute
-    {
-        /// <summary>
-        /// Creates a new instance of the attribute using the specified <paramref name="type"/>.
-        /// </summary>
-        /// <param name="type">The type implementing the asynchronous method builder.</param>
-        public AsyncMethodBuilderAttribute(Type type)
-        {
-        }
-    }
-}

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

@@ -13,7 +13,7 @@ namespace System.Reactive.Subjects
     /// The last value before the OnCompleted notification, or the error received through OnError, is sent to all subscribed observers.
     /// </summary>
     /// <typeparam name="T">The type of the elements processed by the subject.</typeparam>
-    public sealed class AsyncSubject<T> : SubjectBase<T>, IDisposable, INotifyCompletion
+    public sealed class AsyncSubject<T> : SubjectBase<T>, INotifyCompletion
     {
         #region Fields
 
@@ -146,7 +146,6 @@ namespace System.Reactive.Subjects
                 _exception = error;
                 if (Interlocked.CompareExchange(ref _observers, TERMINATED, observers) == observers)
                 {
-                    var ex = _exception;
                     foreach (var o in observers)
                     {
                         if (!o.IsDisposed())

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

@@ -11,7 +11,7 @@ namespace System.Reactive.Subjects
     /// Observers can subscribe to the subject to receive the last (or initial) value and all subsequent notifications.
     /// </summary>
     /// <typeparam name="T">The type of the elements processed by the subject.</typeparam>
-    public sealed class BehaviorSubject<T> : SubjectBase<T>, IDisposable
+    public sealed class BehaviorSubject<T> : SubjectBase<T>
     {
         #region Fields
 

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

@@ -14,7 +14,7 @@ namespace System.Reactive.Subjects
     /// Each notification is broadcasted to all subscribed and future observers, subject to buffer trimming policies.
     /// </summary>
     /// <typeparam name="T">The type of the elements processed by the subject.</typeparam>
-    public sealed class ReplaySubject<T> : SubjectBase<T>, IDisposable
+    public sealed class ReplaySubject<T> : SubjectBase<T>
     {
         #region Fields
 
@@ -656,7 +656,6 @@ namespace System.Reactive.Subjects
             protected readonly Queue<T> _queue;
 
             protected ReplayManyBase(int queueSize)
-                : base()
             {
                 _queue = new Queue<T>(Math.Min(queueSize, 64));
             }

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

@@ -12,7 +12,7 @@ namespace System.Reactive.Subjects
     /// Each notification is broadcasted to all subscribed observers.
     /// </summary>
     /// <typeparam name="T">The type of the elements processed by the subject.</typeparam>
-    public sealed class Subject<T> : SubjectBase<T>, IDisposable
+    public sealed class Subject<T> : SubjectBase<T>
     {
         #region Fields
 

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

@@ -83,6 +83,7 @@ namespace System.Reactive
         TResult OnError(System.Exception exception);
         TResult OnNext(TValue value);
     }
+    [System.Runtime.CompilerServices.AsyncMethodBuilderAttribute(typeof(System.Runtime.CompilerServices.TaskObservableMethodBuilder<>))]
     public interface ITaskObservable<out T> : System.IObservable<T>
     {
         System.Reactive.ITaskObservableAwaiter<T> GetAwaiter();
@@ -2406,7 +2407,7 @@ namespace System.Reactive.PlatformServices
 }
 namespace System.Reactive.Subjects
 {
-    public sealed class AsyncSubject<T> : System.Reactive.Subjects.SubjectBase<T>, System.IDisposable, System.Runtime.CompilerServices.INotifyCompletion
+    public sealed class AsyncSubject<T> : System.Reactive.Subjects.SubjectBase<T>, System.Runtime.CompilerServices.INotifyCompletion
     {
         public AsyncSubject() { }
         public override bool HasObservers { get; }
@@ -2421,7 +2422,7 @@ namespace System.Reactive.Subjects
         public override void OnNext(T value) { }
         public override System.IDisposable Subscribe(System.IObserver<T> observer) { }
     }
-    public sealed class BehaviorSubject<T> : System.Reactive.Subjects.SubjectBase<T>, System.IDisposable
+    public sealed class BehaviorSubject<T> : System.Reactive.Subjects.SubjectBase<T>
     {
         public BehaviorSubject(T value) { }
         public override bool HasObservers { get; }
@@ -2440,7 +2441,7 @@ namespace System.Reactive.Subjects
     }
     public interface ISubject<T> : System.IObservable<T>, System.IObserver<T>, System.Reactive.Subjects.ISubject<T, T> { }
     public interface ISubject<in TSource, out TResult> : System.IObservable<TResult>, System.IObserver<TSource> { }
-    public sealed class ReplaySubject<T> : System.Reactive.Subjects.SubjectBase<T>, System.IDisposable
+    public sealed class ReplaySubject<T> : System.Reactive.Subjects.SubjectBase<T>
     {
         public ReplaySubject() { }
         public ReplaySubject(System.Reactive.Concurrency.IScheduler scheduler) { }
@@ -2467,7 +2468,7 @@ namespace System.Reactive.Subjects
         public static System.Reactive.Subjects.ISubject<TSource, TResult> Synchronize<TSource, TResult>(System.Reactive.Subjects.ISubject<TSource, TResult> subject, System.Reactive.Concurrency.IScheduler scheduler) { }
         public static System.Reactive.Subjects.ISubject<TSource> Synchronize<TSource>(System.Reactive.Subjects.ISubject<TSource> subject, System.Reactive.Concurrency.IScheduler scheduler) { }
     }
-    public sealed class Subject<T> : System.Reactive.Subjects.SubjectBase<T>, System.IDisposable
+    public sealed class Subject<T> : System.Reactive.Subjects.SubjectBase<T>
     {
         public Subject() { }
         public override bool HasObservers { get; }