mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Make classes sealed (#15675)
Fix [RCS1225](https://github.com/JosefPihrt/Roslynator/blob/master/docs/analyzers/RCS1225.md)
This commit is contained in:
+1
-1
@@ -19,7 +19,7 @@ namespace Microsoft.PowerShell.Cmdletization.Cim
|
||||
/// <summary>
|
||||
/// Tracks (per-session) terminating errors in a given cmdlet invocation.
|
||||
/// </summary>
|
||||
internal class TerminatingErrorTracker
|
||||
internal sealed class TerminatingErrorTracker
|
||||
{
|
||||
#region Getting tracker for a given cmdlet invocation
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ using Dbg = System.Management.Automation.Diagnostics;
|
||||
|
||||
namespace Microsoft.PowerShell.Cmdletization.Cim
|
||||
{
|
||||
internal class CimCustomOptionsDictionary
|
||||
internal sealed class CimCustomOptionsDictionary
|
||||
{
|
||||
private readonly IDictionary<string, object> _dict;
|
||||
private readonly object _dictModificationLock = new();
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace System.Management.Automation
|
||||
/// <summary>
|
||||
/// The powershell custom AssemblyLoadContext implementation.
|
||||
/// </summary>
|
||||
internal partial class PowerShellAssemblyLoadContext
|
||||
internal sealed partial class PowerShellAssemblyLoadContext
|
||||
{
|
||||
#region Resource_Strings
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// <summary>
|
||||
/// Helper class for writing formatting directives to XML.
|
||||
/// </summary>
|
||||
internal class FormatXmlWriter
|
||||
internal sealed class FormatXmlWriter
|
||||
{
|
||||
private XmlWriter _writer;
|
||||
private bool _exportScriptBlock;
|
||||
|
||||
@@ -928,7 +928,7 @@ namespace System.Management.Automation
|
||||
/// but can be used where a real type might not be available, in which case the name of the type can be used.
|
||||
/// The type encodes the members of dynamic objects in the type name.
|
||||
/// </summary>
|
||||
internal class PSSyntheticTypeName : PSTypeName
|
||||
internal sealed class PSSyntheticTypeName : PSTypeName
|
||||
{
|
||||
internal static PSSyntheticTypeName Create(string typename, IList<PSMemberNameAndType> membersTypes) => Create(new PSTypeName(typename), membersTypes);
|
||||
|
||||
|
||||
@@ -642,7 +642,7 @@ namespace System.Management.Automation
|
||||
}
|
||||
}
|
||||
|
||||
internal class AnalysisCacheData
|
||||
internal sealed class AnalysisCacheData
|
||||
{
|
||||
private static byte[] GetHeader()
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace System.Management.Automation
|
||||
/// <summary>
|
||||
/// A class representing a name that is qualified by the PSSnapin name.
|
||||
/// </summary>
|
||||
internal class PSSnapinQualifiedName
|
||||
internal sealed class PSSnapinQualifiedName
|
||||
{
|
||||
private PSSnapinQualifiedName(string[] splitName)
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
namespace System.Management.Automation.Interpreter
|
||||
{
|
||||
internal class UpdatePositionInstruction : Instruction
|
||||
internal sealed class UpdatePositionInstruction : Instruction
|
||||
{
|
||||
private readonly int _sequencePoint;
|
||||
private readonly bool _checkBreakpoints;
|
||||
|
||||
@@ -356,7 +356,7 @@ namespace System.Management.Automation.Language
|
||||
* except in the case of handling the unary operator
|
||||
* ExecutionContext is provided to ensure we can resolve variables
|
||||
*/
|
||||
internal class GetSafeValueVisitor : ICustomAstVisitor2
|
||||
internal sealed class GetSafeValueVisitor : ICustomAstVisitor2
|
||||
{
|
||||
internal enum SafeValueContext
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@ using Microsoft.PowerShell.DesiredStateConfiguration.Internal;
|
||||
|
||||
namespace System.Management.Automation.Language
|
||||
{
|
||||
internal class SemanticChecks : AstVisitor2, IAstPostVisitHandler
|
||||
internal sealed class SemanticChecks : AstVisitor2, IAstPostVisitHandler
|
||||
{
|
||||
private readonly Parser _parser;
|
||||
|
||||
|
||||
@@ -275,7 +275,7 @@ namespace System.Management.Automation.Language
|
||||
}
|
||||
}
|
||||
|
||||
internal class SymbolResolver : AstVisitor2, IAstPostVisitHandler
|
||||
internal sealed class SymbolResolver : AstVisitor2, IAstPostVisitHandler
|
||||
{
|
||||
private readonly SymbolResolvePostActionVisitor _symbolResolvePostActionVisitor;
|
||||
internal readonly SymbolTable _symbolTable;
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace System.Management.Automation.Language
|
||||
public List<Ast> AssociatedAsts { get; }
|
||||
}
|
||||
|
||||
internal class FindAllVariablesVisitor : AstVisitor
|
||||
internal sealed class FindAllVariablesVisitor : AstVisitor
|
||||
{
|
||||
private static readonly HashSet<string> s_hashOfPessimizingCmdlets = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace System.Management.Automation.Remoting
|
||||
/// <summary>
|
||||
/// Executes methods on the client.
|
||||
/// </summary>
|
||||
internal class ClientMethodExecutor
|
||||
internal sealed class ClientMethodExecutor
|
||||
{
|
||||
/// <summary>
|
||||
/// Transport manager.
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ namespace System.Management.Automation.Remoting
|
||||
/// version on the server. These capabilities will be used in remote debugging sessions to
|
||||
/// determine what is supported by the server.
|
||||
/// </summary>
|
||||
internal class RemoteDebuggingCapability
|
||||
internal sealed class RemoteDebuggingCapability
|
||||
{
|
||||
private readonly HashSet<string> _supportedCommands = new HashSet<string>();
|
||||
|
||||
|
||||
+1
-1
@@ -171,7 +171,7 @@ namespace System.Management.Automation.Remoting
|
||||
/// <summary>
|
||||
/// The HostDefaultData class.
|
||||
/// </summary>
|
||||
internal class HostDefaultData
|
||||
internal sealed class HostDefaultData
|
||||
{
|
||||
/// <summary>
|
||||
/// Data.
|
||||
|
||||
+1
-1
@@ -267,7 +267,7 @@ namespace System.Management.Automation.Remoting
|
||||
#endregion
|
||||
}
|
||||
|
||||
internal class RemoteDataObject : RemoteDataObject<object>
|
||||
internal sealed class RemoteDataObject : RemoteDataObject<object>
|
||||
{
|
||||
#region Constructors / Factory
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ namespace System.Management.Automation
|
||||
/// <summary>
|
||||
/// Execution context used for stepping.
|
||||
/// </summary>
|
||||
internal class ExecutionContextForStepping : IDisposable
|
||||
internal sealed class ExecutionContextForStepping : IDisposable
|
||||
{
|
||||
private readonly ExecutionContext _executionContext;
|
||||
private PSInformationalBuffers _originalInformationalBuffers;
|
||||
|
||||
@@ -513,7 +513,7 @@ namespace System.Management.Automation.Language
|
||||
/// The standard interop ConvertBinder is used to allow third party dynamic objects to get the first chance
|
||||
/// at the conversion in case they do support enumeration, but do not implement IEnumerable directly.
|
||||
/// </summary>
|
||||
internal class PSEnumerableBinder : ConvertBinder
|
||||
internal sealed class PSEnumerableBinder : ConvertBinder
|
||||
{
|
||||
private static readonly PSEnumerableBinder s_binder = new PSEnumerableBinder();
|
||||
|
||||
@@ -780,7 +780,7 @@ namespace System.Management.Automation.Language
|
||||
/// <summary>
|
||||
/// This binder is used for the @() operator.
|
||||
/// </summary>
|
||||
internal class PSToObjectArrayBinder : DynamicMetaObjectBinder
|
||||
internal sealed class PSToObjectArrayBinder : DynamicMetaObjectBinder
|
||||
{
|
||||
private static readonly PSToObjectArrayBinder s_binder = new PSToObjectArrayBinder();
|
||||
|
||||
@@ -836,7 +836,7 @@ namespace System.Management.Automation.Language
|
||||
}
|
||||
}
|
||||
|
||||
internal class PSPipeWriterBinder : DynamicMetaObjectBinder
|
||||
internal sealed class PSPipeWriterBinder : DynamicMetaObjectBinder
|
||||
{
|
||||
private static readonly PSPipeWriterBinder s_binder = new PSPipeWriterBinder();
|
||||
|
||||
@@ -930,7 +930,7 @@ namespace System.Management.Automation.Language
|
||||
/// The target in this binder is the RHS, the result expression is an IList where the Count matches the
|
||||
/// number of values assigned (_elements) on the left hand side of the assign.
|
||||
/// </summary>
|
||||
internal class PSArrayAssignmentRHSBinder : DynamicMetaObjectBinder
|
||||
internal sealed class PSArrayAssignmentRHSBinder : DynamicMetaObjectBinder
|
||||
{
|
||||
private static readonly List<PSArrayAssignmentRHSBinder> s_binders = new List<PSArrayAssignmentRHSBinder>();
|
||||
private readonly int _elements;
|
||||
@@ -1049,7 +1049,7 @@ namespace System.Management.Automation.Language
|
||||
/// case, the format string is generated by the parser, so we know that there is no custom
|
||||
/// formatting to consider.
|
||||
/// </summary>
|
||||
internal class PSToStringBinder : DynamicMetaObjectBinder
|
||||
internal sealed class PSToStringBinder : DynamicMetaObjectBinder
|
||||
{
|
||||
private static readonly PSToStringBinder s_binder = new PSToStringBinder();
|
||||
|
||||
@@ -1114,7 +1114,7 @@ namespace System.Management.Automation.Language
|
||||
/// <summary>
|
||||
/// This binder is used to optimize the conversion of the result.
|
||||
/// </summary>
|
||||
internal class PSPipelineResultToBoolBinder : DynamicMetaObjectBinder
|
||||
internal sealed class PSPipelineResultToBoolBinder : DynamicMetaObjectBinder
|
||||
{
|
||||
private static readonly PSPipelineResultToBoolBinder s_binder = new PSPipelineResultToBoolBinder();
|
||||
|
||||
@@ -1175,7 +1175,7 @@ namespace System.Management.Automation.Language
|
||||
}
|
||||
}
|
||||
|
||||
internal class PSInvokeDynamicMemberBinder : DynamicMetaObjectBinder
|
||||
internal sealed class PSInvokeDynamicMemberBinder : DynamicMetaObjectBinder
|
||||
{
|
||||
private class KeyComparer : IEqualityComparer<PSInvokeDynamicMemberBinderKeyType>
|
||||
{
|
||||
@@ -1286,7 +1286,7 @@ namespace System.Management.Automation.Language
|
||||
}
|
||||
}
|
||||
|
||||
internal class PSGetDynamicMemberBinder : DynamicMetaObjectBinder
|
||||
internal sealed class PSGetDynamicMemberBinder : DynamicMetaObjectBinder
|
||||
{
|
||||
private static readonly Dictionary<PSGetOrSetDynamicMemberBinderKeyType, PSGetDynamicMemberBinder> s_binderCache =
|
||||
new Dictionary<PSGetOrSetDynamicMemberBinderKeyType, PSGetDynamicMemberBinder>(new PSDynamicGetOrSetBinderKeyComparer());
|
||||
@@ -1396,7 +1396,7 @@ namespace System.Management.Automation.Language
|
||||
}
|
||||
}
|
||||
|
||||
internal class PSSetDynamicMemberBinder : DynamicMetaObjectBinder
|
||||
internal sealed class PSSetDynamicMemberBinder : DynamicMetaObjectBinder
|
||||
{
|
||||
private static readonly Dictionary<PSGetOrSetDynamicMemberBinderKeyType, PSSetDynamicMemberBinder> s_binderCache =
|
||||
new Dictionary<PSGetOrSetDynamicMemberBinderKeyType, PSSetDynamicMemberBinder>(new PSDynamicGetOrSetBinderKeyComparer());
|
||||
@@ -1488,7 +1488,7 @@ namespace System.Management.Automation.Language
|
||||
}
|
||||
}
|
||||
|
||||
internal class PSSwitchClauseEvalBinder : DynamicMetaObjectBinder
|
||||
internal sealed class PSSwitchClauseEvalBinder : DynamicMetaObjectBinder
|
||||
{
|
||||
// Increase this cache size if we add a new flag to the switch statement that:
|
||||
// - Influences evaluation of switch elements
|
||||
@@ -1608,7 +1608,7 @@ namespace System.Management.Automation.Language
|
||||
|
||||
// This class implements the standard binder CreateInstanceBinder, but this binder handles the CallInfo a little differently.
|
||||
// The ArgumentNames are not used to invoke a constructor, instead they are used to set properties/fields in the attribute.
|
||||
internal class PSAttributeGenerator : CreateInstanceBinder
|
||||
internal sealed class PSAttributeGenerator : CreateInstanceBinder
|
||||
{
|
||||
private static readonly Dictionary<CallInfo, PSAttributeGenerator> s_binderCache =
|
||||
new Dictionary<CallInfo, PSAttributeGenerator>();
|
||||
@@ -1789,7 +1789,7 @@ namespace System.Management.Automation.Language
|
||||
}
|
||||
}
|
||||
|
||||
internal class PSCustomObjectConverter : DynamicMetaObjectBinder
|
||||
internal sealed class PSCustomObjectConverter : DynamicMetaObjectBinder
|
||||
{
|
||||
private static readonly PSCustomObjectConverter s_binder = new PSCustomObjectConverter();
|
||||
|
||||
@@ -1825,7 +1825,7 @@ namespace System.Management.Automation.Language
|
||||
}
|
||||
}
|
||||
|
||||
internal class PSDynamicConvertBinder : DynamicMetaObjectBinder
|
||||
internal sealed class PSDynamicConvertBinder : DynamicMetaObjectBinder
|
||||
{
|
||||
private static readonly PSDynamicConvertBinder s_binder = new PSDynamicConvertBinder();
|
||||
|
||||
@@ -1863,7 +1863,7 @@ namespace System.Management.Automation.Language
|
||||
/// <summary>
|
||||
/// This binder is used to copy mutable value types when assigning to variables, otherwise just assigning the target object directly.
|
||||
/// </summary>
|
||||
internal class PSVariableAssignmentBinder : DynamicMetaObjectBinder
|
||||
internal sealed class PSVariableAssignmentBinder : DynamicMetaObjectBinder
|
||||
{
|
||||
private static readonly PSVariableAssignmentBinder s_binder = new PSVariableAssignmentBinder();
|
||||
internal static int s_mutableValueWithInstanceMemberVersion;
|
||||
@@ -2116,7 +2116,7 @@ namespace System.Management.Automation.Language
|
||||
/// <summary>
|
||||
/// The binder for common binary operators. PowerShell specific binary operators are handled elsewhere.
|
||||
/// </summary>
|
||||
internal class PSBinaryOperationBinder : BinaryOperationBinder
|
||||
internal sealed class PSBinaryOperationBinder : BinaryOperationBinder
|
||||
{
|
||||
#region Constructors and factory methods
|
||||
|
||||
@@ -3411,7 +3411,7 @@ namespace System.Management.Automation.Language
|
||||
/// <summary>
|
||||
/// The binder for unary operators like !, -, or +.
|
||||
/// </summary>
|
||||
internal class PSUnaryOperationBinder : UnaryOperationBinder
|
||||
internal sealed class PSUnaryOperationBinder : UnaryOperationBinder
|
||||
{
|
||||
private static PSUnaryOperationBinder s_notBinder;
|
||||
private static PSUnaryOperationBinder s_bnotBinder;
|
||||
@@ -3727,7 +3727,7 @@ namespace System.Management.Automation.Language
|
||||
/// <summary>
|
||||
/// The binder for converting a value, e.g. [int]"42"
|
||||
/// </summary>
|
||||
internal class PSConvertBinder : ConvertBinder
|
||||
internal sealed class PSConvertBinder : ConvertBinder
|
||||
{
|
||||
private static readonly Dictionary<Type, PSConvertBinder> s_binderCache = new Dictionary<Type, PSConvertBinder>();
|
||||
internal int _version;
|
||||
@@ -3926,7 +3926,7 @@ namespace System.Management.Automation.Language
|
||||
/// <summary>
|
||||
/// The binder to get the value of an indexable object, e.g. $x[1]
|
||||
/// </summary>
|
||||
internal class PSGetIndexBinder : GetIndexBinder
|
||||
internal sealed class PSGetIndexBinder : GetIndexBinder
|
||||
{
|
||||
private static readonly Dictionary<Tuple<CallInfo, PSMethodInvocationConstraints, bool>, PSGetIndexBinder> s_binderCache
|
||||
= new Dictionary<Tuple<CallInfo, PSMethodInvocationConstraints, bool>, PSGetIndexBinder>();
|
||||
@@ -4517,7 +4517,7 @@ namespace System.Management.Automation.Language
|
||||
/// <summary>
|
||||
/// The binder for setting the value of an indexable element, like $x[1] = 5.
|
||||
/// </summary>
|
||||
internal class PSSetIndexBinder : SetIndexBinder
|
||||
internal sealed class PSSetIndexBinder : SetIndexBinder
|
||||
{
|
||||
private static readonly Dictionary<Tuple<CallInfo, PSMethodInvocationConstraints>, PSSetIndexBinder> s_binderCache
|
||||
= new Dictionary<Tuple<CallInfo, PSMethodInvocationConstraints>, PSSetIndexBinder>();
|
||||
@@ -6508,7 +6508,7 @@ namespace System.Management.Automation.Language
|
||||
}
|
||||
}
|
||||
|
||||
internal class PSInvokeMemberBinder : InvokeMemberBinder
|
||||
internal sealed class PSInvokeMemberBinder : InvokeMemberBinder
|
||||
{
|
||||
internal enum MethodInvocationType
|
||||
{
|
||||
|
||||
@@ -172,7 +172,7 @@ namespace System.Management.Automation
|
||||
}
|
||||
}
|
||||
|
||||
internal class UsingExpressionAstSearcher : AstSearcher
|
||||
internal sealed class UsingExpressionAstSearcher : AstSearcher
|
||||
{
|
||||
internal static IEnumerable<Ast> FindAllUsingExpressions(Ast ast)
|
||||
{
|
||||
@@ -207,7 +207,7 @@ namespace System.Management.Automation
|
||||
/// Converts a ScriptBlock to a PowerShell object by traversing the
|
||||
/// given Ast.
|
||||
/// </summary>
|
||||
internal class ScriptBlockToPowerShellConverter
|
||||
internal sealed class ScriptBlockToPowerShellConverter
|
||||
{
|
||||
private readonly PowerShell _powershell;
|
||||
private ExecutionContext _context;
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace System.Management.Automation
|
||||
/// <summary>
|
||||
/// Stores help information related to Alias Commands.
|
||||
/// </summary>
|
||||
internal class AliasHelpInfo : HelpInfo
|
||||
internal sealed class AliasHelpInfo : HelpInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the AliasHelpInfo class.
|
||||
|
||||
@@ -1359,7 +1359,7 @@ namespace System.Management.Automation
|
||||
/// Legally, user-defined Help Data should be within the same file as the corresponding
|
||||
/// commandHelp and it should appear after the commandHelp.
|
||||
/// </summary>
|
||||
internal class UserDefinedHelpData
|
||||
internal sealed class UserDefinedHelpData
|
||||
{
|
||||
private UserDefinedHelpData()
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace System.Management.Automation
|
||||
/// <summary>
|
||||
/// Parses help comments and turns them into HelpInfo objects.
|
||||
/// </summary>
|
||||
internal class HelpCommentsParser
|
||||
internal sealed class HelpCommentsParser
|
||||
{
|
||||
private HelpCommentsParser()
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace System.Management.Automation
|
||||
/// Class HelpFileHelpInfo keeps track of help information to be returned by
|
||||
/// command help provider.
|
||||
/// </summary>
|
||||
internal class HelpFileHelpInfo : HelpInfo
|
||||
internal sealed class HelpFileHelpInfo : HelpInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor for HelpFileHelpInfo.
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Text.RegularExpressions;
|
||||
|
||||
namespace System.Management.Automation
|
||||
{
|
||||
internal class MUIFileSearcher
|
||||
internal sealed class MUIFileSearcher
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor. It is private so that MUIFileSearcher is used only internal for this class.
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace System.Management.Automation
|
||||
/// Class ProviderHelpInfo keeps track of help information to be returned by
|
||||
/// command help provider.
|
||||
/// </summary>
|
||||
internal class ProviderHelpInfo : HelpInfo
|
||||
internal sealed class ProviderHelpInfo : HelpInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor for HelpProvider.
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace System.Management.Automation
|
||||
/// Class HelpFileHelpInfo keeps track of help information to be returned by
|
||||
/// command help provider.
|
||||
/// </summary>
|
||||
internal class SyntaxHelpInfo : BaseCommandHelpInfo
|
||||
internal sealed class SyntaxHelpInfo : BaseCommandHelpInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor for SyntaxHelpInfo.
|
||||
|
||||
@@ -370,7 +370,7 @@ namespace System.Management.Automation.Internal
|
||||
/// A reverse compatible implementation of session key exchange. This supports the CAPI
|
||||
/// keyblob formats but uses dotnet std abstract AES and RSA classes for all crypto operations.
|
||||
/// </summary>
|
||||
internal class PSRSACryptoServiceProvider : IDisposable
|
||||
internal sealed class PSRSACryptoServiceProvider : IDisposable
|
||||
{
|
||||
#region Private Members
|
||||
|
||||
@@ -612,7 +612,7 @@ namespace System.Management.Automation.Internal
|
||||
System.GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected void Dispose(bool disposing)
|
||||
private void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace System.Management.Automation.Internal
|
||||
/// 2) show-command window implementation (the actual cmdlet is in Microsoft.PowerShell.Commands.Utility.dll)
|
||||
/// 3) the help window used in the System.Management.Automation.dll's get-help cmdlet when -ShowWindow is specified.
|
||||
/// </summary>
|
||||
internal class GraphicalHostReflectionWrapper
|
||||
internal sealed class GraphicalHostReflectionWrapper
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialized in GetGraphicalHostReflectionWrapper with the Microsoft.PowerShell.GraphicalHost.dll assembly.
|
||||
|
||||
Reference in New Issue
Block a user