Skip to content

Commit

Permalink
Enable CA1052 (static holder types should be static) (#50047)
Browse files Browse the repository at this point in the history
* Enable CA1052 (static holder types should be static)

* Fix a few additional warnings in 'all configurations'
  • Loading branch information
stephentoub committed Mar 23, 2021
1 parent ca1a5cf commit 184a5b1
Show file tree
Hide file tree
Showing 415 changed files with 783 additions and 835 deletions.
7 changes: 4 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,10 @@ csharp_space_between_parentheses = false
csharp_space_between_square_brackets = false

# Analyzers
dotnet_code_quality.ca1802.api_surface = private, internal
dotnet_code_quality.ca1822.api_surface = private, internal
dotnet_code_quality.ca2208.api_surface = public
dotnet_code_quality.CA1052.api_surface = private, internal
dotnet_code_quality.CA1802.api_surface = private, internal
dotnet_code_quality.CA1822.api_surface = private, internal
dotnet_code_quality.CA2208.api_surface = public

# License header
file_header_template = Licensed to the .NET Foundation under one or more agreements.\nThe .NET Foundation licenses this file to you under the MIT license.
Expand Down
2 changes: 1 addition & 1 deletion eng/CodeAnalysis.ruleset
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<Rule Id="CA1047" Action="Warning" /> <!-- Do not declare protected member in sealed type -->
<Rule Id="CA1050" Action="Warning" /> <!-- Declare types in namespaces -->
<Rule Id="CA1051" Action="None" /> <!-- Do not declare visible instance fields -->
<Rule Id="CA1052" Action="None" /> <!-- Static holder types should be Static or NotInheritable -->
<Rule Id="CA1052" Action="Warning" /> <!-- Static holder types should be Static or NotInheritable -->
<Rule Id="CA1054" Action="None" /> <!-- Uri parameters should not be strings -->
<Rule Id="CA1055" Action="None" /> <!-- Uri return values should not be strings -->
<Rule Id="CA1056" Action="None" /> <!-- Uri properties should not be strings -->
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/scripts/genRuntimeEventSources.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def generateKeywordsClass(providerNode, outputFile):
keywordsNode = node
break;

writeOutput(outputFile, "public class Keywords\n")
writeOutput(outputFile, "public static class Keywords\n")
writeOutput(outputFile, "{\n")
increaseTabLevel()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace Microsoft.Extensions.Internal
{
internal class ParameterDefaultValue
internal static class ParameterDefaultValue
{
public static bool TryGetDefaultValue(ParameterInfo parameter, out object? defaultValue)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

internal static partial class Interop
{
internal partial class Sys
internal static partial class Sys
{
[StructLayout(LayoutKind.Sequential)]
internal struct ProcessCpuInformation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

internal static partial class Interop
{
internal partial class Sys
internal static partial class Sys
{
[DllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_GetNonCryptographicallySecureRandomBytes")]
internal static extern unsafe void GetNonCryptographicallySecureRandomBytes(byte* buffer, int length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

internal static partial class Interop
{
internal partial class Sys
internal static partial class Sys
{
[DllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_GetSystemTimeAsTicks")]
[SuppressGCTransition]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

internal static partial class Interop
{
internal partial class Sys
internal static partial class Sys
{
[DllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_MemAlloc")]
internal static extern IntPtr MemAlloc(nuint sizeInBytes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

using System.Runtime.InteropServices;

internal partial class Interop
internal static partial class Interop
{
internal partial class Sys
internal static partial class Sys
{
internal enum CtrlCode
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

using System.Runtime.InteropServices;

internal partial class Interop
internal static partial class Interop
{
internal partial class Sys
internal static partial class Sys
{
[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_RegisterForSigChld")]
internal static extern unsafe void RegisterForSigChld(delegate* unmanaged<int, void> handler);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

using System.Runtime.InteropServices;

internal partial class Interop
internal static partial class Interop
{
internal partial class Sys
internal static partial class Sys
{
[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_RestoreAndHandleCtrl")]
internal static extern void RestoreAndHandleCtrl(CtrlCode ctrlCode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

using System.Runtime.InteropServices;

internal partial class Interop
internal static partial class Interop
{
internal partial class Sys
internal static partial class Sys
{
[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetTerminalInvalidationHandler")]
[SuppressGCTransition]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
using System;
using System.Runtime.InteropServices;

internal partial class Interop
internal static partial class Interop
{
internal partial class Advapi32
internal static partial class Advapi32
{
[DllImport(Libraries.Advapi32, SetLastError = true)]
internal static extern unsafe bool AdjustTokenPrivileges(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
using System;
using System.Runtime.InteropServices;

internal partial class Interop
internal static partial class Interop
{
internal partial class Advapi32
internal static partial class Advapi32
{
[DllImport(Libraries.Advapi32)]
internal static extern bool AllocateLocallyUniqueId(out LUID Luid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
using System;
using System.Runtime.InteropServices;

internal partial class Interop
internal static partial class Interop
{
internal partial class Advapi32
internal static partial class Advapi32
{
[DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool ChangeServiceConfig2(SafeServiceHandle serviceHandle, uint infoLevel, ref SERVICE_DESCRIPTION serviceDesc);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System;
using System.Runtime.InteropServices;

internal partial class Interop
internal static partial class Interop
{
[StructLayout(LayoutKind.Explicit)]
internal struct CLAIM_SECURITY_ATTRIBUTE_INFORMATION_V1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
using System.Runtime.InteropServices;
using Microsoft.Win32.SafeHandles;

internal partial class Interop
internal static partial class Interop
{
internal partial class Advapi32
internal static partial class Advapi32
{
[DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool ClearEventLog(SafeEventLogReadHandle hEventLog, string lpBackupFileName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
using System;
using System.Runtime.InteropServices;

internal partial class Interop
internal static partial class Interop
{
internal partial class Advapi32
internal static partial class Advapi32
{
[DllImport(Libraries.Advapi32, SetLastError = true)]
internal static extern bool CloseEventLog(IntPtr hEventLog);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
using System;
using System.Runtime.InteropServices;

internal partial class Interop
internal static partial class Interop
{
internal partial class Advapi32
internal static partial class Advapi32
{
[DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern bool CloseServiceHandle(IntPtr handle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
using System;
using System.Runtime.InteropServices;

internal partial class Interop
internal static partial class Interop
{
internal partial class Advapi32
internal static partial class Advapi32
{
[DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern unsafe bool ControlService(SafeServiceHandle serviceHandle, int control, SERVICE_STATUS* pStatus);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
using System;
using System.Runtime.InteropServices;

internal partial class Interop
internal static partial class Interop
{
internal partial class Advapi32
internal static partial class Advapi32
{
[DllImport(Interop.Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false)]
internal static extern bool ConvertStringSecurityDescriptorToSecurityDescriptor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
using System.Runtime.InteropServices;
using System.Text;

internal partial class Interop
internal static partial class Interop
{
internal partial class Advapi32
internal static partial class Advapi32
{
[DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true, BestFitMapping = false, EntryPoint = "CreateProcessWithLogonW")]
internal static extern unsafe bool CreateProcessWithLogonW(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
using System;
using System.Runtime.InteropServices;

internal partial class Interop
internal static partial class Interop
{
internal partial class Advapi32
internal static partial class Advapi32
{
[DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
public static extern IntPtr CreateService(SafeServiceHandle databaseHandle, string serviceName, string displayName, int access, int serviceType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
using System.Runtime.InteropServices;
using System.Security.Cryptography;

internal partial class Interop
internal static partial class Interop
{
internal partial class Advapi32
internal static partial class Advapi32
{
[Flags]
internal enum CryptAcquireContextFlags : uint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
using System.Runtime.InteropServices;
using System.Security.Cryptography;

internal partial class Interop
internal static partial class Interop
{
internal partial class Advapi32
internal static partial class Advapi32
{
[Flags]
internal enum CryptCreateHashFlags : int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
using System.Runtime.InteropServices;
using System.Security.Cryptography;

internal partial class Interop
internal static partial class Interop
{
internal partial class Advapi32
internal static partial class Advapi32
{
internal enum CryptDecryptFlags : int
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
using System.Runtime.InteropServices;
using System.Security.Cryptography;

internal partial class Interop
internal static partial class Interop
{
internal partial class Advapi32
internal static partial class Advapi32
{
[DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern bool CryptDeriveKey(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
using System;
using System.Runtime.InteropServices;

internal partial class Interop
internal static partial class Interop
{
internal partial class Advapi32
internal static partial class Advapi32
{
[DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool CryptDestroyHash(IntPtr hHash);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
using System;
using System.Runtime.InteropServices;

internal partial class Interop
internal static partial class Interop
{
internal partial class Advapi32
internal static partial class Advapi32
{
[DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool CryptDestroyKey(IntPtr hKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
using System.Runtime.InteropServices;
using System.Security.Cryptography;

internal partial class Interop
internal static partial class Interop
{
internal partial class Advapi32
internal static partial class Advapi32
{
[DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool CryptEncrypt(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
using System.Runtime.InteropServices;
using System.Security.Cryptography;

internal partial class Interop
internal static partial class Interop
{
internal partial class Advapi32
internal static partial class Advapi32
{
[DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool CryptExportKey(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
using System.Runtime.InteropServices;
using System.Security.Cryptography;

internal partial class Interop
internal static partial class Interop
{
internal partial class Advapi32
internal static partial class Advapi32
{
[DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern bool CryptGenKey(SafeProvHandle hProv, int Algid, int dwFlags, out SafeKeyHandle phKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
using System.Runtime.InteropServices;
using System.Text;

internal partial class Interop
internal static partial class Interop
{
internal partial class Advapi32
internal static partial class Advapi32
{
internal enum GetDefaultProviderFlags : int
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
using System.Runtime.InteropServices;
using System.Security.Cryptography;

internal partial class Interop
internal static partial class Interop
{
internal partial class Advapi32
internal static partial class Advapi32
{
internal enum CryptHashProperty : int
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
using System.Runtime.InteropServices;
using System.Security.Cryptography;

internal partial class Interop
internal static partial class Interop
{
internal partial class Advapi32
internal static partial class Advapi32
{
internal enum CryptGetKeyParamFlags : int
{
Expand Down
Loading

0 comments on commit 184a5b1

Please sign in to comment.