Seal internal and private classes in corelib (#49958)
authorStephen Toub <stoub@microsoft.com>
Mon, 22 Mar 2021 00:47:14 +0000 (20:47 -0400)
committerGitHub <noreply@github.com>
Mon, 22 Mar 2021 00:47:14 +0000 (20:47 -0400)
* Seal private classes in corelib

* Seal internal classes in corelib

91 files changed:
src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj
src/coreclr/System.Private.CoreLib/Tools/GenUnicodeProp/TableLevels.cs
src/coreclr/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComActivator.cs
src/coreclr/System.Private.CoreLib/src/System/Collections/ObjectModel/ReadOnlyDictionary.cs [deleted file]
src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Debugger.cs
src/coreclr/System.Private.CoreLib/src/System/Diagnostics/StackFrameHelper.cs
src/coreclr/System.Private.CoreLib/src/System/OleAutBinder.cs
src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilderData.cs
src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/DynamicILGenerator.cs
src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/ISymWrapperCore.cs
src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilder.cs
src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/ModuleBuilderData.cs
src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.cs
src/coreclr/System.Private.CoreLib/src/System/Reflection/MdImport.cs
src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/CrossLoaderAllocatorHashHelpers.cs
src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/GCHeapHash.cs
src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.CoreCLR.cs
src/coreclr/System.Private.CoreLib/src/System/Runtime/InteropServices/ComEventsInfo.cs
src/coreclr/System.Private.CoreLib/src/System/Runtime/InteropServices/CustomMarshalers/EnumVariantViewOfEnumerator.cs
src/coreclr/System.Private.CoreLib/src/System/Runtime/InteropServices/CustomMarshalers/EnumerableToDispatchMarshaler.cs
src/coreclr/System.Private.CoreLib/src/System/Runtime/InteropServices/CustomMarshalers/EnumerableViewOfDispatch.cs
src/coreclr/System.Private.CoreLib/src/System/Runtime/InteropServices/CustomMarshalers/EnumeratorToEnumVariantMarshaler.cs
src/coreclr/System.Private.CoreLib/src/System/Runtime/InteropServices/CustomMarshalers/EnumeratorViewOfEnumVariant.cs
src/coreclr/System.Private.CoreLib/src/System/Runtime/InteropServices/CustomMarshalers/ExpandoToDispatchExMarshaler.cs
src/coreclr/System.Private.CoreLib/src/System/Runtime/InteropServices/CustomMarshalers/TypeToTypeInfoMarshaler.cs
src/coreclr/System.Private.CoreLib/src/System/RuntimeHandles.cs
src/coreclr/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs
src/libraries/Common/src/System/Runtime/InteropServices/ComEventsMethod.cs
src/libraries/System.Private.CoreLib/generators/EventSourceGenerator.Emitter.cs
src/libraries/System.Private.CoreLib/generators/EventSourceGenerator.Parser.cs
src/libraries/System.Private.CoreLib/generators/EventSourceGenerator.cs
src/libraries/System.Private.CoreLib/src/System/Collections/ArrayList.cs
src/libraries/System.Private.CoreLib/src/System/Collections/Hashtable.cs
src/libraries/System.Private.CoreLib/src/System/Collections/KeyValuePairs.cs
src/libraries/System.Private.CoreLib/src/System/Collections/ListDictionaryInternal.cs
src/libraries/System.Private.CoreLib/src/System/CurrentSystemTimeZone.cs
src/libraries/System.Private.CoreLib/src/System/DefaultBinder.cs
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/ActivityTracker.cs
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/CounterGroup.cs
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/CounterPayload.cs
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventCounter.cs
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/IncrementingEventCounter.cs
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/IncrementingPollingCounter.cs
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/PollingCounter.cs
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EventPayload.cs
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/FieldMetadata.cs
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingMetadataCollector.cs
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/XplatEventLogger.cs
src/libraries/System.Private.CoreLib/src/System/GCMemoryInfo.cs
src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeFormatInfo.cs
src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeFormatInfoScanner.cs
src/libraries/System.Private.CoreLib/src/System/Globalization/GregorianCalendarHelper.cs
src/libraries/System.Private.CoreLib/src/System/Globalization/HebrewCalendar.cs
src/libraries/System.Private.CoreLib/src/System/Lazy.cs
src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/EmptyCAHolder.cs
src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/TypeNameBuilder.cs
src/libraries/System.Private.CoreLib/src/System/Resources/FileBasedResourceGroveler.cs
src/libraries/System.Private.CoreLib/src/System/Resources/ResourceFallbackManager.cs
src/libraries/System.Private.CoreLib/src/System/Resources/ResourceManager.cs
src/libraries/System.Private.CoreLib/src/System/Text/CodePageDataItem.cs
src/libraries/System.Private.CoreLib/src/System/Text/Encoding.cs
src/libraries/System.Private.CoreLib/src/System/Text/StringBuilder.cs
src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.WaitThread.cs
src/libraries/System.Private.CoreLib/src/System/Threading/ReaderWriterLockSlim.cs
src/libraries/System.Private.CoreLib/src/System/Threading/SpinLock.cs
src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Future.cs
src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs
src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskExceptionHolder.cs
src/libraries/System.Private.CoreLib/src/System/Threading/ThreadLocal.cs
src/libraries/System.Private.CoreLib/src/System/ThrowHelper.cs
src/mono/System.Private.CoreLib/src/Mono/RuntimeStructs.cs
src/mono/System.Private.CoreLib/src/System/Array.Mono.cs
src/mono/System.Private.CoreLib/src/System/Diagnostics/StackTrace.Mono.cs
src/mono/System.Private.CoreLib/src/System/Reflection/CustomAttribute.cs
src/mono/System.Private.CoreLib/src/System/Reflection/CustomAttributeData.cs
src/mono/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.Mono.cs
src/mono/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs
src/mono/System.Private.CoreLib/src/System/Reflection/Emit/EventOnTypeBuilderInst.cs
src/mono/System.Private.CoreLib/src/System/Reflection/Emit/ILGenerator.Mono.cs
src/mono/System.Private.CoreLib/src/System/Reflection/Emit/ModuleBuilder.Mono.cs
src/mono/System.Private.CoreLib/src/System/Reflection/Emit/MonoArrayMethod.cs
src/mono/System.Private.CoreLib/src/System/Reflection/Emit/PropertyOnTypeBuilderInst.cs
src/mono/System.Private.CoreLib/src/System/Reflection/RuntimeFieldInfo.cs
src/mono/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs
src/mono/System.Private.CoreLib/src/System/Reflection/RuntimeModule.cs
src/mono/System.Private.CoreLib/src/System/Reflection/RuntimeParameterInfo.cs
src/mono/System.Private.CoreLib/src/System/Reflection/RuntimePropertyInfo.cs
src/mono/System.Private.CoreLib/src/System/TypeIdentifier.cs
src/mono/System.Private.CoreLib/src/System/TypeNameParser.cs
src/mono/System.Private.CoreLib/src/System/TypeSpec.cs

index f7ba149..f927f1f 100644 (file)
     <Compile Include="$(BclSourcesRoot)\System\Collections\Generic\Comparer.CoreCLR.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Collections\Generic\ComparerHelpers.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Collections\Generic\EqualityComparer.CoreCLR.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\Collections\ObjectModel\ReadOnlyDictionary.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Currency.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Delegate.CoreCLR.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Diagnostics\Debugger.cs" />
index 3740447..1435c9c 100644 (file)
@@ -5,7 +5,7 @@ using System;
 
 namespace GenUnicodeProp
 {
-    internal class TableLevels
+    internal sealed class TableLevels
     {
         public readonly int Level1Bits;
         public readonly int Level2Bits;
index 6caaede..9f2c011 100644 (file)
@@ -446,7 +446,7 @@ $@"{nameof(UnregisterClassForTypeInternal)} arguments:
         }
 
         [ComVisible(true)]
-        private class BasicClassFactory : IClassFactory
+        private sealed class BasicClassFactory : IClassFactory
         {
 #if FEATURE_COMINTEROP_UNMANAGED_ACTIVATION
             private readonly Guid _classId;
@@ -578,7 +578,7 @@ $@"{nameof(UnregisterClassForTypeInternal)} arguments:
         }
 
         [ComVisible(true)]
-        private class LicenseClassFactory : IClassFactory2
+        private sealed class LicenseClassFactory : IClassFactory2
         {
 #if FEATURE_COMINTEROP_UNMANAGED_ACTIVATION
             private readonly LicenseInteropProxy _licenseProxy = new LicenseInteropProxy();
diff --git a/src/coreclr/System.Private.CoreLib/src/System/Collections/ObjectModel/ReadOnlyDictionary.cs b/src/coreclr/System.Private.CoreLib/src/System/Collections/ObjectModel/ReadOnlyDictionary.cs
deleted file mode 100644 (file)
index 287c186..0000000
+++ /dev/null
@@ -1,526 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-/*============================================================
-**
-**
-**
-**
-** Purpose: Read-only wrapper for another generic dictionary.
-**
-===========================================================*/
-
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
-using System.Threading;
-
-namespace System.Collections.ObjectModel
-{
-    [DebuggerTypeProxy(typeof(IDictionaryDebugView<,>))]
-    [DebuggerDisplay("Count = {Count}")]
-    internal class ReadOnlyDictionary<TKey, TValue> : IDictionary<TKey, TValue>, IDictionary, IReadOnlyDictionary<TKey, TValue> where TKey : notnull
-    {
-        private readonly IDictionary<TKey, TValue> m_dictionary;
-        private object? m_syncRoot;
-        private KeyCollection? m_keys;
-        private ValueCollection? m_values;
-
-        public ReadOnlyDictionary(IDictionary<TKey, TValue> dictionary)
-        {
-            if (dictionary == null)
-            {
-                throw new ArgumentNullException(nameof(dictionary));
-            }
-            m_dictionary = dictionary;
-        }
-
-        protected IDictionary<TKey, TValue> Dictionary => m_dictionary;
-
-        public KeyCollection Keys => m_keys ??= new KeyCollection(m_dictionary.Keys);
-
-        public ValueCollection Values => m_values ??= new ValueCollection(m_dictionary.Values);
-
-        #region IDictionary<TKey, TValue> Members
-
-        public bool ContainsKey(TKey key) => m_dictionary.ContainsKey(key);
-
-        ICollection<TKey> IDictionary<TKey, TValue>.Keys => Keys;
-
-        public bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value) =>
-            m_dictionary.TryGetValue(key, out value);
-
-        ICollection<TValue> IDictionary<TKey, TValue>.Values => Values;
-
-        public TValue this[TKey key] => m_dictionary[key];
-
-        void IDictionary<TKey, TValue>.Add(TKey key, TValue value) =>
-            ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
-
-        bool IDictionary<TKey, TValue>.Remove(TKey key)
-        {
-            ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
-            return false;
-        }
-
-        TValue IDictionary<TKey, TValue>.this[TKey key]
-        {
-            get => m_dictionary[key];
-            set => ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
-        }
-
-        #endregion
-
-        #region ICollection<KeyValuePair<TKey, TValue>> Members
-
-        public int Count => m_dictionary.Count;
-
-        bool ICollection<KeyValuePair<TKey, TValue>>.Contains(KeyValuePair<TKey, TValue> item) =>
-            m_dictionary.Contains(item);
-
-        void ICollection<KeyValuePair<TKey, TValue>>.CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex) =>
-            m_dictionary.CopyTo(array, arrayIndex);
-
-        bool ICollection<KeyValuePair<TKey, TValue>>.IsReadOnly => true;
-
-        void ICollection<KeyValuePair<TKey, TValue>>.Add(KeyValuePair<TKey, TValue> item) =>
-            ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
-
-        void ICollection<KeyValuePair<TKey, TValue>>.Clear() =>
-            ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
-
-        bool ICollection<KeyValuePair<TKey, TValue>>.Remove(KeyValuePair<TKey, TValue> item)
-        {
-            ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
-            return false;
-        }
-
-        #endregion
-
-        #region IEnumerable<KeyValuePair<TKey, TValue>> Members
-
-        public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator() =>
-            m_dictionary.GetEnumerator();
-
-        #endregion
-
-        #region IEnumerable Members
-
-        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() =>
-            ((IEnumerable)m_dictionary).GetEnumerator();
-
-        #endregion
-
-        #region IDictionary Members
-
-        private static bool IsCompatibleKey(object key)
-        {
-            if (key == null)
-            {
-                ThrowHelper.ThrowArgumentNullException(ExceptionArgument.key);
-            }
-            return key is TKey;
-        }
-
-        void IDictionary.Add(object key, object? value) =>
-            ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
-
-        void IDictionary.Clear() =>
-            ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
-
-        bool IDictionary.Contains(object key) => IsCompatibleKey(key) && ContainsKey((TKey)key);
-
-        IDictionaryEnumerator IDictionary.GetEnumerator()
-        {
-            if (m_dictionary is IDictionary d)
-            {
-                return d.GetEnumerator();
-            }
-            return new DictionaryEnumerator(m_dictionary);
-        }
-
-        bool IDictionary.IsFixedSize => true;
-
-        bool IDictionary.IsReadOnly => true;
-
-        ICollection IDictionary.Keys => Keys;
-
-        void IDictionary.Remove(object key) =>
-            ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
-
-        ICollection IDictionary.Values => Values;
-
-        object? IDictionary.this[object key]
-        {
-            get
-            {
-                if (IsCompatibleKey(key))
-                {
-                    return this[(TKey)key];
-                }
-                return null;
-            }
-            set => ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
-        }
-
-        void ICollection.CopyTo(Array array, int index)
-        {
-            if (array == null)
-            {
-                ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
-            }
-
-            if (array.Rank != 1)
-            {
-                ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_RankMultiDimNotSupported);
-            }
-
-            if (array.GetLowerBound(0) != 0)
-            {
-                ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_NonZeroLowerBound);
-            }
-
-            if (index < 0 || index > array.Length)
-            {
-                ThrowHelper.ThrowIndexArgumentOutOfRange_NeedNonNegNumException();
-            }
-
-            if (array.Length - index < Count)
-            {
-                ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_ArrayPlusOffTooSmall);
-            }
-
-            if (array is KeyValuePair<TKey, TValue>[] pairs)
-            {
-                m_dictionary.CopyTo(pairs, index);
-            }
-            else
-            {
-                if (array is DictionaryEntry[] dictEntryArray)
-                {
-                    foreach (KeyValuePair<TKey, TValue> item in m_dictionary)
-                    {
-                        dictEntryArray[index++] = new DictionaryEntry(item.Key, item.Value);
-                    }
-                }
-                else
-                {
-                    object[]? objects = array as object[];
-                    if (objects == null)
-                    {
-                        ThrowHelper.ThrowArgumentException_Argument_InvalidArrayType();
-                    }
-
-                    try
-                    {
-                        foreach (KeyValuePair<TKey, TValue> item in m_dictionary)
-                        {
-                            objects[index++] = new KeyValuePair<TKey, TValue>(item.Key, item.Value);
-                        }
-                    }
-                    catch (ArrayTypeMismatchException)
-                    {
-                        ThrowHelper.ThrowArgumentException_Argument_InvalidArrayType();
-                    }
-                }
-            }
-        }
-
-        bool ICollection.IsSynchronized => false;
-
-        object ICollection.SyncRoot
-        {
-            get
-            {
-                if (m_syncRoot == null)
-                {
-                    if (m_dictionary is ICollection c)
-                    {
-                        m_syncRoot = c.SyncRoot;
-                    }
-                    else
-                    {
-                        Interlocked.CompareExchange<object?>(ref m_syncRoot, new object(), null);
-                    }
-                }
-                return m_syncRoot;
-            }
-        }
-
-        private struct DictionaryEnumerator : IDictionaryEnumerator
-        {
-            private readonly IDictionary<TKey, TValue> m_dictionary;
-            private readonly IEnumerator<KeyValuePair<TKey, TValue>> m_enumerator;
-
-            public DictionaryEnumerator(IDictionary<TKey, TValue> dictionary)
-            {
-                m_dictionary = dictionary;
-                m_enumerator = m_dictionary.GetEnumerator();
-            }
-
-            public DictionaryEntry Entry => new DictionaryEntry(m_enumerator.Current.Key, m_enumerator.Current.Value);
-
-            public object Key => m_enumerator.Current.Key!;
-
-            public object? Value => m_enumerator.Current.Value;
-
-            public object? Current => Entry;
-
-            public bool MoveNext() => m_enumerator.MoveNext();
-
-            public void Reset() => m_enumerator.Reset();
-        }
-
-        #endregion
-
-        #region IReadOnlyDictionary members
-
-        IEnumerable<TKey> IReadOnlyDictionary<TKey, TValue>.Keys => Keys;
-
-        IEnumerable<TValue> IReadOnlyDictionary<TKey, TValue>.Values => Values;
-
-        #endregion IReadOnlyDictionary members
-
-        [DebuggerTypeProxy(typeof(ICollectionDebugView<>))]
-        [DebuggerDisplay("Count = {Count}")]
-        public sealed class KeyCollection : ICollection<TKey>, ICollection, IReadOnlyCollection<TKey>
-        {
-            private readonly ICollection<TKey> m_collection;
-            private object? m_syncRoot;
-
-            internal KeyCollection(ICollection<TKey> collection)
-            {
-                if (collection == null)
-                {
-                    ThrowHelper.ThrowArgumentNullException(ExceptionArgument.collection);
-                }
-                m_collection = collection;
-            }
-
-            #region ICollection<T> Members
-
-            void ICollection<TKey>.Add(TKey item) => ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
-
-            void ICollection<TKey>.Clear() => ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
-
-            bool ICollection<TKey>.Contains(TKey item) => m_collection.Contains(item);
-
-            public void CopyTo(TKey[] array, int arrayIndex) => m_collection.CopyTo(array, arrayIndex);
-
-            public int Count => m_collection.Count;
-
-            bool ICollection<TKey>.IsReadOnly => true;
-
-            bool ICollection<TKey>.Remove(TKey item)
-            {
-                ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
-                return false;
-            }
-
-            #endregion
-
-            #region IEnumerable<T> Members
-
-            public IEnumerator<TKey> GetEnumerator() => m_collection.GetEnumerator();
-
-            #endregion
-
-            #region IEnumerable Members
-
-            IEnumerator IEnumerable.GetEnumerator() => ((IEnumerable)m_collection).GetEnumerator();
-
-            #endregion
-
-            #region ICollection Members
-
-            void ICollection.CopyTo(Array array, int index) => ReadOnlyDictionaryHelpers.CopyToNonGenericICollectionHelper<TKey>(m_collection, array, index);
-
-            bool ICollection.IsSynchronized => false;
-
-            object ICollection.SyncRoot
-            {
-                get
-                {
-                    if (m_syncRoot == null)
-                    {
-                        if (m_collection is ICollection c)
-                        {
-                            m_syncRoot = c.SyncRoot;
-                        }
-                        else
-                        {
-                            Interlocked.CompareExchange<object?>(ref m_syncRoot, new object(), null);
-                        }
-                    }
-                    return m_syncRoot;
-                }
-            }
-
-            #endregion
-        }
-
-        [DebuggerTypeProxy(typeof(ICollectionDebugView<>))]
-        [DebuggerDisplay("Count = {Count}")]
-        public sealed class ValueCollection : ICollection<TValue>, ICollection, IReadOnlyCollection<TValue>
-        {
-            private readonly ICollection<TValue> m_collection;
-            private object? m_syncRoot;
-
-            internal ValueCollection(ICollection<TValue> collection)
-            {
-                if (collection == null)
-                {
-                    ThrowHelper.ThrowArgumentNullException(ExceptionArgument.collection);
-                }
-                m_collection = collection;
-            }
-
-            #region ICollection<T> Members
-
-            void ICollection<TValue>.Add(TValue item) => ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
-
-            void ICollection<TValue>.Clear() => ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
-
-            bool ICollection<TValue>.Contains(TValue item) => m_collection.Contains(item);
-
-            public void CopyTo(TValue[] array, int arrayIndex) => m_collection.CopyTo(array, arrayIndex);
-
-            public int Count => m_collection.Count;
-
-            bool ICollection<TValue>.IsReadOnly => true;
-
-            bool ICollection<TValue>.Remove(TValue item)
-            {
-                ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
-                return false;
-            }
-
-            #endregion
-
-            #region IEnumerable<T> Members
-
-            public IEnumerator<TValue> GetEnumerator() => m_collection.GetEnumerator();
-
-            #endregion
-
-            #region IEnumerable Members
-
-            IEnumerator IEnumerable.GetEnumerator() => ((IEnumerable)m_collection).GetEnumerator();
-
-            #endregion
-
-            #region ICollection Members
-
-            void ICollection.CopyTo(Array array, int index) => ReadOnlyDictionaryHelpers.CopyToNonGenericICollectionHelper<TValue>(m_collection, array, index);
-
-            bool ICollection.IsSynchronized => false;
-
-            object ICollection.SyncRoot
-            {
-                get
-                {
-                    if (m_syncRoot == null)
-                    {
-                        if (m_collection is ICollection c)
-                        {
-                            m_syncRoot = c.SyncRoot;
-                        }
-                        else
-                        {
-                            Interlocked.CompareExchange<object?>(ref m_syncRoot, new object(), null);
-                        }
-                    }
-                    return m_syncRoot;
-                }
-            }
-
-            #endregion ICollection Members
-        }
-    }
-
-    // To share code when possible, use a non-generic class to get rid of irrelevant type parameters.
-    internal static class ReadOnlyDictionaryHelpers
-    {
-        #region Helper method for our KeyCollection and ValueCollection
-
-        // Abstracted away to avoid redundant implementations.
-        internal static void CopyToNonGenericICollectionHelper<T>(ICollection<T> collection, Array array, int index)
-        {
-            if (array == null)
-            {
-                ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
-            }
-
-            if (array.Rank != 1)
-            {
-                ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_RankMultiDimNotSupported);
-            }
-
-            if (array.GetLowerBound(0) != 0)
-            {
-                ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_NonZeroLowerBound);
-            }
-
-            if (index < 0)
-            {
-                ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.arrayIndex, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
-            }
-
-            if (array.Length - index < collection.Count)
-            {
-                ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_ArrayPlusOffTooSmall);
-            }
-
-            // Easy out if the ICollection<T> implements the non-generic ICollection
-            if (collection is ICollection nonGenericCollection)
-            {
-                nonGenericCollection.CopyTo(array, index);
-                return;
-            }
-
-            if (array is T[] items)
-            {
-                collection.CopyTo(items, index);
-            }
-            else
-            {
-                //
-                // Catch the obvious case assignment will fail.
-                // We can found all possible problems by doing the check though.
-                // For example, if the element type of the Array is derived from T,
-                // we can't figure out if we can successfully copy the element beforehand.
-                //
-                Type targetType = array.GetType().GetElementType()!;
-                Type sourceType = typeof(T);
-                if (!(targetType.IsAssignableFrom(sourceType) || sourceType.IsAssignableFrom(targetType)))
-                {
-                    ThrowHelper.ThrowArgumentException_Argument_InvalidArrayType();
-                }
-
-                //
-                // We can't cast array of value type to object[], so we don't support
-                // widening of primitive types here.
-                //
-                object?[]? objects = array as object[];
-                if (objects == null)
-                {
-                    ThrowHelper.ThrowArgumentException_Argument_InvalidArrayType();
-                }
-
-                try
-                {
-                    foreach (T item in collection)
-                    {
-                        objects[index++] = item;
-                    }
-                }
-                catch (ArrayTypeMismatchException)
-                {
-                    ThrowHelper.ThrowArgumentException_Argument_InvalidArrayType();
-                }
-            }
-        }
-
-        #endregion Helper method for our KeyCollection and ValueCollection
-    }
-}
index 4015192..bed89c4 100644 (file)
@@ -28,7 +28,7 @@ namespace System.Diagnostics
         // This class implements code:ICustomDebuggerNotification and provides a type to be used to notify
         // the debugger that execution is about to enter a path that involves a cross-thread dependency.
         // See code:NotifyOfCrossThreadDependency for more details.
