Browse Source

Seal some types.

Bart De Smet 5 years ago
parent
commit
647e6756ab

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

@@ -7,7 +7,7 @@ using System.Threading;
 
 namespace System.Reactive.Concurrency
 {
-    internal class /*Default*/ConcurrencyAbstractionLayerImpl : IConcurrencyAbstractionLayer
+    internal sealed class /*Default*/ConcurrencyAbstractionLayerImpl : IConcurrencyAbstractionLayer
     {
         public IDisposable StartTimer(Action<object?> action, object? state, TimeSpan dueTime)
         {

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

@@ -13,7 +13,7 @@ namespace System.Reactive.Concurrency
     //          Another copy is kept in System.Reactive.PlatformServices to enlighten the default lowest common denominator
     //          behavior of Rx for PLIB when used on a more capable platform.
     //
-    internal class /*Default*/ConcurrencyAbstractionLayerImpl : IConcurrencyAbstractionLayer
+    internal sealed class /*Default*/ConcurrencyAbstractionLayerImpl : IConcurrencyAbstractionLayer
     {
         private sealed class WorkItem
         {

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

@@ -12,7 +12,7 @@ namespace System.Reactive.PlatformServices
     //          Another copy is kept in System.Reactive.PlatformServices to enlighten the default lowest common denominator
     //          behavior of Rx for PLIB when used on a more capable platform.
     //
-    internal class DefaultExceptionServices/*Impl*/ : IExceptionServices
+    internal sealed class DefaultExceptionServices/*Impl*/ : IExceptionServices
     {
 #pragma warning disable CS8763 // NB: On down-level platforms, Throw is not marked as DoesNotReturn.
         [DoesNotReturn]

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

@@ -12,7 +12,7 @@ namespace System.Reactive.PlatformServices
     //          Another copy is kept in System.Reactive.PlatformServices to enlighten the default lowest common denominator
     //          behavior of Rx for PLIB when used on a more capable platform.
     //
-    internal class /*Default*/ExceptionServicesImpl : IExceptionServices
+    internal sealed class /*Default*/ExceptionServicesImpl : IExceptionServices
     {
 #pragma warning disable CS8763 // NB: On down-level platforms, Throw is not marked as DoesNotReturn.
         [DoesNotReturn]

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

@@ -8,7 +8,7 @@ using Windows.ApplicationModel.Core;
 
 namespace System.Reactive.PlatformServices
 {
-    internal class HostLifecycleNotifications : IHostLifecycleNotifications
+    internal sealed class HostLifecycleNotifications : IHostLifecycleNotifications
     {
         private EventHandler<SuspendingEventArgs>? _suspending;
         private EventHandler<object>? _resuming;

+ 16 - 16
Rx.NET/Source/src/System.Reactive/Joins/ActivePlan.cs

@@ -36,7 +36,7 @@ namespace System.Reactive.Joins
         }
     }
 
-    internal class ActivePlan<T1> : ActivePlan
+    internal sealed class ActivePlan<T1> : ActivePlan
     {
         private readonly Action<T1> _onNext;
         private readonly JoinObserver<T1> _first;
@@ -67,7 +67,7 @@ namespace System.Reactive.Joins
         }
     }
 
-    internal class ActivePlan<T1, T2> : ActivePlan
+    internal sealed class ActivePlan<T1, T2> : ActivePlan
     {
         private readonly Action<T1, T2> _onNext;
         private readonly JoinObserver<T1> _first;
@@ -106,7 +106,7 @@ namespace System.Reactive.Joins
         }
     }
 
-    internal class ActivePlan<T1, T2, T3> : ActivePlan
+    internal sealed class ActivePlan<T1, T2, T3> : ActivePlan
     {
         private readonly Action<T1, T2, T3> _onNext;
         private readonly JoinObserver<T1> _first;
@@ -152,7 +152,7 @@ namespace System.Reactive.Joins
         }
     }
 
-    internal class ActivePlan<T1, T2, T3, T4> : ActivePlan
+    internal sealed class ActivePlan<T1, T2, T3, T4> : ActivePlan
     {
         private readonly Action<T1, T2, T3, T4> _onNext;
         private readonly JoinObserver<T1> _first;
@@ -205,7 +205,7 @@ namespace System.Reactive.Joins
         }
     }
 
-    internal class ActivePlan<T1, T2, T3, T4, T5> : ActivePlan
+    internal sealed class ActivePlan<T1, T2, T3, T4, T5> : ActivePlan
     {
         private readonly Action<T1, T2, T3, T4, T5> _onNext;
         private readonly JoinObserver<T1> _first;
@@ -266,7 +266,7 @@ namespace System.Reactive.Joins
         }
     }
 
-    internal class ActivePlan<T1, T2, T3, T4, T5, T6> : ActivePlan
+    internal sealed class ActivePlan<T1, T2, T3, T4, T5, T6> : ActivePlan
     {
         private readonly Action<T1, T2, T3, T4, T5, T6> _onNext;
         private readonly JoinObserver<T1> _first;
@@ -335,7 +335,7 @@ namespace System.Reactive.Joins
         }
     }
 
-    internal class ActivePlan<T1, T2, T3, T4, T5, T6, T7> : ActivePlan
+    internal sealed class ActivePlan<T1, T2, T3, T4, T5, T6, T7> : ActivePlan
     {
         private readonly Action<T1, T2, T3, T4, T5, T6, T7> _onNext;
         private readonly JoinObserver<T1> _first;
@@ -411,7 +411,7 @@ namespace System.Reactive.Joins
         }
     }
 
