Clean up some static initializers
authorMarek Safar <marek.safar@gmail.com>
Wed, 3 Oct 2012 11:19:19 +0000 (12:19 +0100)
committerMarek Safar <marek.safar@gmail.com>
Wed, 3 Oct 2012 11:19:55 +0000 (12:19 +0100)
41 files changed:
mcs/class/corlib/Mono.Security.Cryptography/KeyPairPersistence.cs
mcs/class/corlib/Mono.Security.X509/PKCS12.cs
mcs/class/corlib/Mono.Security.X509/X509Certificate.cs
mcs/class/corlib/Mono.Security/StrongName.cs
mcs/class/corlib/Mono.Security/StrongNameManager.cs
mcs/class/corlib/System.Collections.Generic/List.cs
mcs/class/corlib/System.Collections/ArrayList.cs
mcs/class/corlib/System.Collections/CaseInsensitiveComparer.cs
mcs/class/corlib/System.Collections/Hashtable.cs
mcs/class/corlib/System.Collections/SortedList.cs
mcs/class/corlib/System.IO.IsolatedStorage/IsolatedStorageFile.cs
mcs/class/corlib/System.IO/MonoIO.cs
mcs/class/corlib/System.Reflection.Emit/EventToken.cs
mcs/class/corlib/System.Reflection.Emit/FieldToken.cs
mcs/class/corlib/System.Reflection.Emit/ILGenerator.cs
mcs/class/corlib/System.Reflection.Emit/MethodToken.cs
mcs/class/corlib/System.Reflection.Emit/OpCodeNames.cs
mcs/class/corlib/System.Reflection.Emit/ParameterToken.cs
mcs/class/corlib/System.Reflection.Emit/PropertyToken.cs
mcs/class/corlib/System.Reflection.Emit/SignatureToken.cs
mcs/class/corlib/System.Reflection.Emit/StringToken.cs
mcs/class/corlib/System.Reflection.Emit/TypeToken.cs
mcs/class/corlib/System.Reflection/Binder.cs
mcs/class/corlib/System.Reflection/Module.cs
mcs/class/corlib/System.Resources/ResourceManager.cs
mcs/class/corlib/System.Runtime.InteropServices/ExtensibleClassFactory.cs
mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs
mcs/class/corlib/System.Text/DecoderFallback.cs
mcs/class/corlib/System.Text/EncoderFallback.cs
mcs/class/corlib/System.Text/Encoding.cs
mcs/class/corlib/System.Text/UTF32Encoding.cs
mcs/class/corlib/System.Text/UTF8Encoding.cs
mcs/class/corlib/System.Text/UnicodeEncoding.cs
mcs/class/corlib/System.Threading/SpinLock.cs
mcs/class/corlib/System.Threading/Timer.cs
mcs/class/corlib/System/EmptyArray.cs [new file with mode: 0644]
mcs/class/corlib/System/Enum.cs
mcs/class/corlib/System/MonoCustomAttrs.cs
mcs/class/corlib/System/StringComparer.cs
mcs/class/corlib/System/TermInfoDriver.cs
mcs/class/corlib/corlib.dll.sources

