Skip to content

Commit 51c1a7c

Browse files
committed
1 parent 5cdafbc commit 51c1a7c

9 files changed

Lines changed: 26 additions & 22 deletions

File tree

.globalconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,10 @@ dotnet_diagnostic.CA1846.severity = warning
510510
# https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1847
511511
dotnet_diagnostic.CA1847.severity = warning
512512

513+
# CA1852: Seal internal types
514+
# https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1852
515+
dotnet_diagnostic.CA1852.severity = warning
516+
513517
# CA1858: Use 'StartsWith' instead of 'IndexOf'
514518
# https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1858
515519
dotnet_diagnostic.CA1858.severity = warning

src/Microsoft.PowerShell.Commands.Diagnostics/NewWinEventCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ protected override void EndProcessing()
323323
}
324324
}
325325

326-
internal class EventWriteException : Exception
326+
internal sealed class EventWriteException : Exception
327327
{
328328
internal EventWriteException(string msg, Exception innerException)
329329
: base(msg, innerException)

src/Microsoft.PowerShell.Commands.Diagnostics/PdhHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ internal struct CounterHandleNInstance
190190
public string InstanceName;
191191
}
192192

193-
internal class PdhHelper : IDisposable
193+
internal sealed class PdhHelper : IDisposable
194194
{
195195
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
196196
private struct PDH_COUNTER_PATH_ELEMENTS

src/Microsoft.PowerShell.Commands.Management/commands/management/GetComputerInfoCommand.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,7 +1335,7 @@ protected static string GetLanguageName(uint? lcid)
13351335

13361336
#pragma warning disable 649 // fields and properties in these class are assigned dynamically
13371337
[SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Justification = "Class is instantiated directly from a CIM instance")]
1338-
internal class WmiBaseBoard
1338+
internal sealed class WmiBaseBoard
13391339
{
13401340
public string Caption;
13411341
public string[] ConfigOptions;
@@ -1368,7 +1368,7 @@ internal class WmiBaseBoard
13681368
}
13691369

13701370
[SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Justification = "Class is instantiated directly from a CIM instance")]
1371-
internal class WmiBios : WmiClassBase
1371+
internal sealed class WmiBios : WmiClassBase
13721372
{
13731373
public ushort[] BiosCharacteristics;
13741374
public string[] BIOSVersion;
@@ -1403,7 +1403,7 @@ internal class WmiBios : WmiClassBase
14031403
}
14041404

14051405
[SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Justification = "Class is instantiated directly from a CIM instance")]
1406-
internal class WmiComputerSystem
1406+
internal sealed class WmiComputerSystem
14071407
{
14081408
public ushort? AdminPasswordStatus;
14091409
public bool? AutomaticManagedPagefile;
@@ -1486,7 +1486,7 @@ public PowerManagementCapabilities[] GetPowerManagementCapabilities()
14861486
}
14871487

14881488
[SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Justification = "Class is instantiated directly from a CIM instance")]
1489-
internal class WmiDeviceGuard
1489+
internal sealed class WmiDeviceGuard
14901490
{
14911491
public uint[] AvailableSecurityProperties;
14921492
public uint? CodeIntegrityPolicyEnforcementStatus;
@@ -1561,7 +1561,7 @@ public DeviceGuard AsOutputType
15611561
}
15621562

15631563
[SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Justification = "Class is instantiated directly from a CIM instance")]
1564-
internal class WmiKeyboard
1564+
internal sealed class WmiKeyboard
15651565
{
15661566
public ushort? Availability;
15671567
public string Caption;
@@ -1588,14 +1588,14 @@ internal class WmiKeyboard
15881588
}
15891589

15901590
[SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Justification = "Class is instantiated directly from a CIM instance")]
1591-
internal class WMiLogicalMemory
1591+
internal sealed class WMiLogicalMemory
15921592
{
15931593
// TODO: fill this in!!!
15941594
public uint? TotalPhysicalMemory;
15951595
}
15961596

15971597
[SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Justification = "Class is instantiated directly from a CIM instance")]
1598-
internal class WmiMsftNetAdapter
1598+
internal sealed class WmiMsftNetAdapter
15991599
{
16001600
public string Caption;
16011601
public string Description;
@@ -1683,7 +1683,7 @@ internal class WmiMsftNetAdapter
16831683
}
16841684

16851685
[SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Justification = "Class is instantiated directly from a CIM instance")]
1686-
internal class WmiNetworkAdapter
1686+
internal sealed class WmiNetworkAdapter
16871687
{
16881688
public string AdapterType;
16891689
public ushort? AdapterTypeID;
@@ -1727,7 +1727,7 @@ internal class WmiNetworkAdapter
17271727
}
17281728