-        private class CrossThreadDependencyNotification : ICustomDebuggerNotification { }
+        private sealed class CrossThreadDependencyNotification : ICustomDebuggerNotification { }
 
         // Do not inline the slow path
         [MethodImpl(MethodImplOptions.NoInlining)]
index a76e031..3dd71b8 100644 (file)
@@ -11,7 +11,7 @@ namespace System.Diagnostics
     // Modifying the order or fields of this object may require other changes
     // to the unmanaged definition of the StackFrameHelper class, in
     // VM\DebugDebugger.h. The binder will catch some of these layout problems.
-    internal class StackFrameHelper
+    internal sealed class StackFrameHelper
     {
         private Thread? targetThread;
         private int[]? rgiOffset;
@@ -152,7 +152,7 @@ namespace System.Diagnostics
             }
         }
 
-        public virtual MethodBase? GetMethodBase(int i)
+        public MethodBase? GetMethodBase(int i)
         {
             // There may be a better way to do this.
             // we got RuntimeMethodHandles here and we need to go to MethodBase
@@ -169,17 +169,17 @@ namespace System.Diagnostics
             return RuntimeType.GetMethodBase(mhReal);
         }
 
-        public virtual int GetOffset(int i) { return rgiOffset![i]; }
-        public virtual int GetILOffset(int i) { return rgiILOffset![i]; }
-        public virtual string? GetFilename(int i) { return rgFilename?[i]; }
-        public virtual int GetLineNumber(int i) { return rgiLineNumber == null ? 0 : rgiLineNumber[i]; }
-        public virtual int GetColumnNumber(int i) { return rgiColumnNumber == null ? 0 : rgiColumnNumber[i]; }
+        public int GetOffset(int i) { return rgiOffset![i]; }
+        public int GetILOffset(int i) { return rgiILOffset![i]; }
+        public string? GetFilename(int i) { return rgFilename?[i]; }
+        public int GetLineNumber(int i) { return rgiLineNumber == null ? 0 : rgiLineNumber[i]; }
+        public int GetColumnNumber(int i) { return rgiColumnNumber == null ? 0 : rgiColumnNumber[i]; }
 
