diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ConvertTo-Html.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ConvertTo-Html.cs
index 2c530a8ab93..41dd159a3ba 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ConvertTo-Html.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ConvertTo-Html.cs
@@ -321,7 +321,7 @@ internal static class ConvertHTMLParameterDefinitionKeys
///
/// This allows for @{e='foo';label='bar';alignment='center';width='20'}.
///
- internal class ConvertHTMLExpressionParameterDefinition : CommandParameterDefinition
+ internal sealed class ConvertHTMLExpressionParameterDefinition : CommandParameterDefinition
{
protected override void SetEntries()
{
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Csv.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Csv.cs
index 9590cd7c771..d0b9f91e7f7 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Csv.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Csv.cs
@@ -8,7 +8,7 @@ namespace Microsoft.PowerShell.Commands
///
/// This class is used to parse CSV text.
///
- internal class CSVHelper
+ internal sealed class CSVHelper
{
internal CSVHelper(char delimiter)
{
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CsvCommands.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CsvCommands.cs
index 6297d9b1f38..414b472e640 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CsvCommands.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CsvCommands.cs
@@ -885,7 +885,7 @@ protected override void ProcessRecord()
///
/// Helper class for Export-Csv and ConvertTo-Csv.
///
- internal class ExportCsvHelper : IDisposable
+ internal sealed class ExportCsvHelper : IDisposable
{
private readonly char _delimiter;
private readonly BaseCsvWritingCommand.QuoteKind _quoteKind;
@@ -1224,7 +1224,7 @@ public void Dispose()
///
/// Helper class to import single CSV file.
///
- internal class ImportCsvHelper
+ internal sealed class ImportCsvHelper
{
#region constructor
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CustomSerialization.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CustomSerialization.cs
index da4e4a1262a..f8a39cce096 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CustomSerialization.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CustomSerialization.cs
@@ -14,7 +14,7 @@ namespace System.Management.Automation
///
/// This class provides functionality for serializing a PSObject.
///
- internal class CustomSerialization
+ internal sealed class CustomSerialization
{
#region constructor
///
@@ -179,8 +179,7 @@ internal void Stop()
///
/// This internal helper class provides methods for serializing mshObject.
///
- internal class
- CustomInternalSerializer
+ internal sealed class CustomInternalSerializer
{
#region constructor
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/ExpressionColumnInfo.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/ExpressionColumnInfo.cs
index e905f5d64b6..4d0c8af875c 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/ExpressionColumnInfo.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/ExpressionColumnInfo.cs
@@ -6,7 +6,7 @@
namespace Microsoft.PowerShell.Commands
{
- internal class ExpressionColumnInfo : ColumnInfo
+ internal sealed class ExpressionColumnInfo : ColumnInfo
{
private readonly PSPropertyExpression _expression;
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/HeaderInfo.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/HeaderInfo.cs
index d811ce32303..4f4e84a1569 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/HeaderInfo.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/HeaderInfo.cs
@@ -7,7 +7,7 @@
namespace Microsoft.PowerShell.Commands
{
- internal class HeaderInfo
+ internal sealed class HeaderInfo
{
private readonly List _columns = new();
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OriginalColumnInfo.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OriginalColumnInfo.cs
index 974188c2f74..4ec5e2240fa 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OriginalColumnInfo.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OriginalColumnInfo.cs
@@ -9,7 +9,7 @@
namespace Microsoft.PowerShell.Commands
{
- internal class OriginalColumnInfo : ColumnInfo
+ internal sealed class OriginalColumnInfo : ColumnInfo
{
private readonly string _liveObjectPropertyName;
private readonly OutGridViewCommand _parentCmdlet;
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OutGridViewCommand.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OutGridViewCommand.cs
index 43e24e8b5b6..574ca39426d 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OutGridViewCommand.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OutGridViewCommand.cs
@@ -323,7 +323,7 @@ internal static GridHeader ConstructGridHeader(PSObject input, OutGridViewComman
internal abstract void ProcessInputObject(PSObject input);
}
- internal class ScalarTypeHeader : GridHeader
+ internal sealed class ScalarTypeHeader : GridHeader
{
private readonly Type _originalScalarType;
@@ -349,7 +349,7 @@ internal override void ProcessInputObject(PSObject input)
}
}
- internal class NonscalarTypeHeader : GridHeader
+ internal sealed class NonscalarTypeHeader : GridHeader
{
private readonly AppliesTo _appliesTo = null;
@@ -453,7 +453,7 @@ internal override void ProcessInputObject(PSObject input)
}
}
- internal class HeteroTypeHeader : GridHeader
+ internal sealed class HeteroTypeHeader : GridHeader
{
internal HeteroTypeHeader(OutGridViewCommand parentCmd, PSObject input) : base(parentCmd)
{
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OutWindowProxy.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OutWindowProxy.cs
index b406c2bc78c..ef9b0528c75 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OutWindowProxy.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OutWindowProxy.cs
@@ -13,7 +13,7 @@
namespace Microsoft.PowerShell.Commands
{
- internal class OutWindowProxy : IDisposable
+ internal sealed class OutWindowProxy : IDisposable
{
private const string OutGridViewWindowClassName = "Microsoft.Management.UI.Internal.OutGridViewWindow";
private const string OriginalTypePropertyName = "OriginalType";
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/ScalarTypeColumnInfo.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/ScalarTypeColumnInfo.cs
index 77f80c269a3..38cc9668856 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/ScalarTypeColumnInfo.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/ScalarTypeColumnInfo.cs
@@ -6,7 +6,7 @@
namespace Microsoft.PowerShell.Commands
{
- internal class ScalarTypeColumnInfo : ColumnInfo
+ internal sealed class ScalarTypeColumnInfo : ColumnInfo
{
private readonly Type _type;
@@ -29,7 +29,7 @@ internal override object GetValue(PSObject liveObject)
}
}
- internal class TypeNameColumnInfo : ColumnInfo
+ internal sealed class TypeNameColumnInfo : ColumnInfo
{
internal TypeNameColumnInfo(string staleObjectPropertyName, string displayName)
: base(staleObjectPropertyName, displayName)
@@ -43,7 +43,7 @@ internal override object GetValue(PSObject liveObject)
}
}
- internal class ToStringColumnInfo : ColumnInfo
+ internal sealed class ToStringColumnInfo : ColumnInfo
{
private readonly OutGridViewCommand _parentCmdlet;
@@ -60,7 +60,7 @@ internal override object GetValue(PSObject liveObject)
}
}
- internal class IndexColumnInfo : ColumnInfo
+ internal sealed class IndexColumnInfo : ColumnInfo
{
private int _index = 0;
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/TableView.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/TableView.cs
index 9213484d332..e152bb7c973 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/TableView.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/TableView.cs
@@ -12,7 +12,7 @@
namespace Microsoft.PowerShell.Commands
{
- internal class TableView
+ internal sealed class TableView
{
private PSPropertyExpressionFactory _expressionFactory;
private TypeInfoDataBase _typeInfoDatabase;
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetRandomCommandBase.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetRandomCommandBase.cs
index 7d6e4e71e67..fef7764c5b8 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetRandomCommandBase.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetRandomCommandBase.cs
@@ -561,7 +561,7 @@ protected override void EndProcessing()
/// methods using the NextBytes() primitive based on the CLR implementation:
/// https://referencesource.microsoft.com/#mscorlib/system/random.cs.
///
- internal class PolymorphicRandomNumberGenerator
+ internal sealed class PolymorphicRandomNumberGenerator
{
///
/// Initializes a new instance of the class.
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs
index 8142f682b36..16b7db47d41 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs
@@ -1916,7 +1916,7 @@ internal List GenerateProxyModule(
#endregion
}
- internal class ImplicitRemotingCodeGenerator
+ internal sealed class ImplicitRemotingCodeGenerator
{
internal static readonly Version VersionOfScriptWriter = new(1, 0);
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/JsonSchemaReferenceResolutionException.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/JsonSchemaReferenceResolutionException.cs
index ba664ccef1b..7c2a7ac65f4 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/JsonSchemaReferenceResolutionException.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/JsonSchemaReferenceResolutionException.cs
@@ -11,7 +11,7 @@ namespace Microsoft.PowerShell.Commands;
/// Thrown during evaluation of when an attempt
/// to resolve a $ref or $dynamicRef fails.
///
-internal class JsonSchemaReferenceResolutionException : Exception
+internal sealed class JsonSchemaReferenceResolutionException : Exception
{
///
/// Initializes a new instance of the class.
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ObjectCommandComparer.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ObjectCommandComparer.cs
index bb71dfdbe1c..fd01768d5a8 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ObjectCommandComparer.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ObjectCommandComparer.cs
@@ -19,7 +19,7 @@ namespace Microsoft.PowerShell.Commands
/// isExistingProperty is needed to distinguish whether a property exists and its value is null or
/// the property does not exist at all.
///
- internal class ObjectCommandPropertyValue
+ internal sealed class ObjectCommandPropertyValue
{
private ObjectCommandPropertyValue() { }
@@ -136,7 +136,7 @@ public override int GetHashCode()
///
/// ObjectCommandComparer class.
///
- internal class ObjectCommandComparer : IComparer
+ internal sealed class ObjectCommandComparer : IComparer
{
///
/// Initializes a new instance of the class.
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/OrderObjectBase.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/OrderObjectBase.cs
index 519b472620b..178eaa12f62 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/OrderObjectBase.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/OrderObjectBase.cs
@@ -24,7 +24,7 @@ internal static class SortObjectParameterDefinitionKeys
///
///
- internal class SortObjectExpressionParameterDefinition : CommandParameterDefinition
+ internal sealed class SortObjectExpressionParameterDefinition : CommandParameterDefinition
{
protected override void SetEntries()
{
@@ -36,7 +36,7 @@ protected override void SetEntries()
///
///
- internal class GroupObjectExpressionParameterDefinition : CommandParameterDefinition
+ internal sealed class GroupObjectExpressionParameterDefinition : CommandParameterDefinition
{
protected override void SetEntries()
{
@@ -630,7 +630,7 @@ internal sealed class OrderByPropertyEntry
internal bool comparable = false;
}
- internal class OrderByPropertyComparer : IComparer
+ internal sealed class OrderByPropertyComparer : IComparer
{
internal OrderByPropertyComparer(bool[] ascending, CultureInfo cultureInfo, bool caseSensitive)
{
@@ -699,7 +699,7 @@ internal static OrderByPropertyComparer CreateComparer(List
+ internal sealed class IndexedOrderByPropertyComparer : IComparer
{
internal IndexedOrderByPropertyComparer(OrderByPropertyComparer orderByPropertyComparer)
{
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Select-Object.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Select-Object.cs
index efd7007e131..9db27335da5 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Select-Object.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Select-Object.cs
@@ -53,7 +53,7 @@ internal bool IsMatch(PSPropertyExpression expression)
private readonly WildcardPattern[] _wildcardPatterns;
}
- internal class SelectObjectExpressionParameterDefinition : CommandParameterDefinition
+ internal sealed class SelectObjectExpressionParameterDefinition : CommandParameterDefinition
{
protected override void SetEntries()
{
@@ -866,7 +866,7 @@ protected override void EndProcessing()
[SuppressMessage("Microsoft.Usage", "CA2237:MarkISerializableTypesWithSerializable", Justification = "This exception is internal and never thrown by any public API")]
[SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", Justification = "This exception is internal and never thrown by any public API")]
[SuppressMessage("Microsoft.Design", "CA1064:ExceptionsShouldBePublic", Justification = "This exception is internal and never thrown by any public API")]
- internal class SelectObjectException : SystemException
+ internal sealed class SelectObjectException : SystemException
{
internal ErrorRecord ErrorRecord { get; }
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandProxy.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandProxy.cs
index a8a9c8f194d..ab8909bb590 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandProxy.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandProxy.cs
@@ -16,7 +16,7 @@ namespace Microsoft.PowerShell.Commands
/// Help show-command create WPF object and invoke WPF windows with the
/// Microsoft.PowerShell.Commands.ShowCommandInternal.ShowCommandHelperhelp type defined in Microsoft.PowerShell.GraphicalHost.dll.
///
- internal class ShowCommandProxy
+ internal sealed class ShowCommandProxy
{
private const string ShowCommandHelperName = "Microsoft.PowerShell.Commands.ShowCommandInternal.ShowCommandHelper";
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/InvokeRestMethodCommand.Common.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/InvokeRestMethodCommand.Common.cs
index eafdaadbede..22ffaef288c 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/InvokeRestMethodCommand.Common.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/InvokeRestMethodCommand.Common.cs
@@ -354,7 +354,7 @@ public enum RestReturnType
Xml,
}
- internal class BufferingStreamReader : Stream
+ internal sealed class BufferingStreamReader : Stream
{
internal BufferingStreamReader(Stream baseStream, TimeSpan perReadTimeout, CancellationToken cancellationToken)
{
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/CoreCLR/WebProxy.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/CoreCLR/WebProxy.cs
index 6e9f6bdf98e..c7400e75f9d 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/CoreCLR/WebProxy.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/CoreCLR/WebProxy.cs
@@ -8,7 +8,7 @@
namespace Microsoft.PowerShell.Commands
{
- internal class WebProxy : IWebProxy, IEquatable
+ internal sealed class WebProxy : IWebProxy, IEquatable
{
private ICredentials? _credentials;
private readonly Uri _proxyAddress;
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/StreamHelper.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/StreamHelper.cs
index 52ff515b0b2..d24961834b6 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/StreamHelper.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/StreamHelper.cs
@@ -22,7 +22,7 @@ namespace Microsoft.PowerShell.Commands
/// this class as a wrapper to MemoryStream to lazily initialize. Otherwise, the
/// content will unnecessarily be read even if there are no consumers for it.
///
- internal class WebResponseContentMemoryStream : MemoryStream
+ internal sealed class WebResponseContentMemoryStream : MemoryStream
{
#region Data
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/XmlCommands.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/XmlCommands.cs
index 6157849eeec..6473d6d4fae 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/XmlCommands.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/XmlCommands.cs
@@ -715,7 +715,7 @@ protected override void ProcessRecord()
///
/// Helper class to import single XML file.
///
- internal class ImportXmlHelper : IDisposable
+ internal sealed class ImportXmlHelper : IDisposable
{
#region constructor
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/MshHostTraceListener.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/MshHostTraceListener.cs
index 357e0222b6d..b7e4ed279aa 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/MshHostTraceListener.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/MshHostTraceListener.cs
@@ -17,7 +17,7 @@ namespace Microsoft.PowerShell.Commands
/// This trace listener cannot be specified in the app.config file.
/// It must be added through the add-tracelistener cmdlet.
///
- internal class PSHostTraceListener
+ internal sealed class PSHostTraceListener
: System.Diagnostics.TraceListener
{
#region TraceListener constructors and disposer
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/TraceExpressionCommand.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/TraceExpressionCommand.cs
index 91cb0d46abc..2bf7045cbed 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/TraceExpressionCommand.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/TraceExpressionCommand.cs
@@ -323,7 +323,7 @@ public void Dispose()
/// cmdlet. It gets attached to the sub-pipelines success or error pipeline and redirects
/// all objects written to these pipelines to trace-command pipeline.
///
- internal class TracePipelineWriter : PipelineWriter
+ internal sealed class TracePipelineWriter : PipelineWriter
{
internal TracePipelineWriter(
TraceListenerCommandBase cmdlet,