Re-enable CA2207 (value type declares a static cctor) (dotnet/corefx#39858)
authorStephen Toub <stoub@microsoft.com>
Mon, 29 Jul 2019 15:54:37 +0000 (11:54 -0400)
committerDan Moseley <danmose@microsoft.com>
Mon, 29 Jul 2019 15:54:37 +0000 (08:54 -0700)
Commit migrated from https://github.com/dotnet/corefx/commit/7e93ad2cd22832060851ba0e18fcb55129564e2c

src/libraries/CodeAnalysis.ruleset
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/OverrideModeSetting.cs

index ecc03a3..c5660d2 100644 (file)
@@ -57,7 +57,6 @@
     <Rule Id="CA2100" Action="None" /> <!-- Review SQL queries for security vulnerabilities -->
     <Rule Id="CA2101" Action="None" /> <!-- Specify marshaling for P/Invoke string arguments -->
     <Rule Id="CA2119" Action="None" /> <!-- Seal methods that satisfy private interfaces -->
-    <Rule Id="CA2207" Action="None" /> <!-- Initialize value type static fields inline -->
     <Rule Id="CA2208" Action="None" /> <!-- Instantiate exception arguments correctly -->
     <Rule Id="CA2211" Action="None" /> <!-- Non-constant fields should not be visible -->
     <Rule Id="CA2213" Action="None" /> <!-- Disposable Fields should be disposed -->
index 985c783..c56f261 100644 (file)
@@ -25,17 +25,11 @@ namespace System.Configuration
 
         private byte _mode;
 
-        internal static OverrideModeSetting s_sectionDefault;
-        internal static OverrideModeSetting s_locationDefault;
+        // Default for section is ALLOW
+        internal static readonly OverrideModeSetting s_sectionDefault = new OverrideModeSetting { _mode = (byte)OverrideMode.Allow };
 
-        static OverrideModeSetting()
-        {
-            // Default for section is ALLOW
-            s_sectionDefault = new OverrideModeSetting { _mode = (byte)OverrideMode.Allow };
-
-            // Default for location tags is INHERIT. Note that we do not make the value as existent in the XML or specified by the API
-            s_locationDefault = new OverrideModeSetting { _mode = (byte)OverrideMode.Inherit };
-        }
+        // Default for location tags is INHERIT. Note that we do not make the value as existent in the XML or specified by the API
+        internal static readonly OverrideModeSetting s_locationDefault = new OverrideModeSetting { _mode = (byte)OverrideMode.Inherit };
 
         internal static OverrideModeSetting CreateFromXmlReadValue(bool allowOverride)
         {