From 883ca98dd74ea13b3d8c0dd62d301963a40483d6 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Mon, 19 Jul 2021 10:09:12 +0100 Subject: [PATCH] Seal private classes (#15725) * Seal private classes * Fix CS0509 * Fix CS0628 --- .../cmdletization/cim/cimConverter.cs | 2 +- .../cmdletization/cim/clientSideQuery.cs | 10 +++++----- .../commands/management/Computer.cs | 2 +- .../management/GetComputerInfoCommand.cs | 10 +++++----- .../commands/utility/AddType.cs | 2 +- .../commands/utility/GetMember.cs | 2 +- .../commands/utility/MatchString.cs | 14 +++++++------- .../commands/utility/Measure-Object.cs | 4 ++-- .../commands/utility/New-Object.cs | 2 +- .../commands/utility/Select-Object.cs | 4 ++-- .../commands/utility/WebCmdlet/JsonObject.cs | 2 +- .../host/msh/ConsoleHost.cs | 6 +++--- .../host/msh/Executor.cs | 2 +- .../host/msh/PendingProgress.cs | 12 ++++-------- .../host/msh/UpdatesNotification.cs | 2 +- .../LocalAccounts/Sam.cs | 4 ++-- .../ScheduledJob.cs | 2 +- .../common/BaseOutputtingCommand.cs | 4 ++-- .../displayResourceManagerCache.cs | 2 +- .../FormatAndOutput/common/TableWriter.cs | 4 ++-- .../out-console/ConsoleLineOutput.cs | 2 +- .../engine/CmdletParameterBinderController.cs | 2 +- .../CommandCompletion/CommandCompletion.cs | 2 +- .../CommandCompletion/CompletionCompleters.cs | 16 ++++++++-------- .../engine/CommandInfo.cs | 2 +- .../engine/CommandParameter.cs | 4 ++-- .../engine/CoreAdapter.cs | 2 +- .../engine/GetCommandCommand.cs | 2 +- .../engine/LanguagePrimitives.cs | 18 +++++++++--------- .../engine/Modules/RemoteDiscoveryHelper.cs | 4 ++-- .../engine/Modules/ScriptAnalysis.cs | 2 +- .../engine/MshCommandRuntime.cs | 2 +- .../engine/PSVersionInfo.cs | 2 +- .../engine/TypeTable.cs | 2 +- .../engine/debugger/Breakpoint.cs | 2 +- .../engine/debugger/debugger.cs | 2 +- .../engine/hostifaces/ConnectionBase.cs | 2 +- .../engine/hostifaces/pipelinebase.cs | 2 +- .../engine/interpreter/LightCompiler.cs | 2 +- .../engine/parser/Compiler.cs | 4 ++-- .../engine/parser/PSType.cs | 4 ++-- .../engine/parser/TypeResolver.cs | 2 +- .../engine/parser/VariableAnalysis.cs | 6 +++--- .../engine/regex.cs | 10 +++++----- .../engine/remoting/client/Job.cs | 2 +- .../engine/remoting/client/ThrottlingJob.cs | 2 +- .../engine/remoting/client/remotepipeline.cs | 2 +- .../remoting/commands/ConnectPSSession.cs | 2 +- .../remoting/commands/DisconnectPSSession.cs | 2 +- .../remoting/fanin/WSManTransportManager.cs | 4 ++-- .../server/ServerRunspacePoolDriver.cs | 2 +- .../engine/runtime/Binding/Binders.cs | 14 +++++++------- .../engine/runtime/Operations/MiscOps.cs | 2 +- .../engine/runtime/Operations/VariableOps.cs | 2 +- .../engine/serialization.cs | 2 +- .../namespaces/FileSystemProvider.cs | 2 +- .../utils/tracing/EtwActivity.cs | 4 ++-- src/TypeCatalogGen/TypeCatalogGen.cs | 2 +- src/powershell/Program.cs | 2 +- 59 files changed, 116 insertions(+), 120 deletions(-) diff --git a/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/cimConverter.cs b/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/cimConverter.cs index 91500758a..74f0f922c 100644 --- a/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/cimConverter.cs +++ b/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/cimConverter.cs @@ -26,7 +26,7 @@ namespace Microsoft.PowerShell.Cim { internal class CimSensitiveValueConverter : IDisposable { - private class SensitiveString : IDisposable + private sealed class SensitiveString : IDisposable { private GCHandle _gcHandle; private string _string; diff --git a/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/clientSideQuery.cs b/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/clientSideQuery.cs index 7ee599402..731007eb6 100644 --- a/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/clientSideQuery.cs +++ b/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/clientSideQuery.cs @@ -181,7 +181,7 @@ namespace Microsoft.PowerShell.Cmdletization.Cim } } - private class CimInstanceRegularFilter : CimInstancePropertyBasedFilter + private sealed class CimInstanceRegularFilter : CimInstancePropertyBasedFilter { public CimInstanceRegularFilter(string propertyName, IEnumerable allowedPropertyValues, bool wildcardsEnabled, BehaviorOnNoMatch behaviorOnNoMatch) { @@ -247,7 +247,7 @@ namespace Microsoft.PowerShell.Cmdletization.Cim } } - private class CimInstanceExcludeFilter : CimInstancePropertyBasedFilter + private sealed class CimInstanceExcludeFilter : CimInstancePropertyBasedFilter { public CimInstanceExcludeFilter(string propertyName, IEnumerable excludedPropertyValues, bool wildcardsEnabled, BehaviorOnNoMatch behaviorOnNoMatch) { @@ -272,7 +272,7 @@ namespace Microsoft.PowerShell.Cmdletization.Cim } } - private class CimInstanceMinFilter : CimInstancePropertyBasedFilter + private sealed class CimInstanceMinFilter : CimInstancePropertyBasedFilter { public CimInstanceMinFilter(string propertyName, object minPropertyValue, BehaviorOnNoMatch behaviorOnNoMatch) { @@ -293,7 +293,7 @@ namespace Microsoft.PowerShell.Cmdletization.Cim } } - private class CimInstanceMaxFilter : CimInstancePropertyBasedFilter + private sealed class CimInstanceMaxFilter : CimInstancePropertyBasedFilter { public CimInstanceMaxFilter(string propertyName, object minPropertyValue, BehaviorOnNoMatch behaviorOnNoMatch) { @@ -314,7 +314,7 @@ namespace Microsoft.PowerShell.Cmdletization.Cim } } - private class CimInstanceAssociationFilter : CimInstanceFilterBase + private sealed class CimInstanceAssociationFilter : CimInstanceFilterBase { public CimInstanceAssociationFilter(BehaviorOnNoMatch behaviorOnNoMatch) { diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs index 61b5fe448..05c44c26d 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs @@ -522,7 +522,7 @@ $result } } - private class ComputerInfo + private sealed class ComputerInfo { internal string LastBootUpTime; internal bool RebootComplete; diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/GetComputerInfoCommand.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/GetComputerInfoCommand.cs index 4c8a95ddd..527cd08ba 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/GetComputerInfoCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/GetComputerInfoCommand.cs @@ -31,7 +31,7 @@ namespace Microsoft.PowerShell.Commands public class GetComputerInfoCommand : PSCmdlet { #region Inner Types - private class OSInfoGroup + private sealed class OSInfoGroup { public WmiOperatingSystem os; public HotFix[] hotFixes; @@ -41,7 +41,7 @@ namespace Microsoft.PowerShell.Commands public RegWinNtCurrentVersion regCurVer; } - private class SystemInfoGroup + private sealed class SystemInfoGroup { public WmiBaseBoard baseboard; public WmiBios bios; @@ -50,7 +50,7 @@ namespace Microsoft.PowerShell.Commands public NetworkAdapter[] networkAdapters; } - private class HyperVInfo + private sealed class HyperVInfo { public bool? Present; public bool? VMMonitorModeExtensions; @@ -59,13 +59,13 @@ namespace Microsoft.PowerShell.Commands public bool? DataExecutionPreventionAvailable; } - private class DeviceGuardInfo + private sealed class DeviceGuardInfo { public DeviceGuardSmartStatus status; public DeviceGuard deviceGuard; } - private class MiscInfoGroup + private sealed class MiscInfoGroup { public ulong? physicallyInstalledMemory; public string timeZone; diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs index b86cadc1e..48ee839e9 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs @@ -1107,7 +1107,7 @@ namespace Microsoft.PowerShell.Commands } // Visit symbols in all namespaces and collect duplicates. - private class AllNamedTypeSymbolsVisitor : SymbolVisitor + private sealed class AllNamedTypeSymbolsVisitor : SymbolVisitor { public readonly ConcurrentBag DuplicateSymbols = new(); public readonly ConcurrentBag UniqueSymbols = new(); diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetMember.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetMember.cs index 2fd9a4990..cfd380853 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetMember.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetMember.cs @@ -249,7 +249,7 @@ namespace Microsoft.PowerShell.Commands } } - private class MemberComparer : System.Collections.Generic.IComparer + private sealed class MemberComparer : System.Collections.Generic.IComparer { public int Compare(MemberDefinition first, MemberDefinition second) { diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/MatchString.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/MatchString.cs index 6271e6f57..4375e21bf 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/MatchString.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/MatchString.cs @@ -410,7 +410,7 @@ namespace Microsoft.PowerShell.Commands /// A generic circular buffer. /// /// The type of items that are buffered. - private class CircularBuffer : ICollection + private sealed class CircularBuffer : ICollection { // Ring of items private readonly T[] _items; @@ -627,7 +627,7 @@ namespace Microsoft.PowerShell.Commands /// /// A state machine to track display context for each match. /// - private class DisplayContextTracker : IContextTracker + private sealed class DisplayContextTracker : IContextTracker { private enum ContextState { @@ -784,12 +784,12 @@ namespace Microsoft.PowerShell.Commands /// and other matching lines (since they will appear /// as their own match entries.). /// - private class LogicalContextTracker : IContextTracker + private sealed class LogicalContextTracker : IContextTracker { // A union: string | MatchInfo. Needed since // context lines could be either proper matches // or non-matching lines. - private class ContextEntry + private sealed class ContextEntry { public readonly string Line; public readonly MatchInfo Match; @@ -989,7 +989,7 @@ namespace Microsoft.PowerShell.Commands /// /// A class to track both logical and display contexts. /// - private class ContextTracker : IContextTracker + private sealed class ContextTracker : IContextTracker { private readonly IContextTracker _displayTracker; private readonly IContextTracker _logicalTracker; @@ -1058,7 +1058,7 @@ namespace Microsoft.PowerShell.Commands /// /// ContextTracker that does not work for the case when pre- and post context is 0. /// - private class NoContextTracker : IContextTracker + private sealed class NoContextTracker : IContextTracker { private readonly IList _matches = new List(1); @@ -1996,7 +1996,7 @@ namespace Microsoft.PowerShell.Commands /// /// Magic class that works around the limitations on ToString() for FileInfo. /// - private class FileinfoToStringAttribute : ArgumentTransformationAttribute + private sealed class FileinfoToStringAttribute : ArgumentTransformationAttribute { public override object Transform(EngineIntrinsics engineIntrinsics, object inputData) { diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Measure-Object.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Measure-Object.cs index 452e8bfe0..e6a99c38c 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Measure-Object.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Measure-Object.cs @@ -160,7 +160,7 @@ namespace Microsoft.PowerShell.Commands /// Keys are strings. Keys are compared with OrdinalIgnoreCase. /// /// Value type. - private class MeasureObjectDictionary : Dictionary + private sealed class MeasureObjectDictionary : Dictionary where TValue : new() { /// @@ -200,7 +200,7 @@ namespace Microsoft.PowerShell.Commands /// what mode we're in. /// [SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses")] - private class Statistics + private sealed class Statistics { // Common properties internal int count = 0; diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/New-Object.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/New-Object.cs index 90ef2ca43..0ca9ad7b9 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/New-Object.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/New-Object.cs @@ -416,7 +416,7 @@ namespace Microsoft.PowerShell.Commands return result; } - private class ComCreateInfo + private sealed class ComCreateInfo { public object objectCreated; public bool success; 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 efdd82d79..b57be43f2 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Select-Object.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Select-Object.cs @@ -223,7 +223,7 @@ namespace Microsoft.PowerShell.Commands private SelectObjectQueue _selectObjectQueue; - private class SelectObjectQueue : Queue + private sealed class SelectObjectQueue : Queue { internal SelectObjectQueue(int first, int last, int skip, int skipLast, bool firstOrLastSpecified) { @@ -324,7 +324,7 @@ namespace Microsoft.PowerShell.Commands private PSPropertyExpressionFilter _exclusionFilter; - private class UniquePSObjectHelper + private sealed class UniquePSObjectHelper { internal UniquePSObjectHelper(PSObject o, int notePropertyCount) { diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/JsonObject.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/JsonObject.cs index 526b251b5..3a60e6590 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/JsonObject.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/JsonObject.cs @@ -98,7 +98,7 @@ namespace Microsoft.PowerShell.Commands } } - private class DuplicateMemberHashSet : HashSet + private sealed class DuplicateMemberHashSet : HashSet { public DuplicateMemberHashSet(int capacity) : base(capacity, StringComparer.OrdinalIgnoreCase) diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs index 67b777aa4..167186ae0 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs @@ -2322,7 +2322,7 @@ namespace Microsoft.PowerShell /// Neither this class' instances nor its static data is threadsafe. Caller is responsible for ensuring threadsafe /// access. /// - private class InputLoop + private sealed class InputLoop { internal static void RunNewInputLoop(ConsoleHost parent, bool isNested) { @@ -2902,7 +2902,7 @@ namespace Microsoft.PowerShell [Serializable] [SuppressMessage("Microsoft.Design", "CA1064:ExceptionsShouldBePublic", Justification = "This exception cannot be used outside of the console host application. It is not thrown by a library routine, only by an application.")] - private class ConsoleHostStartupException : Exception + private sealed class ConsoleHostStartupException : Exception { internal ConsoleHostStartupException() @@ -2916,7 +2916,7 @@ namespace Microsoft.PowerShell { } - protected + private ConsoleHostStartupException( System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/Executor.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/Executor.cs index 68df51be5..e6f597b94 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/Executor.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/Executor.cs @@ -124,7 +124,7 @@ namespace Microsoft.PowerShell _parent.ErrorSerializer.Serialize(er); } - private class PipelineFinishedWaitHandle + private sealed class PipelineFinishedWaitHandle { internal PipelineFinishedWaitHandle(Pipeline p) { diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/PendingProgress.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/PendingProgress.cs index 0c38f3596..08e796220 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/PendingProgress.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/PendingProgress.cs @@ -265,8 +265,7 @@ namespace Microsoft.PowerShell #endif } - private - class FindOldestNodeVisitor : NodeVisitor + private sealed class FindOldestNodeVisitor : NodeVisitor { internal override bool @@ -366,8 +365,7 @@ namespace Microsoft.PowerShell FindNodeById(sourceId, activityId, out listWhereFound, out indexWhereFound); } - private - class FindByIdNodeVisitor : NodeVisitor + private sealed class FindByIdNodeVisitor : NodeVisitor { internal FindByIdNodeVisitor(Int64 sourceIdToFind, int activityIdToFind) @@ -508,8 +506,7 @@ namespace Microsoft.PowerShell return found; } - private - class AgeAndResetStyleVisitor : NodeVisitor + private sealed class AgeAndResetStyleVisitor : NodeVisitor { internal override bool @@ -666,8 +663,7 @@ namespace Microsoft.PowerShell } } - private - class HeightTallyer : NodeVisitor + private sealed class HeightTallyer : NodeVisitor { internal HeightTallyer(PSHostRawUserInterface rawUi, int maxHeight, int maxWidth) { diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/UpdatesNotification.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/UpdatesNotification.cs index 08e0ed8e1..b33d8f2e6 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/UpdatesNotification.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/UpdatesNotification.cs @@ -428,7 +428,7 @@ namespace Microsoft.PowerShell LTS = 2 } - private class Release + private sealed class Release { internal Release(string publishAt, string tagName) { diff --git a/src/Microsoft.PowerShell.LocalAccounts/LocalAccounts/Sam.cs b/src/Microsoft.PowerShell.LocalAccounts/LocalAccounts/Sam.cs index e87147fd3..2ec7f4149 100644 --- a/src/Microsoft.PowerShell.LocalAccounts/LocalAccounts/Sam.cs +++ b/src/Microsoft.PowerShell.LocalAccounts/LocalAccounts/Sam.cs @@ -214,7 +214,7 @@ namespace System.Management.Automation.SecurityAccountsManager /// Used primarily by the private ThrowOnFailure method when building /// Exception objects to throw. /// - private class Context + private sealed class Context { public ContextOperation operation; public ContextObjectType type; @@ -308,7 +308,7 @@ namespace System.Management.Automation.SecurityAccountsManager /// AccountInfo is the return type from the private /// LookupAccountInfo method. /// - private class AccountInfo + private sealed class AccountInfo { public string AccountName; public string DomainName; diff --git a/src/Microsoft.PowerShell.ScheduledJob/ScheduledJob.cs b/src/Microsoft.PowerShell.ScheduledJob/ScheduledJob.cs index 4c7dcb146..85680da94 100644 --- a/src/Microsoft.PowerShell.ScheduledJob/ScheduledJob.cs +++ b/src/Microsoft.PowerShell.ScheduledJob/ScheduledJob.cs @@ -953,7 +953,7 @@ namespace Microsoft.PowerShell.ScheduledJob #region Private ResultsInfo class [Serializable] - private class ResultsInfo : ISerializable + private sealed class ResultsInfo : ISerializable { // Private Members private Collection _output; diff --git a/src/System.Management.Automation/FormatAndOutput/common/BaseOutputtingCommand.cs b/src/System.Management.Automation/FormatAndOutput/common/BaseOutputtingCommand.cs index 48ab13076..b92aac636 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/BaseOutputtingCommand.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/BaseOutputtingCommand.cs @@ -848,7 +848,7 @@ namespace Microsoft.PowerShell.Commands.Internal.Format /// /// Context for the outer scope of the format sequence. /// - private class FormatOutputContext : FormatMessagesContextManager.OutputContext + private sealed class FormatOutputContext : FormatMessagesContextManager.OutputContext { /// /// Construct a context to push on the stack. @@ -1296,7 +1296,7 @@ namespace Microsoft.PowerShell.Commands.Internal.Format /// Helper class to accumulate the display values so that when the end /// of a line is reached, a full line can be composed. /// - private class StringValuesBuffer + private sealed class StringValuesBuffer { /// /// Construct the buffer. diff --git a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayResourceManagerCache.cs b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayResourceManagerCache.cs index fbdd1287a..b5eb4d456 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayResourceManagerCache.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayResourceManagerCache.cs @@ -142,7 +142,7 @@ namespace Microsoft.PowerShell.Commands.Internal.Format /// Helper class to resolve an assembly name to an assembly reference /// The class caches previous results for faster lookup. /// - private class AssemblyNameResolver + private sealed class AssemblyNameResolver { /// /// Resolve the assembly name against the set of loaded assemblies. diff --git a/src/System.Management.Automation/FormatAndOutput/common/TableWriter.cs b/src/System.Management.Automation/FormatAndOutput/common/TableWriter.cs index 54aaa9438..67f2c812f 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/TableWriter.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/TableWriter.cs @@ -16,7 +16,7 @@ namespace Microsoft.PowerShell.Commands.Internal.Format /// /// Information about each column boundaries. /// - private class ColumnInfo + private sealed class ColumnInfo { internal int startCol = 0; internal int width = 0; @@ -25,7 +25,7 @@ namespace Microsoft.PowerShell.Commands.Internal.Format /// /// Class containing information about the tabular layout. /// - private class ScreenInfo + private sealed class ScreenInfo { internal int screenColumns = 0; internal int screenRows = 0; diff --git a/src/System.Management.Automation/FormatAndOutput/out-console/ConsoleLineOutput.cs b/src/System.Management.Automation/FormatAndOutput/out-console/ConsoleLineOutput.cs index 89188d173..f3ed3ba61 100644 --- a/src/System.Management.Automation/FormatAndOutput/out-console/ConsoleLineOutput.cs +++ b/src/System.Management.Automation/FormatAndOutput/out-console/ConsoleLineOutput.cs @@ -473,7 +473,7 @@ namespace Microsoft.PowerShell.Commands.Internal.Format /// /// Object to manage prompting. /// - private class PromptHandler + private sealed class PromptHandler { /// /// Prompt handler with the given prompt. diff --git a/src/System.Management.Automation/engine/CmdletParameterBinderController.cs b/src/System.Management.Automation/engine/CmdletParameterBinderController.cs index 267ea4e24..8f8536104 100644 --- a/src/System.Management.Automation/engine/CmdletParameterBinderController.cs +++ b/src/System.Management.Automation/engine/CmdletParameterBinderController.cs @@ -4047,7 +4047,7 @@ namespace System.Management.Automation private ReflectionParameterBinder _commonParametersBinder; - private class DelayedScriptBlockArgument + private sealed class DelayedScriptBlockArgument { // Remember the parameter binder so we know when to invoke the script block // and when to use the evaluated argument. diff --git a/src/System.Management.Automation/engine/CommandCompletion/CommandCompletion.cs b/src/System.Management.Automation/engine/CommandCompletion/CommandCompletion.cs index 730861ecb..0549f93e2 100644 --- a/src/System.Management.Automation/engine/CommandCompletion/CommandCompletion.cs +++ b/src/System.Management.Automation/engine/CommandCompletion/CommandCompletion.cs @@ -1141,7 +1141,7 @@ namespace System.Management.Automation /// LastWordFinder implements the algorithm we use to search for the last word in a line of input taken from the console. /// This class exists for legacy purposes only - V3 and forward uses a slightly different interface. /// - private class LastWordFinder + private sealed class LastWordFinder { internal static string FindLastWord(string sentence, out int replacementIndexOut, out char closingQuote) { diff --git a/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs b/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs index f961e291a..69f24c243 100644 --- a/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs +++ b/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs @@ -408,7 +408,7 @@ namespace System.Management.Automation return results; } - private class FindFunctionsVisitor : AstVisitor + private sealed class FindFunctionsVisitor : AstVisitor { internal readonly List FunctionDefinitions = new List(); @@ -4887,7 +4887,7 @@ namespace System.Management.Automation } } - private class FindVariablesVisitor : AstVisitor + private sealed class FindVariablesVisitor : AstVisitor { internal Ast Top; internal Ast CompletionVariableAst; @@ -6092,7 +6092,7 @@ namespace System.Management.Automation /// This type represents a generic type for type name completion. It only contains information that can be /// inferred from the full type name. /// - private class GenericTypeCompletionInStringFormat : TypeCompletionInStringFormat + private sealed class GenericTypeCompletionInStringFormat : TypeCompletionInStringFormat { /// /// Get the number of generic type arguments required by the type represented by this instance. @@ -6209,7 +6209,7 @@ namespace System.Management.Automation /// /// This type represents a generic type for type name completion. It contains the actual type instance. /// - private class GenericTypeCompletion : TypeCompletion + private sealed class GenericTypeCompletion : TypeCompletion { internal override CompletionResult GetCompletionResult(string keyMatched, string prefix, string suffix) { @@ -6246,7 +6246,7 @@ namespace System.Management.Automation /// /// This type represents a namespace for namespace completion. /// - private class NamespaceCompletion : TypeCompletionBase + private sealed class NamespaceCompletion : TypeCompletionBase { internal string Namespace; @@ -6268,7 +6268,7 @@ namespace System.Management.Automation } } - private class TypeCompletionMapping + private sealed class TypeCompletionMapping { // The Key is the string we'll be searching on. It could complete to various things. internal string Key; @@ -7334,7 +7334,7 @@ namespace System.Management.Automation return defaultChoice; } - private class ItemPathComparer : IComparer + private sealed class ItemPathComparer : IComparer { public int Compare(PSObject x, PSObject y) { @@ -7369,7 +7369,7 @@ namespace System.Management.Automation } } - private class CommandNameComparer : IComparer + private sealed class CommandNameComparer : IComparer { public int Compare(PSObject x, PSObject y) { diff --git a/src/System.Management.Automation/engine/CommandInfo.cs b/src/System.Management.Automation/engine/CommandInfo.cs index c38d4b808..7e28fece9 100644 --- a/src/System.Management.Automation/engine/CommandInfo.cs +++ b/src/System.Management.Automation/engine/CommandInfo.cs @@ -481,7 +481,7 @@ namespace System.Management.Automation return result; } - private class GetMergedCommandParameterMetadataSafelyEventArgs : EventArgs + private sealed class GetMergedCommandParameterMetadataSafelyEventArgs : EventArgs { public MergedCommandParameterMetadata Result; public ExceptionDispatchInfo Exception; diff --git a/src/System.Management.Automation/engine/CommandParameter.cs b/src/System.Management.Automation/engine/CommandParameter.cs index e6752ff02..227795cf1 100644 --- a/src/System.Management.Automation/engine/CommandParameter.cs +++ b/src/System.Management.Automation/engine/CommandParameter.cs @@ -12,14 +12,14 @@ namespace System.Management.Automation [DebuggerDisplay("{ParameterName}")] internal sealed class CommandParameterInternal { - private class Parameter + private sealed class Parameter { internal Ast ast; internal string parameterName; internal string parameterText; } - private class Argument + private sealed class Argument { internal Ast ast; internal object value; diff --git a/src/System.Management.Automation/engine/CoreAdapter.cs b/src/System.Management.Automation/engine/CoreAdapter.cs index 530cfc973..bf9775b35 100644 --- a/src/System.Management.Automation/engine/CoreAdapter.cs +++ b/src/System.Management.Automation/engine/CoreAdapter.cs @@ -1177,7 +1177,7 @@ namespace System.Management.Automation } [DebuggerDisplay("OverloadCandidate: {method.methodDefinition}")] - private class OverloadCandidate + private sealed class OverloadCandidate { internal MethodInformation method; internal ParameterInformation[] parameters; diff --git a/src/System.Management.Automation/engine/GetCommandCommand.cs b/src/System.Management.Automation/engine/GetCommandCommand.cs index b4b6bb740..a1e5fa768 100644 --- a/src/System.Management.Automation/engine/GetCommandCommand.cs +++ b/src/System.Management.Automation/engine/GetCommandCommand.cs @@ -645,7 +645,7 @@ namespace Microsoft.PowerShell.Commands /// /// The comparer to sort CommandInfo objects in the result list. /// - private class CommandInfoComparer : IComparer + private sealed class CommandInfoComparer : IComparer { /// /// Compare two CommandInfo objects first by their command types, and if they diff --git a/src/System.Management.Automation/engine/LanguagePrimitives.cs b/src/System.Management.Automation/engine/LanguagePrimitives.cs index f6261b85c..3caceb40b 100644 --- a/src/System.Management.Automation/engine/LanguagePrimitives.cs +++ b/src/System.Management.Automation/engine/LanguagePrimitives.cs @@ -362,7 +362,7 @@ namespace System.Management.Automation /// implementation of an object when we can't use it's non-generic /// implementation. /// - private class EnumerableTWrapper : IEnumerable + private sealed class EnumerableTWrapper : IEnumerable { private readonly object _enumerable; private readonly Type _enumerableType; @@ -1889,7 +1889,7 @@ namespace System.Management.Automation internal class EnumSingleTypeConverter : PSTypeConverter { - private class EnumHashEntry + private sealed class EnumHashEntry { internal EnumHashEntry(string[] names, Array values, UInt64 allValues, bool hasNegativeValue, bool hasFlagsAttribute) { @@ -3684,7 +3684,7 @@ namespace System.Management.Automation return ConvertStringToEnum(sbResult.ToString(), resultType, recursion, originalValueToConvert, formatProvider, backupTable); } - private class PSMethodToDelegateConverter + private sealed class PSMethodToDelegateConverter { // Index of the matching overload method. private readonly int _matchIndex; @@ -3744,7 +3744,7 @@ namespace System.Management.Automation } } - private class ConvertViaParseMethod + private sealed class ConvertViaParseMethod { // TODO - use an ETS wrapper that generates a dynamic method internal MethodInfo parse; @@ -3810,7 +3810,7 @@ namespace System.Management.Automation } } - private class ConvertViaConstructor + private sealed class ConvertViaConstructor { internal Func TargetCtorLambda; @@ -3854,7 +3854,7 @@ namespace System.Management.Automation /// 1. toType is a closed generic type and it has a constructor that takes IEnumerable[T], ICollection[T] or IList[T] /// 2. fromType is System.Array, System.Object[] or it's the same as the element type of toType /// - private class ConvertViaIEnumerableConstructor + private sealed class ConvertViaIEnumerableConstructor { internal Func ListCtorLambda; internal Func TargetCtorLambda; @@ -3947,7 +3947,7 @@ namespace System.Management.Automation } } - private class ConvertViaNoArgumentConstructor + private sealed class ConvertViaNoArgumentConstructor { private readonly Func _constructor; @@ -4050,7 +4050,7 @@ namespace System.Management.Automation } } - private class ConvertViaCast + private sealed class ConvertViaCast { internal MethodInfo cast; @@ -4130,7 +4130,7 @@ namespace System.Management.Automation } } - private class ConvertCheckingForCustomConverter + private sealed class ConvertCheckingForCustomConverter { internal PSConverter tryfirstConverter; internal PSConverter fallbackConverter; diff --git a/src/System.Management.Automation/engine/Modules/RemoteDiscoveryHelper.cs b/src/System.Management.Automation/engine/Modules/RemoteDiscoveryHelper.cs index bbc176f1d..18e125415 100644 --- a/src/System.Management.Automation/engine/Modules/RemoteDiscoveryHelper.cs +++ b/src/System.Management.Automation/engine/Modules/RemoteDiscoveryHelper.cs @@ -689,7 +689,7 @@ namespace System.Management.Automation private List _moduleFiles; - private class CimModuleManifestFile : CimModuleFile + private sealed class CimModuleManifestFile : CimModuleFile { internal CimModuleManifestFile(string fileName, byte[] rawFileData) { @@ -705,7 +705,7 @@ namespace System.Management.Automation internal override byte[] RawFileDataCore { get; } } - private class CimModuleImplementationFile : CimModuleFile + private sealed class CimModuleImplementationFile : CimModuleFile { private readonly CimInstance _baseObject; diff --git a/src/System.Management.Automation/engine/Modules/ScriptAnalysis.cs b/src/System.Management.Automation/engine/Modules/ScriptAnalysis.cs index f2005400c..8720fc1f1 100644 --- a/src/System.Management.Automation/engine/Modules/ScriptAnalysis.cs +++ b/src/System.Management.Automation/engine/Modules/ScriptAnalysis.cs @@ -557,7 +557,7 @@ namespace System.Management.Automation private static readonly Dictionary s_parameterBindingInfoTable; - private class ParameterBindingInfo + private sealed class ParameterBindingInfo { internal ParameterInfo[] parameterInfo; } diff --git a/src/System.Management.Automation/engine/MshCommandRuntime.cs b/src/System.Management.Automation/engine/MshCommandRuntime.cs index bf8fe32fd..c9a83a8bb 100644 --- a/src/System.Management.Automation/engine/MshCommandRuntime.cs +++ b/src/System.Management.Automation/engine/MshCommandRuntime.cs @@ -2318,7 +2318,7 @@ namespace System.Management.Automation return new AllowWrite(_thisCommand, permittedToWriteToPipeline); } - private class AllowWrite : IDisposable + private sealed class AllowWrite : IDisposable { /// /// Begin the scope where WriteObject/WriteError is permitted. diff --git a/src/System.Management.Automation/engine/PSVersionInfo.cs b/src/System.Management.Automation/engine/PSVersionInfo.cs index 5dc19e336..54cf9e072 100644 --- a/src/System.Management.Automation/engine/PSVersionInfo.cs +++ b/src/System.Management.Automation/engine/PSVersionInfo.cs @@ -376,7 +376,7 @@ namespace System.Management.Automation } } - private class PSVersionTableComparer : IComparer + private sealed class PSVersionTableComparer : IComparer { public int Compare(object x, object y) { diff --git a/src/System.Management.Automation/engine/TypeTable.cs b/src/System.Management.Automation/engine/TypeTable.cs index ecf915e0f..0bcd276a4 100644 --- a/src/System.Management.Automation/engine/TypeTable.cs +++ b/src/System.Management.Automation/engine/TypeTable.cs @@ -1683,7 +1683,7 @@ namespace System.Management.Automation.Runspaces internal static readonly IEqualityComparer EqualityComparer = new ConsolidatedStringEqualityComparer(); - private class ConsolidatedStringEqualityComparer : IEqualityComparer + private sealed class ConsolidatedStringEqualityComparer : IEqualityComparer { bool IEqualityComparer.Equals(ConsolidatedString x, ConsolidatedString y) { diff --git a/src/System.Management.Automation/engine/debugger/Breakpoint.cs b/src/System.Management.Automation/engine/debugger/Breakpoint.cs index ca1c98182..5daf3bdc1 100644 --- a/src/System.Management.Automation/engine/debugger/Breakpoint.cs +++ b/src/System.Management.Automation/engine/debugger/Breakpoint.cs @@ -439,7 +439,7 @@ namespace System.Management.Automation internal BitArray BreakpointBitArray { get; set; } - private class CheckBreakpointInScript : AstVisitor + private sealed class CheckBreakpointInScript : AstVisitor { public static bool IsInNestedScriptBlock(Ast ast, LineBreakpoint breakpoint) { diff --git a/src/System.Management.Automation/engine/debugger/debugger.cs b/src/System.Management.Automation/engine/debugger/debugger.cs index 2d049fe76..e8e8c8494 100644 --- a/src/System.Management.Automation/engine/debugger/debugger.cs +++ b/src/System.Management.Automation/engine/debugger/debugger.cs @@ -1575,7 +1575,7 @@ namespace System.Management.Automation #region private members [DebuggerDisplay("{FunctionContext.CurrentPosition}")] - private class CallStackInfo + private sealed class CallStackInfo { internal InvocationInfo InvocationInfo { get; set; } diff --git a/src/System.Management.Automation/engine/hostifaces/ConnectionBase.cs b/src/System.Management.Automation/engine/hostifaces/ConnectionBase.cs index 99151b7b0..b6b571e90 100644 --- a/src/System.Management.Automation/engine/hostifaces/ConnectionBase.cs +++ b/src/System.Management.Automation/engine/hostifaces/ConnectionBase.cs @@ -670,7 +670,7 @@ namespace System.Management.Automation.Runspaces /// private Queue _runspaceEventQueue = new Queue(); - private class RunspaceEventQueueItem + private sealed class RunspaceEventQueueItem { public RunspaceEventQueueItem(RunspaceStateInfo runspaceStateInfo, RunspaceAvailability currentAvailability, RunspaceAvailability newAvailability) { diff --git a/src/System.Management.Automation/engine/hostifaces/pipelinebase.cs b/src/System.Management.Automation/engine/hostifaces/pipelinebase.cs index 2d74430a4..0eaa30daa 100644 --- a/src/System.Management.Automation/engine/hostifaces/pipelinebase.cs +++ b/src/System.Management.Automation/engine/hostifaces/pipelinebase.cs @@ -768,7 +768,7 @@ namespace System.Management.Automation.Runspaces /// private Queue _executionEventQueue = new Queue(); - private class ExecutionEventQueueItem + private sealed class ExecutionEventQueueItem { public ExecutionEventQueueItem(PipelineStateInfo pipelineStateInfo, RunspaceAvailability currentAvailability, RunspaceAvailability newAvailability) { diff --git a/src/System.Management.Automation/engine/interpreter/LightCompiler.cs b/src/System.Management.Automation/engine/interpreter/LightCompiler.cs index 4a0443464..279a36baa 100644 --- a/src/System.Management.Automation/engine/interpreter/LightCompiler.cs +++ b/src/System.Management.Automation/engine/interpreter/LightCompiler.cs @@ -192,7 +192,7 @@ namespace System.Management.Automation.Interpreter public bool IsClear; private static readonly DebugInfoComparer s_debugComparer = new DebugInfoComparer(); - private class DebugInfoComparer : IComparer + private sealed class DebugInfoComparer : IComparer { // We allow comparison between int and DebugInfo here int IComparer.Compare(DebugInfo d1, DebugInfo d2) diff --git a/src/System.Management.Automation/engine/parser/Compiler.cs b/src/System.Management.Automation/engine/parser/Compiler.cs index 5d320d9fd..14057f05f 100644 --- a/src/System.Management.Automation/engine/parser/Compiler.cs +++ b/src/System.Management.Automation/engine/parser/Compiler.cs @@ -2200,7 +2200,7 @@ namespace System.Management.Automation.Language return Expression.Lambda>(body, parameters).Compile(); } - private class LoopGotoTargets + private sealed class LoopGotoTargets { internal LoopGotoTargets(string label, LabelTarget breakLabel, LabelTarget continueLabel) { @@ -5154,7 +5154,7 @@ namespace System.Management.Automation.Language // } // // This is a little convoluted because an automatic variable isn't necessarily set. - private class AutomaticVarSaver + private sealed class AutomaticVarSaver { private readonly Compiler _compiler; private readonly int _automaticVar; diff --git a/src/System.Management.Automation/engine/parser/PSType.cs b/src/System.Management.Automation/engine/parser/PSType.cs index a7a22df87..1f961af8d 100644 --- a/src/System.Management.Automation/engine/parser/PSType.cs +++ b/src/System.Management.Automation/engine/parser/PSType.cs @@ -265,7 +265,7 @@ namespace System.Management.Automation.Language } } - private class DefineTypeHelper + private sealed class DefineTypeHelper { private readonly Parser _parser; internal readonly TypeDefinitionAst _typeDefinitionAst; @@ -1007,7 +1007,7 @@ namespace System.Management.Automation.Language } } - private class DefineEnumHelper + private sealed class DefineEnumHelper { private readonly Parser _parser; private readonly TypeDefinitionAst _enumDefinitionAst; diff --git a/src/System.Management.Automation/engine/parser/TypeResolver.cs b/src/System.Management.Automation/engine/parser/TypeResolver.cs index 8843ff5cd..dd69985bd 100644 --- a/src/System.Management.Automation/engine/parser/TypeResolver.cs +++ b/src/System.Management.Automation/engine/parser/TypeResolver.cs @@ -673,7 +673,7 @@ namespace System.Management.Automation.Language internal static class TypeCache { - private class KeyComparer : IEqualityComparer> + private sealed class KeyComparer : IEqualityComparer> { public bool Equals(Tuple x, Tuple y) diff --git a/src/System.Management.Automation/engine/parser/VariableAnalysis.cs b/src/System.Management.Automation/engine/parser/VariableAnalysis.cs index a867ff815..b38954ebf 100644 --- a/src/System.Management.Automation/engine/parser/VariableAnalysis.cs +++ b/src/System.Management.Automation/engine/parser/VariableAnalysis.cs @@ -338,7 +338,7 @@ namespace System.Management.Automation.Language // in these cases, we rely on the setter PSVariable.Value to handle those attributes. internal const int ForceDynamic = -2; - private class LoopGotoTargets + private sealed class LoopGotoTargets { internal LoopGotoTargets(string label, Block breakTarget, Block continueTarget) { @@ -354,7 +354,7 @@ namespace System.Management.Automation.Language internal Block ContinueTarget { get; } } - private class Block + private sealed class Block { internal readonly List _asts = new List(); private readonly List _successors = new List(); @@ -439,7 +439,7 @@ namespace System.Management.Automation.Language } } - private class AssignmentTarget : Ast + private sealed class AssignmentTarget : Ast { internal readonly ExpressionAst _targetAst; internal readonly string _variableName; diff --git a/src/System.Management.Automation/engine/regex.cs b/src/System.Management.Automation/engine/regex.cs index 3f827dc08..dbdbcb413 100644 --- a/src/System.Management.Automation/engine/regex.cs +++ b/src/System.Management.Automation/engine/regex.cs @@ -1001,7 +1001,7 @@ namespace System.Management.Automation } } - private class PatternPositionsVisitor : IDisposable + private sealed class PatternPositionsVisitor : IDisposable { private readonly int _lengthOfPattern; @@ -1122,7 +1122,7 @@ namespace System.Management.Automation } } - private class LiteralCharacterElement : QuestionMarkElement + private sealed class LiteralCharacterElement : QuestionMarkElement { private readonly char _literalCharacter; @@ -1148,7 +1148,7 @@ namespace System.Management.Automation } } - private class BracketExpressionElement : QuestionMarkElement + private sealed class BracketExpressionElement : QuestionMarkElement { private readonly Regex _regex; @@ -1173,7 +1173,7 @@ namespace System.Management.Automation } } - private class AsterixElement : PatternElement + private sealed class AsterixElement : PatternElement { public override void ProcessStringCharacter( char currentStringCharacter, @@ -1197,7 +1197,7 @@ namespace System.Management.Automation } } - private class MyWildcardPatternParser : WildcardPatternParser + private sealed class MyWildcardPatternParser : WildcardPatternParser { private readonly List _patternElements = new List(); private CharacterNormalizer _characterNormalizer; diff --git a/src/System.Management.Automation/engine/remoting/client/Job.cs b/src/System.Management.Automation/engine/remoting/client/Job.cs index 657b72bef..6c7efa68f 100644 --- a/src/System.Management.Automation/engine/remoting/client/Job.cs +++ b/src/System.Management.Automation/engine/remoting/client/Job.cs @@ -2048,7 +2048,7 @@ namespace System.Management.Automation /// /// Simple throttle operation class for connecting jobs. /// - private class ConnectJobOperation : IThrottleOperation + private sealed class ConnectJobOperation : IThrottleOperation { private readonly PSRemotingChildJob _psRemoteChildJob; diff --git a/src/System.Management.Automation/engine/remoting/client/ThrottlingJob.cs b/src/System.Management.Automation/engine/remoting/client/ThrottlingJob.cs index 3ed2bcd43..db2f5403d 100644 --- a/src/System.Management.Automation/engine/remoting/client/ThrottlingJob.cs +++ b/src/System.Management.Automation/engine/remoting/client/ThrottlingJob.cs @@ -846,7 +846,7 @@ namespace System.Management.Automation } } - private class ForwardingHelper : IDisposable + private sealed class ForwardingHelper : IDisposable { // This is higher than 1000 used in // RxExtensionMethods+ToEnumerableObserver.BlockingCollectionCapacity diff --git a/src/System.Management.Automation/engine/remoting/client/remotepipeline.cs b/src/System.Management.Automation/engine/remoting/client/remotepipeline.cs index c791d7288..164e9f11f 100644 --- a/src/System.Management.Automation/engine/remoting/client/remotepipeline.cs +++ b/src/System.Management.Automation/engine/remoting/client/remotepipeline.cs @@ -42,7 +42,7 @@ namespace System.Management.Automation /// private Queue _executionEventQueue = new Queue(); - private class ExecutionEventQueueItem + private sealed class ExecutionEventQueueItem { public ExecutionEventQueueItem(PipelineStateInfo pipelineStateInfo, RunspaceAvailability currentAvailability, RunspaceAvailability newAvailability) { diff --git a/src/System.Management.Automation/engine/remoting/commands/ConnectPSSession.cs b/src/System.Management.Automation/engine/remoting/commands/ConnectPSSession.cs index 906074a8c..8dfdacd12 100644 --- a/src/System.Management.Automation/engine/remoting/commands/ConnectPSSession.cs +++ b/src/System.Management.Automation/engine/remoting/commands/ConnectPSSession.cs @@ -487,7 +487,7 @@ namespace Microsoft.PowerShell.Commands /// /// Throttle class to perform a remoterunspace connect operation. /// - private class ConnectRunspaceOperation : IThrottleOperation + private sealed class ConnectRunspaceOperation : IThrottleOperation { private PSSession _session; private PSSession _oldSession; diff --git a/src/System.Management.Automation/engine/remoting/commands/DisconnectPSSession.cs b/src/System.Management.Automation/engine/remoting/commands/DisconnectPSSession.cs index 0e2458dab..74bcbac2c 100644 --- a/src/System.Management.Automation/engine/remoting/commands/DisconnectPSSession.cs +++ b/src/System.Management.Automation/engine/remoting/commands/DisconnectPSSession.cs @@ -392,7 +392,7 @@ namespace Microsoft.PowerShell.Commands /// /// Throttle class to perform a remoterunspace disconnect operation. /// - private class DisconnectRunspaceOperation : IThrottleOperation + private sealed class DisconnectRunspaceOperation : IThrottleOperation { private readonly PSSession _remoteSession; private readonly ObjectStream _writeStream; diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManTransportManager.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManTransportManager.cs index 99b2d4848..60e4228c9 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManTransportManager.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManTransportManager.cs @@ -305,7 +305,7 @@ namespace System.Management.Automation.Remoting.Client #region CompletionEventArgs - private class CompletionEventArgs : EventArgs + private sealed class CompletionEventArgs : EventArgs { internal CompletionEventArgs(CompletionNotification notification) { @@ -2833,7 +2833,7 @@ namespace System.Management.Automation.Remoting.Client private readonly string _cmdLine; private readonly WSManClientSessionTransportManager _sessnTm; - private class SendDataChunk + private sealed class SendDataChunk { public SendDataChunk(byte[] data, DataPriorityType type) { diff --git a/src/System.Management.Automation/engine/remoting/server/ServerRunspacePoolDriver.cs b/src/System.Management.Automation/engine/remoting/server/ServerRunspacePoolDriver.cs index 6b553b23a..69866f2d4 100644 --- a/src/System.Management.Automation/engine/remoting/server/ServerRunspacePoolDriver.cs +++ b/src/System.Management.Automation/engine/remoting/server/ServerRunspacePoolDriver.cs @@ -1252,7 +1252,7 @@ namespace System.Management.Automation BreakpointManagement, } - private class DebuggerCommandArgument + private sealed class DebuggerCommandArgument { public DebugModes? Mode { get; set; } diff --git a/src/System.Management.Automation/engine/runtime/Binding/Binders.cs b/src/System.Management.Automation/engine/runtime/Binding/Binders.cs index 14e5035d2..6cfc72fd1 100644 --- a/src/System.Management.Automation/engine/runtime/Binding/Binders.cs +++ b/src/System.Management.Automation/engine/runtime/Binding/Binders.cs @@ -1177,7 +1177,7 @@ namespace System.Management.Automation.Language internal sealed class PSInvokeDynamicMemberBinder : DynamicMetaObjectBinder { - private class KeyComparer : IEqualityComparer + private sealed class KeyComparer : IEqualityComparer { public bool Equals(PSInvokeDynamicMemberBinderKeyType x, PSInvokeDynamicMemberBinderKeyType y) { @@ -4887,7 +4887,7 @@ namespace System.Management.Automation.Language /// internal class PSGetMemberBinder : GetMemberBinder { - private class KeyComparer : IEqualityComparer + private sealed class KeyComparer : IEqualityComparer { public bool Equals(PSGetMemberBinderKeyType x, PSGetMemberBinderKeyType y) { @@ -4911,7 +4911,7 @@ namespace System.Management.Automation.Language } } - private class ReservedMemberBinder : PSGetMemberBinder + private sealed class ReservedMemberBinder : PSGetMemberBinder { internal ReservedMemberBinder(string name, bool ignoreCase, bool @static) : base(name, null, ignoreCase, @static, nonEnumerating: false) { @@ -5936,7 +5936,7 @@ namespace System.Management.Automation.Language /// internal class PSSetMemberBinder : SetMemberBinder { - private class KeyComparer : IEqualityComparer + private sealed class KeyComparer : IEqualityComparer { public bool Equals(PSSetMemberBinderKeyType x, PSSetMemberBinderKeyType y) { @@ -6519,7 +6519,7 @@ namespace System.Management.Automation.Language NonVirtual, } - private class KeyComparer : IEqualityComparer + private sealed class KeyComparer : IEqualityComparer { public bool Equals(PSInvokeMemberBinderKeyType x, PSInvokeMemberBinderKeyType y) { @@ -7509,7 +7509,7 @@ namespace System.Management.Automation.Language private readonly bool _publicTypeOnly; private int _version; - private class KeyComparer : IEqualityComparer> + private sealed class KeyComparer : IEqualityComparer> { public bool Equals(Tuple x, Tuple y) @@ -7687,7 +7687,7 @@ namespace System.Management.Automation.Language private readonly CallInfo _callInfo; private readonly PSMethodInvocationConstraints _constraints; - private class KeyComparer : IEqualityComparer> + private sealed class KeyComparer : IEqualityComparer> { public bool Equals(Tuple x, Tuple y) diff --git a/src/System.Management.Automation/engine/runtime/Operations/MiscOps.cs b/src/System.Management.Automation/engine/runtime/Operations/MiscOps.cs index a1063e626..de9ef697f 100644 --- a/src/System.Management.Automation/engine/runtime/Operations/MiscOps.cs +++ b/src/System.Management.Automation/engine/runtime/Operations/MiscOps.cs @@ -1379,7 +1379,7 @@ namespace System.Management.Automation /// /// Represent a handler search result. /// - private class HandlerSearchResult + private sealed class HandlerSearchResult { internal HandlerSearchResult() { diff --git a/src/System.Management.Automation/engine/runtime/Operations/VariableOps.cs b/src/System.Management.Automation/engine/runtime/Operations/VariableOps.cs index d337c56ab..6799d1bd9 100644 --- a/src/System.Management.Automation/engine/runtime/Operations/VariableOps.cs +++ b/src/System.Management.Automation/engine/runtime/Operations/VariableOps.cs @@ -277,7 +277,7 @@ namespace System.Management.Automation return null; } - private class UsingResult + private sealed class UsingResult { public object Value { get; set; } } diff --git a/src/System.Management.Automation/engine/serialization.cs b/src/System.Management.Automation/engine/serialization.cs index 8608dd622..d801178a2 100644 --- a/src/System.Management.Automation/engine/serialization.cs +++ b/src/System.Management.Automation/engine/serialization.cs @@ -5639,7 +5639,7 @@ namespace System.Management.Automation /// type of dictionary values internal class WeakReferenceDictionary : IDictionary { - private class WeakReferenceEqualityComparer : IEqualityComparer + private sealed class WeakReferenceEqualityComparer : IEqualityComparer { public bool Equals(WeakReference x, WeakReference y) { diff --git a/src/System.Management.Automation/namespaces/FileSystemProvider.cs b/src/System.Management.Automation/namespaces/FileSystemProvider.cs index f4473d7fb..a32dc4217 100644 --- a/src/System.Management.Automation/namespaces/FileSystemProvider.cs +++ b/src/System.Management.Automation/namespaces/FileSystemProvider.cs @@ -7401,7 +7401,7 @@ namespace Microsoft.PowerShell.Commands /// /// Tracks visited files/directories by caching their device IDs and inodes. /// - private class InodeTracker + private sealed class InodeTracker { private readonly HashSet<(UInt64, UInt64)> _visitations; diff --git a/src/System.Management.Automation/utils/tracing/EtwActivity.cs b/src/System.Management.Automation/utils/tracing/EtwActivity.cs index b50f68e69..b8b4ac330 100644 --- a/src/System.Management.Automation/utils/tracing/EtwActivity.cs +++ b/src/System.Management.Automation/utils/tracing/EtwActivity.cs @@ -94,7 +94,7 @@ namespace System.Management.Automation.Tracing /// This is a helper class that is used to wrap many multi-threading scenarios /// and makes correlation event to be logged easily. /// - private class CorrelatedCallback + private sealed class CorrelatedCallback { private readonly CallbackNoParameter callbackNoParam; private readonly CallbackWithState callbackWithState; @@ -103,7 +103,7 @@ namespace System.Management.Automation.Tracing /// /// ParentActivityId. /// - protected readonly Guid parentActivityId; + private readonly Guid parentActivityId; private readonly EtwActivity tracer; /// diff --git a/src/TypeCatalogGen/TypeCatalogGen.cs b/src/TypeCatalogGen/TypeCatalogGen.cs index 993413bc5..543d5931e 100644 --- a/src/TypeCatalogGen/TypeCatalogGen.cs +++ b/src/TypeCatalogGen/TypeCatalogGen.cs @@ -459,7 +459,7 @@ namespace System.Management.Automation /// /// Helper class to keep the metadata of a type. /// - private class TypeMetadata + private sealed class TypeMetadata { internal readonly string AssemblyName; internal readonly bool IsObsolete; diff --git a/src/powershell/Program.cs b/src/powershell/Program.cs index d9dfa2f80..3fee68361 100644 --- a/src/powershell/Program.cs +++ b/src/powershell/Program.cs @@ -19,7 +19,7 @@ namespace Microsoft.PowerShell /// /// Exception to signify an early startup failure. /// - private class StartupException : Exception + private sealed class StartupException : Exception { /// /// Construct a new startup exception instance.