Remove a few explicit static cctors (dotnet/coreclr#9669)
authorStephen Toub <stoub@microsoft.com>
Sun, 19 Feb 2017 01:17:34 +0000 (20:17 -0500)
committerJan Kotas <jkotas@microsoft.com>
Sun, 19 Feb 2017 01:17:34 +0000 (18:17 -0700)
Commit migrated from https://github.com/dotnet/coreclr/commit/3a6af9d433115c6d84cb7bc8028aabd55aef8b1c

src/coreclr/src/mscorlib/corefx/System/Globalization/CalendarData.cs
src/coreclr/src/mscorlib/src/Microsoft/Win32/Registry.cs
src/coreclr/src/mscorlib/src/System/Globalization/CalendarData.cs
src/coreclr/src/mscorlib/src/System/Globalization/EncodingTable.cs
src/coreclr/src/mscorlib/src/System/Threading/Overlapped.cs
src/coreclr/src/mscorlib/src/System/Threading/Thread.cs

index d22bd67..ad97ca9 100644 (file)
@@ -48,13 +48,13 @@ namespace System.Globalization
         internal bool bUseUserOverrides; // True if we want user overrides.
 
         // Static invariant for the invariant locale
-        internal static CalendarData Invariant;
+        internal static readonly CalendarData Invariant = CreateInvariant();
 
         // Private constructor
         private CalendarData() { }
 
-        // Invariant constructor
-        static CalendarData()
+        // Invariant factory
+        private static CalendarData CreateInvariant()
         {
             // Set our default/gregorian US calendar data
             // Calendar IDs are 1-based, arrays are 0 based.
@@ -91,8 +91,7 @@ namespace System.Globalization
 
             invariant.bUseUserOverrides = false;
 
-            // Calendar was built, go ahead and assign it...            
-            Invariant = invariant;
+            return invariant;
         }
 
         //
index bf4f739..d8c8db7 100644 (file)
@@ -16,9 +16,6 @@ namespace Microsoft.Win32 {
      */
     //This class contains only static members and does not need to be serializable.
     internal static class Registry {
-        static Registry()
-        { 
-        }
 
         /**
          * Current User Key.
index d66331b..ed961b3 100644 (file)
@@ -63,15 +63,14 @@ namespace System.Globalization
         internal bool       bUseUserOverrides        ; // True if we want user overrides.
 
         // Static invariant for the invariant locale
-        internal static CalendarData Invariant;
+        internal static readonly CalendarData Invariant = CreateInvariant();
 
         // Private constructor
         private CalendarData() {}
 
-        // Invariant constructor
-        static CalendarData()
+        // Invariant factory
+        private static CalendarData CreateInvariant()
         {
-
             // Set our default/gregorian US calendar data
             // Calendar IDs are 1-based, arrays are 0 based.
             CalendarData invariant = new CalendarData();
@@ -107,8 +106,7 @@ namespace System.Globalization
 
             invariant.bUseUserOverrides     = false;
 
-            // Calendar was built, go ahead and assign it...            
-            Invariant = invariant;
+            return invariant;
         }
 
 
index b7c268a..127cbff 100644 (file)
@@ -49,10 +49,6 @@ namespace System.Globalization
         //
         private static Hashtable hashByCodePage = Hashtable.Synchronized(new Hashtable());
 
-        static EncodingTable()
-        { 
-        }
-
         // Find the data item by binary searching the table that we have in native.
         // nativeCompareOrdinalWC is an internal-only function.
         unsafe private static int internalGetCodePageFromName(String name) {
index d3caff5..fe55be7 100644 (file)
@@ -65,10 +65,6 @@ namespace System.Threading
         uint _numBytes; // No. of bytes transferred 
         NativeOverlapped* _pOVERLAP;
 
-        static _IOCompletionCallback()
-        {
-        }
-
         internal _IOCompletionCallback(IOCompletionCallback ioCompletionCallback)
         {
             _ioCompletionCallback = ioCompletionCallback;
index 6211a09..60b3378 100644 (file)
@@ -33,8 +33,6 @@ namespace System.Threading {
 
     internal class ThreadHelper
     {
-        static ThreadHelper() {}
-
         Delegate _start;
         Object _startArg = null;
         ExecutionContext _executionContext = null;