소스 검색

Fix naming of static readonly fields as suggested by .editorconfig and ReSharper.

Daniel Weber 7 년 전
부모
커밋
93aa64653b

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

@@ -12,7 +12,7 @@ namespace System.Reactive.Concurrency
     /// <seealso cref="Scheduler.CurrentThread">Singleton instance of this type exposed through this static property.</seealso>
     public sealed class CurrentThreadScheduler : LocalScheduler
     {
-        private static readonly Lazy<CurrentThreadScheduler> _staticInstance = new Lazy<CurrentThreadScheduler>(() => new CurrentThreadScheduler());
+        private static readonly Lazy<CurrentThreadScheduler> StaticInstance = new Lazy<CurrentThreadScheduler>(() => new CurrentThreadScheduler());
 
         private CurrentThreadScheduler()
         {
@@ -21,7 +21,7 @@ namespace System.Reactive.Concurrency
         /// <summary>
         /// Gets the singleton instance of the current thread scheduler.
         /// </summary>
-        public static CurrentThreadScheduler Instance => _staticInstance.Value;
+        public static CurrentThreadScheduler Instance => StaticInstance.Value;
 
         [ThreadStatic]
         private static SchedulerQueue<TimeSpan> _threadLocalQueue;

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

@@ -13,7 +13,7 @@ namespace System.Reactive.Concurrency
     public sealed class DefaultScheduler : LocalScheduler, ISchedulerPeriodic
     {
         private static readonly Lazy<DefaultScheduler> _instance = new Lazy<DefaultScheduler>(() => new DefaultScheduler());
-        private static readonly IConcurrencyAbstractionLayer _cal = ConcurrencyAbstractionLayer.Current;
+        private static readonly IConcurrencyAbstractionLayer Cal = ConcurrencyAbstractionLayer.Current;
 
         /// <summary>
         /// Gets the singleton instance of the default scheduler.
@@ -41,7 +41,7 @@ namespace System.Reactive.Concurrency
 
             var workItem = new UserWorkItem<TState>(this, state, action);
 
-            workItem.CancelQueueDisposable = _cal.QueueUserWorkItem(
+            workItem.CancelQueueDisposable = Cal.QueueUserWorkItem(
                 closureWorkItem => ((UserWorkItem<TState>)closureWorkItem).Run(),
                 workItem);
 
@@ -72,7 +72,7 @@ namespace System.Reactive.Concurrency
 
             var workItem = new UserWorkItem<TState>(this, state, action);
 
-            workItem.CancelQueueDisposable = _cal.StartTimer(
+            workItem.CancelQueueDisposable = Cal.StartTimer(
                 closureWorkItem => ((UserWorkItem<TState>)closureWorkItem).Run(),
                 workItem,
                 dt);
@@ -117,7 +117,7 @@ namespace System.Reactive.Concurrency
                 _state = state;
                 _action = action;
 
-                _cancel = _cal.StartPeriodicTimer(Tick, period);
+                _cancel = Cal.StartPeriodicTimer(Tick, period);
             }
 
             private void Tick()
@@ -145,7 +145,7 @@ namespace System.Reactive.Concurrency
         {
             if (serviceType == typeof(ISchedulerLongRunning))
             {
-                if (_cal.SupportsLongRunning)
+                if (Cal.SupportsLongRunning)
                 {
                     return LongRunning.Instance;
                 }
@@ -168,7 +168,7 @@ namespace System.Reactive.Concurrency
                     _state = state;
                     _action = action;
 
-                    _cal.StartThread(
+                    Cal.StartThread(
                         thisObject =>
                         {
                             var @this = (LongScheduledWorkItem<TState>)thisObject;

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

@@ -14,26 +14,26 @@ namespace System.Reactive.Concurrency
         /// <summary>
         /// Gate to protect local scheduler queues.
         /// </summary>
-        private static readonly object _gate = new object();
+        private static readonly object Gate = new object();
 
         /// <summary>
         /// Gate to protect queues and to synchronize scheduling decisions and system clock
         /// change management.
         /// </summary>
-        private static readonly object _staticGate = new object();
+        private static readonly object StaticGate = new object();
 
         /// <summary>
         /// Long term work queue. Contains work that's due beyond SHORTTERM, computed at the
         /// time of enqueueing.
         /// </summary>
-        private static readonly PriorityQueue<WorkItem/*!*/> _longTerm = new PriorityQueue<WorkItem/*!*/>();
+        private static readonly PriorityQueue<WorkItem/*!*/> LongTerm = new PriorityQueue<WorkItem/*!*/>();
 
         /// <summary>
         /// Disposable resource for the long term timer that will reevaluate and dispatch the
         /// first item in the long term queue. A serial disposable is used to make "dispose
         /// current and assign new" logic easier. The disposable itself is never disposed.
         /// </summary>
-        private static readonly SerialDisposable _nextLongTermTimer = new SerialDisposable();
+        private static readonly SerialDisposable NextLongTermTimer = new SerialDisposable();
 
         /// <summary>
         /// Item at the head of the long term queue for which the current long term timer is
@@ -173,7 +173,7 @@ namespace System.Reactive.Concurrency
         /// <param name="item">Work item to schedule in the short term. The caller is responsible to determine the work is indeed short term.</param>
         private void ScheduleShortTermWork(WorkItem/*!*/ item)
         {
-            lock (_gate)
+            lock (Gate)
             {
                 _shortTerm.Enqueue(item);
 
@@ -209,7 +209,7 @@ namespace System.Reactive.Concurrency
         {
             var next = default(WorkItem);
 
-            lock (_gate)
+            lock (Gate)
             {
                 //
                 // Notice that even though we try to cancel all work in the short term queue upon a
@@ -277,9 +277,9 @@ namespace System.Reactive.Concurrency
         /// <param name="item">Work item to schedule on the long term. The caller is responsible to determine the work is indeed long term.</param>
         private static void ScheduleLongTermWork(WorkItem/*!*/ item)
         {
-            lock (_staticGate)
+            lock (StaticGate)
             {
-                _longTerm.Enqueue(item);
+                LongTerm.Enqueue(item);
 
                 //
                 // In case we're the first long-term item in the queue now, the timer will have
@@ -301,7 +301,7 @@ namespace System.Reactive.Concurrency
              * 
             lock (s_gate) */
             {
-                if (_longTerm.Count == 0)
+                if (LongTerm.Count == 0)
                 {
                     return;
                 }
@@ -310,7 +310,7 @@ namespace System.Reactive.Concurrency
                 // To avoid setting the timer all over again for the first work item if it hasn't changed,
                 // we keep track of the next long term work item that will be processed by the timer.
                 //
-                var next = _longTerm.Peek();
+                var next = LongTerm.Peek();
                 if (next == _nextLongTermWorkItem)
                 {
                     return;
@@ -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);
             }
         }
 
@@ -343,13 +343,13 @@ namespace System.Reactive.Concurrency
         /// </summary>
         private static void EvaluateLongTermQueue()
         {
-            lock (_staticGate)
+            lock (StaticGate)
             {
                 var next = default(WorkItem);
 
-                while (_longTerm.Count > 0)
+                while (LongTerm.Count > 0)
                 {
-                    next = _longTerm.Peek();
+                    next = LongTerm.Peek();
 
                     var due = Scheduler.Normalize(next.DueTime - next.Scheduler.Now);
                     if (due >= ShortTerm)
@@ -357,7 +357,7 @@ namespace System.Reactive.Concurrency
                         break;
                     }
 
-                    var item = _longTerm.Dequeue();
+                    var item = LongTerm.Dequeue();
                     item.Scheduler.ScheduleShortTermWork(item);
                 }
 
@@ -374,9 +374,9 @@ namespace System.Reactive.Concurrency
         /// <param name="sender">Currently not used.</param>
         internal void SystemClockChanged(object sender, SystemClockChangedEventArgs args)
         {
-            lock (_staticGate)
+            lock (StaticGate)
             {
-                lock (_gate)
+                lock (Gate)
                 {
                     //
                     // Best-effort cancellation of short term work. A check for presence in the hash set
@@ -399,7 +399,7 @@ namespace System.Reactive.Concurrency
                     while (_shortTerm.Count > 0)
                     {
                         var next = _shortTerm.Dequeue();
-                        _longTerm.Enqueue(next);
+                        LongTerm.Enqueue(next);
                     }
 
                     //

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

@@ -9,15 +9,15 @@ namespace System.Reactive
 {
     internal static class ExceptionHelpers
     {
-        private static readonly Lazy<IExceptionServices> _services = new Lazy<IExceptionServices>(Initialize);
+        private static readonly Lazy<IExceptionServices> Services = new Lazy<IExceptionServices>(Initialize);
 
-        public static void Throw(this Exception exception) => _services.Value.Rethrow(exception);
+        public static void Throw(this Exception exception) => Services.Value.Rethrow(exception);
 
         public static void ThrowIfNotNull(this Exception exception)
         {
             if (exception != null)
             {
-                _services.Value.Rethrow(exception);
+                Services.Value.Rethrow(exception);
             }
         }
 

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

@@ -13,7 +13,7 @@ namespace System.Reactive.PlatformServices
     [EditorBrowsable(EditorBrowsableState.Never)]
     public static class HostLifecycleService
     {
-        private static readonly Lazy<IHostLifecycleNotifications> _notifications = new Lazy<IHostLifecycleNotifications>(InitializeNotifications);
+        private static readonly Lazy<IHostLifecycleNotifications> Notifications = new Lazy<IHostLifecycleNotifications>(InitializeNotifications);
 
         private static int _refCount;
 
@@ -34,7 +34,7 @@ namespace System.Reactive.PlatformServices
         {
             if (Interlocked.Increment(ref _refCount) == 1)
             {
-                var notifications = _notifications.Value;
+                var notifications = Notifications.Value;
                 if (notifications != null)
                 {
                     notifications.Suspending += OnSuspending;
@@ -51,7 +51,7 @@ namespace System.Reactive.PlatformServices
         {
             if (Interlocked.Decrement(ref _refCount) == 0)
             {
-                var notifications = _notifications.Value;
+                var notifications = Notifications.Value;
                 if (notifications != null)
                 {
                     notifications.Suspending -= OnSuspending;

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

@@ -8,9 +8,9 @@ namespace System.Reactive.Linq
 {
     internal static class QueryServices
     {
-        private static readonly IQueryServices _services = Initialize();
+        private static readonly IQueryServices Services = Initialize();
 
-        public static T GetQueryImpl<T>(T defaultInstance) => _services.Extend(defaultInstance);
+        public static T GetQueryImpl<T>(T defaultInstance) => Services.Extend(defaultInstance);
 
         private static IQueryServices Initialize()
         {

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

@@ -19,9 +19,9 @@ namespace System.Reactive.PlatformServices
     [EditorBrowsable(EditorBrowsableState.Never)]
     public static class SystemClock
     {
-        private static readonly Lazy<ISystemClock> _serviceSystemClock = new Lazy<ISystemClock>(InitializeSystemClock);
-        private static readonly Lazy<INotifySystemClockChanged> _serviceSystemClockChanged = new Lazy<INotifySystemClockChanged>(InitializeSystemClockChanged);
-        private static readonly HashSet<WeakReference<LocalScheduler>> _systemClockChanged = new HashSet<WeakReference<LocalScheduler>>();
+        private static readonly Lazy<ISystemClock> ServiceSystemClock = new Lazy<ISystemClock>(InitializeSystemClock);
+        private static readonly Lazy<INotifySystemClockChanged> ServiceSystemClockChanged = new Lazy<INotifySystemClockChanged>(InitializeSystemClockChanged);
+        private static readonly HashSet<WeakReference<LocalScheduler>> SystemClockChanged = new HashSet<WeakReference<LocalScheduler>>();
         private static IDisposable _systemClockChangedHandlerCollector;
 
         private static int _refCount;
@@ -29,7 +29,7 @@ namespace System.Reactive.PlatformServices
         /// <summary>
         /// Gets the local system clock time.
         /// </summary>
-        public static DateTimeOffset UtcNow => _serviceSystemClock.Value.UtcNow;
+        public static DateTimeOffset UtcNow => ServiceSystemClock.Value.UtcNow;
 
         /// <summary>
         /// Adds a reference to the system clock monitor, causing it to be sending notifications.
@@ -39,7 +39,7 @@ namespace System.Reactive.PlatformServices
         {
             if (Interlocked.Increment(ref _refCount) == 1)
             {
-                _serviceSystemClockChanged.Value.SystemClockChanged += OnSystemClockChanged;
+                ServiceSystemClockChanged.Value.SystemClockChanged += OnSystemClockChanged;
             }
         }
 
@@ -51,15 +51,15 @@ namespace System.Reactive.PlatformServices
         {
             if (Interlocked.Decrement(ref _refCount) == 0)
             {
-                _serviceSystemClockChanged.Value.SystemClockChanged -= OnSystemClockChanged;
+                ServiceSystemClockChanged.Value.SystemClockChanged -= OnSystemClockChanged;
             }
         }
 
         private static void OnSystemClockChanged(object sender, SystemClockChangedEventArgs e)
         {
-            lock (_systemClockChanged)
+            lock (SystemClockChanged)
             {
-                foreach (var entry in _systemClockChanged)
+                foreach (var entry in SystemClockChanged)
                 {
                     if (entry.TryGetTarget(out var scheduler))
                     {
@@ -93,15 +93,15 @@ namespace System.Reactive.PlatformServices
             // can have a lot of instances, so we need to collect spurious handlers
             // at regular times.
             //
-            lock (_systemClockChanged)
+            lock (SystemClockChanged)
             {
-                _systemClockChanged.Add(new WeakReference<LocalScheduler>(scheduler));
+                SystemClockChanged.Add(new WeakReference<LocalScheduler>(scheduler));
 
-                if (_systemClockChanged.Count == 1)
+                if (SystemClockChanged.Count == 1)
                 {
                     _systemClockChangedHandlerCollector = ConcurrencyAbstractionLayer.Current.StartPeriodicTimer(CollectHandlers, TimeSpan.FromSeconds(30));
                 }
-                else if (_systemClockChanged.Count % 64 == 0)
+                else if (SystemClockChanged.Count % 64 == 0)
                 {
                     CollectHandlers();
                 }
@@ -117,11 +117,11 @@ namespace System.Reactive.PlatformServices
             // the ConditionalWeakTable<TKey, TValue> type here because we need to
             // be able to enumerate the keys.
             //
-            lock (_systemClockChanged)
+            lock (SystemClockChanged)
             {
                 var remove = default(HashSet<WeakReference<LocalScheduler>>);
 
-                foreach (var handler in _systemClockChanged)
+                foreach (var handler in SystemClockChanged)
                 {
                     if (!handler.TryGetTarget(out _))
                     {
@@ -138,11 +138,11 @@ namespace System.Reactive.PlatformServices
                 {
                     foreach (var handler in remove)
                     {
-                        _systemClockChanged.Remove(handler);
+                        SystemClockChanged.Remove(handler);
                     }
                 }
 
-                if (_systemClockChanged.Count == 0)
+                if (SystemClockChanged.Count == 0)
                 {
                     _systemClockChangedHandlerCollector.Dispose();
                     _systemClockChangedHandlerCollector = null;

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

@@ -364,7 +364,7 @@ namespace System.Reactive
                 }
             }
 
-            private static readonly Lazy<ILookup<string, MethodInfo>> _observableMethods = new Lazy<ILookup<string, MethodInfo>>(() => GetMethods(typeof(Observable)));
+            private static readonly Lazy<ILookup<string, MethodInfo>> ObservableMethods = new Lazy<ILookup<string, MethodInfo>>(() => GetMethods(typeof(Observable)));
 
             private static MethodCallExpression FindObservableMethod(MethodInfo method, IList<Expression> arguments)
             {
@@ -376,7 +376,7 @@ namespace System.Reactive
                 if (method.DeclaringType == typeof(Qbservable))
                 {
                     targetType = typeof(Observable);
-                    methods = _observableMethods.Value;
+                    methods = ObservableMethods.Value;
                 }
                 else
                 {