index ac694bb5ef0d1d2721a43743de6e688ef642e00f..c118cc3785c7633399b4d0fff3da33ba6cdbf9a4 100644 (file)
@@ -100,10 +100,10 @@ namespace Mono.Security.Cryptography {
 #endif
        class KeyPairPersistence {
        
-               private static bool _userPathExists = false; // check at 1st use
+               private static bool _userPathExists; // check at 1st use
                private static string _userPath;
                
-               private static bool _machinePathExists = false; // check at 1st use
+               private static bool _machinePathExists; // check at 1st use
                private static string _machinePath;
 
                private CspParameters _params;
index 5ecce72b8db96d41dbc1aaa51cdfd990a99cb69f..848ce803589e6c26a5cf9c519fa9c555df18d1e5 100644 (file)
@@ -265,7 +265,7 @@ namespace Mono.Security.X509 {
                        }
                }
 
-               static private int recommendedIterationCount = 2000;
+               const int recommendedIterationCount = 2000;
 
                //private int _version;
                private byte[] _password;
index 330dfae260227731381ed69334ad88e96670485f..af0c0a1f81994a6338526ef52a6bc25516204533 100644 (file)
@@ -49,6 +49,7 @@ namespace Mono.Security.X509 {
 #else
        public class X509Certificate : ISerializable {
 #endif
+               const string encoding_error = "Input data cannot be coded as a valid certificate.";
 
                private ASN1 decoder;
 
@@ -97,9 +98,6 @@ namespace Mono.Security.X509 {
                private byte[] subjectUniqueID;
                private X509ExtensionCollection extensions;
 
-               private static string encoding_error = Locale.GetText ("Input data cannot be coded as a valid certificate.");
-
-
                // that's were the real job is!
                private void Parse (byte[] data) 
                {
index 2905a03c125c4a9302b0249f588504d2d4bae5cd..6fb7d88eedfd2fcdc0fc1db229a33510500e91ea 100644 (file)
@@ -459,7 +459,7 @@ namespace Mono.Security {
 
 #if INSIDE_CORLIB
                static object lockObject = new object ();
-               static bool initialized = false;
+               static bool initialized;
 
                // We don't want a dependency on StrongNameManager in Mono.Security.dll
                static public bool IsAssemblyStrongnamed (string assemblyName) 
index 4567c8b35b679b60e4d9d996f8a06d655adc5289..a7e5a8c34b1b2552ae13e798fffff4c1cc4f7ba1 100644 (file)
@@ -101,10 +101,6 @@ namespace Mono.Security {
                static private Hashtable mappings;
                static private Hashtable tokens;
 
-               static StrongNameManager () 
-               {
-               }
-
                // note: more than one configuration file can be loaded at the 
                // same time (e.g. user specific and machine specific config).
                static public void LoadConfig (string filename) 
index b08fcbb80a50e43f9002fee5b04820960ffc0c3b..15ecdb845c2e40eaa50ae2c2062d45c61b5d9c06 100644 (file)
@@ -50,12 +50,11 @@ namespace System.Collections.Generic {
                int _size;
                int _version;
                
-               static readonly T [] EmptyArray = new T [0]; 
                const int DefaultCapacity = 4;
                
                public List ()
                {
-                       _items = EmptyArray;
+                       _items = EmptyArray<T>.Value;
                }
                
                public List (IEnumerable <T> collection)
@@ -66,7 +65,7 @@ namespace System.Collections.Generic {
                        // initialize to needed size (if determinable)
                        ICollection <T> c = collection as ICollection <T>;
                        if (c == null) {
-                               _items = EmptyArray;
+                               _items = EmptyArray<T>.Value;;
                                AddEnumerable (collection);
                        } else {
                                _size = c.Count;
index 0a67c6a2c830e103b621716de866a21453f744e7..44544c18d504bd0d53cd3fd1eeaee17ef11392b7 100644 (file)
@@ -115,7 +115,7 @@ namespace System.Collections
                        object currentElement;
                        int index;
                        int version;
-                       static object endFlag = new object ();
+                       static readonly object endFlag = new object ();
                                                        
                        public SimpleEnumerator (ArrayList list)
                        {
@@ -2510,8 +2510,6 @@ namespace System.Collections
                /// </summary>
                private int _version;
 
-               private static readonly object [] EmptyArray = new object [0]; 
-
                #endregion
                
                #region Constructors
@@ -2522,7 +2520,7 @@ namespace System.Collections
                /// </summary>
                public ArrayList()
                {
-                       _items = EmptyArray;
+                       _items = EmptyArray<object>.Value;
                }               
 
                /// <summary>
index 2674397491a4159e6948ccb0ab8b6b97be4cafc8..9f4177e2f86796d183938c3925338b7b2ea64af7 100644 (file)
@@ -44,8 +44,8 @@ namespace System.Collections
 #endif
        class CaseInsensitiveComparer : IComparer
        {
-               private static CaseInsensitiveComparer defaultComparer = new CaseInsensitiveComparer ();
-               private static CaseInsensitiveComparer defaultInvariantComparer = new CaseInsensitiveComparer (true);
+               readonly static CaseInsensitiveComparer defaultComparer = new CaseInsensitiveComparer ();
+               readonly static CaseInsensitiveComparer defaultInvariantComparer = new CaseInsensitiveComparer (true);
 
                private CultureInfo culture;
 
index e11ef658bc88dbbdf4c9ee2f77b7875dd0bca501..dad69c1a62b6fd15f57d288996c40021ae8cff59 100644 (file)
@@ -864,7 +864,7 @@ namespace System.Collections {
                        private int size;
                        private EnumeratorMode mode;
 
-                       private readonly static string xstr = "Hashtable.Enumerator: snapshot out of sync.";
+                       const string xstr = "Hashtable.Enumerator: snapshot out of sync.";
 
                        public Enumerator (Hashtable host, EnumeratorMode mode) {
                                this.host = host;
index 874986ba6a65a498d993615407b8e6791d0a09e2..56ac10f5bf876cc83f620f1b7b0852c5df74c270 100644 (file)
@@ -618,9 +618,9 @@ namespace System.Collections {
                        private int size;
                        private EnumeratorMode mode;
 
-                       bool invalid = false;
+                       bool invalid;
 
-                       private readonly static string xstr = "SortedList.Enumerator: snapshot out of sync.";
+                       const string xstr = "SortedList.Enumerator: snapshot out of sync.";
 
                        public Enumerator (SortedList host, EnumeratorMode mode)
                        {
index 47ce1efaa346a960c5e64e63d8380928ebf6a4af..5d5e233222577a10c68c4c151de16bc34cf38693 100644 (file)
@@ -56,7 +56,7 @@ namespace System.IO.IsolatedStorage {
                private ulong _maxSize;
 #endif
                private Evidence _fullEvidences;
-               private static Mutex mutex = new Mutex ();
+               private static readonly Mutex mutex = new Mutex ();
 #if NET_4_0 || MOBILE
                private bool closed;
                private bool disposed;
index e50bc40698e02ab06e1d23bd728e6adf64c080ae..b62e1453665f5909d7a43a5fceb9aa27fd571b1a 100644 (file)
@@ -41,10 +41,10 @@ using System.IO.IsolatedStorage;
 
 namespace System.IO
 {
-       unsafe internal sealed class MonoIO {
-               internal static int FileAlreadyExistsHResult = unchecked ((int) 0x80070000) | (int)MonoIOError.ERROR_FILE_EXISTS;
+       unsafe static class MonoIO {
+               public const int FileAlreadyExistsHResult = unchecked ((int) 0x80070000) | (int)MonoIOError.ERROR_FILE_EXISTS;
 
-               public static readonly FileAttributes
+               public const FileAttributes
                        InvalidFileAttributes = (FileAttributes)(-1);
 
                public static readonly IntPtr
index a77019cd9bb930926f821213720c092e9e2d7235..6d04142bc52297ef01038a4d55a98949c64c8d98 100644 (file)
@@ -39,14 +39,7 @@ namespace System.Reflection.Emit {
 
                internal int tokValue;
 
-               public static readonly EventToken Empty;
-
-
-               static EventToken ()
-               {
-                       Empty = new EventToken ();
-               }
-
+               public static readonly EventToken Empty = new EventToken ();
 
                internal EventToken (int val)
                {
index 13295696f839d09bf48b1eefbc2f0a9149cd642b..85cc6599ee68be075f36f9a36fb4d9b325fe4abd 100644 (file)
@@ -39,14 +39,7 @@ namespace System.Reflection.Emit {
 
                internal int tokValue;
 
-               public static readonly FieldToken Empty;
-
-
-               static FieldToken ()
-               {
-                       Empty = new FieldToken ();
-               }
-
+               public static readonly FieldToken Empty = new FieldToken ();
 
                internal FieldToken (int val)
                {
index 9d5b22558cfadc82aa5875f097adc52d36808364..cd521f59a38ca88d9164be18ca676dd3abe8b921 100644 (file)
@@ -207,7 +207,6 @@ namespace System.Reflection.Emit {
                        public int maxStack; 
                }
                
-               static readonly Type void_type = typeof (void);
                #region Sync with reflection.h
                private byte[] code;
                private int code_len;
@@ -740,7 +739,7 @@ namespace System.Reflection.Emit {
                                        add_token_fixup (meth);
                        }
                        emit_int (token);
-                       if (meth.ReturnType != void_type)
+                       if (meth.ReturnType != typeof (void))
                                cur_stack ++;
 
                        if (opcode.StackBehaviourPop == StackBehaviour.Varpop)
@@ -758,7 +757,7 @@ namespace System.Reflection.Emit {
                                        add_token_fixup (method);
                        }
                        emit_int (token);
-                       if (method.ReturnType != void_type)
+                       if (method.ReturnType != typeof (void))
                                cur_stack ++;
 
                        if (opcode.StackBehaviourPop == StackBehaviour.Varpop)
index a4f1b916e141909ffd0f282e8816a1717faed9d5..f4ad83a767aebb7577d13d61172971fe5d7f6bdd 100644 (file)
@@ -39,14 +39,7 @@ namespace System.Reflection.Emit {
 
                internal int tokValue;
 
-               public static readonly MethodToken Empty;
-
-
-               static MethodToken ()
-               {
-                       Empty = new MethodToken ();
-               }
-
+               public static readonly MethodToken Empty = new MethodToken ();
 
                internal MethodToken (int val)
                {
index f3d717529ff20bbcb2ae1f606dc814961b3143ae..67ddad4a581323bc34bab0f11809093484e2224f 100644 (file)
@@ -1,5 +1,5 @@
 namespace System.Reflection.Emit {
-       internal class OpCodeNames {
+       static class OpCodeNames {
                internal static readonly string [] names = {
                        "nop",
                        "break",
index 6858f248e2d187b775e6d6c0db30e713cde612de..87f56282a29fe87828cb8b71c2e7287b13db5bfe 100644 (file)
@@ -39,14 +39,7 @@ namespace System.Reflection.Emit {
 
                internal int tokValue;
 
-               public static readonly ParameterToken Empty;
-
-
-               static ParameterToken ()
-               {
-                       Empty = new ParameterToken ();
-               }
-
+               public static readonly ParameterToken Empty = new ParameterToken ();
 
                internal ParameterToken (int val)
                {
index b5ba3de6858c8f858e4b684bb66d25830d508a39..ca4868ec3ca0a93c2ca50ab34ad649c864e2a441 100644 (file)
@@ -39,14 +39,7 @@ namespace System.Reflection.Emit {
 
                internal int tokValue;
 
-               public static readonly PropertyToken Empty;
-
-
-               static PropertyToken ()
-               {
-                       Empty = new PropertyToken ();
-               }
-
+               public static readonly PropertyToken Empty = new PropertyToken ();
 
                internal PropertyToken (int val)
                {
index 1dde91245f6fda1843364a57e1c63ba4159e446a..193feb610ecd2ae2e9ee70b494581b565b519ec3 100644 (file)
@@ -38,14 +38,7 @@ namespace System.Reflection.Emit {
 
                internal int tokValue;
 
-               public static readonly SignatureToken Empty;
-
-
-               static SignatureToken ()
-               {
-                       Empty = new SignatureToken ();
-               }
-
+               public static readonly SignatureToken Empty = new SignatureToken ();
 
                internal SignatureToken (int val)
                {
index 6f632cc1941f1bc62b9cd2a13610cea427ecac9a..2bba43467ff0815a8b4e85a6b98b783f5ec0ade9 100644 (file)
@@ -39,11 +39,6 @@ namespace System.Reflection.Emit {
 
                internal int tokValue;
 
-               static StringToken ()
-               {
-               }
-
-
                internal StringToken (int val)
                {
                        tokValue = val;
index a3690df96a3b27bdb38a7518bb63981aa97019b3..4a8a56b1d9e3ae5cab268a6f0a3888702a885b13 100644 (file)
@@ -39,14 +39,7 @@ namespace System.Reflection.Emit {
 
                internal int tokValue;
 
-               public static readonly TypeToken Empty;
-
-
-               static TypeToken ()
-               {
-                       Empty = new TypeToken ();
-               }
-
+               public static readonly TypeToken Empty = new TypeToken ();
 
                internal TypeToken (int val)
                {
index 9000bec0430ac3d1569e4a2f228d383face4a830..f02283d73543e75b940cee1724796accc17ec88f 100644 (file)
@@ -50,7 +50,7 @@ namespace System.Reflection
                public abstract MethodBase SelectMethod (BindingFlags bindingAttr, MethodBase[] match, Type[] types, ParameterModifier[] modifiers);
                public abstract PropertyInfo SelectProperty( BindingFlags bindingAttr, PropertyInfo[] match, Type returnType, Type[] indexes, ParameterModifier[] modifiers);
 
-               static Binder default_binder = new Default ();
+               static readonly Binder default_binder = new Default ();
 
                internal static Binder DefaultBinder {
                        get {
index 3e3c66cbb8d3730e2d18eab4bed6811b0e326f92..8cb5b609fc007f0e210b53351b3f684b89ef31a0 100644 (file)
@@ -53,8 +53,8 @@ namespace System.Reflection {
 #else
        public partial class Module : ISerializable, ICustomAttributeProvider, _Module {
 #endif
-               public static readonly TypeFilter FilterTypeName;
-               public static readonly TypeFilter FilterTypeNameIgnoreCase;
+               public static readonly TypeFilter FilterTypeName = new TypeFilter (filter_by_type_name);
+               public static readonly TypeFilter FilterTypeNameIgnoreCase = new TypeFilter (filter_by_type_name_ignore_case);
        
 #pragma warning disable 649    
                internal IntPtr _impl; /* a pointer to a MonoImage */
@@ -68,12 +68,6 @@ namespace System.Reflection {
        
                const BindingFlags defaultBindingFlags = 
                        BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance;
-               
-               static Module () {
-                       FilterTypeName = new TypeFilter (filter_by_type_name);
-                       FilterTypeNameIgnoreCase = new TypeFilter (filter_by_type_name_ignore_case);
-               }
-
 
 #if NET_4_0 || MOONLIGHT || MOBILE
                protected
index 9f8692c3884a6bdbea3f5043e2a31e07c9cfa488..0f9fce9cf0f2af2d2f95d6b7b48b2c03a69832b6 100644 (file)
@@ -45,8 +45,8 @@ namespace System.Resources
        public class ResourceManager
        {
                static readonly object thisLock = new object ();
-               static Hashtable ResourceCache = new Hashtable (); 
-               static Hashtable NonExistent = Hashtable.Synchronized (new Hashtable ());
+               static readonly Hashtable ResourceCache = new Hashtable (); 
+               static readonly Hashtable NonExistent = Hashtable.Synchronized (new Hashtable ());
                public static readonly int HeaderVersionNumber = 1;
                public static readonly int MagicNumber = unchecked ((int) 0xBEEFCACE);
 
index 68d3c49bb0534fb63b151ebf8e373bd1d5cd9de5..ef5f55f6a8d32808590f721cfe1083087085c1c2 100644 (file)
@@ -39,12 +39,7 @@ namespace System.Runtime.InteropServices
        [ComVisible (true)]
        public sealed class ExtensibleClassFactory
        {
-               static Hashtable hashtable;
-
-               static ExtensibleClassFactory ()
-               {
-                       hashtable = new Hashtable ();
-               }
+               static readonly Hashtable hashtable = new Hashtable ();
 
                private ExtensibleClassFactory ()
                {
index 6a706c9da652471851b81cfcf11a7c2aedc2bd99..43cf9bfe2ea147e350cbaaa314d07a366256f953 100644 (file)
@@ -52,12 +52,7 @@ namespace System.Runtime.InteropServices
        {
                /* fields */
                public static readonly int SystemMaxDBCSCharSize = 2; // don't know what this is
-               public static readonly int SystemDefaultCharSize;
-
-               static Marshal ()
-               {
-                       SystemDefaultCharSize = Environment.OSVersion.Platform == PlatformID.Win32NT ? 2 : 1;
-               }
+               public static readonly int SystemDefaultCharSize = Environment.OSVersion.Platform == PlatformID.Win32NT ? 2 : 1;
 
                [MethodImplAttribute (MethodImplOptions.InternalCall)]
                private extern static int AddRefInternal (IntPtr pUnk);
index f90da2624a9963acad6ee34a2967667d1bee4492..c5ffe76aaa046a2ba62bb408c8fea1485d514165 100644 (file)
@@ -33,11 +33,11 @@ namespace System.Text
        [Serializable]
        public abstract class DecoderFallback
        {
-               static DecoderFallback exception_fallback =
+               static readonly DecoderFallback exception_fallback =
                        new DecoderExceptionFallback ();
-               static DecoderFallback replacement_fallback =
+               static readonly DecoderFallback replacement_fallback =
                        new DecoderReplacementFallback ();
-               static DecoderFallback standard_safe_fallback =
+               static readonly DecoderFallback standard_safe_fallback =
                        new DecoderReplacementFallback ("\uFFFD");
 
                protected DecoderFallback ()
index 818b51de37fbbbcf3b09f187e892bf6ab0b5d59b..182ff72f5329441985d1beabe04ab7a47c40e8dd 100644 (file)
@@ -33,11 +33,11 @@ namespace System.Text
        [Serializable]
        public abstract class EncoderFallback
        {
-               static EncoderFallback exception_fallback =
+               static readonly EncoderFallback exception_fallback =
                        new EncoderExceptionFallback ();
-               static EncoderFallback replacement_fallback =
+               static readonly EncoderFallback replacement_fallback =
                        new EncoderReplacementFallback ();
-               static EncoderFallback standard_safe_fallback =
+               static readonly EncoderFallback standard_safe_fallback =
                        new EncoderReplacementFallback ("\uFFFD");
 
                protected EncoderFallback ()
index 8570be976042cd43fbfcd7f6b5c9415666c4cd1b..7033b15d075ec8bb9d5a2e06dcfaa95ee74eb103 100644 (file)
@@ -42,8 +42,6 @@ public abstract class Encoding : ICloneable
        internal int codePage;
        internal int windows_code_page;
        bool is_readonly = true;
-       
-       internal static readonly byte[] empty = new byte[0];
 
        // Constructor.
        protected Encoding ()
@@ -246,10 +244,10 @@ public abstract class Encoding : ICloneable
                        throw new ArgumentNullException ("s");
 
                if (s.Length == 0)
-                       return empty;
+                       return EmptyArray<byte>.Value;
                int byteCount = GetByteCount (s);
                if (byteCount == 0)
-                       return empty;
+                       return EmptyArray<byte>.Value;
                unsafe {
                        fixed (char* cptr = s) {
                                byte [] bytes = new byte [byteCount];
@@ -697,7 +695,7 @@ public abstract class Encoding : ICloneable
        // Get the identifying preamble for this encoding.
        public virtual byte[] GetPreamble ()
        {
-               return empty;
+               return EmptyArray<byte>.Value;
        }
 
        // Decode a buffer of bytes into a string.
index 3761ecf41a6b7c66bb691d1cefe95858efd7f264..16413e8ad578a703c747aabed5bd206b6c0e0c2c 100644 (file)
@@ -316,7 +316,7 @@ public sealed class UTF32Encoding : Encoding
                        return preamble;
                }
                
-               return empty;
+               return EmptyArray<byte>.Value;
        }
 
        // Determine if this object is equal to another.
index f6d779996b3183a5ac97b17535341dd036939225..fd5e83be04e2305a2e4f14d198fe4e660401b196 100644 (file)
@@ -879,7 +879,7 @@ fail_no_space:
                if (emitIdentifier)
                        return new byte [] { 0xEF, 0xBB, 0xBF };
 
-               return empty;
+               return EmptyArray<byte>.Value;
        }
 
        // Determine if this object is equal to another.
index 216538d73bf54177357141ae482aa3426bd00d8b..6332b1509b352e9a92402cc6e00667ffdd4a2df5 100644 (file)
@@ -380,7 +380,7 @@ public class UnicodeEncoding : Encoding
                        return preamble;
                }
                
-               return empty;
+               return EmptyArray<byte>.Value;
        }
 
        // Determine if this object is equal to another.
index 7666e17e496388e669e598b1a39680179e0393d8..683c98374180e2dad7e7a2160cda1144ccfeabee 100644 (file)
@@ -57,7 +57,7 @@ namespace System.Threading
                int threadWhoTookLock;
                readonly bool isThreadOwnerTrackingEnabled;
 
-               static Watch sw = Watch.StartNew ();
+               static readonly Watch sw = Watch.StartNew ();
 
                ConcurrentOrderedList<int> stallTickets;
 
index 917c66729ae4a6a5aa1cbdcb06f40bcfb29ed1d8..7bebd9c013bd1554fd4285ed54e5a61454841f0c 100644 (file)
@@ -41,7 +41,7 @@ namespace System.Threading
                : MarshalByRefObject, IDisposable
 #endif
        {
-               static Scheduler scheduler = Scheduler.Instance;
+               static readonly Scheduler scheduler = Scheduler.Instance;
 #region Timer instance fields
                TimerCallback callback;
                object state;
diff --git a/mcs/class/corlib/System/EmptyArray.cs b/mcs/class/corlib/System/EmptyArray.cs
new file mode 100644 (file)
index 0000000..136f887
--- /dev/null
@@ -0,0 +1,35 @@
+//
+// EmptyArray.cs
+//
+// Authors:
+//     Marek Safar  <marek.safar@gmail.com>
+//
+// Copyright (C) 2012 Xamarin, Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace System
+{
+       static class EmptyArray<T>
+       {
+               public static readonly T[] Value = new T [0];
+       }
+}
\ No newline at end of file
index 4cc6f3c55413ce9a421fbea0c27e5c62f4351a50..789ad5de6d8be4649fe39af889d40d1843ccb229 100644 (file)
@@ -48,8 +48,8 @@ namespace System
                internal Hashtable name_hash;
                [ThreadStatic]
                static Hashtable cache;
-               static Hashtable global_cache;
-               static object global_cache_monitor;
+               static Hashtable global_cache = new Hashtable ();
+               static object global_cache_monitor = new object ();
                
                [MethodImplAttribute (MethodImplOptions.InternalCall)]
                private static extern void get_enum_info (Type enumType, out MonoEnumInfo info);
@@ -145,12 +145,6 @@ namespace System
                                return 1;
                        }
                }
-                       
-               static MonoEnumInfo ()
-               {
-                       global_cache_monitor = new object ();
-                       global_cache = new Hashtable ();
-               }
 
                static Hashtable Cache {
                        get {
@@ -512,8 +506,6 @@ namespace System
                        throw new ArgumentException ("typeCode is not a valid type code for an Enum");
                }
 
-               private static char [] split_char = { ',' };
-
                [ComVisible(true)]
                public static object Parse (Type enumType, string value, bool ignoreCase)
                {
@@ -537,6 +529,8 @@ namespace System
                        return result;
                }
 
+               static char [] split_char;
+
                static bool Parse<TEnum> (Type enumType, string value, bool ignoreCase, out TEnum result)
                {
                        result = default (TEnum);
@@ -555,6 +549,8 @@ namespace System
 
                        // is 'value' a list of named constants?
                        if (value.IndexOf (',') != -1) {
+                               if (split_char == null)
+                                       split_char = new [] { ',' };
                                string [] names = value.Split (split_char);
                                ulong retVal = 0;
                                for (int i = 0; i < names.Length; ++i) {
index dda41dd8c767c6c91ef9a0e19950bca9e84a8eca..15a58c0be476810863fec276206bb608c540a00e 100644 (file)
@@ -402,8 +402,7 @@ namespace System
                                return new AttributeUsageAttribute (AttributeTargets.Class);
 
                        AttributeUsageAttribute usageAttribute = null;
-                       object[] attribs = GetCustomAttributes (attributeType,
-                               MonoCustomAttrs.AttributeUsageType, false);
+                       object[] attribs = GetCustomAttributes (attributeType, typeof(AttributeUsageAttribute), false);
                        if (attribs.Length == 0)
                        {
                                // if no AttributeUsage was defined on the attribute level, then
@@ -435,7 +434,6 @@ namespace System
                        return ((AttributeUsageAttribute) attribs[0]);
                }
 
-               private static readonly Type AttributeUsageType = typeof(AttributeUsageAttribute);
                private static readonly AttributeUsageAttribute DefaultAttributeUsage =
                        new AttributeUsageAttribute (AttributeTargets.All);
 
index a08bc519668d65bf8c3f2ded3675cdc22bdc5403..906d21addafbbc87d2fc1ae6e2ac4f8a6f7bb79a 100644 (file)
@@ -37,11 +37,14 @@ namespace System
        [Serializable, ComVisible(true)]
        public abstract class StringComparer : IComparer, IEqualityComparer, IComparer<string>, IEqualityComparer<string>
        {
-               static StringComparer invariantCultureIgnoreCase = new CultureAwareComparer (CultureInfo.InvariantCulture, true);
-               static StringComparer invariantCulture = new CultureAwareComparer (CultureInfo.InvariantCulture, false);
-               static StringComparer ordinalIgnoreCase = new OrdinalComparer (true);
-               static StringComparer ordinal = new OrdinalComparer (false);
-
+               static class Predefined
+               {
+                       public static readonly StringComparer invariantCultureIgnoreCase = new CultureAwareComparer (CultureInfo.InvariantCulture, true);
+                       public static readonly StringComparer invariantCulture = new CultureAwareComparer (CultureInfo.InvariantCulture, false);
+                       public static readonly StringComparer ordinalIgnoreCase = new OrdinalComparer (true);
+                       public static readonly StringComparer ordinal = new OrdinalComparer (false);
+               }
+               
                // Constructors
                protected StringComparer ()
                {
@@ -62,22 +65,22 @@ namespace System
 
                public static StringComparer InvariantCulture {
                        get {
-                               return invariantCulture;
+                               return Predefined.invariantCulture;
                        }
                }
 
                public static StringComparer InvariantCultureIgnoreCase {
                        get {
-                               return invariantCultureIgnoreCase;
+                               return Predefined.invariantCultureIgnoreCase;
                        }
                }
 
                public static StringComparer Ordinal {
-                       get { return ordinal; }
+                       get { return Predefined.ordinal; }
                }
 
                public static StringComparer OrdinalIgnoreCase {
-                       get { return ordinalIgnoreCase; }
+                       get { return Predefined.ordinalIgnoreCase; }
                }
 
                // Methods
index 89279cab218e128e8a12987a64d3cef1abd5aed0..e14f7127e20c9e1a93b7b943e2a5830e86b225c7 100644 (file)
@@ -47,7 +47,7 @@ namespace System {
                static int terminal_size;
                
                //static uint flag = 0xdeadbeef;
-               static string [] locations = { "/etc/terminfo", "/usr/share/terminfo", "/usr/lib/terminfo" };
+               readonly static string [] locations = { "/etc/terminfo", "/usr/share/terminfo", "/usr/lib/terminfo" };
 
                TermInfoReader reader;
                int cursorLeft;
@@ -1325,74 +1325,6 @@ namespace System {
                        keymap [TermInfoStrings.KeyIc] = new ConsoleKeyInfo ('\0', ConsoleKey.Insert, false, false, false);
                }
 
-               //
-               // The keys that we know about and use
-               //
-               static TermInfoStrings [] UsedKeys = {
-                       TermInfoStrings.KeyBackspace,
-                       TermInfoStrings.KeyClear,
-                       TermInfoStrings.KeyDown,
-                       TermInfoStrings.KeyF1,
-                       TermInfoStrings.KeyF10,
-                       TermInfoStrings.KeyF2,
-                       TermInfoStrings.KeyF3,
-                       TermInfoStrings.KeyF4,
-                       TermInfoStrings.KeyF5,
-                       TermInfoStrings.KeyF6,
-                       TermInfoStrings.KeyF7,
-                       TermInfoStrings.KeyF8,
-                       TermInfoStrings.KeyF9,
-                       TermInfoStrings.KeyHome,
-                       TermInfoStrings.KeyLeft,
-                       TermInfoStrings.KeyLl,
-                       TermInfoStrings.KeyNpage,
-                       TermInfoStrings.KeyPpage,
-                       TermInfoStrings.KeyRight,
-                       TermInfoStrings.KeySf,
-                       TermInfoStrings.KeySr,
-                       TermInfoStrings.KeyUp,
-                       TermInfoStrings.KeyA1,
-                       TermInfoStrings.KeyA3,
-                       TermInfoStrings.KeyB2,
-                       TermInfoStrings.KeyC1,
-                       TermInfoStrings.KeyC3,
-                       TermInfoStrings.KeyBtab,
-                       TermInfoStrings.KeyBeg,
-                       TermInfoStrings.KeyCopy,
-                       TermInfoStrings.KeyEnd,
-                       TermInfoStrings.KeyEnter,
-                       TermInfoStrings.KeyHelp,
-                       TermInfoStrings.KeyPrint,
-                       TermInfoStrings.KeyUndo,
-                       TermInfoStrings.KeySbeg,
-                       TermInfoStrings.KeyScopy,
-                       TermInfoStrings.KeySdc,
-                       TermInfoStrings.KeyShelp,
-                       TermInfoStrings.KeyShome,
-                       TermInfoStrings.KeySleft,
-                       TermInfoStrings.KeySprint,
-                       TermInfoStrings.KeySright,
-                       TermInfoStrings.KeySundo,
-                       TermInfoStrings.KeyF11,
-                       TermInfoStrings.KeyF12,
-                       TermInfoStrings.KeyF13,
-                       TermInfoStrings.KeyF14,
-                       TermInfoStrings.KeyF15,
-                       TermInfoStrings.KeyF16,
-                       TermInfoStrings.KeyF17,
-                       TermInfoStrings.KeyF18,
-                       TermInfoStrings.KeyF19,
-                       TermInfoStrings.KeyF20,
-                       TermInfoStrings.KeyF21,
-                       TermInfoStrings.KeyF22,
-                       TermInfoStrings.KeyF23,
-                       TermInfoStrings.KeyF24,
-
-                       // These were missing
-                       TermInfoStrings.KeyDc,
-                       TermInfoStrings.KeyIc
-               };
-               
                void InitKeys ()
                {
                        if (initKeys)
@@ -1401,6 +1333,74 @@ namespace System {
                        CreateKeyMap ();
                        rootmap = new ByteMatcher ();
 
+                       //
+                       // The keys that we know about and use
+                       //
+                       var UsedKeys = new [] {
+                               TermInfoStrings.KeyBackspace,
+                               TermInfoStrings.KeyClear,
+                               TermInfoStrings.KeyDown,
+                               TermInfoStrings.KeyF1,
+                               TermInfoStrings.KeyF10,
+                               TermInfoStrings.KeyF2,
+                               TermInfoStrings.KeyF3,
+                               TermInfoStrings.KeyF4,
+                               TermInfoStrings.KeyF5,
+                               TermInfoStrings.KeyF6,
+                               TermInfoStrings.KeyF7,
+                               TermInfoStrings.KeyF8,
+                               TermInfoStrings.KeyF9,
+                               TermInfoStrings.KeyHome,
+                               TermInfoStrings.KeyLeft,
+                               TermInfoStrings.KeyLl,
+                               TermInfoStrings.KeyNpage,
+                               TermInfoStrings.KeyPpage,
+                               TermInfoStrings.KeyRight,
+                               TermInfoStrings.KeySf,
+                               TermInfoStrings.KeySr,
+                               TermInfoStrings.KeyUp,
+                               TermInfoStrings.KeyA1,
+                               TermInfoStrings.KeyA3,
+                               TermInfoStrings.KeyB2,
+                               TermInfoStrings.KeyC1,
+                               TermInfoStrings.KeyC3,
+                               TermInfoStrings.KeyBtab,
+                               TermInfoStrings.KeyBeg,
+                               TermInfoStrings.KeyCopy,
+                               TermInfoStrings.KeyEnd,
+                               TermInfoStrings.KeyEnter,
+                               TermInfoStrings.KeyHelp,
+                               TermInfoStrings.KeyPrint,
+                               TermInfoStrings.KeyUndo,
+                               TermInfoStrings.KeySbeg,
+                               TermInfoStrings.KeyScopy,
+                               TermInfoStrings.KeySdc,
+                               TermInfoStrings.KeyShelp,
+                               TermInfoStrings.KeyShome,
+                               TermInfoStrings.KeySleft,
+                               TermInfoStrings.KeySprint,
+                               TermInfoStrings.KeySright,
+                               TermInfoStrings.KeySundo,
+                               TermInfoStrings.KeyF11,
+                               TermInfoStrings.KeyF12,
+                               TermInfoStrings.KeyF13,
+                               TermInfoStrings.KeyF14,
+                               TermInfoStrings.KeyF15,
+                               TermInfoStrings.KeyF16,
+                               TermInfoStrings.KeyF17,
+                               TermInfoStrings.KeyF18,
+                               TermInfoStrings.KeyF19,
+                               TermInfoStrings.KeyF20,
+                               TermInfoStrings.KeyF21,
+                               TermInfoStrings.KeyF22,
+                               TermInfoStrings.KeyF23,
+                               TermInfoStrings.KeyF24,
+
+                               // These were missing
+                               TermInfoStrings.KeyDc,
+                               TermInfoStrings.KeyIc
+                       };
+                       
                        foreach (TermInfoStrings tis in UsedKeys)
                                AddStringMapping (tis);
                        
index dea4b02a9a5c2d209848cc82ac9d910831e61239..e1b8ba133d29f70369bfc3cbbaa5268671407365 100644 (file)
@@ -143,6 +143,7 @@ System/DllNotFoundException.cs
 System/DomainManagerInitializationFlags.cs
 System/Double.cs
 System/DuplicateWaitObjectException.cs
+System/EmptyArray.cs
 System/EntryPointNotFoundException.cs
 System/Enum.cs
 System/Environment.cs