From 4fa7bafc1bb8499720b39fa5dbe0a020f214b6bb Mon Sep 17 00:00:00 2001 From: xtqqczze Date: Sun, 1 Nov 2020 21:45:32 +0000 Subject: [PATCH 1/2] Enable IDE0040: AddAccessibilityModifiers https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0040 --- .globalconfig | 2 +- .../engine/PSConfiguration.cs | 4 ++-- .../utils/tracing/SysLogProvider.cs | 16 ++++++++-------- test/tools/TestExe/TestExe.cs | 8 ++++---- test/tools/TestService/Program.cs | 4 ++-- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.globalconfig b/.globalconfig index 33d6fe31e7e..70a8d48ac6c 100644 --- a/.globalconfig +++ b/.globalconfig @@ -844,7 +844,7 @@ dotnet_diagnostic.IDE0038.severity = silent dotnet_diagnostic.IDE0039.severity = silent # IDE0040: AddAccessibilityModifiers -dotnet_diagnostic.IDE0040.severity = silent +dotnet_diagnostic.IDE0040.severity = warning # IDE0041: UseIsNullCheck dotnet_diagnostic.IDE0041.severity = silent diff --git a/src/System.Management.Automation/engine/PSConfiguration.cs b/src/System.Management.Automation/engine/PSConfiguration.cs index aacf5c50e32..ade427b2154 100644 --- a/src/System.Management.Automation/engine/PSConfiguration.cs +++ b/src/System.Management.Automation/engine/PSConfiguration.cs @@ -290,12 +290,12 @@ internal PSLevel GetLogLevel() /// /// The supported separator characters for listing channels and keywords in configuration. /// - static readonly char[] s_valueSeparators = new char[] {' ', ',', '|'}; + private static readonly char[] s_valueSeparators = new char[] {' ', ',', '|'}; /// /// Provides a string name to indicate the default for a configuration setting. /// - const string LogDefaultValue = "default"; + private const string LogDefaultValue = "default"; /// /// Gets the bitmask of the PSChannel values to log. diff --git a/src/System.Management.Automation/utils/tracing/SysLogProvider.cs b/src/System.Management.Automation/utils/tracing/SysLogProvider.cs index f7f7168e659..1e468a67515 100755 --- a/src/System.Management.Automation/utils/tracing/SysLogProvider.cs +++ b/src/System.Management.Automation/utils/tracing/SysLogProvider.cs @@ -80,12 +80,12 @@ namespace System.Management.Automation.Tracing internal class SysLogProvider { // Ensure the string pointer is not garbage collected. - static IntPtr _nativeSyslogIdent = IntPtr.Zero; - static NativeMethods.SysLogPriority _facility = NativeMethods.SysLogPriority.Local0; + private static IntPtr _nativeSyslogIdent = IntPtr.Zero; + private static NativeMethods.SysLogPriority _facility = NativeMethods.SysLogPriority.Local0; - byte _channelFilter; - ulong _keywordFilter; - byte _levelFilter; + private byte _channelFilter; + private ulong _keywordFilter; + private byte _levelFilter; /// /// Initializes a new instance of this class. @@ -148,7 +148,7 @@ private static StringBuilder MessageBuilder /// to ensure correct thread initialization. /// [ThreadStatic] - static Guid? t_activity; + private static Guid? t_activity; private static Guid Activity { @@ -276,7 +276,7 @@ private static void GetEventMessage(StringBuilder sb, PSEventId eventId, params #region logging // maps a LogLevel to an associated SysLogPriority. - static NativeMethods.SysLogPriority[] _levels = + private static NativeMethods.SysLogPriority[] _levels = { NativeMethods.SysLogPriority.Info, NativeMethods.SysLogPriority.Critical, @@ -375,7 +375,7 @@ internal enum LogLevel : uint internal static class NativeMethods { - const string libpslnative = "libpsl-native"; + private const string libpslnative = "libpsl-native"; /// /// Write a message to the system logger, which in turn writes the message to the system console, log files, etc. /// See man 3 syslog for more info. diff --git a/test/tools/TestExe/TestExe.cs b/test/tools/TestExe/TestExe.cs index 1293a4acaee..c8f91d4d38e 100644 --- a/test/tools/TestExe/TestExe.cs +++ b/test/tools/TestExe/TestExe.cs @@ -7,9 +7,9 @@ namespace TestExe { - class TestExe + internal class TestExe { - static int Main(string[] args) + private static int Main(string[] args) { if (args.Length > 0) { @@ -44,7 +44,7 @@ static int Main(string[] args) // // Echos back to stdout the arguments passed in // - static void EchoArgs(string[] args) + private static void EchoArgs(string[] args) { for (int i = 1; i < args.Length; i++) { @@ -56,7 +56,7 @@ static void EchoArgs(string[] args) // First argument is the number of child processes to create which are instances of itself // Processes automatically exit after 100 seconds // - static void CreateChildProcess(string[] args) + private static void CreateChildProcess(string[] args) { if (args.Length > 1) { diff --git a/test/tools/TestService/Program.cs b/test/tools/TestService/Program.cs index 2e7a2ae1b42..83305624582 100644 --- a/test/tools/TestService/Program.cs +++ b/test/tools/TestService/Program.cs @@ -5,9 +5,9 @@ namespace TestService { - static class Program + internal static class Program { - static void Main() + private static void Main() { ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] From eca52b9d51383dcb9ed1d00c1b217f49ac8d2f48 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Fri, 6 Nov 2020 18:26:36 +0000 Subject: [PATCH 2/2] Fix whitespace --- .../utils/tracing/SysLogProvider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/System.Management.Automation/utils/tracing/SysLogProvider.cs b/src/System.Management.Automation/utils/tracing/SysLogProvider.cs index 660bdbc0113..633c320b7af 100755 --- a/src/System.Management.Automation/utils/tracing/SysLogProvider.cs +++ b/src/System.Management.Automation/utils/tracing/SysLogProvider.cs @@ -82,7 +82,7 @@ internal class SysLogProvider // Ensure the string pointer is not garbage collected. private static IntPtr _nativeSyslogIdent = IntPtr.Zero; private static readonly NativeMethods.SysLogPriority _facility = NativeMethods.SysLogPriority.Local0; - + private readonly byte _channelFilter; private readonly ulong _keywordFilter; private readonly byte _levelFilter;