* BinaryCommon.cs: Added UseReflectionSerialization property.
[mono.git] / mcs / class / corlib / System.Runtime.Serialization.Formatters.Binary / BinaryCommon.cs
index 0812f956174c33937a1c565607019416f1b12c4c..5370ff36a6376b7901402e95e2f87a69d25a8e25 100644 (file)
@@ -16,6 +16,7 @@ namespace System.Runtime.Serialization.Formatters.Binary
 \r
                static Type[] _typeCodesToType;\r
                static byte[] _typeCodeMap;\r
+               public static bool UseReflectionSerialization = false;\r
 \r
                static BinaryCommon()\r
                {\r
@@ -57,6 +58,12 @@ namespace System.Runtime.Serialization.Formatters.Binary
 \r
                        // TimeStamp does not have a TypeCode, so it is managed as a special\r
                        // case in GetTypeCode()\r
+                       \r
+                       // This environment variable is only for test and benchmarking pourposes.\r
+                       // By default, mono will always use IL generated class serializers.\r
+                       string s = Environment.GetEnvironmentVariable("MONO_REFLECTION_SERIALIZER");\r
+                       if (s == null) s = "no";\r
+                       UseReflectionSerialization = (s != "no");\r
                }\r
 \r
                public static bool IsPrimitive (Type type)\r