-        public virtual bool IsLastFrameFromForeignExceptionStackTrace(int i)
+        public bool IsLastFrameFromForeignExceptionStackTrace(int i)
         {
             return (rgiLastFrameFromForeignExceptionStackTrace == null) ? false : rgiLastFrameFromForeignExceptionStackTrace[i];
         }
 
-        public virtual int GetNumberOfFrames() { return iFrameCount; }
+        public int GetNumberOfFrames() { return iFrameCount; }
     }
 }
index 587738b..d1072ff 100644 (file)
@@ -12,7 +12,7 @@ using CultureInfo = System.Globalization.CultureInfo;
 namespace System
 {
     // Made serializable in anticipation of this class eventually having state.
-    internal class OleAutBinder : DefaultBinder
+    internal sealed class OleAutBinder : DefaultBinder
     {
         // ChangeType
         // This binder uses OLEAUT to change the type of the variant.
index 4b44a4d..3d1bf2a 100644 (file)
@@ -10,7 +10,7 @@ namespace System.Reflection.Emit
     /// data member for AssemblyBuilder. Note that what ever data members added to
     /// this class cannot be accessed from the EE.
     /// </summary>
-    internal class AssemblyBuilderData
+    internal sealed class AssemblyBuilderData
     {
         public const int AssemblyDefToken = 0x20000001;
 
index 3e11afa..79d0a26 100644 (file)
@@ -8,7 +8,7 @@ using System.Diagnostics;
 
 namespace System.Reflection.Emit
 {
-    internal class DynamicILGenerator : ILGenerator
+    internal sealed class DynamicILGenerator : ILGenerator
     {
         internal DynamicScope m_scope;
         private int m_methodSigToken;
@@ -563,7 +563,7 @@ namespace System.Reflection.Emit
 
     }
 
-    internal class DynamicResolver : Resolver
+    internal sealed class DynamicResolver : Resolver
     {
         #region Private Data Members
         private __ExceptionInfo[]? m_exceptions;
@@ -643,7 +643,7 @@ namespace System.Reflection.Emit
             scout.m_methodHandle = method.m_methodHandle.Value;
         }
 
-        private class DestroyScout
+        private sealed class DestroyScout
         {
             internal RuntimeMethodHandleInternal m_methodHandle;
 
@@ -982,7 +982,7 @@ namespace System.Reflection.Emit
         #endregion
     }
 
-    internal class DynamicScope
+    internal sealed class DynamicScope
     {
         #region Private Data Members
         internal readonly List<object?> m_tokens = new List<object?> { null };
index 39f4eac..72e3edb 100644 (file)
@@ -28,7 +28,7 @@ namespace System.Reflection.Emit
     // SymWrapperCore is never instantiated and is used as an encapsulation class.
     // It is our "ISymWrapper.dll" assembly within an assembly.
     //------------------------------------------------------------------------------
-    internal class SymWrapperCore
+    internal sealed class SymWrapperCore
     {
         //------------------------------------------------------------------------------
         // Block instantiation
index db05015..bf58dc1 100644 (file)
@@ -827,7 +827,7 @@ namespace System.Reflection.Emit
         #endregion
     }
 
-    internal class LocalSymInfo
+    internal sealed class LocalSymInfo
     {
         // This class tracks the local variable's debugging information
         // and namespace information with a given active lexical scope.
@@ -928,7 +928,7 @@ namespace System.Reflection.Emit
             checked { m_iNameSpaceCount++; }
         }
 
-        internal virtual void EmitLocalSymInfo(ISymbolWriter symWriter)
+        internal void EmitLocalSymInfo(ISymbolWriter symWriter)
         {
             int i;
 
index c925625..f4048ea 100644 (file)
@@ -6,7 +6,7 @@ namespace System.Reflection.Emit
     // This is a package private class. This class hold all of the managed
     // data member for ModuleBuilder. Note that what ever data members added to
     // this class cannot be accessed from the EE.
-    internal class ModuleBuilderData
+    internal sealed class ModuleBuilderData
     {
         public const string MultiByteValueClass = "$ArrayType$";
 
index 88c8ccb..064e8ed 100644 (file)
@@ -19,7 +19,7 @@ namespace System.Reflection.Emit
         }
 
         #region Declarations
-        private class CustAttr
+        private sealed class CustAttr
         {
             private readonly ConstructorInfo? m_con;
             private readonly byte[]? m_binaryAttribute;
index d31c719..d367052 100644 (file)
@@ -552,7 +552,7 @@ namespace System.Reflection
         #endregion
     }
 
-    internal class MetadataException : Exception
+    internal sealed class MetadataException : Exception
     {
         private int m_hr;
         internal MetadataException(int hr) { m_hr = hr; }
index 99b3911..9bb4628 100644 (file)
@@ -10,7 +10,7 @@ namespace System.Runtime.CompilerServices
     /// data.
     /// </summary>
     [StructLayout(LayoutKind.Sequential)]
-    internal class LAHashDependentHashTracker
+    internal sealed class LAHashDependentHashTracker
     {
         private GCHandle _dependentHandle;
         private IntPtr _loaderAllocator;
@@ -27,7 +27,7 @@ namespace System.Runtime.CompilerServices
     /// to LAHashDependentHashTracker's
     /// </summary>
     [StructLayout(LayoutKind.Sequential)]
-    internal class LAHashKeyToTrackers
+    internal sealed class LAHashKeyToTrackers
     {
         private object? _trackerOrTrackerSet;
         private object? _laLocalKeyValueStore;
index a5ce5ed..82f9919 100644 (file)
@@ -10,7 +10,7 @@ namespace System.Runtime.CompilerServices
     /// by C++ runtime code which manages its memory in the GC heap.
     /// </summary>
     [StructLayout(LayoutKind.Sequential)]
-    internal class GCHeapHash
+    internal sealed class GCHeapHash
     {
         private Array? _data;
         private int _count;
index 661b3d5..d65b043 100644 (file)
@@ -364,7 +364,7 @@ namespace System.Runtime.CompilerServices
     }
     // Helper class to assist with unsafe pinning of arbitrary objects.
     // It's used by VM code.
-    internal class RawData
+    internal sealed class RawData
     {
         public byte Data;
     }
@@ -377,7 +377,7 @@ namespace System.Runtime.CompilerServices
     // The BaseSize of an array includes all the fields before the array data,
     // including the sync block and method table. The reference to RawData.Data
     // points at the number of components, skipping over these two pointer-sized fields.
-    internal class RawArrayData
+    internal sealed class RawArrayData
     {
         public uint Length; // Array._numComponents padded to IntPtr
 #if TARGET_64BIT
index ac434ad..12035fd 100644 (file)
@@ -6,7 +6,7 @@ using System.Runtime.Versioning;
 namespace System.Runtime.InteropServices
 {
     [SupportedOSPlatform("windows")]
-    internal class ComEventsInfo
+    internal sealed class ComEventsInfo
     {
         private ComEventsSink? _sinks;
         private readonly object _rcw;
index 818b4b5..c6a27d6 100644 (file)
@@ -6,7 +6,7 @@ using ComTypes = System.Runtime.InteropServices.ComTypes;
 
 namespace System.Runtime.InteropServices.CustomMarshalers
 {
-    internal class EnumVariantViewOfEnumerator : ComTypes.IEnumVARIANT, ICustomAdapter
+    internal sealed class EnumVariantViewOfEnumerator : ComTypes.IEnumVARIANT, ICustomAdapter
     {
         public EnumVariantViewOfEnumerator(IEnumerator enumerator)
         {
index 3bd63b3..adc6338 100644 (file)
@@ -7,7 +7,7 @@ using System.Runtime.Versioning;
 namespace System.Runtime.InteropServices.CustomMarshalers
 {
     [SupportedOSPlatform("windows")]
-    internal class EnumerableToDispatchMarshaler : ICustomMarshaler
+    internal sealed class EnumerableToDispatchMarshaler : ICustomMarshaler
     {
         private static readonly EnumerableToDispatchMarshaler s_enumerableToDispatchMarshaler = new EnumerableToDispatchMarshaler();
 
index a64da69..d9d9411 100644 (file)
@@ -6,7 +6,7 @@ using System.Runtime.InteropServices.ComTypes;
 
 namespace System.Runtime.InteropServices.CustomMarshalers
 {
-    internal class EnumerableViewOfDispatch : ICustomAdapter, System.Collections.IEnumerable
+    internal sealed class EnumerableViewOfDispatch : ICustomAdapter, System.Collections.IEnumerable
     {
         // Reserved DISPID slot for getting an enumerator from an IDispatch-implementing COM interface.
         private const int DISPID_NEWENUM = -4;
index b4718f5..997d22d 100644 (file)
@@ -8,7 +8,7 @@ using ComTypes = System.Runtime.InteropServices.ComTypes;
 namespace System.Runtime.InteropServices.CustomMarshalers
 {
     [SupportedOSPlatform("windows")]
-    internal class EnumeratorToEnumVariantMarshaler : ICustomMarshaler
+    internal sealed class EnumeratorToEnumVariantMarshaler : ICustomMarshaler
     {
         private static readonly EnumeratorToEnumVariantMarshaler s_enumeratorToEnumVariantMarshaler = new EnumeratorToEnumVariantMarshaler();
 
index f0b725a..a62fad1 100644 (file)
@@ -5,7 +5,7 @@ using System.Runtime.InteropServices.ComTypes;
 
 namespace System.Runtime.InteropServices.CustomMarshalers
 {
-    internal class EnumeratorViewOfEnumVariant : ICustomAdapter, System.Collections.IEnumerator
+    internal sealed class EnumeratorViewOfEnumVariant : ICustomAdapter, System.Collections.IEnumerator
     {
         private readonly IEnumVARIANT _enumVariantObject;
         private bool _fetchedLastObject;
index 07e7802..047bc24 100644 (file)
@@ -3,7 +3,7 @@
 
 namespace System.Runtime.InteropServices.CustomMarshalers
 {
-    internal class ExpandoToDispatchExMarshaler : ICustomMarshaler
+    internal sealed class ExpandoToDispatchExMarshaler : ICustomMarshaler
     {
         private static readonly ExpandoToDispatchExMarshaler s_ExpandoToDispatchExMarshaler = new ExpandoToDispatchExMarshaler();
 
index da82567..afcd880 100644 (file)
@@ -3,7 +3,7 @@
 
 namespace System.Runtime.InteropServices.CustomMarshalers
 {
-    internal class TypeToTypeInfoMarshaler : ICustomMarshaler
+    internal sealed class TypeToTypeInfoMarshaler : ICustomMarshaler
     {
         private static readonly TypeToTypeInfoMarshaler s_typeToTypeInfoMarshaler = new TypeToTypeInfoMarshaler();
 
index 7dfcb3a..60fe3a1 100644 (file)
@@ -746,7 +746,7 @@ namespace System
         internal IntPtr m_handle;
     }
 
-    internal class RuntimeMethodInfoStub : IRuntimeMethodInfo
+    internal sealed class RuntimeMethodInfoStub : IRuntimeMethodInfo
     {
         public RuntimeMethodInfoStub(RuntimeMethodHandleInternal methodHandleValue, object keepalive)
         {
@@ -1095,7 +1095,7 @@ namespace System
     }
 
     [StructLayout(LayoutKind.Sequential)]
-    internal class RuntimeFieldInfoStub : IRuntimeFieldInfo
+    internal sealed class RuntimeFieldInfoStub : IRuntimeFieldInfo
     {
         // These unused variables are used to ensure that this class has the same layout as RuntimeFieldInfo
 #pragma warning disable 414, 169
index 3f860e3..a1d1746 100644 (file)
@@ -134,7 +134,7 @@ namespace System
             }
         }
 
-        internal class RuntimeTypeCache
+        internal sealed class RuntimeTypeCache
         {
             private const int MAXNAMELEN = 1024;
 
@@ -203,7 +203,7 @@ namespace System
                 }
             }
 
-            private class MemberInfoCache<T> where T : MemberInfo
+            private sealed class MemberInfoCache<T> where T : MemberInfo
             {
                 #region Private Data Members
 
@@ -3920,7 +3920,7 @@ namespace System.Reflection
     // reliable in the presence of asynchronous exceptions.
     internal struct CerHashtable<K, V> where K : class
     {
-        private class Table
+        private sealed class Table
         {
             // Note that m_keys and m_values arrays are immutable to allow lock-free reads. A new instance
             // of CerHashtable has to be allocated to grow the size of the hashtable.
index 8db5db7..e8e736e 100644 (file)
@@ -11,7 +11,7 @@ namespace System.Runtime.InteropServices
     /// Part of ComEventHelpers APIs which allow binding
     /// managed delegates to COM's connection point based events.
     /// </summary>
-    internal class ComEventsMethod
+    internal sealed class ComEventsMethod
     {
         /// <summary>
         /// This delegate wrapper class handles dynamic invocation of delegates. The reason for the wrapper's
index 9b30dd4..d855d34 100644 (file)
@@ -12,7 +12,7 @@ namespace Generators
 {
     public partial class EventSourceGenerator
     {
-        private class Emitter
+        private sealed class Emitter
         {
             private readonly StringBuilder _builder = new StringBuilder(1024);
             private readonly GeneratorExecutionContext _context;
index 03e9dad..be971bb 100644 (file)
@@ -16,7 +16,7 @@ namespace Generators
 {
     public partial class EventSourceGenerator
     {
-        private class Parser
+        private sealed class Parser
         {
             private readonly CancellationToken _cancellationToken;
             private readonly Compilation _compilation;
index b86cdeb..1a13393 100644 (file)
@@ -97,7 +97,7 @@ namespace Generators
             }
         }
 
-        private class EventSourceClass
+        private sealed class EventSourceClass
         {
             public string Namespace = string.Empty;
             public string ClassName = string.Empty;
index 5e672ac..d20f81a 100644 (file)
@@ -743,7 +743,7 @@ namespace System.Collections
 
         // This class wraps an IList, exposing it as a ArrayList
         // Note this requires reimplementing half of ArrayList...
-        private class IListWrapper : ArrayList
+        private sealed class IListWrapper : ArrayList
         {
             private readonly IList _list;
 
@@ -1183,7 +1183,7 @@ namespace System.Collections
             }
         }
 
-        private class SyncArrayList : ArrayList
+        private sealed class SyncArrayList : ArrayList
         {
             private readonly ArrayList _list;
             private readonly object _root;
@@ -1510,7 +1510,7 @@ namespace System.Collections
         }
 
 
-        private class SyncIList : IList
+        private sealed class SyncIList : IList
         {
             private readonly IList _list;
             private readonly object _root;
@@ -1521,19 +1521,19 @@ namespace System.Collections
                 _root = list.SyncRoot;
             }
 
-            public virtual int Count
+            public int Count
             {
                 get { lock (_root) { return _list.Count; } }
             }
 
-            public virtual bool IsReadOnly => _list.IsReadOnly;
+            public bool IsReadOnly => _list.IsReadOnly;
 
-            public virtual bool IsFixedSize => _list.IsFixedSize;
+            public bool IsFixedSize => _list.IsFixedSize;
 
 
-            public virtual bool IsSynchronized => true;
+            public bool IsSynchronized => true;
 
-            public virtual object? this[int index]
+            public object? this[int index]
             {
                 get
                 {
@@ -1551,9 +1551,9 @@ namespace System.Collections
                 }
             }
 
-            public virtual object SyncRoot => _root;
+            public object SyncRoot => _root;
 
-            public virtual int Add(object? value)
+            public int Add(object? value)
             {
                 lock (_root)
                 {
@@ -1562,7 +1562,7 @@ namespace System.Collections
             }
 
 
-            public virtual void Clear()
+            public void Clear()
             {
                 lock (_root)
                 {
@@ -1570,7 +1570,7 @@ namespace System.Collections
                 }
             }
 
-            public virtual bool Contains(object? item)
+            public bool Contains(object? item)
             {
                 lock (_root)
                 {
@@ -1578,7 +1578,7 @@ namespace System.Collections
                 }
             }
 
-            public virtual void CopyTo(Array array, int index)
+            public void CopyTo(Array array, int index)
             {
                 lock (_root)
                 {
@@ -1586,7 +1586,7 @@ namespace System.Collections
                 }
             }
 
-            public virtual IEnumerator GetEnumerator()
+            public IEnumerator GetEnumerator()
             {
                 lock (_root)
                 {
@@ -1594,7 +1594,7 @@ namespace System.Collections
                 }
             }
 
-            public virtual int IndexOf(object? value)
+            public int IndexOf(object? value)
             {
                 lock (_root)
                 {
@@ -1602,7 +1602,7 @@ namespace System.Collections
                 }
             }
 
-            public virtual void Insert(int index, object? value)
+            public void Insert(int index, object? value)
             {
                 lock (_root)
                 {
@@ -1610,7 +1610,7 @@ namespace System.Collections
                 }
             }
 
-            public virtual void Remove(object? value)
+            public void Remove(object? value)
             {
                 lock (_root)
                 {
@@ -1618,7 +1618,7 @@ namespace System.Collections
                 }
             }
 
-            public virtual void RemoveAt(int index)
+            public void RemoveAt(int index)
             {
                 lock (_root)
                 {
@@ -1627,7 +1627,7 @@ namespace System.Collections
             }
         }
 
-        private class FixedSizeList : IList
+        private sealed class FixedSizeList : IList
         {
             private readonly IList _list;
 
@@ -1636,69 +1636,69 @@ namespace System.Collections
                 _list = l;
             }
 
-            public virtual int Count => _list.Count;
+            public int Count => _list.Count;
 
-            public virtual bool IsReadOnly => _list.IsReadOnly;
+            public bool IsReadOnly => _list.IsReadOnly;
 
-            public virtual bool IsFixedSize => true;
+            public bool IsFixedSize => true;
 
-            public virtual bool IsSynchronized => _list.IsSynchronized;
+            public bool IsSynchronized => _list.IsSynchronized;
 
-            public virtual object? this[int index]
+            public object? this[int index]
             {
                 get => _list[index];
                 set => _list[index] = value;
             }
 
-            public virtual object SyncRoot => _list.SyncRoot;
+            public object SyncRoot => _list.SyncRoot;
 
-            public virtual int Add(object? obj)
+            public int Add(object? obj)
             {
                 throw new NotSupportedException(SR.NotSupported_FixedSizeCollection);
             }
 
-            public virtual void Clear()
+            public void Clear()
             {
                 throw new NotSupportedException(SR.NotSupported_FixedSizeCollection);
             }
 
-            public virtual bool Contains(object? obj)
+            public bool Contains(object? obj)
             {
                 return _list.Contains(obj);
             }
 
-            public virtual void CopyTo(Array array, int index)
+            public void CopyTo(Array array, int index)
             {
                 _list.CopyTo(array, index);
             }
 
-            public virtual IEnumerator GetEnumerator()
+            public IEnumerator GetEnumerator()
             {
                 return _list.GetEnumerator();
             }
 
-            public virtual int IndexOf(object? value)
+            public int IndexOf(object? value)
             {
                 return _list.IndexOf(value);
             }
 
-            public virtual void Insert(int index, object? obj)
+            public void Insert(int index, object? obj)
             {
                 throw new NotSupportedException(SR.NotSupported_FixedSizeCollection);
             }
 
-            public virtual void Remove(object? value)
+            public void Remove(object? value)
             {
                 throw new NotSupportedException(SR.NotSupported_FixedSizeCollection);
             }
 
-            public virtual void RemoveAt(int index)
+            public void RemoveAt(int index)
             {
                 throw new NotSupportedException(SR.NotSupported_FixedSizeCollection);
             }
         }
 
-        private class FixedSizeArrayList : ArrayList
+        private sealed class FixedSizeArrayList : ArrayList
         {
             private ArrayList _list;
 
@@ -1885,7 +1885,7 @@ namespace System.Collections
             }
         }
 
-        private class ReadOnlyList : IList
+        private sealed class ReadOnlyList : IList
         {
             private readonly IList _list;
 
@@ -1894,69 +1894,69 @@ namespace System.Collections
                 _list = l;
             }
 
-            public virtual int Count => _list.Count;
+            public int Count => _list.Count;
 
-            public virtual bool IsReadOnly => true;
+            public bool IsReadOnly => true;
 
-            public virtual bool IsFixedSize => true;
+            public bool IsFixedSize => true;
 
-            public virtual bool IsSynchronized => _list.IsSynchronized;
+            public bool IsSynchronized => _list.IsSynchronized;
 
-            public virtual object? this[int index]
+            public object? this[int index]
             {
                 get => _list[index];
                 set => throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection);
             }
 
-            public virtual object SyncRoot => _list.SyncRoot;
+            public object SyncRoot => _list.SyncRoot;
 
-            public virtual int Add(object? obj)
+            public int Add(object? obj)
             {
                 throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection);
             }
 
-            public virtual void Clear()
+            public void Clear()
             {
                 throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection);
             }
 
-            public virtual bool Contains(object? obj)
+            public bool Contains(object? obj)
             {
                 return _list.Contains(obj);
             }
 
-            public virtual void CopyTo(Array array, int index)
+            public void CopyTo(Array array, int index)
             {
                 _list.CopyTo(array, index);
             }
 
-            public virtual IEnumerator GetEnumerator()
+            public IEnumerator GetEnumerator()
             {
                 return _list.GetEnumerator();
             }
 
-            public virtual int IndexOf(object? value)
+            public int IndexOf(object? value)
             {
                 return _list.IndexOf(value);
             }
 
-            public virtual void Insert(int index, object? obj)
+            public void Insert(int index, object? obj)
             {
                 throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection);
             }
 
-            public virtual void Remove(object? value)
+            public void Remove(object? value)
             {
                 throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection);
             }
 
-            public virtual void RemoveAt(int index)
+            public void RemoveAt(int index)
             {
                 throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection);
             }
         }
 
-        private class ReadOnlyArrayList : ArrayList
+        private sealed class ReadOnlyArrayList : ArrayList
         {
             private ArrayList _list;
 
@@ -2200,7 +2200,7 @@ namespace System.Collections
 
         // Implementation of a generic list subrange. An instance of this class
         // is returned by the default implementation of List.GetRange.
-        private class Range : ArrayList
+        private sealed class Range : ArrayList
         {
             private ArrayList _baseList;
             private readonly int _baseIndex;
@@ -2686,7 +2686,7 @@ namespace System.Collections
             }
         }
 
-        internal class ArrayListDebugView
+        internal sealed class ArrayListDebugView
         {
             private readonly ArrayList _arrayList;
 
index 373304c..0b65c04 100644 (file)
@@ -1194,7 +1194,7 @@ namespace System.Collections
 
         // Implements a Collection for the keys of a hashtable. An instance of this
         // class is created by the GetKeys method of a hashtable.
-        private class KeyCollection : ICollection
+        private sealed class KeyCollection : ICollection
         {
             private readonly Hashtable _hashtable;
 
@@ -1203,7 +1203,7 @@ namespace System.Collections
                 _hashtable = hashtable;
             }
 
-            public virtual void CopyTo(Array array, int arrayIndex)
+            public void CopyTo(Array array, int arrayIndex)
             {
                 if (array == null)
                     throw new ArgumentNullException(nameof(array));
@@ -1216,21 +1216,21 @@ namespace System.Collections
                 _hashtable.CopyKeys(array, arrayIndex);
             }
 
-            public virtual IEnumerator GetEnumerator()
+            public IEnumerator GetEnumerator()
             {
                 return new HashtableEnumerator(_hashtable, HashtableEnumerator.Keys);
             }
 
-            public virtual bool IsSynchronized => _hashtable.IsSynchronized;
+            public bool IsSynchronized => _hashtable.IsSynchronized;
 
-            public virtual object SyncRoot => _hashtable.SyncRoot;
+            public object SyncRoot => _hashtable.SyncRoot;
 
-            public virtual int Count => _hashtable._count;
+            public int Count => _hashtable._count;
         }
 
         // Implements a Collection for the values of a hashtable. An instance of
         // this class is created by the GetValues method of a hashtable.
-        private class ValueCollection : ICollection
+        private sealed class ValueCollection : ICollection
         {
             private readonly Hashtable _hashtable;
 
@@ -1239,7 +1239,7 @@ namespace System.Collections
                 _hashtable = hashtable;
             }
 
-            public virtual void CopyTo(Array array, int arrayIndex)
+            public void CopyTo(Array array, int arrayIndex)
             {
                 if (array == null)
                     throw new ArgumentNullException(nameof(array));
@@ -1252,22 +1252,22 @@ namespace System.Collections
                 _hashtable.CopyValues(array, arrayIndex);
             }
 
-            public virtual IEnumerator GetEnumerator()
+            public IEnumerator GetEnumerator()
             {
                 return new HashtableEnumerator(_hashtable, HashtableEnumerator.Values);
             }
 
-            public virtual bool IsSynchronized => _hashtable.IsSynchronized;
+            public bool IsSynchronized => _hashtable.IsSynchronized;
 
-            public virtual object SyncRoot => _hashtable.SyncRoot;
+            public object SyncRoot => _hashtable.SyncRoot;
 
-            public virtual int Count => _hashtable._count;
+            public int Count => _hashtable._count;
         }
 
         // Synchronized wrapper for hashtable
-        private class SyncHashtable : Hashtable, IEnumerable
+        private sealed class SyncHashtable : Hashtable, IEnumerable
         {
-            protected Hashtable _table;
+            private Hashtable _table;
 
             internal SyncHashtable(Hashtable table) : base(false)
             {
@@ -1416,7 +1416,7 @@ namespace System.Collections
         // Implements an enumerator for a hashtable. The enumerator uses the
         // internal version number of the hashtable to ensure that no modifications
         // are made to the hashtable while an enumeration is in progress.
-        private class HashtableEnumerator : IDictionaryEnumerator, ICloneable
+        private sealed class HashtableEnumerator : IDictionaryEnumerator, ICloneable
         {
             private readonly Hashtable _hashtable;
             private int _bucket;
@@ -1441,7 +1441,7 @@ namespace System.Collections
 
             public object Clone() => MemberwiseClone();
 
-            public virtual object Key
+            public object Key
             {
                 get
                 {
@@ -1451,7 +1451,7 @@ namespace System.Collections
                 }
             }
 
-            public virtual bool MoveNext()
+            public bool MoveNext()
             {
                 if (_version != _hashtable._version)
                     throw new InvalidOperationException(SR.InvalidOperation_EnumFailedVersion);
@@ -1471,7 +1471,7 @@ namespace System.Collections
                 return false;
             }
 
-            public virtual DictionaryEntry Entry
+            public DictionaryEntry Entry
             {
                 get
                 {
@@ -1481,7 +1481,7 @@ namespace System.Collections
                 }
             }
 
-            public virtual object? Current
+            public object? Current
             {
                 get
                 {
@@ -1497,7 +1497,7 @@ namespace System.Collections
                 }
             }
 
-            public virtual object? Value
+            public object? Value
             {
                 get
                 {
@@ -1507,7 +1507,7 @@ namespace System.Collections
                 }
             }
 
-            public virtual void Reset()
+            public void Reset()
             {
                 if (_version != _hashtable._version)
                     throw new InvalidOperationException(SR.InvalidOperation_EnumFailedVersion);
@@ -1519,7 +1519,7 @@ namespace System.Collections
         }
 
         // internal debug view class for hashtable
-        internal class HashtableDebugView
+        internal sealed class HashtableDebugView
         {
             private readonly Hashtable _hashtable;
 
index 6d1e362..58eb617 100644 (file)
@@ -15,7 +15,7 @@ using System.Diagnostics;
 namespace System.Collections
 {
     [DebuggerDisplay("{_value}", Name = "[{_key}]")]
-    internal class KeyValuePairs
+    internal sealed class KeyValuePairs
     {
         [DebuggerBrowsable(DebuggerBrowsableState.Never)]
         private readonly object _key;
index e0419b1..b06c9ed 100644 (file)
@@ -222,7 +222,7 @@ namespace System.Collections
             count--;
         }
 
-        private class NodeEnumerator : IDictionaryEnumerator
+        private sealed class NodeEnumerator : IDictionaryEnumerator
         {
             private readonly ListDictionaryInternal list;
             private DictionaryNode? current;
@@ -307,7 +307,7 @@ namespace System.Collections
             }
         }
 
-        private class NodeKeyValueCollection : ICollection
+        private sealed class NodeKeyValueCollection : ICollection
         {
             private readonly ListDictionaryInternal list;
             private readonly bool isKeys;
@@ -357,7 +357,7 @@ namespace System.Collections
                 return new NodeKeyValueEnumerator(list, isKeys);
             }
 
-            private class NodeKeyValueEnumerator : IEnumerator
+            private sealed class NodeKeyValueEnumerator : IEnumerator
             {
                 private readonly ListDictionaryInternal list;
                 private DictionaryNode? current;
@@ -420,7 +420,7 @@ namespace System.Collections
         }
 
         [Serializable]
-        private class DictionaryNode
+        private sealed class DictionaryNode
         {
             public object key = null!;
             public object? value;
index 973a95c..3517d08 100644 (file)
@@ -22,7 +22,7 @@ using System.Globalization;
 namespace System
 {
     [Obsolete("System.CurrentSystemTimeZone has been deprecated.  Please investigate the use of System.TimeZoneInfo.Local instead.")]
-    internal class CurrentSystemTimeZone : TimeZone
+    internal sealed class CurrentSystemTimeZone : TimeZone
     {
         // Standard offset in ticks to the Universal time if
         // no daylight saving is in used.
index 6b275ff..2571935 100644 (file)
@@ -1257,7 +1257,7 @@ namespace System
             String = 1 << TypeCode.String,
         }
 
-        internal class BinderState
+        internal sealed class BinderState
         {
             internal readonly int[] _argsMap;
             internal readonly int _originalSize;
index e3f6632..0774782 100644 (file)
@@ -38,7 +38,7 @@ namespace System.Diagnostics.Tracing
     ///
     /// On any normal event log the event with activityTracker.CurrentActivityId
     /// </summary>
-    internal class ActivityTracker
+    internal sealed class ActivityTracker
     {
         /// <summary>
         /// Called on work item begins.  The activity name = providerName + activityName without 'Start' suffix.
@@ -300,7 +300,7 @@ namespace System.Diagnostics.Tracing
         /// the 'list of live parents' which indicate of those ancestors, which are alive (if they
         /// are not marked dead they are alive).
         /// </summary>
-        private class ActivityInfo
+        private sealed class ActivityInfo
         {
             public ActivityInfo(string name, long uniqueId, ActivityInfo? creator, Guid activityIDToRestore, EventActivityOptions options)
             {
@@ -618,7 +618,7 @@ namespace System.Diagnostics.Tracing
     /// </summary>
     ///
     [EventSource(Name = "Microsoft.Tasks.Nuget")]
-    internal class TplEventSource : EventSource
+    internal sealed class TplEventSource : EventSource
     {
         public class Keywords
         {
index ce521a0..3146d1f 100644 (file)
@@ -16,7 +16,7 @@ namespace System.Diagnostics.Tracing
 #endif
 {
     [UnsupportedOSPlatform("browser")]
-    internal class CounterGroup
+    internal sealed class CounterGroup
     {
         private readonly EventSource _eventSource;
         private readonly List<DiagnosticCounter> _counters;
index cb8fbaf..6c87215 100644 (file)
@@ -15,7 +15,7 @@ namespace System.Diagnostics.Tracing
 #endif
 {
     [EventData]
-    internal class CounterPayload : IEnumerable<KeyValuePair<string, object?>>
+    internal sealed class CounterPayload : IEnumerable<KeyValuePair<string, object?>>
     {
         public string? Name { get; set; }
 
@@ -76,7 +76,7 @@ namespace System.Diagnostics.Tracing
     }
 
     [EventData]
-    internal class IncrementingCounterPayload : IEnumerable<KeyValuePair<string, object?>>
+    internal sealed class IncrementingCounterPayload : IEnumerable<KeyValuePair<string, object?>>
     {
         public string? Name { get; set; }
 
index a5ae224..52dac79 100644 (file)
@@ -198,7 +198,7 @@ namespace System.Diagnostics.Tracing
     /// This is the payload that is sent in the with EventSource.Write
     /// </summary>
     [EventData]
-    internal class CounterPayloadType
+    internal sealed class CounterPayloadType
     {
         public CounterPayloadType(CounterPayload payload) { Payload = payload; }
         public CounterPayload Payload { get; set; }
index 9e1d568..ff9278b 100644 (file)
@@ -2401,7 +2401,7 @@ namespace System.Diagnostics.Tracing
         /// <summary>
         /// This class lets us hook the 'OnEventCommand' from the eventSource.
         /// </summary>
-        private class OverrideEventProvider : EventProvider
+        private sealed class OverrideEventProvider : EventProvider
         {
             public OverrideEventProvider(EventSource eventSource, EventProviderType providerType)
                 : base(providerType)
@@ -5127,7 +5127,7 @@ namespace System.Diagnostics.Tracing
     /// one EventListener (although EventDispatcher does not 'remember' the EventSource it is
     /// associated with.
     /// </summary>
-    internal class EventDispatcher
+    internal sealed class EventDispatcher
     {
         internal EventDispatcher(EventDispatcher? next, bool[]? eventEnabled, EventListener listener)
         {
@@ -5181,7 +5181,7 @@ namespace System.Diagnostics.Tracing
     /// ManifestBuilder is designed to isolate the details of the message of the event from the
     /// rest of EventSource.  This one happens to create XML.
     /// </summary>
-    internal class ManifestBuilder
+    internal sealed class ManifestBuilder
     {
         /// <summary>
         /// Build a manifest for 'providerName' with the given GUID, which will be packaged into 'dllName'.
@@ -6087,7 +6087,7 @@ namespace System.Diagnostics.Tracing
         }
 
 #if FEATURE_MANAGED_ETW_CHANNELS
-        private class ChannelInfo
+        private sealed class ChannelInfo
         {
             public string? Name;
             public ulong Keywords;
index 633ab21..13e5f19 100644 (file)
@@ -96,7 +96,7 @@ namespace System.Diagnostics.Tracing
     /// This is the payload that is sent in the with EventSource.Write
     /// </summary>
     [EventData]
-    internal class IncrementingEventCounterPayloadType
+    internal sealed class IncrementingEventCounterPayloadType
     {
         public IncrementingEventCounterPayloadType(IncrementingCounterPayload payload) { Payload = payload; }
         public IncrementingCounterPayload Payload { get; set; }
index 1097c38..86d46a0 100644 (file)
@@ -99,7 +99,7 @@ namespace System.Diagnostics.Tracing
     /// This is the payload that is sent in the with EventSource.Write
     /// </summary>
     [EventData]
-    internal class IncrementingPollingCounterPayloadType
+    internal sealed class IncrementingPollingCounterPayloadType
     {
         public IncrementingPollingCounterPayloadType(IncrementingCounterPayload payload) { Payload = payload; }
         public IncrementingCounterPayload Payload { get; set; }
index 5b3063f..fee9867 100644 (file)
@@ -89,7 +89,7 @@ namespace System.Diagnostics.Tracing
     /// This is the payload that is sent in the with EventSource.Write
     /// </summary>
     [EventData]
-    internal class PollingPayloadType
+    internal sealed class PollingPayloadType
     {
         public PollingPayloadType(CounterPayload payload) { Payload = payload; }
         public CounterPayload Payload { get; set; }
index 005ffb1..cd34723 100644 (file)
@@ -20,7 +20,7 @@ namespace System.Diagnostics.Tracing
     /// EventSource APIs.
     /// Preserving the order of the elements as they were found inside user defined types is the most important characteristic of this class.
     /// </summary>
-    internal class EventPayload : IDictionary<string, object?>
+    internal sealed class EventPayload : IDictionary<string, object?>
     {
         internal EventPayload(List<string> payloadNames, List<object?> payloadValues)
         {
index cd5db86..776dc1c 100644 (file)
@@ -15,7 +15,7 @@ namespace System.Diagnostics.Tracing
     /// TraceLogging: Contains the information needed to generate tracelogging
     /// metadata for an event field.
     /// </summary>
-    internal class FieldMetadata
+    internal sealed class FieldMetadata
     {
         /// <summary>
         /// Name of the field
index e0f2943..598898f 100644 (file)
@@ -14,7 +14,7 @@ namespace System.Diagnostics.Tracing
     /// TraceLogging: used when implementing a custom TraceLoggingTypeInfo.
     /// An instance of this type is provided to the TypeInfo.WriteMetadata method.
     /// </summary>
-    internal class TraceLoggingMetadataCollector
+    internal sealed class TraceLoggingMetadataCollector
     {
         private readonly Impl impl;
         private readonly FieldMetadata? currentGroup;
@@ -313,7 +313,7 @@ namespace System.Diagnostics.Tracing
             }
         }
 
-        private class Impl
+        private sealed class Impl
         {
             internal readonly List<FieldMetadata> fields = new List<FieldMetadata>();
             internal short scratchSize;
index 51ce2ce..c341452 100644 (file)
@@ -14,7 +14,7 @@ using System.Runtime.Versioning;
 
 namespace System.Diagnostics.Tracing
 {
-    internal class XplatEventLogger : EventListener
+    internal sealed class XplatEventLogger : EventListener
     {
         public XplatEventLogger() {}
 
index 8aadade..9754b21 100644 (file)
@@ -54,7 +54,7 @@ namespace System
     };
 
     [StructLayout(LayoutKind.Sequential)]
-    internal class GCMemoryInfoData
+    internal sealed class GCMemoryInfoData
     {
         internal long _highMemoryLoadThresholdBytes;
         internal long _totalAvailableMemoryBytes;
index aa2b30f..c91e7fa 100644 (file)
@@ -2618,7 +2618,7 @@ namespace System.Globalization
             return Culture.CompareInfo.Compare(string1, offset1, length1, string2, offset2, length2, CompareOptions.IgnoreCase) == 0;
         }
 
-        internal class TokenHashValue
+        internal sealed class TokenHashValue
         {
             internal string tokenString;
             internal TokenType tokenType;
index bae033c..e459993 100644 (file)
@@ -67,7 +67,7 @@ namespace System.Globalization
         LAST_CALENDAR = 23      // Last calendar ID
     }
 
-    internal class DateTimeFormatInfoScanner
+    internal sealed class DateTimeFormatInfoScanner
     {
         // Special prefix-like flag char in DateWord array.
 
index e1dd518..3fd6480 100644 (file)
@@ -4,7 +4,7 @@
 namespace System.Globalization
 {
     // Gregorian Calendars use Era Info
-    internal class EraInfo
+    internal sealed class EraInfo
     {
         internal int era;          // The value of the era.
         internal long ticks;    // The time in ticks when the era starts
@@ -45,7 +45,7 @@ namespace System.Globalization
     // This calendar recognizes two era values:
     // 0 CurrentEra (AD)
     // 1 BeforeCurrentEra (BC)
-    internal class GregorianCalendarHelper
+    internal sealed class GregorianCalendarHelper
     {
         // 1 tick = 100ns = 10E-7 second
         // Number of ticks per time unit
index b11fa9b..4a6aef5 100644 (file)
@@ -892,7 +892,7 @@ namespace System.Globalization
             return year;
         }
 
-        internal class DateBuffer
+        internal sealed class DateBuffer
         {
             internal int year;
             internal int month;
index b0778f5..b60daed 100644 (file)
@@ -40,7 +40,7 @@ namespace System
     /// - allows for instantiation for ExecutionAndPublication so as to create an object for locking on
     /// - holds exception information.
     /// </summary>
-    internal class LazyHelper
+    internal sealed class LazyHelper
     {
         internal static readonly LazyHelper NoneViaConstructor            = new LazyHelper(LazyState.NoneViaConstructor);
         internal static readonly LazyHelper NoneViaFactory                = new LazyHelper(LazyState.NoneViaFactory);
index 1d30d3c..0a8d72c 100644 (file)
@@ -3,7 +3,7 @@
 
 namespace System.Reflection.Emit
 {
-    internal class EmptyCAHolder : ICustomAttributeProvider
+    internal sealed class EmptyCAHolder : ICustomAttributeProvider
     {
         internal EmptyCAHolder() { }
 
index 569bd36..b402b32 100644 (file)
@@ -13,7 +13,7 @@ using System.Diagnostics;
 
 namespace System.Reflection.Emit
 {
-    internal class TypeNameBuilder
+    internal sealed class TypeNameBuilder
     {
         private StringBuilder _str = new StringBuilder();
         private int _instNesting;
index af70d9f..2bbdd3d 100644 (file)
@@ -19,7 +19,7 @@ using Internal.IO;
 
 namespace System.Resources
 {
-    internal class FileBasedResourceGroveler : IResourceGroveler
+    internal sealed class FileBasedResourceGroveler : IResourceGroveler
     {
         private readonly ResourceManager.ResourceManagerMediator _mediator;
 
index 66434a2..84b3a70 100644 (file)
@@ -19,7 +19,7 @@ using System.Globalization;
 
 namespace System.Resources
 {
-    internal class ResourceFallbackManager : IEnumerable<CultureInfo>
+    internal sealed class ResourceFallbackManager : IEnumerable<CultureInfo>
     {
         private readonly CultureInfo m_startingCulture;
         private readonly CultureInfo? m_neutralResourcesCulture;
index 16c585d..d7b8bae 100644 (file)
@@ -92,7 +92,7 @@ namespace System.Resources
 
     public partial class ResourceManager
     {
-        internal class CultureNameResourceSetPair
+        internal sealed class CultureNameResourceSetPair
         {
             public string? lastCultureName;
             public ResourceSet? lastResourceSet;
@@ -743,7 +743,7 @@ namespace System.Resources
             return ums;
         }
 
-        internal class ResourceManagerMediator
+        internal sealed class ResourceManagerMediator
         {
             private readonly ResourceManager _rm;
 
index 7232108..3e58726 100644 (file)
@@ -3,7 +3,7 @@
 
 namespace System.Text
 {
-    internal class CodePageDataItem
+    internal sealed class CodePageDataItem
     {
         public int UIFamilyCodePage { get; }
         public string WebName { get; }
index 1c7066e..927c1de 100644 (file)
@@ -1301,7 +1301,7 @@ namespace System.Text
                 _encoding.GetChars(bytes, byteCount, chars, charCount);
         }
 
-        internal class EncodingCharBuffer
+        internal sealed class EncodingCharBuffer
         {
             private unsafe char* _chars;
             private readonly unsafe char* _charStart;
@@ -1449,7 +1449,7 @@ namespace System.Text
             internal int Count => _charCountResult;
         }
 
-        internal class EncodingByteBuffer
+        internal sealed class EncodingByteBuffer
         {
             private unsafe byte* _bytes;
             private readonly unsafe byte* _byteStart;
index 7111d94..820df39 100644 (file)
@@ -661,7 +661,7 @@ namespace System.Text
             /// <summary>
             /// Used to hold all the chunks indexes when you have many chunks.
             /// </summary>
-            private class ManyChunkInfo
+            private sealed class ManyChunkInfo
             {
                 private readonly StringBuilder[] _chunks;    // These are in normal order (first chunk first)
                 private int _chunkPos;
index 59d5b52..8a972e5 100644 (file)
@@ -136,7 +136,7 @@ namespace System.Threading
             }
         }
 
-        private class WaitThreadNode
+        private sealed class WaitThreadNode
         {
             public WaitThread Thread { get; }
             public WaitThreadNode? Next { get; set; }
@@ -147,7 +147,7 @@ namespace System.Threading
         /// <summary>
         /// A thread pool wait thread.
         /// </summary>
-        internal class WaitThread
+        internal sealed class WaitThread
         {
             /// <summary>
             /// The wait handles registered on this wait thread.
index f2d7f91..d8767a5 100644 (file)
@@ -20,7 +20,7 @@ namespace System.Threading
     // allocate N of these, where N is the maximum number of locks held simultaneously
     // by that thread.
     //
-    internal class ReaderWriterCount
+    internal sealed class ReaderWriterCount
     {
         // Which lock does this object belong to?  This is a numeric ID for two reasons:
         // 1) We don't want this field to keep the lock object alive, and a WeakReference would
index 171a44f..bcb28ec 100644 (file)
@@ -582,9 +582,9 @@ namespace System.Threading
 
         #region Debugger proxy class
         /// <summary>
-        /// Internal class used by debug type proxy attribute to display the owner thread ID
+        /// internal sealed class used by debug type proxy attribute to display the owner thread ID
         /// </summary>
-        internal class SystemThreading_SpinLockDebugView
+        internal sealed class SystemThreading_SpinLockDebugView
         {
             // SpinLock object
             private SpinLock _spinLock;
index f468d0b..f2dd5b2 100644 (file)
@@ -1394,7 +1394,7 @@ namespace System.Threading.Tasks
     }
 
     // Proxy class for better debugging experience
-    internal class SystemThreadingTasks_FutureDebugView<TResult>
+    internal sealed class SystemThreadingTasks_FutureDebugView<TResult>
     {
         private readonly Task<TResult> m_task;
 
index a487e57..18a7b33 100644 (file)
@@ -224,7 +224,7 @@ namespace System.Threading.Tasks
         // need to be accessed during the life cycle of a Task, so we don't want to instantiate them every time.  Once
         // one of these properties needs to be written, we will instantiate a ContingentProperties object and set
         // the appropriate property.
-        internal class ContingentProperties
+        internal sealed class ContingentProperties
         {
             // Additional context
 
@@ -6487,7 +6487,7 @@ namespace System.Threading.Tasks
     }
 
     // Proxy class for better debugging experience
-    internal class SystemThreadingTasks_TaskDebugView
+    internal sealed class SystemThreadingTasks_TaskDebugView
     {
         private readonly Task m_task;
 
index 3c3e809..a3277c5 100644 (file)
@@ -24,7 +24,7 @@ namespace System.Threading.Tasks
     /// is ever GC'd without the holder's contents ever having been requested
     /// (e.g. by a Task.Wait, Task.get_Exception, etc).
     /// </summary>
-    internal class TaskExceptionHolder
+    internal sealed class TaskExceptionHolder
     {
         /// <summary>The task with which this holder is associated.</summary>
         private readonly Task m_task;
index cf80323..0da194e 100644 (file)
@@ -671,7 +671,7 @@ namespace System.Threading
         /// <summary>
         /// A manager class that assigns IDs to ThreadLocal instances
         /// </summary>
-        private class IdManager
+        private sealed class IdManager
         {
             // The next ID to try
             private int _nextIdToTry;
@@ -728,7 +728,7 @@ namespace System.Threading
         /// (all those LinkedSlot instances can be found by following references from the table slots) and
         /// releases the table so that it can get GC'd.
         /// </summary>
-        private class FinalizationHelper
+        private sealed class FinalizationHelper
         {
             internal LinkedSlotVolatile[] SlotArray;
             private readonly bool _trackAllValues;
index d49e39d..128b59d 100644 (file)
@@ -2,7 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 
 
-// This file defines an internal class used to throw exceptions in BCL code.
+// This file defines an internal static class used to throw exceptions in BCL code.
 // The main purpose is to reduce code size.
 //
 // The old way to throw an exception generates quite a lot IL code and assembly code.
index b327ae3..fca9cf4 100644 (file)
@@ -150,7 +150,7 @@ namespace Mono
     {
     }
 
-    internal class NullByRefReturnException : Exception
+    internal sealed class NullByRefReturnException : Exception
     {
         public NullByRefReturnException()
         {
index 3c9aae9..bb4ba93 100644 (file)
@@ -13,7 +13,7 @@ namespace System
     public partial class Array
     {
         [StructLayout(LayoutKind.Sequential)]
-        private class RawData
+        private sealed class RawData
         {
             public IntPtr Bounds;
             // The following is to prevent a mismatch between the managed and runtime
index e026e51..0d807bb 100644 (file)
@@ -10,7 +10,7 @@ namespace System.Diagnostics
 {
     // Need our own stackframe class since the shared version has its own fields
     [StructLayout(LayoutKind.Sequential)]
-    internal class MonoStackFrame
+    internal sealed class MonoStackFrame
     {
         #region Keep in sync with object-internals.h
         internal int ilOffset;
index 0f12e9c..52ef945 100644 (file)
@@ -752,7 +752,7 @@ namespace System.Reflection
         private static readonly AttributeUsageAttribute DefaultAttributeUsage =
             new AttributeUsageAttribute(AttributeTargets.All);
 
-        private class AttributeInfo
+        private sealed class AttributeInfo
         {
             private AttributeUsageAttribute _usage;
             private int _inheritanceLevel;
index ec376ae..f5b70f5 100644 (file)
@@ -36,7 +36,7 @@ namespace System.Reflection
 {
     public class CustomAttributeData
     {
-        private class LazyCAttrData
+        private sealed class LazyCAttrData
         {
             internal Assembly assembly = null!; // only call site always sets it
             internal IntPtr data;
index bdebf80..a6a9321 100644 (file)
@@ -43,7 +43,7 @@ using System.Runtime.InteropServices;
 
 namespace System.Reflection.Emit
 {
-    internal class GenericInstanceKey
+    internal sealed class GenericInstanceKey
     {
         private Type gtd;
         internal Type[] args;
index 8ca3550..c1d101c 100644 (file)
@@ -492,7 +492,7 @@ namespace System.Reflection.Emit
         }
     }
 
-    internal class DynamicMethodTokenGenerator : ITokenGenerator
+    internal sealed class DynamicMethodTokenGenerator : ITokenGenerator
     {
 
         private DynamicMethod m;
index 6573748..1db909b 100644 (file)
@@ -40,7 +40,7 @@ namespace System.Reflection.Emit
      * This class represents an event of an instantiation of a generic type builder.
      */
     [StructLayout(LayoutKind.Sequential)]
-    internal class EventOnTypeBuilderInst : EventInfo
+    internal sealed class EventOnTypeBuilderInst : EventInfo
     {
         private TypeBuilderInstantiation instantiation;
         private EventBuilder? event_builder;
index 3a68f0e..e6b6339 100644 (file)
@@ -1069,7 +1069,7 @@ namespace System.Reflection.Emit
         }
     }
 
-    internal class SequencePointList
+    internal sealed class SequencePointList
     {
         private ISymbolDocumentWriter doc;
         private SequencePoint[]? points;
@@ -1167,7 +1167,7 @@ namespace System.Reflection.Emit
         public int EndCol;
     }
 
-    internal class Stack
+    internal sealed class Stack
     {
         private object?[] _array;
         private int _size;
@@ -1194,7 +1194,7 @@ namespace System.Reflection.Emit
             _version = 0;
         }
 
-        public virtual int Count
+        public int Count
         {
             get
             {
@@ -1202,7 +1202,7 @@ namespace System.Reflection.Emit
             }
         }
 
-        public virtual object? Peek()
+        public object? Peek()
         {
             if (_size == 0)
                 throw new InvalidOperationException();
@@ -1210,7 +1210,7 @@ namespace System.Reflection.Emit
             return _array[_size - 1];
         }
 
-        public virtual object? Pop()
+        public object? Pop()
         {
             if (_size == 0)
                 throw new InvalidOperationException();
@@ -1221,7 +1221,7 @@ namespace System.Reflection.Emit
             return obj;
         }
 
-        public virtual void Push(object obj)
+        public void Push(object obj)
         {
             if (_size == _array.Length)
             {
index 80220b2..bc0b594 100644 (file)
@@ -991,7 +991,7 @@ namespace System.Reflection.Emit
         }
     }
 
-    internal class ModuleBuilderTokenGenerator : ITokenGenerator
+    internal sealed class ModuleBuilderTokenGenerator : ITokenGenerator
     {
 
         private ModuleBuilder mb;
index 0d51eee..8421804 100644 (file)
@@ -41,7 +41,7 @@ using System.Runtime.InteropServices;
 namespace System.Reflection
 {
     [StructLayout(LayoutKind.Sequential)]
-    internal class MonoArrayMethod : MethodInfo
+    internal sealed class MonoArrayMethod : MethodInfo
     {
 #pragma warning disable 649
         internal RuntimeMethodHandle mhandle;
index a3ad727..0a172d3 100644 (file)
@@ -40,7 +40,7 @@ namespace System.Reflection.Emit
      * This class represents a property of an instantiation of a generic type builder.
      */
     [StructLayout(LayoutKind.Sequential)]
-    internal class PropertyOnTypeBuilderInst : PropertyInfo
+    internal sealed class PropertyOnTypeBuilderInst : PropertyInfo
     {
         private TypeBuilderInstantiation instantiation;
         private PropertyInfo prop;
index 56dd436..b4a9c2f 100644 (file)
@@ -40,7 +40,7 @@ namespace System.Reflection
     }
 
     [StructLayout(LayoutKind.Sequential)]
-    internal class RuntimeFieldInfo : RtFieldInfo
+    internal sealed class RuntimeFieldInfo : RtFieldInfo
     {
 #pragma warning disable 649
         internal IntPtr klass;
index 83c67ea..aba9b94 100644 (file)
@@ -139,7 +139,7 @@ namespace System.Reflection
 
 #region Sync with _MonoReflectionMethod in object-internals.h
     [StructLayout(LayoutKind.Sequential)]
-    internal class RuntimeMethodInfo : MethodInfo
+    internal sealed class RuntimeMethodInfo : MethodInfo
     {
 #pragma warning disable 649
         internal IntPtr mhandle;
@@ -765,7 +765,7 @@ namespace System.Reflection
     }
 #region Sync with _MonoReflectionMethod in object-internals.h
     [StructLayout(LayoutKind.Sequential)]
-    internal class RuntimeConstructorInfo : ConstructorInfo
+    internal sealed class RuntimeConstructorInfo : ConstructorInfo
     {
 #pragma warning disable 649
         internal IntPtr mhandle;
index 4d2f8e7..22b5774 100644 (file)
@@ -33,7 +33,7 @@ namespace System.Reflection
 {
 
     [StructLayout(LayoutKind.Sequential)]
-    internal class RuntimeModule : Module
+    internal sealed class RuntimeModule : Module
     {
 #pragma warning disable 649
         #region Sync with object-internals.h
index b725f72..6bbad3a 100644 (file)
@@ -9,7 +9,7 @@ using System.Text;
 
 namespace System.Reflection
 {
-    internal class RuntimeParameterInfo : ParameterInfo
+    internal sealed class RuntimeParameterInfo : ParameterInfo
     {
         internal MarshalAsAttribute? marshalAs;
 
index 0967b1e..9e05a18 100644 (file)
@@ -62,7 +62,7 @@ namespace System.Reflection
     internal delegate R Getter<T, R>(T _this);
 
     [StructLayout(LayoutKind.Sequential)]
-    internal class RuntimePropertyInfo : PropertyInfo
+    internal sealed class RuntimePropertyInfo : PropertyInfo
     {
 #pragma warning disable 649
         internal IntPtr klass;
index a2560dd..2d1e780 100644 (file)
@@ -91,7 +91,7 @@ namespace System
             }
         }
 
-        private class Display : ATypeName
+        private sealed class Display : ATypeName
         {
             private readonly string displayName;
 
@@ -135,7 +135,7 @@ namespace System
             return new NoEscape(simpleName);
         }
 
-        private class Display : TypeNames.ATypeName, ITypeIdentifier
+        private sealed class Display : TypeNames.ATypeName, ITypeIdentifier
         {
             private readonly string displayName;
             private string? internal_name; //cached
@@ -158,7 +158,7 @@ namespace System
                 TypeNames.FromDisplay(DisplayName + "+" + innerName.DisplayName);
         }
 
-        private class Internal : TypeNames.ATypeName, ITypeIdentifier
+        private sealed class Internal : TypeNames.ATypeName, ITypeIdentifier
         {
             private readonly string internalName;
             private string? display_name; //cached
@@ -183,7 +183,7 @@ namespace System
                 TypeNames.FromDisplay(DisplayName + "+" + innerName.DisplayName);
         }
 
-        private class NoEscape : TypeNames.ATypeName, ITypeIdentifier
+        private sealed class NoEscape : TypeNames.ATypeName, ITypeIdentifier
         {
             private readonly string simpleName;
             internal NoEscape(string simpleName)
index 852bf81..63e6a70 100644 (file)
@@ -219,7 +219,7 @@ namespace System
             return sb.ToString();
         }
 
-        private class ParsedName
+        private sealed class ParsedName
         {
             public List<string>? Names;
             public List<ParsedName>? TypeArguments;
index f78b4c2..cd8c267 100644 (file)
@@ -42,7 +42,7 @@ namespace System
         Type Resolve(Type type);
         Text.StringBuilder Append(Text.StringBuilder sb);
     }
-    internal class IArraySpec : IModifierSpec
+    internal sealed class IArraySpec : IModifierSpec
     {
         // dimensions == 1 and bound, or dimensions > 1 and !bound
         private readonly int dimensions;
@@ -94,7 +94,7 @@ namespace System
         }
     }
 
-    internal class PointerSpec : IModifierSpec
+    internal sealed class PointerSpec : IModifierSpec
     {
         private readonly int pointer_level;
 
@@ -122,7 +122,7 @@ namespace System
 
     }
 
-    internal class TypeSpec
+    internal sealed class TypeSpec
     {
         private ITypeIdentifier? name;
         private string? assembly_name;
@@ -652,7 +652,7 @@ namespace System
             get { return new TypeSpecTypeName(this, true); }
         }
 
-        private class TypeSpecTypeName : TypeNames.ATypeName, ITypeName
+        private sealed class TypeSpecTypeName : TypeNames.ATypeName, ITypeName
         {
             private readonly TypeSpec ts;
             private readonly bool want_modifiers;