-    internal class ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8> : ActivePlan
+    internal sealed class ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8> : ActivePlan
     {
         private readonly Action<T1, T2, T3, T4, T5, T6, T7, T8> _onNext;
         private readonly JoinObserver<T1> _first;
@@ -496,7 +496,7 @@ namespace System.Reactive.Joins
         }
     }
 
-    internal class ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9> : ActivePlan
+    internal sealed class ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9> : ActivePlan
     {
         private readonly Action<T1, T2, T3, T4, T5, T6, T7, T8, T9> _onNext;
         private readonly JoinObserver<T1> _first;
@@ -589,7 +589,7 @@ namespace System.Reactive.Joins
         }
     }
 
-    internal class ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> : ActivePlan
+    internal sealed class ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> : ActivePlan
     {
         private readonly Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> _onNext;
         private readonly JoinObserver<T1> _first;
@@ -689,7 +689,7 @@ namespace System.Reactive.Joins
         }
     }
 
-    internal class ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> : ActivePlan
+    internal sealed class ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> : ActivePlan
     {
         private readonly Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> _onNext;
         private readonly JoinObserver<T1> _first;
@@ -796,7 +796,7 @@ namespace System.Reactive.Joins
         }
     }
 
-    internal class ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> : ActivePlan
+    internal sealed class ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> : ActivePlan
     {
         private readonly Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> _onNext;
         private readonly JoinObserver<T1> _first;
@@ -911,7 +911,7 @@ namespace System.Reactive.Joins
         }
     }
 
-    internal class ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> : ActivePlan
+    internal sealed class ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> : ActivePlan
     {
         private readonly Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> _onNext;
         private readonly JoinObserver<T1> _first;
@@ -1033,7 +1033,7 @@ namespace System.Reactive.Joins
         }
     }
 
-    internal class ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> : ActivePlan
+    internal sealed class ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> : ActivePlan
     {
         private readonly Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> _onNext;
         private readonly JoinObserver<T1> _first;
@@ -1162,7 +1162,7 @@ namespace System.Reactive.Joins
         }
     }
 
-    internal class ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> : ActivePlan
+    internal sealed class ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> : ActivePlan
     {
         private readonly Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> _onNext;
         private readonly JoinObserver<T1> _first;
@@ -1299,7 +1299,7 @@ namespace System.Reactive.Joins
         }
     }
 
-    internal class ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> : ActivePlan
+    internal sealed class ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> : ActivePlan
     {
         private readonly Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> _onNext;
         private readonly JoinObserver<T1> _first;

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

@@ -38,7 +38,7 @@ namespace System.Reactive.Joins
         }
     }
 
-    internal class Plan<T1, TResult> : Plan<TResult>
+    internal sealed class Plan<T1, TResult> : Plan<TResult>
     {
         internal Pattern<T1> Expression { get; }
 
@@ -83,7 +83,7 @@ namespace System.Reactive.Joins
         }
     }
 
-    internal class Plan<T1, T2, TResult> : Plan<TResult>
+    internal sealed class Plan<T1, T2, TResult> : Plan<TResult>
     {
         internal Pattern<T1, T2> Expression { get; }
 
@@ -131,7 +131,7 @@ namespace System.Reactive.Joins
         }
     }
 
-    internal class Plan<T1, T2, T3, TResult> : Plan<TResult>
+    internal sealed class Plan<T1, T2, T3, TResult> : Plan<TResult>
     {
         internal Pattern<T1, T2, T3> Expression { get; }
 
@@ -183,7 +183,7 @@ namespace System.Reactive.Joins
         }
     }
 
-    internal class Plan<T1, T2, T3, T4, TResult> : Plan<TResult>
+    internal sealed class Plan<T1, T2, T3, T4, TResult> : Plan<TResult>
     {
         internal Pattern<T1, T2, T3, T4> Expression { get; }
 
@@ -238,7 +238,7 @@ namespace System.Reactive.Joins
         }
     }
 
