Fix CA1852: Seal internal types. Part 1 (#26205)

This commit is contained in:
xtqqczze
2025-10-16 05:23:32 +00:00
committed by GitHub
parent 380758aff4
commit d2d0defd5f
7 changed files with 23 additions and 23 deletions
@@ -323,7 +323,7 @@ namespace Microsoft.PowerShell.Commands
}
}
internal class EventWriteException : Exception
internal sealed class EventWriteException : Exception
{
internal EventWriteException(string msg, Exception innerException)
: base(msg, innerException)
@@ -190,7 +190,7 @@ namespace Microsoft.Powershell.Commands.GetCounter.PdhNative
public string InstanceName;
}
internal class PdhHelper : IDisposable
internal sealed class PdhHelper : IDisposable
{
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
private struct PDH_COUNTER_PATH_ELEMENTS
@@ -1335,7 +1335,7 @@ namespace Microsoft.PowerShell.Commands
#pragma warning disable 649 // fields and properties in these class are assigned dynamically
[SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Justification = "Class is instantiated directly from a CIM instance")]
internal class WmiBaseBoard
internal sealed class WmiBaseBoard
{
public string Caption;
public string[] ConfigOptions;
@@ -1368,7 +1368,7 @@ namespace Microsoft.PowerShell.Commands
}
[SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Justification = "Class is instantiated directly from a CIM instance")]
internal class WmiBios : WmiClassBase
internal sealed class WmiBios : WmiClassBase
{
public ushort[] BiosCharacteristics;
public string[] BIOSVersion;
@@ -1403,7 +1403,7 @@ namespace Microsoft.PowerShell.Commands
}
[SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Justification = "Class is instantiated directly from a CIM instance")]
internal class WmiComputerSystem
internal sealed class WmiComputerSystem
{
public ushort? AdminPasswordStatus;
public bool? AutomaticManagedPagefile;
@@ -1486,7 +1486,7 @@ namespace Microsoft.PowerShell.Commands
}
[SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Justification = "Class is instantiated directly from a CIM instance")]
internal class WmiDeviceGuard
internal sealed class WmiDeviceGuard
{
public uint[] AvailableSecurityProperties;
public uint? CodeIntegrityPolicyEnforcementStatus;
@@ -1561,7 +1561,7 @@ namespace Microsoft.PowerShell.Commands
}
[SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Justification = "Class is instantiated directly from a CIM instance")]
internal class WmiKeyboard
internal sealed class WmiKeyboard
{
public ushort? Availability;
public string Caption;
@@ -1588,14 +1588,14 @@ namespace Microsoft.PowerShell.Commands
}
[SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Justification = "Class is instantiated directly from a CIM instance")]
internal class WMiLogicalMemory
internal sealed class WMiLogicalMemory
{
// TODO: fill this in!!!
public uint? TotalPhysicalMemory;
}
[SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Justification = "Class is instantiated directly from a CIM instance")]
internal class WmiMsftNetAdapter
internal sealed class WmiMsftNetAdapter
{
public string Caption;
public string Description;
@@ -1683,7 +1683,7 @@ namespace Microsoft.PowerShell.Commands
}
[SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Justification = "Class is instantiated directly from a CIM instance")]
internal class WmiNetworkAdapter
internal sealed class WmiNetworkAdapter
{
public string AdapterType;
public ushort? AdapterTypeID;
@@ -1727,7 +1727,7 @@ namespace Microsoft.PowerShell.Commands
}
[SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Justification = "Class is instantiated directly from a CIM instance")]
internal class WmiNetworkAdapterConfiguration
internal sealed class WmiNetworkAdapterConfiguration
{
public bool? ArpAlwaysSourceRoute;
public bool? ArpUseEtherSNAP;
@@ -1793,7 +1793,7 @@ namespace Microsoft.PowerShell.Commands
}
[SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Justification = "Class is instantiated directly from a CIM instance")]
internal class WmiOperatingSystem : WmiClassBase
internal sealed class WmiOperatingSystem : WmiClassBase
{
#region Fields
public string BootDevice;
@@ -1900,7 +1900,7 @@ namespace Microsoft.PowerShell.Commands
}
[SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Justification = "Class is instantiated directly from a CIM instance")]
internal class WmiPageFileUsage
internal sealed class WmiPageFileUsage
{
public uint? AllocatedBaseSize;
public string Caption;
@@ -1914,7 +1914,7 @@ namespace Microsoft.PowerShell.Commands
}
[SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Justification = "Class is instantiated directly from a CIM instance")]
internal class WmiProcessor
internal sealed class WmiProcessor
{
public ushort? AddressWidth;
public ushort? Architecture;
@@ -1977,7 +1977,7 @@ namespace Microsoft.PowerShell.Commands
#endregion Intermediate WMI classes
#region Other Intermediate classes
internal class RegWinNtCurrentVersion
internal sealed class RegWinNtCurrentVersion
{
public string BuildLabEx;
public string CurrentVersion;
@@ -2841,7 +2841,7 @@ namespace Microsoft.PowerShell.Commands
}
[StructLayout(LayoutKind.Sequential)]
internal class SECURITY_ATTRIBUTES
internal sealed class SECURITY_ATTRIBUTES
{
public int nLength;
public SafeLocalMemHandle lpSecurityDescriptor;
@@ -2879,7 +2879,7 @@ namespace Microsoft.PowerShell.Commands
}
[StructLayout(LayoutKind.Sequential)]
internal class STARTUPINFO
internal sealed class STARTUPINFO
{
public int cb;
public IntPtr lpReserved;
@@ -11,7 +11,7 @@ namespace Microsoft.WSMan.Management
/// Class that queries the server and gets current configurations.
/// Also provides a generic way to update the configurations.
/// </summary>
internal class CurrentConfigurations
internal sealed class CurrentConfigurations
{
/// <summary>
/// Prefix used to add NameSpace of root element to namespace manager.
@@ -22,7 +22,7 @@ using Microsoft.Win32;
namespace Microsoft.WSMan.Management
{
[SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "0#")]
internal class WSManHelper
internal sealed class WSManHelper
{
// regular expressions
private const string PTRN_URI_LAST = @"([a-z_][-a-z0-9._]*)$";
@@ -89,7 +89,7 @@ namespace Microsoft.WSMan.Management
//
//
// Below class is just a static container which would release sessions in case this DLL is unloaded.
internal class Sessions
internal sealed class Sessions
{
/// <summary>
/// Dictionary object to store the connection.
+3 -3
View File
@@ -8,17 +8,17 @@ using Xunit;
namespace PSTests.Parallel
{
internal class MyICustomAstVisitor2 : ICustomAstVisitor2
internal sealed class MyICustomAstVisitor2 : ICustomAstVisitor2
{
public object DefaultVisit(Ast ast) => ast.GetType().Name;
}
internal class MyDefaultCustomAstVisitor2 : DefaultCustomAstVisitor2
internal sealed class MyDefaultCustomAstVisitor2 : DefaultCustomAstVisitor2
{
public override object DefaultVisit(Ast ast) => ast.GetType().Name;
}
internal class MyAstVisitor2 : AstVisitor2
internal sealed class MyAstVisitor2 : AstVisitor2
{
public List<string> Commands { get; }