#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;
}
}
- static private int recommendedIterationCount = 2000;
+ const int recommendedIterationCount = 2000;
//private int _version;
private byte[] _password;
#else
public class X509Certificate : ISerializable {
#endif
+ const string encoding_error = "Input data cannot be coded as a valid certificate.";
private ASN1 decoder;
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)
{
#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)
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)
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)
// 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;
object currentElement;
int index;
int version;
- static object endFlag = new object ();
+ static readonly object endFlag = new object ();
public SimpleEnumerator (ArrayList list)
{
/// </summary>
private int _version;
- private static readonly object [] EmptyArray = new object [0];
-
#endregion
#region Constructors
/// </summary>
public ArrayList()
{
- _items = EmptyArray;
+ _items = EmptyArray<object>.Value;
}
/// <summary>
#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;
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;
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)
{
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;
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
internal int tokValue;
- public static readonly EventToken Empty;
-
-
- static EventToken ()
- {
- Empty = new EventToken ();
- }
-
+ public static readonly EventToken Empty = new EventToken ();
internal EventToken (int val)
{
internal int tokValue;
- public static readonly FieldToken Empty;
-
-
- static FieldToken ()
- {
- Empty = new FieldToken ();
- }
-
+ public static readonly FieldToken Empty = new FieldToken ();
internal FieldToken (int val)
{
public int maxStack;
}
- static readonly Type void_type = typeof (void);
#region Sync with reflection.h
private byte[] code;
private int code_len;
add_token_fixup (meth);
}
emit_int (token);
- if (meth.ReturnType != void_type)
+ if (meth.ReturnType != typeof (void))
cur_stack ++;
if (opcode.StackBehaviourPop == StackBehaviour.Varpop)
add_token_fixup (method);
}
emit_int (token);
- if (method.ReturnType != void_type)
+ if (method.ReturnType != typeof (void))
cur_stack ++;
if (opcode.StackBehaviourPop == StackBehaviour.Varpop)
internal int tokValue;
- public static readonly MethodToken Empty;
-
-
- static MethodToken ()
- {
- Empty = new MethodToken ();
- }
-
+ public static readonly MethodToken Empty = new MethodToken ();
internal MethodToken (int val)
{
namespace System.Reflection.Emit {
- internal class OpCodeNames {
+ static class OpCodeNames {
internal static readonly string [] names = {
"nop",
"break",
internal int tokValue;
- public static readonly ParameterToken Empty;
-
-
- static ParameterToken ()
- {
- Empty = new ParameterToken ();
- }
-
+ public static readonly ParameterToken Empty = new ParameterToken ();
internal ParameterToken (int val)
{
internal int tokValue;
- public static readonly PropertyToken Empty;
-
-
- static PropertyToken ()
- {
- Empty = new PropertyToken ();
- }
-
+ public static readonly PropertyToken Empty = new PropertyToken ();
internal PropertyToken (int val)
{
internal int tokValue;
- public static readonly SignatureToken Empty;
-
-
- static SignatureToken ()
- {
- Empty = new SignatureToken ();
- }
-
+ public static readonly SignatureToken Empty = new SignatureToken ();
internal SignatureToken (int val)
{
internal int tokValue;
- static StringToken ()
- {
- }
-
-
internal StringToken (int val)
{
tokValue = val;
internal int tokValue;
- public static readonly TypeToken Empty;
-
-
- static TypeToken ()
- {
- Empty = new TypeToken ();
- }
-
+ public static readonly TypeToken Empty = new TypeToken ();
internal TypeToken (int val)
{
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 {
#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 */
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
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);
[ComVisible (true)]
public sealed class ExtensibleClassFactory
{
- static Hashtable hashtable;
-
- static ExtensibleClassFactory ()
- {
- hashtable = new Hashtable ();
- }
+ static readonly Hashtable hashtable = new Hashtable ();
private ExtensibleClassFactory ()
{
{
/* 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);
[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 ()
[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 ()
internal int codePage;
internal int windows_code_page;
bool is_readonly = true;
-
- internal static readonly byte[] empty = new byte[0];
// Constructor.
protected Encoding ()
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];
// 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.
return preamble;
}
- return empty;
+ return EmptyArray<byte>.Value;
}
// Determine if this object is equal to another.
if (emitIdentifier)
return new byte [] { 0xEF, 0xBB, 0xBF };
- return empty;
+ return EmptyArray<byte>.Value;
}
// Determine if this object is equal to another.
return preamble;
}
- return empty;
+ return EmptyArray<byte>.Value;
}
// Determine if this object is equal to another.
int threadWhoTookLock;
readonly bool isThreadOwnerTrackingEnabled;
- static Watch sw = Watch.StartNew ();
+ static readonly Watch sw = Watch.StartNew ();
ConcurrentOrderedList<int> stallTickets;
: MarshalByRefObject, IDisposable
#endif
{
- static Scheduler scheduler = Scheduler.Instance;
+ static readonly Scheduler scheduler = Scheduler.Instance;
#region Timer instance fields
TimerCallback callback;
object state;
--- /dev/null
+//
+// 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
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);
return 1;
}
}
-
- static MonoEnumInfo ()
- {
- global_cache_monitor = new object ();
- global_cache = new Hashtable ();
- }
static Hashtable Cache {
get {
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)
{
return result;
}
+ static char [] split_char;
+
static bool Parse<TEnum> (Type enumType, string value, bool ignoreCase, out TEnum result)
{
result = default (TEnum);
// 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) {
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
return ((AttributeUsageAttribute) attribs[0]);
}
- private static readonly Type AttributeUsageType = typeof(AttributeUsageAttribute);
private static readonly AttributeUsageAttribute DefaultAttributeUsage =
new AttributeUsageAttribute (AttributeTargets.All);
[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 ()
{
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
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;
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)
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);
System/DomainManagerInitializationFlags.cs
System/Double.cs
System/DuplicateWaitObjectException.cs
+System/EmptyArray.cs
System/EntryPointNotFoundException.cs
System/Enum.cs
System/Environment.cs