-    internal class Plan<T1, T2, T3, T4, T5, TResult> : Plan<TResult>
+    internal sealed class Plan<T1, T2, T3, T4, T5, TResult> : Plan<TResult>
     {
         internal Pattern<T1, T2, T3, T4, T5> Expression { get; }
 
@@ -296,7 +296,7 @@ namespace System.Reactive.Joins
         }
     }
 
-    internal class Plan<T1, T2, T3, T4, T5, T6, TResult> : Plan<TResult>
+    internal sealed class Plan<T1, T2, T3, T4, T5, T6, TResult> : Plan<TResult>
     {
         internal Pattern<T1, T2, T3, T4, T5, T6> Expression { get; }
 
@@ -358,7 +358,7 @@ namespace System.Reactive.Joins
         }
     }
 
-    internal class Plan<T1, T2, T3, T4, T5, T6, T7, TResult> : Plan<TResult>
+    internal sealed class Plan<T1, T2, T3, T4, T5, T6, T7, TResult> : Plan<TResult>
     {
         internal Pattern<T1, T2, T3, T4, T5, T6, T7> Expression { get; }
 
@@ -423,7 +423,7 @@ namespace System.Reactive.Joins
         }
     }
 
-    internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, TResult> : Plan<TResult>
+    internal sealed class Plan<T1, T2, T3, T4, T5, T6, T7, T8, TResult> : Plan<TResult>
     {
         internal Pattern<T1, T2, T3, T4, T5, T6, T7, T8> Expression { get; }
 
@@ -491,7 +491,7 @@ namespace System.Reactive.Joins
         }
     }
 
-    internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult> : Plan<TResult>
+    internal sealed class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult> : Plan<TResult>
     {
         internal Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9> Expression { get; }
 
@@ -562,7 +562,7 @@ namespace System.Reactive.Joins
         }
     }
 
-    internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult> : Plan<TResult>
+    internal sealed class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult> : Plan<TResult>
     {
         internal Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> Expression { get; }
 
@@ -636,7 +636,7 @@ namespace System.Reactive.Joins
         }
     }
 
-    internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult> : Plan<TResult>
+    internal sealed class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult> : Plan<TResult>
     {
         internal Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Expression { get; }
 
@@ -714,7 +714,7 @@ namespace System.Reactive.Joins
         }
     }
 
-    internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult> : Plan<TResult>
+    internal sealed class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult> : Plan<TResult>
     {
         internal Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Expression { get; }
 
@@ -797,7 +797,7 @@ namespace System.Reactive.Joins
     }
 
 
-    internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TResult> : Plan<TResult>
+    internal sealed class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TResult> : Plan<TResult>
     {
         internal Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> Expression { get; }
 
@@ -883,7 +883,7 @@ namespace System.Reactive.Joins
     }
 
 
-    internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TResult> : Plan<TResult>
+    internal sealed class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TResult> : Plan<TResult>
     {
         internal Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> Expression { get; }
 
@@ -975,7 +975,7 @@ namespace System.Reactive.Joins
         }
     }
 
-    internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TResult> : Plan<TResult>
+    internal sealed class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TResult> : Plan<TResult>
     {
         internal Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> Expression { get; }
 
@@ -1069,7 +1069,7 @@ namespace System.Reactive.Joins
             return activePlan;
         }
     }
-    internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TResult> : Plan<TResult>
+    internal sealed class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TResult> : Plan<TResult>
     {
         internal Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> Expression { get; }
 

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

@@ -73,18 +73,7 @@ namespace System.Reactive
 
         private static MethodInfo? _staticAsQueryable;
 
-        private static MethodInfo AsQueryable
-        {
-            get
-            {
-                if (_staticAsQueryable == null)
-                {
-                    _staticAsQueryable = Qbservable.InfoOf<object>(() => Queryable.AsQueryable<object>(null)).GetGenericMethodDefinition();
-                }
-
-                return _staticAsQueryable;
-            }
-        }
+        private static MethodInfo AsQueryable => _staticAsQueryable ??=  Qbservable.InfoOf<object>(() => Queryable.AsQueryable<object>(null!)).GetGenericMethodDefinition();
 
         IQueryable IQueryProvider.CreateQuery(Expression expression)
         {

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

@@ -11,7 +11,7 @@ namespace System.Reactive.Subjects
     /// </summary>
     /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
     /// <typeparam name="TResult">The type of the elements in the resulting sequence, after transformation through the subject.</typeparam>
-    internal class ConnectableObservable<TSource, TResult> : IConnectableObservable<TResult>
+    internal sealed class ConnectableObservable<TSource, TResult> : IConnectableObservable<TResult>
     {
         private readonly ISubject<TSource, TResult> _subject;
         private readonly IObservable<TSource> _source;