17291729
[SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Justification = "Class is instantiated directly from a CIM instance")]
1730-
internal class WmiNetworkAdapterConfiguration
1730+
internal sealed class WmiNetworkAdapterConfiguration
17311731
{
17321732
public bool? ArpAlwaysSourceRoute;
17331733
public bool? ArpUseEtherSNAP;
@@ -1793,7 +1793,7 @@ internal class WmiNetworkAdapterConfiguration
17931793
}
17941794

17951795
[SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Justification = "Class is instantiated directly from a CIM instance")]
1796-
internal class WmiOperatingSystem : WmiClassBase
1796+
internal sealed class WmiOperatingSystem : WmiClassBase
17971797
{
17981798
#region Fields
17991799
public string BootDevice;
@@ -1900,7 +1900,7 @@ private static OSProductSuite[] MakeProductSuites(uint? suiteMask)
19001900
}
19011901

19021902
[SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Justification = "Class is instantiated directly from a CIM instance")]
1903-
internal class WmiPageFileUsage
1903+
internal sealed class WmiPageFileUsage
19041904
{
19051905
public uint? AllocatedBaseSize;
19061906
public string Caption;
@@ -1914,7 +1914,7 @@ internal class WmiPageFileUsage
19141914
}
19151915

19161916
[SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Justification = "Class is instantiated directly from a CIM instance")]
1917-
internal class WmiProcessor
1917+
internal sealed class WmiProcessor
19181918
{
19191919
public ushort? AddressWidth;
19201920
public ushort? Architecture;
@@ -1977,7 +1977,7 @@ internal class WmiProcessor
19771977
#endregion Intermediate WMI classes
19781978

19791979
#region Other Intermediate classes
1980-
internal class RegWinNtCurrentVersion
1980+
internal sealed class RegWinNtCurrentVersion
19811981
{
19821982
public string BuildLabEx;
19831983
public string CurrentVersion;

src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2841,7 +2841,7 @@ internal struct PROCESS_INFORMATION
28412841
}
28422842

28432843
[StructLayout(LayoutKind.Sequential)]
2844-
internal class SECURITY_ATTRIBUTES
2844+
internal sealed class SECURITY_ATTRIBUTES
28452845
{
28462846
public int nLength;
28472847
public SafeLocalMemHandle lpSecurityDescriptor;
@@ -2879,7 +2879,7 @@ protected override bool ReleaseHandle()
28792879
}
28802880

28812881
[StructLayout(LayoutKind.Sequential)]
2882-
internal class STARTUPINFO
2882+
internal sealed class STARTUPINFO
28832883
{
28842884
public int cb;
28852885
public IntPtr lpReserved;

src/Microsoft.WSMan.Management/CurrentConfigurations.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Microsoft.WSMan.Management
1111
/// Class that queries the server and gets current configurations.
1212
/// Also provides a generic way to update the configurations.
1313
/// </summary>
14-
internal class CurrentConfigurations
14+
internal sealed class CurrentConfigurations
1515
{
1616
/// <summary>
1717
/// Prefix used to add NameSpace of root element to namespace manager.

src/Microsoft.WSMan.Management/WsManHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
namespace Microsoft.WSMan.Management
2323
{
2424
[SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "0#")]
25-
internal class WSManHelper
25+
internal sealed class WSManHelper
2626
{
2727
// regular expressions
2828
private const string PTRN_URI_LAST = @"([a-z_][-a-z0-9._]*)$";
@@ -89,7 +89,7 @@ internal class WSManHelper
8989
//
9090
//
9191
// Below class is just a static container which would release sessions in case this DLL is unloaded.
92-
internal class Sessions
92+
internal sealed class Sessions
9393
{
9494
/// <summary>
9595
/// Dictionary object to store the connection.

test/tools/TestAlc/init/Init.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
namespace Test.Isolated.Init
1212
{
13-
internal class CustomLoadContext : AssemblyLoadContext
13+
internal sealed class CustomLoadContext : AssemblyLoadContext
1414
{
1515
private readonly string _dependencyDirPath;
1616

test/tools/TestExe/TestExe.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ internal enum EnvTarget
2020
System = 2,
2121
}
2222

23-
internal class TestExe
23+
internal sealed class TestExe
2424
{
2525
private static int Main(string[] args)
2626
{

0 commit comments

Comments
 (0)