diff --git a/.globalconfig b/.globalconfig
index 17f004b93e..439455a0f5 100644
--- a/.globalconfig
+++ b/.globalconfig
@@ -100,7 +100,8 @@ dotnet_diagnostic.CA1050.severity = warning
dotnet_diagnostic.CA1051.severity = silent
# CA1052: Static holder types should be Static or NotInheritable
-dotnet_diagnostic.CA1052.severity = none
+dotnet_diagnostic.CA1052.severity = warning
+dotnet_code_quality.ca1052.api_surface = private, internal
# CA1054: URI-like parameters should not be strings
dotnet_diagnostic.CA1054.severity = none
diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/TimeZoneCommands.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/TimeZoneCommands.cs
index 0289e885e6..69e8860f3a 100644
--- a/src/Microsoft.PowerShell.Commands.Management/commands/management/TimeZoneCommands.cs
+++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/TimeZoneCommands.cs
@@ -428,15 +428,8 @@ namespace Microsoft.PowerShell.Commands
#region Win32 interop helper
- internal class NativeMethods
+ internal static class NativeMethods
{
- ///
- /// Private constructor to prevent instantiation.
- ///
- private NativeMethods()
- {
- }
-
#region Native DLL locations
private const string SetDynamicTimeZoneApiDllName = "api-ms-win-core-timezone-l1-1-0.dll";
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 54e323dfac..90ef2ca437 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/New-Object.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/New-Object.cs
@@ -519,12 +519,8 @@ namespace Microsoft.PowerShell.Commands
///
/// Native methods for dealing with COM objects.
///
- internal class NewObjectNativeMethods
+ internal static class NewObjectNativeMethods
{
- private NewObjectNativeMethods()
- {
- }
-
/// Return Type: HRESULT->LONG->int
[DllImport(PinvokeDllNames.CLSIDFromProgIDDllName)]
internal static extern int CLSIDFromProgID([MarshalAs(UnmanagedType.LPWStr)] string lpszProgID, out Guid pclsid);
diff --git a/src/Microsoft.PowerShell.ConsoleHost/WindowsTaskbarJumpList/PropVariant.cs b/src/Microsoft.PowerShell.ConsoleHost/WindowsTaskbarJumpList/PropVariant.cs
index 90148ca7e2..10db7912b4 100644
--- a/src/Microsoft.PowerShell.ConsoleHost/WindowsTaskbarJumpList/PropVariant.cs
+++ b/src/Microsoft.PowerShell.ConsoleHost/WindowsTaskbarJumpList/PropVariant.cs
@@ -58,7 +58,7 @@ namespace Microsoft.PowerShell
Dispose();
}
- private class PropVariantNativeMethods
+ private static class PropVariantNativeMethods
{
[DllImport("Ole32.dll", PreserveSig = false)]
internal static extern void PropVariantClear([In, Out] PropVariant pvar);
diff --git a/src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/Reader/NativeWrapper.cs b/src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/Reader/NativeWrapper.cs
index c9cd4d255e..007cf74891 100644
--- a/src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/Reader/NativeWrapper.cs
+++ b/src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/Reader/NativeWrapper.cs
@@ -22,7 +22,7 @@ using System.Text;
namespace System.Diagnostics.Eventing.Reader
{
- internal class NativeWrapper
+ internal static class NativeWrapper
{
public class SystemProperties
{
diff --git a/src/System.Management.Automation/AssemblyInfo.cs b/src/System.Management.Automation/AssemblyInfo.cs
index 279feede65..1963b331ef 100644
--- a/src/System.Management.Automation/AssemblyInfo.cs
+++ b/src/System.Management.Automation/AssemblyInfo.cs
@@ -27,7 +27,7 @@ using System.Runtime.CompilerServices;
namespace System.Management.Automation
{
- internal class NTVerpVars
+ internal static class NTVerpVars
{
internal const int PRODUCTMAJORVERSION = 10;
internal const int PRODUCTMINORVERSION = 0;
diff --git a/src/System.Management.Automation/CoreCLR/CorePsStub.cs b/src/System.Management.Automation/CoreCLR/CorePsStub.cs
index 85b775f925..d99bcbb398 100644
--- a/src/System.Management.Automation/CoreCLR/CorePsStub.cs
+++ b/src/System.Management.Automation/CoreCLR/CorePsStub.cs
@@ -417,7 +417,7 @@ namespace System.Management.Automation.ComInterop
}
}
- internal class VarEnumSelector
+ internal static class VarEnumSelector
{
internal static Type GetTypeForVarEnum(VarEnum vt)
{
diff --git a/src/System.Management.Automation/engine/COM/ComUtil.cs b/src/System.Management.Automation/engine/COM/ComUtil.cs
index bc7609b733..e244e4cdf3 100644
--- a/src/System.Management.Automation/engine/COM/ComUtil.cs
+++ b/src/System.Management.Automation/engine/COM/ComUtil.cs
@@ -16,7 +16,7 @@ namespace System.Management.Automation
///
/// Defines a utility class that is used by COM adapter.
///
- internal class ComUtil
+ internal static class ComUtil
{
// HResult error code '-2147352573' - Member not found.
internal const int DISP_E_MEMBERNOTFOUND = unchecked((int)0x80020003);
diff --git a/src/System.Management.Automation/engine/ExperimentalFeature/EnableDisableExperimentalFeatureCommand.cs b/src/System.Management.Automation/engine/ExperimentalFeature/EnableDisableExperimentalFeatureCommand.cs
index c15d8628cb..7a76a18ddb 100644
--- a/src/System.Management.Automation/engine/ExperimentalFeature/EnableDisableExperimentalFeatureCommand.cs
+++ b/src/System.Management.Automation/engine/ExperimentalFeature/EnableDisableExperimentalFeatureCommand.cs
@@ -70,7 +70,7 @@ namespace Microsoft.PowerShell.Commands
}
}
- internal class ExperimentalFeatureConfigHelper
+ internal static class ExperimentalFeatureConfigHelper
{
internal static void UpdateConfig(PSCmdlet cmdlet, string[] name, ConfigScope scope, bool enable)
{
diff --git a/src/System.Management.Automation/engine/InitialSessionState.cs b/src/System.Management.Automation/engine/InitialSessionState.cs
index 2495a4ac0f..257cb79ce7 100644
--- a/src/System.Management.Automation/engine/InitialSessionState.cs
+++ b/src/System.Management.Automation/engine/InitialSessionState.cs
@@ -26,7 +26,7 @@ using Debug = System.Management.Automation.Diagnostics;
namespace System.Management.Automation.Runspaces
{
- internal class EarlyStartup
+ internal static class EarlyStartup
{
internal static void Init()
{
diff --git a/src/System.Management.Automation/engine/Modules/AnalysisCache.cs b/src/System.Management.Automation/engine/Modules/AnalysisCache.cs
index 8b055d8fb0..0d80b976aa 100644
--- a/src/System.Management.Automation/engine/Modules/AnalysisCache.cs
+++ b/src/System.Management.Automation/engine/Modules/AnalysisCache.cs
@@ -27,7 +27,7 @@ namespace System.Management.Automation
/// Changes to these type of modules will not be re-analyzed, unless the user re-imports the module,
/// or runs Get-Module -List.
///
- internal class AnalysisCache
+ internal static class AnalysisCache
{
private static readonly AnalysisCacheData s_cacheData = AnalysisCacheData.Get();
diff --git a/src/System.Management.Automation/engine/Modules/RemoteDiscoveryHelper.cs b/src/System.Management.Automation/engine/Modules/RemoteDiscoveryHelper.cs
index 9ece4af620..a0039cee17 100644
--- a/src/System.Management.Automation/engine/Modules/RemoteDiscoveryHelper.cs
+++ b/src/System.Management.Automation/engine/Modules/RemoteDiscoveryHelper.cs
@@ -25,7 +25,7 @@ using Dbg = System.Management.Automation.Diagnostics;
namespace System.Management.Automation
{
- internal class RemoteDiscoveryHelper
+ internal static class RemoteDiscoveryHelper
{
#region PSRP
diff --git a/src/System.Management.Automation/engine/MshMemberInfo.cs b/src/System.Management.Automation/engine/MshMemberInfo.cs
index 34a3a1f9ee..73ee243f6e 100644
--- a/src/System.Management.Automation/engine/MshMemberInfo.cs
+++ b/src/System.Management.Automation/engine/MshMemberInfo.cs
@@ -3670,7 +3670,7 @@ namespace System.Management.Automation
///
/// /// This class is used in PSMemberInfoInternalCollection and ReadOnlyPSMemberInfoCollection.
///
- internal class MemberMatch
+ internal static class MemberMatch
{
internal static WildcardPattern GetNamePattern(string name)
{
diff --git a/src/System.Management.Automation/engine/WinRT/IInspectable.cs b/src/System.Management.Automation/engine/WinRT/IInspectable.cs
index f6f4d9ee7d..abc589b487 100644
--- a/src/System.Management.Automation/engine/WinRT/IInspectable.cs
+++ b/src/System.Management.Automation/engine/WinRT/IInspectable.cs
@@ -26,7 +26,7 @@ namespace System.Management.Automation
///
/// Helper class for WinRT types.
///
- internal class WinRTHelper
+ internal static class WinRTHelper
{
internal static bool IsWinRTType(Type type)
{
diff --git a/src/System.Management.Automation/engine/interpreter/Utilities.cs b/src/System.Management.Automation/engine/interpreter/Utilities.cs
index ac896719d6..be7bb1935c 100644
--- a/src/System.Management.Automation/engine/interpreter/Utilities.cs
+++ b/src/System.Management.Automation/engine/interpreter/Utilities.cs
@@ -224,7 +224,7 @@ namespace System.Management.Automation.Interpreter
}
}
- internal class ScriptingRuntimeHelpers
+ internal static class ScriptingRuntimeHelpers
{
internal static object Int32ToObject(int i)
{
diff --git a/src/System.Management.Automation/engine/parser/PSType.cs b/src/System.Management.Automation/engine/parser/PSType.cs
index 7ffc308369..7a60d06a6b 100644
--- a/src/System.Management.Automation/engine/parser/PSType.cs
+++ b/src/System.Management.Automation/engine/parser/PSType.cs
@@ -14,7 +14,7 @@ using Microsoft.PowerShell;
namespace System.Management.Automation.Language
{
- internal class TypeDefiner
+ internal static class TypeDefiner
{
internal const string DynamicClassAssemblyName = "PowerShell Class Assembly";
internal const string DynamicClassAssemblyFullNamePrefix = "PowerShell Class Assembly,";
diff --git a/src/System.Management.Automation/engine/parser/TypeResolver.cs b/src/System.Management.Automation/engine/parser/TypeResolver.cs
index 85325b6130..8843ff5cd3 100644
--- a/src/System.Management.Automation/engine/parser/TypeResolver.cs
+++ b/src/System.Management.Automation/engine/parser/TypeResolver.cs
@@ -671,7 +671,7 @@ namespace System.Management.Automation.Language
}
}
- internal class TypeCache
+ internal static class TypeCache
{
private class KeyComparer : IEqualityComparer>
{
diff --git a/src/System.Management.Automation/engine/remoting/commands/NewPSSessionConfigurationFile.cs b/src/System.Management.Automation/engine/remoting/commands/NewPSSessionConfigurationFile.cs
index f306246e28..56bd72e90d 100644
--- a/src/System.Management.Automation/engine/remoting/commands/NewPSSessionConfigurationFile.cs
+++ b/src/System.Management.Automation/engine/remoting/commands/NewPSSessionConfigurationFile.cs
@@ -1855,7 +1855,7 @@ namespace Microsoft.PowerShell.Commands
///
/// Utility methods for configuration file commands.
///
- internal class SessionConfigurationUtils
+ internal static class SessionConfigurationUtils
{
///
/// This routine builds a fragment of the config file
diff --git a/src/System.Management.Automation/engine/remoting/common/WireDataFormat/RemoteHostEncoder.cs b/src/System.Management.Automation/engine/remoting/common/WireDataFormat/RemoteHostEncoder.cs
index 2c3a2c65b1..3ffc278a81 100644
--- a/src/System.Management.Automation/engine/remoting/common/WireDataFormat/RemoteHostEncoder.cs
+++ b/src/System.Management.Automation/engine/remoting/common/WireDataFormat/RemoteHostEncoder.cs
@@ -24,7 +24,7 @@ namespace System.Management.Automation.Remoting
/// guarantees that transmitting on the wire will not change the encoded
/// object's type.
///
- internal class RemoteHostEncoder
+ internal static class RemoteHostEncoder
{
///
/// Is known type.
diff --git a/src/System.Management.Automation/engine/runtime/Binding/Binders.cs b/src/System.Management.Automation/engine/runtime/Binding/Binders.cs
index 83dc432ef5..275529b7b3 100644
--- a/src/System.Management.Automation/engine/runtime/Binding/Binders.cs
+++ b/src/System.Management.Automation/engine/runtime/Binding/Binders.cs
@@ -444,7 +444,7 @@ namespace System.Management.Automation.Language
}
}
- internal class BinderUtils
+ internal static class BinderUtils
{
internal static BindingRestrictions GetVersionCheck(DynamicMetaObjectBinder binder, int expectedVersionNumber)
{
diff --git a/src/System.Management.Automation/engine/runtime/CompiledScriptBlock.cs b/src/System.Management.Automation/engine/runtime/CompiledScriptBlock.cs
index eb48283455..6478e9b091 100644
--- a/src/System.Management.Automation/engine/runtime/CompiledScriptBlock.cs
+++ b/src/System.Management.Automation/engine/runtime/CompiledScriptBlock.cs
@@ -1789,7 +1789,7 @@ namespace System.Management.Automation
return null;
}
- private class SuspiciousContentChecker
+ private static class SuspiciousContentChecker
{
// Based on a (bad) random number generator, but good enough
// for our simple needs.
diff --git a/src/System.Management.Automation/help/CabinetAPI.cs b/src/System.Management.Automation/help/CabinetAPI.cs
index b450cc0b87..9ccdc08baa 100644
--- a/src/System.Management.Automation/help/CabinetAPI.cs
+++ b/src/System.Management.Automation/help/CabinetAPI.cs
@@ -78,7 +78,7 @@ namespace System.Management.Automation.Internal
///
/// Used to create a CabinetExtractor class.
///
- internal class CabinetExtractorFactory
+ internal static class CabinetExtractorFactory
{
private static readonly ICabinetExtractorLoader s_cabinetLoader;
internal static readonly ICabinetExtractor EmptyExtractor = new EmptyCabinetExtractor();
diff --git a/src/System.Management.Automation/help/DefaultCommandHelpObjectBuilder.cs b/src/System.Management.Automation/help/DefaultCommandHelpObjectBuilder.cs
index 6b2a63f375..34b1bd84ce 100644
--- a/src/System.Management.Automation/help/DefaultCommandHelpObjectBuilder.cs
+++ b/src/System.Management.Automation/help/DefaultCommandHelpObjectBuilder.cs
@@ -40,7 +40,7 @@ namespace System.Management.Automation.Help
/// is present in the box. This class mimics the exact same structure as that of a MAML
/// node, so that the default UX does not introduce regressions.
///
- internal class DefaultCommandHelpObjectBuilder
+ internal static class DefaultCommandHelpObjectBuilder
{
internal static readonly string TypeNameForDefaultHelp = "ExtendedCmdletHelpInfo";
///
diff --git a/src/System.Management.Automation/help/HelpUtils.cs b/src/System.Management.Automation/help/HelpUtils.cs
index 0c0770173b..d4f2abe255 100644
--- a/src/System.Management.Automation/help/HelpUtils.cs
+++ b/src/System.Management.Automation/help/HelpUtils.cs
@@ -9,7 +9,7 @@ using Microsoft.PowerShell.Commands;
namespace System.Management.Automation
{
- internal class HelpUtils
+ internal static class HelpUtils
{
private static string userHomeHelpPath = null;
diff --git a/src/System.Management.Automation/help/MamlUtil.cs b/src/System.Management.Automation/help/MamlUtil.cs
index 3022d71f4a..d809655f97 100644
--- a/src/System.Management.Automation/help/MamlUtil.cs
+++ b/src/System.Management.Automation/help/MamlUtil.cs
@@ -9,7 +9,7 @@ namespace System.Management.Automation
///
/// The MamlUtil class.
///
- internal class MamlUtil
+ internal static class MamlUtil
{
///
/// Takes Name value from maml2 and overrides it in maml1.
diff --git a/src/System.Management.Automation/security/SecuritySupport.cs b/src/System.Management.Automation/security/SecuritySupport.cs
index eb77f2b2cb..dba2441413 100644
--- a/src/System.Management.Automation/security/SecuritySupport.cs
+++ b/src/System.Management.Automation/security/SecuritySupport.cs
@@ -1334,7 +1334,7 @@ namespace System.Management.Automation
Decryption
}
- internal class AmsiUtils
+ internal static class AmsiUtils
{
private static string GetProcessHostName(string processName)
{
@@ -1580,7 +1580,7 @@ namespace System.Management.Automation
public static bool AmsiInitialized = false;
public static bool AmsiCleanedUp = false;
- internal class AmsiNativeMethods
+ internal static class AmsiNativeMethods
{
internal enum AMSI_RESULT
{
diff --git a/src/System.Management.Automation/security/nativeMethods.cs b/src/System.Management.Automation/security/nativeMethods.cs
index 37e29c1f7c..69f018bb7b 100644
--- a/src/System.Management.Automation/security/nativeMethods.cs
+++ b/src/System.Management.Automation/security/nativeMethods.cs
@@ -13,7 +13,7 @@ using BOOL = System.UInt32;
namespace System.Management.Automation.Security
{
// Crypto API native constants
- internal partial class NativeConstants
+ internal static partial class NativeConstants
{
internal const int CRYPT_OID_INFO_OID_KEY = 1;
internal const int CRYPT_OID_INFO_NAME_KEY = 2;
diff --git a/src/System.Management.Automation/security/wldpNativeMethods.cs b/src/System.Management.Automation/security/wldpNativeMethods.cs
index 0eb53dbcb3..04e73079ca 100644
--- a/src/System.Management.Automation/security/wldpNativeMethods.cs
+++ b/src/System.Management.Automation/security/wldpNativeMethods.cs
@@ -491,7 +491,7 @@ namespace System.Management.Automation.Security
///
/// Native constants for dealing with the lockdown policy.
///
- internal class WldpNativeConstants
+ internal static class WldpNativeConstants
{
internal const uint WLDP_HOST_INFORMATION_REVISION = 0x00000001;
@@ -541,7 +541,7 @@ namespace System.Management.Automation.Security
///
/// Native methods for dealing with the lockdown policy.
///
- internal class WldpNativeMethods
+ internal static class WldpNativeMethods
{
/// Return Type: HRESULT->LONG->int
/// pHostInformation: PWLDP_HOST_INFORMATION->_WLDP_HOST_INFORMATION*
diff --git a/src/System.Management.Automation/utils/PlatformInvokes.cs b/src/System.Management.Automation/utils/PlatformInvokes.cs
index c8dc629051..b6d919df82 100644
--- a/src/System.Management.Automation/utils/PlatformInvokes.cs
+++ b/src/System.Management.Automation/utils/PlatformInvokes.cs
@@ -8,7 +8,7 @@ using Microsoft.Win32.SafeHandles;
namespace System.Management.Automation
{
- internal class PlatformInvokes
+ internal static class PlatformInvokes
{
[StructLayout(LayoutKind.Sequential)]
internal class FILETIME
diff --git a/src/System.Management.Automation/utils/PsUtils.cs b/src/System.Management.Automation/utils/PsUtils.cs
index 187ed387bc..e217a8f478 100644
--- a/src/System.Management.Automation/utils/PsUtils.cs
+++ b/src/System.Management.Automation/utils/PsUtils.cs
@@ -560,7 +560,7 @@ namespace System.Management.Automation
/// A simple implementation of CRC32.
/// See "CRC-32 algorithm" in https://en.wikipedia.org/wiki/Cyclic_redundancy_check.
///
- internal class CRC32Hash
+ internal static class CRC32Hash
{
// CRC-32C polynomial representations
private const uint polynomial = 0x1EDC6F41;