1 // TypeTest.cs - NUnit Test Cases for the System.Type class
2 //
3 // Authors:
4 // 	Zoltan Varga (vargaz@freemail.hu)
5 //  Patrik Torstensson
6 //  Aleksey Kliger (aleksey@xamarin.com)
7 //
8 // (C) 2003 Ximian, Inc.  http://www.ximian.com
9 // Copyright (C) 2015 Xamarin, Inc. (http://www.xamarin.com)
10 //
11 
12 using NUnit.Framework;
13 using System;
14 using System.Threading;
15 using System.Collections;
16 using System.Collections.Generic;
17 using System.IO;
18 using System.Reflection;
19 #if !MONOTOUCH && !FULL_AOT_RUNTIME
20 using System.Reflection.Emit;
21 #endif
22 using System.Runtime.InteropServices;
23 using System.Text;
24 using System.Globalization;
25 
26 class NoNamespaceClass {
27 }
28 
29 namespace MonoTests.System
30 {
31 	class Super : ICloneable
32 	{
Clone()33 		public virtual object Clone ()
34 		{
35 			return null;
36 		}
37 	}
38 
39 	class Duper: Super
40 	{
41 	}
42 
43 	interface IFace1
44 	{
foo()45 		void foo ();
46 	}
47 
48 	interface IFace2 : IFace1
49 	{
bar()50 		void bar ();
51 	}
52 
53 	interface IFace3 : IFace2
54 	{
55 	}
56 
57 	enum TheEnum
58 	{
59 		A,
60 		B,
61 		C
62 	};
63 
64 	abstract class Base
65 	{
66 		public int level;
67 
68 		public abstract int this [byte i] {
69 			get;
70 		}
71 
72 		public abstract int this [int i] {
73 			get;
74 		}
75 
TestVoid()76 		public abstract void TestVoid ();
TestInt(int i)77 		public abstract void TestInt (int i);
78 	}
79 
80 	class DeriveVTable : Base
81 	{
82 		public override int this [byte i] {
83 			get { return 1; }
84 		}
85 
86 		public override int this [int i] {
87 			get { return 1; }
88 		}
89 
TestVoid()90 		public override void TestVoid ()
91 		{
92 			level = 1;
93 		}
94 
TestInt(int i)95 		public override void TestInt (int i)
96 		{
97 			level = 1;
98 		}
99 	}
100 
101 	class NewVTable : DeriveVTable
102 	{
103 		public new int this [byte i] {
104 			get { return 2; }
105 		}
106 
107 		public new int this [int i] {
108 			get { return 2; }
109 		}
110 
TestVoid()111 		public new void TestVoid ()
112 		{
113 			level = 2;
114 		}
115 
TestInt(int i)116 		public new void TestInt (int i)
117 		{
118 			level = 2;
119 		}
120 
Overload()121 		public void Overload ()
122 		{
123 		}
124 
Overload(int i)125 		public void Overload (int i)
126 		{
127 		}
128 
NewVTable(out int i)129 		public NewVTable (out int i)
130 		{
131 			i = 0;
132 		}
133 
byref_method(out int i)134 		public void byref_method (out int i)
135 		{
136 			i = 0;
137 		}
138 	}
139 
140 	class Base1
141 	{
142 		public virtual int Foo {
143 			get { return 1; }
144 			set { }
145 		}
146 
147 		public event EventHandler E;
Dummy()148 		public void Dummy ()
149 		{
150 			E += delegate {};
151 		}
152 	}
153 
154 	class Derived1 : Base1
155 	{
156 		public override int Foo {
157 			set { }
158 		}
159 	}
160 
161 	class Derived2 : Base1
162 	{
163 		public new int Foo {
164 			get { return 1; }
165 			set { }
166 		}
167 
168 		public new event Action E;
Dummy()169 		public new void Dummy ()
170 		{
171 			E += delegate {};
172 		}
173 	}
174 
175 	public class Foo<T>
176 	{
177 		public T Whatever;
178 
179 		public T Test {
180 			get { throw new NotImplementedException (); }
181 		}
182 
Execute(T a)183 		public T Execute (T a)
184 		{
185 			return a;
186 		}
187 
188 		public class Nested<K> {}
189 	}
190 
191 	class Foo<T, U>
192 	{
193 	}
194 
195 	public interface IBar<T>
196 	{
197 	}
198 
199 	public class Baz<T> : IBar<T>
200 	{
201 	}
202 
203 	class Gazonk {
204 
Bang()205 		public static void Bang<S> () {}
206 	}
207 
208 	public class Bug348522
209 	{
Test(int __argument)210 		public void Test (int __argument)
211 		{
212 		}
213 	}
214 
215 	public class GenericIndexers<T, U>
216 	{
217 		// This class has two indexers that take different
218 		// arguments.  GetProperties on all instances of this
219 		// generic type should still have 2 properties, even
220 		// if T and U are instantiated with the same types.
221 		public T this[T t] { get { return t; } }
222 		public U this[U u] { get { return u; } }
223 	}
224 
225 	public class FirstMethodBinder : Binder
226 	{
BindToMethod(BindingFlags bindingAttr, MethodBase [] match, ref object [] args, ParameterModifier [] modifiers, CultureInfo culture, string [] names, out object state)227 		public override MethodBase BindToMethod (BindingFlags bindingAttr, MethodBase [] match, ref object [] args,
228 							 ParameterModifier [] modifiers, CultureInfo culture, string [] names,
229 							 out object state)
230 		{
231 			state = null;
232 			return match [0];
233 		}
234 
ChangeType(object value, Type type1, CultureInfo culture)235 		public override object ChangeType (object value, Type type1, CultureInfo culture)
236 		{
237 			return value;
238 		}
239 
240 		// The rest is just to please the compiler
BindToField(BindingFlags a, FieldInfo[] b, object c, CultureInfo d)241 		public override FieldInfo BindToField (BindingFlags a, FieldInfo[] b, object c, CultureInfo d)
242 		{
243 			return null;
244 		}
245 
ReorderArgumentArray(ref object[] a, object b)246 		public override void ReorderArgumentArray(ref object[] a, object b)
247 		{
248 		}
249 
SelectMethod(BindingFlags a, MethodBase[] b, Type[] c, ParameterModifier[] d)250 		public override MethodBase SelectMethod(BindingFlags a, MethodBase[] b, Type[] c, ParameterModifier[] d)
251 		{
252 		    return null;
253 		}
254 
SelectProperty(BindingFlags a, PropertyInfo[] b, Type c, Type[] d, ParameterModifier[] e)255 		public override PropertyInfo SelectProperty(BindingFlags a, PropertyInfo[] b, Type c, Type[] d, ParameterModifier[] e)
256 		{
257 			return null;
258 		}
259 	}
260 
261 	[TestFixture]
262 	public class TypeTest
263 	{
264 #if !MONOTOUCH && !FULL_AOT_RUNTIME
265 		private ModuleBuilder module;
266 #endif
267 		const string ASSEMBLY_NAME = "MonoTests.System.TypeTest";
268 		static int typeIndexer = 0;
269 		static bool isMono = Type.GetType ("Mono.Runtime", false) != null;
270 
271 		[SetUp]
SetUp()272 		public void SetUp ()
273 		{
274 			AssemblyName assemblyName = new AssemblyName ();
275 			assemblyName.Name = ASSEMBLY_NAME;
276 #if !MONOTOUCH && !FULL_AOT_RUNTIME
277 			var assembly = AppDomain.CurrentDomain.DefineDynamicAssembly (
278 					assemblyName, AssemblyBuilderAccess.RunAndSave, Path.GetTempPath ());
279 			module = assembly.DefineDynamicModule ("module1");
280 #endif
281 		}
282 
genTypeName()283 		private string genTypeName ()
284 		{
285 			return "t" + (typeIndexer++);
286 		}
287 
ByrefMethod(ref int i, ref Derived1 j, ref Base1 k)288 		private void ByrefMethod (ref int i, ref Derived1 j, ref Base1 k)
289 		{
290 		}
291 
292 		public interface IFace {
293 		}
294 
295 		private void GenericMethod<Q, T1> (Q q, T1 t) where T1 : IFace
296 		{
297 		}
298 
299 		private void GenericMethod2<A, B, C, D> ()
300 			where C : Duper
301 			where A : B, IFace
302 			where B : C
303 			where D : Baz<object>
304 		{
305 		}
306 
307 		public class Nested
308 		{
309 
310 		}
311 
312 		[Test]
TestIsAssignableFrom()313 		public void TestIsAssignableFrom ()
314 		{
315 			// Simple tests for inheritance
316 			Assert.AreEqual (typeof (Super).IsAssignableFrom (typeof (Duper)) , true, "#01");
317 			Assert.AreEqual (typeof (Duper).IsAssignableFrom (typeof (Duper)), true, "#02");
318 			Assert.AreEqual (typeof (Object).IsAssignableFrom (typeof (Duper)), true, "#03");
319 			Assert.AreEqual (typeof (ICloneable).IsAssignableFrom (typeof (Duper)), true, "#04");
320 
321 			// Tests for arrays
322 			Assert.AreEqual (typeof (Super[]).IsAssignableFrom (typeof (Duper[])), true, "#05");
323 			Assert.AreEqual (typeof (Duper[]).IsAssignableFrom (typeof (Super[])), false, "#06");
324 			Assert.AreEqual (typeof (Object[]).IsAssignableFrom (typeof (Duper[])), true, "#07");
325 			Assert.AreEqual (typeof (ICloneable[]).IsAssignableFrom (typeof (Duper[])), true, "#08");
326 
327 			// Tests for multiple dimensional arrays
328 			Assert.AreEqual (typeof (Super[][]).IsAssignableFrom (typeof (Duper[][])), true, "#09");
329 			Assert.AreEqual (typeof (Duper[][]).IsAssignableFrom (typeof (Super[][])), false, "#10");
330 			Assert.AreEqual (typeof (Object[][]).IsAssignableFrom (typeof (Duper[][])), true, "#11");
331 			Assert.AreEqual (typeof (ICloneable[][]).IsAssignableFrom (typeof (Duper[][])), true, "#12");
332 
333 			// Tests for vectors<->one dimensional arrays */
334 			Array arr1 = Array.CreateInstance (typeof (int), new int[] {1}, new int[] {0});
335 			Array arr2 = Array.CreateInstance (typeof (int), new int[] {1}, new int[] {10});
336 
337 			Assert.AreEqual (typeof (int[]).IsAssignableFrom (arr1.GetType ()), true, "#13");
338 			Assert.AreEqual (typeof (int[]).IsAssignableFrom (arr2.GetType ()), false, "#14");
339 
340 			// Test that arrays of enums can be cast to their base types
341 			Assert.AreEqual (typeof (int[]).IsAssignableFrom (typeof (TypeCode[])), true, "#15");
342 
343 			// Test that arrays of valuetypes can't be cast to arrays of
344 			// references
345 			Assert.AreEqual (typeof (object[]).IsAssignableFrom (typeof (TypeCode[])), false, "#16");
346 			Assert.AreEqual (typeof (ValueType[]).IsAssignableFrom (typeof (TypeCode[])), false, "#17");
347 			Assert.AreEqual (typeof (Enum[]).IsAssignableFrom (typeof (TypeCode[])), false, "#18");
348 
349 			// Test that arrays of enums can't be cast to arrays of references
350 			Assert.AreEqual (typeof (object[]).IsAssignableFrom (typeof (TheEnum[])), false, "#19");
351 			Assert.AreEqual (typeof (ValueType[]).IsAssignableFrom (typeof (TheEnum[])), false, "#20");
352 			Assert.AreEqual (typeof (Enum[]).IsAssignableFrom (typeof (TheEnum[])), false, "#21");
353 
354 			// Check that ValueType and Enum are recognized as reference types
355 			Assert.AreEqual (typeof (object).IsAssignableFrom (typeof (ValueType)), true, "#22");
356 			Assert.AreEqual (typeof (object).IsAssignableFrom (typeof (Enum)), true, "#23");
357 			Assert.AreEqual (typeof (ValueType).IsAssignableFrom (typeof (Enum)), true, "#24");
358 
359 			Assert.AreEqual (typeof (object[]).IsAssignableFrom (typeof (ValueType[])), true, "#25");
360 			Assert.AreEqual (typeof (ValueType[]).IsAssignableFrom (typeof (ValueType[])), true, "#26");
361 			Assert.AreEqual (typeof (Enum[]).IsAssignableFrom (typeof (ValueType[])), false, "#27");
362 
363 			Assert.AreEqual (typeof (object[]).IsAssignableFrom (typeof (Enum[])), true, "#28");
364 			Assert.AreEqual (typeof (ValueType[]).IsAssignableFrom (typeof (Enum[])), true, "#29");
365 			Assert.AreEqual (typeof (Enum[]).IsAssignableFrom (typeof (Enum[])), true, "#30");
366 
367 			// Tests for byref types
368 			MethodInfo mi = typeof (TypeTest).GetMethod ("ByrefMethod", BindingFlags.Instance|BindingFlags.NonPublic);
369 			Assert.IsTrue (mi.GetParameters ()[2].ParameterType.IsAssignableFrom (mi.GetParameters ()[1].ParameterType));
370 			Assert.IsTrue (mi.GetParameters ()[1].ParameterType.IsAssignableFrom (mi.GetParameters ()[1].ParameterType));
371 
372 			// Tests for type parameters
373 			mi = typeof (TypeTest).GetMethod ("GenericMethod", BindingFlags.Instance|BindingFlags.NonPublic);
374 			Assert.IsTrue (mi.GetParameters ()[0].ParameterType.IsAssignableFrom (mi.GetParameters ()[0].ParameterType));
375 			Assert.IsFalse (mi.GetParameters ()[0].ParameterType.IsAssignableFrom (typeof (int)));
376 
377 			// Tests for parameters with generic constraints
378 			mi = typeof (TypeTest).GetMethod ("GenericMethod", BindingFlags.Instance|BindingFlags.NonPublic);
379 			Assert.IsTrue (typeof (IFace).IsAssignableFrom (mi.GetParameters ()[1].ParameterType));
380 
381 			// Transitivity of IsAssignableFrom for type parameters
382 			mi = typeof (TypeTest).GetMethod ("GenericMethod2", BindingFlags.Instance|BindingFlags.NonPublic);
383 			var gparams = mi.GetGenericArguments ();
384 			// B : Duper since B : C and C : Duper
385 			Assert.IsTrue (typeof (Duper).IsAssignableFrom (gparams[1]), "#36");
386 			// A : Duper since A : B and B : Duper
387 			Assert.IsTrue (typeof (Duper).IsAssignableFrom (gparams[0]), "#37a");
388 			// A : IFace since A : IFace
389 			Assert.IsTrue (typeof (IFace).IsAssignableFrom (gparams[0]), "#37b");
390 			// B : Super since B : Duper and Duper : Super
391 			Assert.IsTrue (typeof (Super).IsAssignableFrom (gparams[1]), "#38");
392 			// A : Super since A : B and B : Super
393 			Assert.IsTrue (typeof (Super).IsAssignableFrom (gparams[0]), "#39");
394 			// D : IBar<object> since D : Baz<object> and Baz<object> : IBar<object>
395 			Assert.IsTrue (typeof (IBar<object>).IsAssignableFrom (gparams [3]), "#40");
396 			// A not assignable from B since A : B
397 			Assert.IsFalse (gparams[0].IsAssignableFrom (gparams [1]), "#41");
398 			Assert.IsFalse (gparams[0].IsAssignableFrom (gparams [2]), "#42");
399 
400 			// A is not assignable from Array and Delegate and vice versa
401 			Assert.IsFalse (gparams[0].IsAssignableFrom (typeof (Array)), "#43");
402 			Assert.IsFalse (gparams[0].IsAssignableFrom (typeof (Delegate)), "#44");
403 			Assert.IsFalse (typeof (Array).IsAssignableFrom (gparams[0]), "#45");
404 			Assert.IsFalse (typeof (Delegate).IsAssignableFrom (gparams[0]), "#46");
405 
406 		}
407 
408 		[Test]
GenericParameterBaseType()409 		public void GenericParameterBaseType ()
410 		{
411 			var mi = typeof (TypeTest).GetMethod ("GenericMethod2", BindingFlags.Instance|BindingFlags.NonPublic);
412 			var gparams = mi.GetGenericArguments ();
413 
414 			// From the .NET documentation: BaseType property of a
415 			// gparam is "object" if its only constraints are other
416 			// gparams or interfaces, otherwise if it has a class
417 			// constraint that class is the BaseType.
418 
419 			// A : B where B is a gparam, and A : IFace which is an
420 			// interface, so A.BaseType is object
421 			Assert.AreEqual (typeof (object), gparams[0].BaseType, "#1");
422 			// B : C where C is a gparam, so B.BaseType is object
423 			Assert.AreEqual (typeof (object), gparams[1].BaseType, "#2");
424 			// C : Duper where Duper is a class, so A.BaseType is Duper
425 			Assert.AreEqual (typeof (Duper), gparams[2].BaseType, "#3");
426 			// D : Baz<object>
427 			Assert.AreEqual (typeof (Baz<object>), gparams[3].BaseType, "#4");
428 		}
429 
430 		[Test]
431 		[ExpectedException (typeof (ArgumentException))]
GetInterfaceMapOnInterface()432 		public void GetInterfaceMapOnInterface ()
433 		{
434 			typeof (IList).GetInterfaceMap (typeof (ICollection));
435 		}
436 
437 		[Test]
TestIsSubclassOf()438 		public void TestIsSubclassOf ()
439 		{
440 			Assert.IsTrue (typeof (ICloneable).IsSubclassOf (typeof (object)), "#01");
441 
442 			// Tests for byref types
443 			Type paramType = typeof (TypeTest).GetMethod ("ByrefMethod", BindingFlags.Instance|BindingFlags.NonPublic).GetParameters () [0].ParameterType;
444 			Assert.IsFalse (paramType.IsSubclassOf (typeof(ValueType)), "#02");
445 			Assert.IsNull (paramType.BaseType, "#02-b");
446 			Assert.IsTrue (paramType.IsSubclassOf (typeof (Object)), "#03");
447 			Assert.IsFalse (paramType.IsSubclassOf (paramType), "#04");
448 		}
449 
450 		[Test]
TestGetMethodImpl()451 		public void TestGetMethodImpl ()
452 		{
453 			// Test binding of new slot methods (using no types)
454 			Assert.AreEqual (typeof (Base), typeof (Base).GetMethod("TestVoid").DeclaringType, "#01");
455 			Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetMethod ("TestVoid").DeclaringType, "#02");
456 
457 			// Test binding of new slot methods (using types)
458 			Assert.AreEqual (typeof (Base), typeof (Base).GetMethod ("TestInt", new Type[] { typeof (int) }).DeclaringType, "#03");
459 			Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetMethod ("TestInt", new Type[] { typeof (int) }).DeclaringType, "#04");
460 
461 			// Test overload resolution
462 			Assert.AreEqual (0, typeof (NewVTable).GetMethod ("Overload", new Type[0]).GetParameters ().Length, "#05");
463 
464 			// Test byref parameters
465 			Assert.AreEqual (null, typeof (NewVTable).GetMethod ("byref_method", new Type[] { typeof (int) }), "#06");
466 			Type byrefInt = typeof (NewVTable).GetMethod ("byref_method").GetParameters ()[0].ParameterType;
467 			Assert.IsNotNull (typeof (NewVTable).GetMethod ("byref_method", new Type[] { byrefInt }), "#07");
468 		}
469 
470 		[Test]
TestGetPropertyImpl()471 		public void TestGetPropertyImpl ()
472 		{
473 			// Test getting property that is exact
474 			Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetProperty ("Item", new Type[1] { typeof (Int32) }).DeclaringType, "#01");
475 
476 			// Test getting property that is not exact
477 			Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetProperty ("Item", new Type[1] { typeof (Int16) }).DeclaringType, "#02");
478 
479 			// Test overriding of properties when only the set accessor is overriden
480 			Assert.AreEqual (1, typeof (Derived1).GetProperties ().Length, "#03");
481 		}
482 
483 		[Test]
GetEvents()484 		public void GetEvents ()
485 		{
486 			// Test hide-by-name
487 			Assert.AreEqual (1, typeof (Derived2).GetEvents ().Length);
488 			Assert.AreEqual (typeof (Derived2), typeof (Derived2).GetEvents ()[0].DeclaringType);
489 		}
490 
491 		[Test]
GetProperties()492 		public void GetProperties ()
493 		{
494 			// Test hide-by-name-and-signature
495 			Assert.AreEqual (1, typeof (Derived2).GetProperties ().Length, "#1");
496 			Assert.AreEqual (typeof (Derived2), typeof (Derived2).GetProperties ()[0].DeclaringType, "#2");
497 
498 			// For generics, hide-by-name-and-signature works on the unexpanded types. The
499 			// GenericIndexers<T,U> class has two indexers that take different arguments.
500 			// GetProperties on all instances of this generic type should still have 2 properties,
501 			// even if T and U are instantiated with the same types.
502 
503 			var ps = typeof (GenericIndexers<int,int>).GetProperties ();
504 			Assert.AreEqual (2, ps.Length, "#3");
505 			for (int i = 0; i < ps.Length; i++) {
506 				var p = ps[i];
507 
508 				var getterResultType = p.GetGetMethod ().ReturnType;
509 
510 				var msg = String.Format ("#4-{0}", i);
511 				Assert.AreEqual (typeof (int), getterResultType, msg);
512 			}
513 
514 		}
515 
516 		class GetProperties_Overrides_Input
517 		{
518 			public class TestClass : BaseClass<object>
519 			{
520 				public override object TestProperty { get; set; }
521 			}
522 
523 			public abstract class BaseClass<T>
524 			{
525 				public virtual T TestProperty { get; set; }
526 			}
527 
528 			public class TestClass_Indexer : BaseClass_Indexer<object>
529 			{
530 				public override object this[int arg] { set { } }
531 			}
532 
533 			public abstract class BaseClass_Indexer<T>
534 			{
535 				public virtual T this[int arg] { set { } }
536 			}
537 
538 			public interface IB : IA<object>
539 			{
540 				new object TestProperty { get; set; }
541 			}
542 
543 			public interface IA<T>
544 			{
545 				T TestProperty { get; set; }
546 			}
547 
548 			public class TestClass_HiddenProperty : BaseClass_HiddenProperty
549 			{
550 				public new virtual string Prop { set { } }
551 			}
552 
553 			public class BaseClass_HiddenProperty
554 			{
555 				public virtual string Prop { set  { } }
556 			}
557 		}
558 
559 		[Test]
GetProperties_Overrides()560 		public void GetProperties_Overrides ()
561 		{
562 			Assert.AreEqual (1, typeof (GetProperties_Overrides_Input.IB).GetProperties().Length);
563 
564 			var prop = typeof (GetProperties_Overrides_Input.TestClass).GetProperty ("TestProperty");
565 			Assert.AreEqual (typeof (GetProperties_Overrides_Input.TestClass), prop.DeclaringType);
566 
567 			var prop_2 = typeof (GetProperties_Overrides_Input.TestClass_HiddenProperty).GetProperty ("Prop");
568 			Assert.AreEqual (typeof (GetProperties_Overrides_Input.TestClass_HiddenProperty), prop_2.DeclaringType);
569 
570 			Assert.AreEqual (1, typeof (GetProperties_Overrides_Input.TestClass).GetProperties().Length);
571 			Assert.AreEqual (1, typeof (GetProperties_Overrides_Input.TestClass_Indexer).GetProperties().Length);
572 			Assert.AreEqual (1, typeof (GetProperties_Overrides_Input.TestClass_HiddenProperty).GetProperties().Length);
573 	    }
574 
575 		[Test] // GetProperties (BindingFlags)
GetProperties_Flags()576 		public void GetProperties_Flags ()
577 		{
578 			PropertyInfo [] props;
579 			Type type = typeof (Bar);
580 			BindingFlags flags;
581 
582 			flags = BindingFlags.Instance | BindingFlags.NonPublic;
583 			props = type.GetProperties (flags);
584 
585 			Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#A1");
586 			Assert.IsTrue (ContainsProperty (props, "ProtInstBase"), "#A2");
587 			Assert.IsTrue (ContainsProperty (props, "ProIntInstBase"), "#A3");
588 			Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#A4");
589 			Assert.IsTrue (ContainsProperty (props, "IntInstBase"), "#A5");
590 			Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#A6");
591 			Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#A7");
592 			Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#A8");
593 			Assert.IsFalse (ContainsProperty (props, "PubInst"), "#A9");
594 			Assert.IsTrue (ContainsProperty (props, "IntInst"), "#A10");
595 			Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#A11");
596 			Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#A12");
597 			Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#A13");
598 			Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#A14");
599 			Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#A15");
600 			Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#A16");
601 			Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#A17");
602 			Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#A18");
603 			Assert.IsFalse (ContainsProperty (props, "PubStat"), "#A19");
604 			Assert.IsFalse (ContainsProperty (props, "IntStat"), "#A20");
605 			Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#A21");
606 			Assert.IsTrue (ContainsProperty (props, "ProtInstBlue"), "#A22");
607 			Assert.IsTrue (ContainsProperty (props, "ProIntInstBlue"), "#A23");
608 			Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#A24");
609 			Assert.IsTrue (ContainsProperty (props, "IntInstBlue"), "#A25");
610 			Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#A26");
611 			Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#A27");
612 			Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#A28");
613 			Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#A29");
614 			Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#A30");
615 
616 			flags = BindingFlags.Instance | BindingFlags.Public;
617 			props = type.GetProperties (flags);
618 
619 			Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#B1");
620 			Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#B2");
621 			Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#B3");
622 			Assert.IsTrue (ContainsProperty (props, "PubInstBase"), "#B4");
623 			Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#B5");
624 			Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#B6");
625 			Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#B7");
626 			Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#B8");
627 			Assert.IsTrue (ContainsProperty (props, "PubInst"), "#B9");
628 			Assert.IsFalse (ContainsProperty (props, "IntInst"), "#B10");
629 			Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#B11");
630 			Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#B12");
631 			Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#B13");
632 			Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#B14");
633 			Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#B15");
634 			Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#B16");
635 			Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#B17");
636 			Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#B18");
637 			Assert.IsFalse (ContainsProperty (props, "PubStat"), "#B19");
638 			Assert.IsFalse (ContainsProperty (props, "IntStat"), "#B20");
639 			Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#B21");
640 			Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#B22");
641 			Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#B23");
642 			Assert.IsTrue (ContainsProperty (props, "PubInstBlue"), "#B24");
643 			Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#B25");
644 			Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#B26");
645 			Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#B27");
646 			Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#B28");
647 			Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#B29");
648 			Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#B30");
649 
650 			flags = BindingFlags.Static | BindingFlags.Public;
651 			props = type.GetProperties (flags);
652 
653 			Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#C1");
654 			Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#C2");
655 			Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#C3");
656 			Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#C4");
657 			Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#C5");
658 			Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#C6");
659 			Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#C7");
660 			Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#C8");
661 			Assert.IsFalse (ContainsProperty (props, "PubInst"), "#C9");
662 			Assert.IsFalse (ContainsProperty (props, "IntInst"), "#C10");
663 			Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#C11");
664 			Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#C12");
665 			Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#C13");
666 			Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#C14");
667 			Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#C15");
668 			Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#C16");
669 			Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#C17");
670 			Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#C18");
671 			Assert.IsTrue (ContainsProperty (props, "PubStat"), "#C19");
672 			Assert.IsFalse (ContainsProperty (props, "IntStat"), "#C20");
673 			Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#C21");
674 			Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#C22");
675 			Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#C23");
676 			Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#C24");
677 			Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#C25");
678 			Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#C26");
679 			Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#C27");
680 			Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#C28");
681 			Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#C29");
682 			Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#C30");
683 
684 			flags = BindingFlags.Static | BindingFlags.NonPublic;
685 			props = type.GetProperties (flags);
686 
687 			Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#D1");
688 			Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#D2");
689 			Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#D3");
690 			Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#D4");
691 			Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#D5");
692 			Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#D6");
693 			Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#D7");
694 			Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#D8");
695 			Assert.IsFalse (ContainsProperty (props, "PubInst"), "#D9");
696 			Assert.IsFalse (ContainsProperty (props, "IntInst"), "#D10");
697 			Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#D11");
698 			Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#D12");
699 			Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#D13");
700 			Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#D14");
701 			Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#D15");
702 			Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#D16");
703 			Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#D17");
704 			Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#D18");
705 			Assert.IsFalse (ContainsProperty (props, "PubStat"), "#D19");
706 			Assert.IsTrue (ContainsProperty (props, "IntStat"), "#D20");
707 			Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#D21");
708 			Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#D22");
709 			Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#D23");
710 			Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#D24");
711 			Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#D25");
712 			Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#D26");
713 			Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#D27");
714 			Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#D28");
715 			Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#D29");
716 			Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#D30");
717 
718 			flags = BindingFlags.Instance | BindingFlags.NonPublic |
719 				BindingFlags.FlattenHierarchy;
720 			props = type.GetProperties (flags);
721 
722 			Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#E1");
723 			Assert.IsTrue (ContainsProperty (props, "ProtInstBase"), "#E2");
724 			Assert.IsTrue (ContainsProperty (props, "ProIntInstBase"), "#E3");
725 			Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#E4");
726 			Assert.IsTrue (ContainsProperty (props, "IntInstBase"), "#E5");
727 			Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#E6");
728 			Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#E7");
729 			Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#E8");
730 			Assert.IsFalse (ContainsProperty (props, "PubInst"), "#E9");
731 			Assert.IsTrue (ContainsProperty (props, "IntInst"), "#E10");
732 			Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#E11");
733 			Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#E12");
734 			Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#E13");
735 			Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#E14");
736 			Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#E15");
737 			Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#E16");
738 			Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#E17");
739 			Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#E18");
740 			Assert.IsFalse (ContainsProperty (props, "PubStat"), "#E19");
741 			Assert.IsFalse (ContainsProperty (props, "IntStat"), "#E20");
742 			Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#E21");
743 			Assert.IsTrue (ContainsProperty (props, "ProtInstBlue"), "#E22");
744 			Assert.IsTrue (ContainsProperty (props, "ProIntInstBlue"), "#E23");
745 			Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#E24");
746 			Assert.IsTrue (ContainsProperty (props, "IntInstBlue"), "#E25");
747 			Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#E26");
748 			Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#E27");
749 			Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#E28");
750 			Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#E29");
751 			Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#E30");
752 
753 			flags = BindingFlags.Instance | BindingFlags.Public |
754 				BindingFlags.FlattenHierarchy;
755 			props = type.GetProperties (flags);
756 
757 			Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#F1");
758 			Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#F2");
759 			Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#F3");
760 			Assert.IsTrue (ContainsProperty (props, "PubInstBase"), "#F4");
761 			Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#F5");
762 			Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#F6");
763 			Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#F7");
764 			Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#F8");
765 			Assert.IsTrue (ContainsProperty (props, "PubInst"), "#F9");
766 			Assert.IsFalse (ContainsProperty (props, "IntInst"), "#F10");
767 			Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#F11");
768 			Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#F12");
769 			Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#F13");
770 			Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#F14");
771 			Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#F15");
772 			Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#F16");
773 			Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#F17");
774 			Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#F18");
775 			Assert.IsFalse (ContainsProperty (props, "PubStat"), "#F19");
776 			Assert.IsFalse (ContainsProperty (props, "IntStat"), "#F20");
777 			Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#F21");
778 			Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#F22");
779 			Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#F23");
780 			Assert.IsTrue (ContainsProperty (props, "PubInstBlue"), "#F24");
781 			Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#F25");
782 			Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#F26");
783 			Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#F27");
784 			Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#F28");
785 			Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#F29");
786 			Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#F30");
787 
788 			flags = BindingFlags.Static | BindingFlags.Public |
789 				BindingFlags.FlattenHierarchy;
790 			props = type.GetProperties (flags);
791 
792 			Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#G1");
793 			Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#G2");
794 			Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#G3");
795 			Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#G4");
796 			Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#G5");
797 			Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#G6");
798 			Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#G7");
799 			Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#G8");
800 			Assert.IsFalse (ContainsProperty (props, "PubInst"), "#G9");
801 			Assert.IsFalse (ContainsProperty (props, "IntInst"), "#G10");
802 			Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#G11");
803 			Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#G12");
804 			Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#G13");
805 			Assert.IsTrue (ContainsProperty (props, "PubStatBase"), "#G14");
806 			Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#G15");
807 			Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#G16");
808 			Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#G17");
809 			Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#G18");
810 			Assert.IsTrue (ContainsProperty (props, "PubStat"), "#G19");
811 			Assert.IsFalse (ContainsProperty (props, "IntStat"), "#G20");
812 			Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#G21");
813 			Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#G22");
814 			Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#G23");
815 			Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#G24");
816 			Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#G25");
817 			Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#G26");
818 			Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#G27");
819 			Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#G28");
820 			Assert.IsTrue (ContainsProperty (props, "PubStatBlue"), "#G29");
821 			Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#G30");
822 
823 			flags = BindingFlags.Static | BindingFlags.NonPublic |
824 				BindingFlags.FlattenHierarchy;
825 			props = type.GetProperties (flags);
826 
827 			Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#H1");
828 			Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#H2");
829 			Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#H3");
830 			Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#H4");
831 			Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#H5");
832 			Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#H6");
833 			Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#H7");
834 			Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#H8");
835 			Assert.IsFalse (ContainsProperty (props, "PubInst"), "#H9");
836 			Assert.IsFalse (ContainsProperty (props, "IntInst"), "#H10");
837 			Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#H11");
838 			Assert.IsTrue (ContainsProperty (props, "ProtStatBase"), "#H12");
839 			Assert.IsTrue (ContainsProperty (props, "ProIntStatBase"), "#H13");
840 			Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#H14");
841 			Assert.IsTrue (ContainsProperty (props, "IntStatBase"), "#H15");
842 			Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#H16");
843 			Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#H17");
844 			Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#H18");
845 			Assert.IsFalse (ContainsProperty (props, "PubStat"), "#H19");
846 			Assert.IsTrue (ContainsProperty (props, "IntStat"), "#H20");
847 			Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#H21");
848 			Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#H22");
849 			Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#H23");
850 			Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#H24");
851 			Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#H25");
852 			Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#H26");
853 			Assert.IsTrue (ContainsProperty (props, "ProtStatBlue"), "#H27");
854 			Assert.IsTrue (ContainsProperty (props, "ProIntStatBlue"), "#H28");
855 			Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#H29");
856 			Assert.IsTrue (ContainsProperty (props, "IntStatBlue"), "#H30");
857 
858 			flags = BindingFlags.Instance | BindingFlags.NonPublic |
859 				BindingFlags.DeclaredOnly;
860 			props = type.GetProperties (flags);
861 
862 			Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#I1");
863 			Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#I2");
864 			Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#I3");
865 			Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#I4");
866 			Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#I5");
867 			Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#I6");
868 			Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#I7");
869 			Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#I8");
870 			Assert.IsFalse (ContainsProperty (props, "PubInst"), "#I9");
871 			Assert.IsTrue (ContainsProperty (props, "IntInst"), "#I10");
872 			Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#I11");
873 			Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#I12");
874 			Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#I13");
875 			Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#I14");
876 			Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#I15");
877 			Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#I16");
878 			Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#I17");
879 			Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#I18");
880 			Assert.IsFalse (ContainsProperty (props, "PubStat"), "#I19");
881 			Assert.IsFalse (ContainsProperty (props, "IntStat"), "#I20");
882 			Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#I21");
883 			Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#I22");
884 			Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#I23");
885 			Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#I24");
886 			Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#I25");
887 			Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#I26");
888 			Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#I27");
889 			Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#I28");
890 			Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#I29");
891 			Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#I30");
892 
893 			flags = BindingFlags.Instance | BindingFlags.Public |
894 				BindingFlags.DeclaredOnly;
895 			props = type.GetProperties (flags);
896 
897 			Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#J1");
898 			Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#J2");
899 			Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#J3");
900 			Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#J4");
901 			Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#J5");
902 			Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#J6");
903 			Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#J7");
904 			Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#J8");
905 			Assert.IsTrue (ContainsProperty (props, "PubInst"), "#J9");
906 			Assert.IsFalse (ContainsProperty (props, "IntInst"), "#J10");
907 			Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#J11");
908 			Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#J12");
909 			Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#J13");
910 			Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#J14");
911 			Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#J15");
912 			Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#J16");
913 			Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#J17");
914 			Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#J18");
915 			Assert.IsFalse (ContainsProperty (props, "PubStat"), "#J19");
916 			Assert.IsFalse (ContainsProperty (props, "IntStat"), "#J20");
917 			Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#J21");
918 			Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#J22");
919 			Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#J23");
920 			Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#J24");
921 			Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#J25");
922 			Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#J26");
923 			Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#J27");
924 			Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#J28");
925 			Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#J29");
926 			Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#J30");
927 
928 			flags = BindingFlags.Static | BindingFlags.Public |
929 				BindingFlags.DeclaredOnly;
930 			props = type.GetProperties (flags);
931 
932 			Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#K1");
933 			Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#K2");
934 			Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#K3");
935 			Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#K4");
936 			Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#K5");
937 			Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#K6");
938 			Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#K7");
939 			Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#K8");
940 			Assert.IsFalse (ContainsProperty (props, "PubInst"), "#K9");
941 			Assert.IsFalse (ContainsProperty (props, "IntInst"), "#K10");
942 			Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#K11");
943 			Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#K12");
944 			Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#K13");
945 			Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#K14");
946 			Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#K15");
947 			Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#K16");
948 			Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#K17");
949 			Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#K18");
950 			Assert.IsTrue (ContainsProperty (props, "PubStat"), "#K19");
951 			Assert.IsFalse (ContainsProperty (props, "IntStat"), "#K20");
952 			Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#K21");
953 			Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#K22");
954 			Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#K23");
955 			Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#K24");
956 			Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#K25");
957 			Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#K26");
958 			Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#K27");
959 			Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#K28");
960 			Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#K29");
961 			Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#K30");
962 
963 			flags = BindingFlags.Static | BindingFlags.NonPublic |
964 				BindingFlags.DeclaredOnly;
965 			props = type.GetProperties (flags);
966 
967 			Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#L1");
968 			Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#L2");
969 			Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#L3");
970 			Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#L4");
971 			Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#L5");
972 			Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#L6");
973 			Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#L7");
974 			Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#L8");
975 			Assert.IsFalse (ContainsProperty (props, "PubInst"), "#L9");
976 			Assert.IsFalse (ContainsProperty (props, "IntInst"), "#L10");
977 			Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#L11");
978 			Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#L12");
979 			Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#L13");
980 			Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#L14");
981 			Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#L15");
982 			Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#L16");
983 			Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#L17");
984 			Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#L18");
985 			Assert.IsFalse (ContainsProperty (props, "PubStat"), "#L19");
986 			Assert.IsTrue (ContainsProperty (props, "IntStat"), "#L20");
987 			Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#L21");
988 			Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#L22");
989 			Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#L23");
990 			Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#L24");
991 			Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#L25");
992 			Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#L26");
993 			Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#L27");
994 			Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#L28");
995 			Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#L29");
996 			Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#L30");
997 
998 			flags = BindingFlags.Instance | BindingFlags.NonPublic |
999 				BindingFlags.Public;
1000 			props = type.GetProperties (flags);
1001 
1002 			Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#M1");
1003 			Assert.IsTrue (ContainsProperty (props, "ProtInstBase"), "#M2");
1004 			Assert.IsTrue (ContainsProperty (props, "ProIntInstBase"), "#M3");
1005 			Assert.IsTrue (ContainsProperty (props, "PubInstBase"), "#M4");
1006 			Assert.IsTrue (ContainsProperty (props, "IntInstBase"), "#M5");
1007 			Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#M6");
1008 			Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#M7");
1009 			Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#M8");
1010 			Assert.IsTrue (ContainsProperty (props, "PubInst"), "#M9");
1011 			Assert.IsTrue (ContainsProperty (props, "IntInst"), "#M10");
1012 			Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#M11");
1013 			Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#M12");
1014 			Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#M13");
1015 			Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#M14");
1016 			Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#M15");
1017 			Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#M16");
1018 			Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#M17");
1019 			Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#M18");
1020 			Assert.IsFalse (ContainsProperty (props, "PubStat"), "#M19");
1021 			Assert.IsFalse (ContainsProperty (props, "IntStat"), "#M20");
1022 			Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#M21");
1023 			Assert.IsTrue (ContainsProperty (props, "ProtInstBlue"), "#M22");
1024 			Assert.IsTrue (ContainsProperty (props, "ProIntInstBlue"), "#M23");
1025 			Assert.IsTrue (ContainsProperty (props, "PubInstBlue"), "#M24");
1026 			Assert.IsTrue (ContainsProperty (props, "IntInstBlue"), "#M25");
1027 			Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#M26");
1028 			Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#M27");
1029 			Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#M28");
1030 			Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#M29");
1031 			Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#M30");
1032 
1033 			flags = BindingFlags.Static | BindingFlags.NonPublic |
1034 				BindingFlags.Public;
1035 			props = type.GetProperties (flags);
1036 
1037 			Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#N1");
1038 			Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#N2");
1039 			Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#N3");
1040 			Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#N4");
1041 			Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#N5");
1042 			Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#N6");
1043 			Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#N7");
1044 			Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#N8");
1045 			Assert.IsFalse (ContainsProperty (props, "PubInst"), "#N9");
1046 			Assert.IsFalse (ContainsProperty (props, "IntInst"), "#N10");
1047 			Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#N11");
1048 			Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#N12");
1049 			Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#N13");
1050 			Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#N14");
1051 			Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#N15");
1052 			Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#N16");
1053 			Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#N17");
1054 			Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#N18");
1055 			Assert.IsTrue (ContainsProperty (props, "PubStat"), "#N19");
1056 			Assert.IsTrue (ContainsProperty (props, "IntStat"), "#N20");
1057 			Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#N21");
1058 			Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#N22");
1059 			Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#N23");
1060 			Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#N24");
1061 			Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#N25");
1062 			Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#N26");
1063 			Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#N27");
1064 			Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#N28");
1065 			Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#N29");
1066 			Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#N30");
1067 		}
1068 
1069 		[Test] // GetProperty (String)
GetProperty1_Name_Null()1070 		public void GetProperty1_Name_Null ()
1071 		{
1072 			Type type = typeof (Bar);
1073 			try {
1074 				type.GetProperty ((string) null);
1075 				Assert.Fail ("#1");
1076 			} catch (ArgumentNullException ex) {
1077 				Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1078 				Assert.IsNull (ex.InnerException, "#3");
1079 				Assert.IsNotNull (ex.Message, "#4");
1080 				Assert.IsNotNull (ex.ParamName, "#5");
1081 				Assert.AreEqual ("name", ex.ParamName, "#6");
1082 			}
1083 		}
1084 
1085 		[Test] // GetProperty (String, BindingFlags)
GetProperty2()1086 		public void GetProperty2 ()
1087 		{
1088 			Type type = typeof (Bar);
1089 			BindingFlags flags;
1090 
1091 			flags = BindingFlags.Instance | BindingFlags.NonPublic;
1092 
1093 			Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#A1");
1094 			Assert.IsNotNull (type.GetProperty ("ProtInstBase", flags), "#A2");
1095 			Assert.IsNotNull (type.GetProperty ("ProIntInstBase", flags), "#A3");
1096 			Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#A4");
1097 			Assert.IsNotNull (type.GetProperty ("IntInstBase", flags), "#A5");
1098 			Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#A6");
1099 			Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#A7");
1100 			Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#A8");
1101 			Assert.IsNull (type.GetProperty ("PubInst", flags), "#A9");
1102 			Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#A10");
1103 			Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#A11");
1104 			Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#A12");
1105 			Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#A13");
1106 			Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#A14");
1107 			Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#A15");
1108 			Assert.IsNull (type.GetProperty ("PrivStat", flags), "#A16");
1109 			Assert.IsNull (type.GetProperty ("ProtStat", flags), "#A17");
1110 			Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#A18");
1111 			Assert.IsNull (type.GetProperty ("PubStat", flags), "#A19");
1112 			Assert.IsNull (type.GetProperty ("IntStat", flags), "#A20");
1113 			Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#A21");
1114 			Assert.IsNotNull (type.GetProperty ("ProtInstBlue", flags), "#A22");
1115 			Assert.IsNotNull (type.GetProperty ("ProIntInstBlue", flags), "#A23");
1116 			Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#A24");
1117 			Assert.IsNotNull (type.GetProperty ("IntInstBlue", flags), "#A25");
1118 			Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#A26");
1119 			Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#A27");
1120 			Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#A28");
1121 			Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#A29");
1122 			Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#A30");
1123 
1124 			flags = BindingFlags.Instance | BindingFlags.Public;
1125 
1126 			Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#B1");
1127 			Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#B2");
1128 			Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#B3");
1129 			Assert.IsNotNull (type.GetProperty ("PubInstBase", flags), "#B4");
1130 			Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#B5");
1131 			Assert.IsNull (type.GetProperty ("PrivInst", flags), "#B6");
1132 			Assert.IsNull (type.GetProperty ("ProtInst", flags), "#B7");
1133 			Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#B8");
1134 			Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#B9");
1135 			Assert.IsNull (type.GetProperty ("IntInst", flags), "#B10");
1136 			Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#B11");
1137 			Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#B12");
1138 			Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#B13");
1139 			Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#B14");
1140 			Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#B15");
1141 			Assert.IsNull (type.GetProperty ("PrivStat", flags), "#B16");
1142 			Assert.IsNull (type.GetProperty ("ProtStat", flags), "#B17");
1143 			Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#B18");
1144 			Assert.IsNull (type.GetProperty ("PubStat", flags), "#B19");
1145 			Assert.IsNull (type.GetProperty ("IntStat", flags), "#B20");
1146 			Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#B21");
1147 			Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#B22");
1148 			Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#B23");
1149 			Assert.IsNotNull (type.GetProperty ("PubInstBlue", flags), "#B24");
1150 			Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#B25");
1151 			Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#B26");
1152 			Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#B27");
1153 			Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#B28");
1154 			Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#B29");
1155 			Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#B30");
1156 
1157 			flags = BindingFlags.Static | BindingFlags.Public;
1158 
1159 			Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#C1");
1160 			Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#C2");
1161 			Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#C3");
1162 			Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#C4");
1163 			Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#C5");
1164 			Assert.IsNull (type.GetProperty ("PrivInst", flags), "#C6");
1165 			Assert.IsNull (type.GetProperty ("ProtInst", flags), "#C7");
1166 			Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#C8");
1167 			Assert.IsNull (type.GetProperty ("PubInst", flags), "#C9");
1168 			Assert.IsNull (type.GetProperty ("IntInst", flags), "#C10");
1169 			Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#C11");
1170 			Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#C12");
1171 			Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#C13");
1172 			Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#C14");
1173 			Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#C15");
1174 			Assert.IsNull (type.GetProperty ("PrivStat", flags), "#C16");
1175 			Assert.IsNull (type.GetProperty ("ProtStat", flags), "#C17");
1176 			Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#C18");
1177 			Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#C19");
1178 			Assert.IsNull (type.GetProperty ("IntStat", flags), "#C20");
1179 			Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#C21");
1180 			Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#C22");
1181 			Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#C23");
1182 			Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#C24");
1183 			Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#C25");
1184 			Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#C26");
1185 			Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#C27");
1186 			Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#C28");
1187 			Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#C29");
1188 			Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#C30");
1189 
1190 			flags = BindingFlags.Static | BindingFlags.NonPublic;
1191 
1192 			Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#D1");
1193 			Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#D2");
1194 			Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#D3");
1195 			Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#D4");
1196 			Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#D5");
1197 			Assert.IsNull (type.GetProperty ("PrivInst", flags), "#D6");
1198 			Assert.IsNull (type.GetProperty ("ProtInst", flags), "#D7");
1199 			Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#D8");
1200 			Assert.IsNull (type.GetProperty ("PubInst", flags), "#D9");
1201 			Assert.IsNull (type.GetProperty ("IntInst", flags), "#D10");
1202 			Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#D11");
1203 			Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#D12");
1204 			Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#D13");
1205 			Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#D14");
1206 			Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#D15");
1207 			Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#D16");
1208 			Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#D17");
1209 			Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#D18");
1210 			Assert.IsNull (type.GetProperty ("PubStat", flags), "#D19");
1211 			Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#D20");
1212 			Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#D21");
1213 			Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#D22");
1214 			Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#D23");
1215 			Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#D24");
1216 			Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#D25");
1217 			Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#D26");
1218 			Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#D27");
1219 			Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#D28");
1220 			Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#D29");
1221 			Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#D30");
1222 
1223 			flags = BindingFlags.Instance | BindingFlags.NonPublic |
1224 				BindingFlags.FlattenHierarchy;
1225 
1226 			Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#E1");
1227 			Assert.IsNotNull (type.GetProperty ("ProtInstBase", flags), "#E2");
1228 			Assert.IsNotNull (type.GetProperty ("ProIntInstBase", flags), "#E3");
1229 			Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#E4");
1230 			Assert.IsNotNull (type.GetProperty ("IntInstBase", flags), "#E5");
1231 			Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#E6");
1232 			Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#E7");
1233 			Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#E8");
1234 			Assert.IsNull (type.GetProperty ("PubInst", flags), "#E9");
1235 			Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#E10");
1236 			Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#E11");
1237 			Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#E12");
1238 			Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#E13");
1239 			Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#E14");
1240 			Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#E15");
1241 			Assert.IsNull (type.GetProperty ("PrivStat", flags), "#E16");
1242 			Assert.IsNull (type.GetProperty ("ProtStat", flags), "#E17");
1243 			Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#E18");
1244 			Assert.IsNull (type.GetProperty ("PubStat", flags), "#E19");
1245 			Assert.IsNull (type.GetProperty ("IntStat", flags), "#E20");
1246 			Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#E21");
1247 			Assert.IsNotNull (type.GetProperty ("ProtInstBlue", flags), "#E22");
1248 			Assert.IsNotNull (type.GetProperty ("ProIntInstBlue", flags), "#E23");
1249 			Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#E24");
1250 			Assert.IsNotNull (type.GetProperty ("IntInstBlue", flags), "#E25");
1251 			Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#E26");
1252 			Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#E27");
1253 			Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#E28");
1254 			Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#E29");
1255 			Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#E30");
1256 
1257 			flags = BindingFlags.Instance | BindingFlags.Public |
1258 				BindingFlags.FlattenHierarchy;
1259 
1260 			Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#F1");
1261 			Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#F2");
1262 			Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#F3");
1263 			Assert.IsNotNull (type.GetProperty ("PubInstBase", flags), "#F4");
1264 			Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#F5");
1265 			Assert.IsNull (type.GetProperty ("PrivInst", flags), "#F6");
1266 			Assert.IsNull (type.GetProperty ("ProtInst", flags), "#F7");
1267 			Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#F8");
1268 			Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#F9");
1269 			Assert.IsNull (type.GetProperty ("IntInst", flags), "#F10");
1270 			Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#F11");
1271 			Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#F12");
1272 			Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#F13");
1273 			Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#F14");
1274 			Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#F15");
1275 			Assert.IsNull (type.GetProperty ("PrivStat", flags), "#F16");
1276 			Assert.IsNull (type.GetProperty ("ProtStat", flags), "#F17");
1277 			Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#F18");
1278 			Assert.IsNull (type.GetProperty ("PubStat", flags), "#F19");
1279 			Assert.IsNull (type.GetProperty ("IntStat", flags), "#F20");
1280 			Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#F21");
1281 			Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#F22");
1282 			Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#F23");
1283 			Assert.IsNotNull (type.GetProperty ("PubInstBlue", flags), "#F24");
1284 			Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#F25");
1285 			Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#F26");
1286 			Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#F27");
1287 			Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#F28");
1288 			Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#F29");
1289 			Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#F30");
1290 
1291 			flags = BindingFlags.Static | BindingFlags.Public |
1292 				BindingFlags.FlattenHierarchy;
1293 
1294 			Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#G1");
1295 			Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#G2");
1296 			Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#G3");
1297 			Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#G4");
1298 			Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#G5");
1299 			Assert.IsNull (type.GetProperty ("PrivInst", flags), "#G6");
1300 			Assert.IsNull (type.GetProperty ("ProtInst", flags), "#G7");
1301 			Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#G8");
1302 			Assert.IsNull (type.GetProperty ("PubInst", flags), "#G9");
1303 			Assert.IsNull (type.GetProperty ("IntInst", flags), "#G10");
1304 			Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#G11");
1305 			Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#G12");
1306 			Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#G13");
1307 			Assert.IsNotNull (type.GetProperty ("PubStatBase", flags), "#G14");
1308 			Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#G15");
1309 			Assert.IsNull (type.GetProperty ("PrivStat", flags), "#G16");
1310 			Assert.IsNull (type.GetProperty ("ProtStat", flags), "#G17");
1311 			Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#G18");
1312 			Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#G19");
1313 			Assert.IsNull (type.GetProperty ("IntStat", flags), "#G20");
1314 			Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#G21");
1315 			Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#G22");
1316 			Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#G23");
1317 			Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#G24");
1318 			Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#G25");
1319 			Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#G26");
1320 			Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#G27");
1321 			Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#G28");
1322 			Assert.IsNotNull (type.GetProperty ("PubStatBlue", flags), "#G29");
1323 			Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#G30");
1324 
1325 			flags = BindingFlags.Static | BindingFlags.NonPublic |
1326 				BindingFlags.FlattenHierarchy;
1327 
1328 			Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#H1");
1329 			Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#H2");
1330 			Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#H3");
1331 			Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#H4");
1332 			Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#H5");
1333 			Assert.IsNull (type.GetProperty ("PrivInst", flags), "#H6");
1334 			Assert.IsNull (type.GetProperty ("ProtInst", flags), "#H7");
1335 			Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#H8");
1336 			Assert.IsNull (type.GetProperty ("PubInst", flags), "#H9");
1337 			Assert.IsNull (type.GetProperty ("IntInst", flags), "#H10");
1338 			Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#H11");
1339 			Assert.IsNotNull (type.GetProperty ("ProtStatBase", flags), "#H12");
1340 			Assert.IsNotNull (type.GetProperty ("ProIntStatBase", flags), "#H13");
1341 			Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#H14");
1342 			Assert.IsNotNull (type.GetProperty ("IntStatBase", flags), "#H15");
1343 			Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#H16");
1344 			Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#H17");
1345 			Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#H18");
1346 			Assert.IsNull (type.GetProperty ("PubStat", flags), "#H19");
1347 			Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#H20");
1348 			Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#H21");
1349 			Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#H22");
1350 			Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#H23");
1351 			Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#H24");
1352 			Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#H25");
1353 			Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#H26");
1354 			Assert.IsNotNull (type.GetProperty ("ProtStatBlue", flags), "#H27");
1355 			Assert.IsNotNull (type.GetProperty ("ProIntStatBlue", flags), "#H28");
1356 			Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#H29");
1357 			Assert.IsNotNull (type.GetProperty ("IntStatBlue", flags), "#H30");
1358 
1359 			flags = BindingFlags.Instance | BindingFlags.NonPublic |
1360 				BindingFlags.DeclaredOnly;
1361 
1362 			Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#I1");
1363 			Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#I2");
1364 			Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#I3");
1365 			Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#I4");
1366 			Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#I5");
1367 			Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#I6");
1368 			Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#I7");
1369 			Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#I8");
1370 			Assert.IsNull (type.GetProperty ("PubInst", flags), "#I9");
1371 			Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#I10");
1372 			Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#I11");
1373 			Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#I12");
1374 			Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#I13");
1375 			Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#I14");
1376 			Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#I15");
1377 			Assert.IsNull (type.GetProperty ("PrivStat", flags), "#I16");
1378 			Assert.IsNull (type.GetProperty ("ProtStat", flags), "#I17");
1379 			Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#I18");
1380 			Assert.IsNull (type.GetProperty ("PubStat", flags), "#I19");
1381 			Assert.IsNull (type.GetProperty ("IntStat", flags), "#I20");
1382 			Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#I21");
1383 			Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#I22");
1384 			Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#I23");
1385 			Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#I24");
1386 			Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#I25");
1387 			Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#I26");
1388 			Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#I27");
1389 			Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#I28");
1390 			Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#I29");
1391 			Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#I30");
1392 
1393 			flags = BindingFlags.Instance | BindingFlags.Public |
1394 				BindingFlags.DeclaredOnly;
1395 
1396 			Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#J1");
1397 			Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#J2");
1398 			Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#J3");
1399 			Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#J4");
1400 			Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#J5");
1401 			Assert.IsNull (type.GetProperty ("PrivInst", flags), "#J6");
1402 			Assert.IsNull (type.GetProperty ("ProtInst", flags), "#J7");
1403 			Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#J8");
1404 			Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#J9");
1405 			Assert.IsNull (type.GetProperty ("IntInst", flags), "#J10");
1406 			Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#J11");
1407 			Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#J12");
1408 			Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#J13");
1409 			Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#J14");
1410 			Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#J15");
1411 			Assert.IsNull (type.GetProperty ("PrivStat", flags), "#J16");
1412 			Assert.IsNull (type.GetProperty ("ProtStat", flags), "#J17");
1413 			Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#J18");
1414 			Assert.IsNull (type.GetProperty ("PubStat", flags), "#J19");
1415 			Assert.IsNull (type.GetProperty ("IntStat", flags), "#J20");
1416 			Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#J21");
1417 			Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#J22");
1418 			Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#J23");
1419 			Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#J24");
1420 			Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#J25");
1421 			Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#J26");
1422 			Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#J27");
1423 			Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#J28");
1424 			Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#J29");
1425 			Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#J30");
1426 
1427 			flags = BindingFlags.Static | BindingFlags.Public |
1428 				BindingFlags.DeclaredOnly;
1429 
1430 			Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#K1");
1431 			Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#K2");
1432 			Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#K3");
1433 			Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#K4");
1434 			Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#K5");
1435 			Assert.IsNull (type.GetProperty ("PrivInst", flags), "#K6");
1436 			Assert.IsNull (type.GetProperty ("ProtInst", flags), "#K7");
1437 			Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#K8");
1438 			Assert.IsNull (type.GetProperty ("PubInst", flags), "#K9");
1439 			Assert.IsNull (type.GetProperty ("IntInst", flags), "#K10");
1440 			Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#K11");
1441 			Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#K12");
1442 			Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#K13");
1443 			Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#K14");
1444 			Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#K15");
1445 			Assert.IsNull (type.GetProperty ("PrivStat", flags), "#K16");
1446 			Assert.IsNull (type.GetProperty ("ProtStat", flags), "#K17");
1447 			Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#K18");
1448 			Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#K19");
1449 			Assert.IsNull (type.GetProperty ("IntStat", flags), "#K20");
1450 			Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#K21");
1451 			Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#K22");
1452 			Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#K23");
1453 			Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#K24");
1454 			Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#K25");
1455 			Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#K26");
1456 			Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#K27");
1457 			Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#K28");
1458 			Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#K29");
1459 			Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#K30");
1460 
1461 			flags = BindingFlags.Static | BindingFlags.NonPublic |
1462 				BindingFlags.DeclaredOnly;
1463 
1464 			Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#L1");
1465 			Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#L2");
1466 			Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#L3");
1467 			Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#L4");
1468 			Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#L5");
1469 			Assert.IsNull (type.GetProperty ("PrivInst", flags), "#L6");
1470 			Assert.IsNull (type.GetProperty ("ProtInst", flags), "#L7");
1471 			Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#L8");
1472 			Assert.IsNull (type.GetProperty ("PubInst", flags), "#L9");
1473 			Assert.IsNull (type.GetProperty ("IntInst", flags), "#L10");
1474 			Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#L11");
1475 			Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#L12");
1476 			Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#L13");
1477 			Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#L14");
1478 			Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#L15");
1479 			Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#L16");
1480 			Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#L17");
1481 			Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#L18");
1482 			Assert.IsNull (type.GetProperty ("PubStat", flags), "#L19");
1483 			Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#L20");
1484 			Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#L21");
1485 			Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#L22");
1486 			Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#L23");
1487 			Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#L24");
1488 			Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#L25");
1489 			Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#L26");
1490 			Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#L27");
1491 			Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#L28");
1492 			Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#L29");
1493 			Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#L30");
1494 
1495 			flags = BindingFlags.Instance | BindingFlags.NonPublic |
1496 				BindingFlags.Public;
1497 
1498 			Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#M1");
1499 			Assert.IsNotNull (type.GetProperty ("ProtInstBase", flags), "#M2");
1500 			Assert.IsNotNull (type.GetProperty ("ProIntInstBase", flags), "#M3");
1501 			Assert.IsNotNull (type.GetProperty ("PubInstBase", flags), "#M4");
1502 			Assert.IsNotNull (type.GetProperty ("IntInstBase", flags), "#M5");
1503 			Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#M6");
1504 			Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#M7");
1505 			Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#M8");
1506 			Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#M9");
1507 			Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#M10");
1508 			Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#M11");
1509 			Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#M12");
1510 			Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#M13");
1511 			Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#M14");
1512 			Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#M15");
1513 			Assert.IsNull (type.GetProperty ("PrivStat", flags), "#M16");
1514 			Assert.IsNull (type.GetProperty ("ProtStat", flags), "#M17");
1515 			Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#M18");
1516 			Assert.IsNull (type.GetProperty ("PubStat", flags), "#M19");
1517 			Assert.IsNull (type.GetProperty ("IntStat", flags), "#M20");
1518 			Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#M21");
1519 			Assert.IsNotNull (type.GetProperty ("ProtInstBlue", flags), "#M22");
1520 			Assert.IsNotNull (type.GetProperty ("ProIntInstBlue", flags), "#M23");
1521 			Assert.IsNotNull (type.GetProperty ("PubInstBlue", flags), "#M24");
1522 			Assert.IsNotNull (type.GetProperty ("IntInstBlue", flags), "#M25");
1523 			Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#M26");
1524 			Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#M27");
1525 			Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#M28");
1526 			Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#M29");
1527 			Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#M30");
1528 
1529 			flags = BindingFlags.Static | BindingFlags.NonPublic |
1530 				BindingFlags.Public;
1531 
1532 			Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#N1");
1533 			Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#N2");
1534 			Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#N3");
1535 			Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#N4");
1536 			Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#N5");
1537 			Assert.IsNull (type.GetProperty ("PrivInst", flags), "#N6");
1538 			Assert.IsNull (type.GetProperty ("ProtInst", flags), "#N7");
1539 			Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#N8");
1540 			Assert.IsNull (type.GetProperty ("PubInst", flags), "#N9");
1541 			Assert.IsNull (type.GetProperty ("IntInst", flags), "#N10");
1542 			Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#N11");
1543 			Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#N12");
1544 			Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#N13");
1545 			Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#N14");
1546 			Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#N15");
1547 			Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#N16");
1548 			Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#N17");
1549 			Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#N18");
1550 			Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#N19");
1551 			Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#N20");
1552 			Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#N21");
1553 			Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#N22");
1554 			Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#N23");
1555 			Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#N24");
1556 			Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#N25");
1557 			Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#N26");
1558 			Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#N27");
1559 			Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#N28");
1560 			Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#N29");
1561 			Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#N30");
1562 		}
1563 
1564 		[Test] // GetProperty (String, BindingFlags)
GetProperty2_Name_Null()1565 		public void GetProperty2_Name_Null ()
1566 		{
1567 			Type type = typeof (Bar);
1568 			try {
1569 				type.GetProperty ((string) null);
1570 				Assert.Fail ("#1");
1571 			} catch (ArgumentNullException ex) {
1572 				Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1573 				Assert.IsNull (ex.InnerException, "#3");
1574 				Assert.IsNotNull (ex.Message, "#4");
1575 				Assert.IsNotNull (ex.ParamName, "#5");
1576 				Assert.AreEqual ("name", ex.ParamName, "#6");
1577 			}
1578 		}
1579 
1580 		[Test] // GetProperty (String, Type)
GetProperty3_Name_Null()1581 		public void GetProperty3_Name_Null ()
1582 		{
1583 			Type type = typeof (Bar);
1584 			try {
1585 				type.GetProperty ((string) null, typeof (int));
1586 				Assert.Fail ("#1");
1587 			} catch (ArgumentNullException ex) {
1588 				Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1589 				Assert.IsNull (ex.InnerException, "#3");
1590 				Assert.IsNotNull (ex.Message, "#4");
1591 				Assert.IsNotNull (ex.ParamName, "#5");
1592 				Assert.AreEqual ("name", ex.ParamName, "#6");
1593 			}
1594 		}
1595 
1596 		[Test] // GetProperty (String, Type [])
GetProperty4_Name_Null()1597 		public void GetProperty4_Name_Null ()
1598 		{
1599 			Type type = typeof (Bar);
1600 			try {
1601 				type.GetProperty ((string) null, Type.EmptyTypes);
1602 				Assert.Fail ("#1");
1603 			} catch (ArgumentNullException ex) {
1604 				Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1605 				Assert.IsNull (ex.InnerException, "#3");
1606 				Assert.IsNotNull (ex.Message, "#4");
1607 				Assert.IsNotNull (ex.ParamName, "#5");
1608 				Assert.AreEqual ("name", ex.ParamName, "#6");
1609 			}
1610 		}
1611 
1612 		[Test] // GetProperty (String, Type, Type [])
GetProperty5_Name_Null()1613 		public void GetProperty5_Name_Null ()
1614 		{
1615 			Type type = typeof (Bar);
1616 			try {
1617 				type.GetProperty ((string) null, typeof (int),
1618 					Type.EmptyTypes);
1619 				Assert.Fail ("#1");
1620 			} catch (ArgumentNullException ex) {
1621 				Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1622 				Assert.IsNull (ex.InnerException, "#3");
1623 				Assert.IsNotNull (ex.Message, "#4");
1624 				Assert.IsNotNull (ex.ParamName, "#5");
1625 				Assert.AreEqual ("name", ex.ParamName, "#6");
1626 			}
1627 		}
1628 
1629 		[Test] // GetProperty (String, Type, Type [], ParameterModifier [])
GetProperty6_Name_Null()1630 		public void GetProperty6_Name_Null ()
1631 		{
1632 			Type type = typeof (Bar);
1633 			try {
1634 				type.GetProperty ((string) null, typeof (int),
1635 					Type.EmptyTypes, null);
1636 				Assert.Fail ("#1");
1637 			} catch (ArgumentNullException ex) {
1638 				Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1639 				Assert.IsNull (ex.InnerException, "#3");
1640 				Assert.IsNotNull (ex.Message, "#4");
1641 				Assert.IsNotNull (ex.ParamName, "#5");
1642 				Assert.AreEqual ("name", ex.ParamName, "#6");
1643 			}
1644 		}
1645 
1646 		[Test] // GetProperty (String, BindingFlags, Binder, Type, Type [], ParameterModifier [])
GetProperty7_Name_Null()1647 		public void GetProperty7_Name_Null ()
1648 		{
1649 			Type type = typeof (Bar);
1650 			try {
1651 				type.GetProperty ((string) null, BindingFlags.Public,
1652 					null, typeof (int), Type.EmptyTypes, null);
1653 				Assert.Fail ("#1");
1654 			} catch (ArgumentNullException ex) {
1655 				Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1656 				Assert.IsNull (ex.InnerException, "#3");
1657 				Assert.IsNotNull (ex.Message, "#4");
1658 				Assert.IsNotNull (ex.ParamName, "#5");
1659 				Assert.AreEqual ("name", ex.ParamName, "#6");
1660 			}
1661 		}
1662 
1663 		[Test]
GetProperty8_PropertyType()1664 		public void GetProperty8_PropertyType ()
1665 		{
1666 			Type type = typeof (Bar);
1667 			Assert.IsNull (type.GetProperty ("PubInst", BindingFlags.Public | BindingFlags.Instance,
1668 							 null, typeof (int), Type.EmptyTypes, null), "#1");
1669 			Assert.IsNotNull (type.GetProperty ("PubInst", BindingFlags.Public | BindingFlags.Instance, null,
1670 							    typeof (long), new Type[0], null), "#2");
1671 		}
1672 
1673 		[Test]
GetProperty9_Indexers()1674 		public void GetProperty9_Indexers ()
1675 		{
1676 
1677 			var bindingFlags = BindingFlags.Public | BindingFlags.Instance;
1678 
1679 			Type type1 = typeof (List<byte>);
1680 			var p1 = type1.GetProperty ("Item", bindingFlags, null, typeof (byte), new Type[] { typeof (int) }, null);
1681 			Assert.IsNotNull (p1, "#1");
1682 
1683 			Type type2 = typeof (List<string>);
1684 			var p2 = type2.GetProperty ("Item", bindingFlags, null, typeof (string), new Type[] { typeof (int) }, null);
1685 			Assert.IsNotNull (p2, "#2");
1686 
1687 			Type type3 = typeof (List<Type>);
1688 			// result type not convertible, make sure we fail.
1689 			var p3 = type3.GetProperty ("Item", bindingFlags, null, typeof (string) /*!*/,
1690 						    new Type[] { typeof (int) }, null);
1691 			Assert.IsNull (p3, "#3");
1692 		}
1693 
1694 		[StructLayout(LayoutKind.Explicit, Pack = 4, Size = 64)]
1695 		public class Class1
1696 		{
1697 		}
1698 
1699 		[StructLayout(LayoutKind.Explicit, CharSet=CharSet.Unicode)]
1700 		public class Class2
1701 		{
1702 		}
1703 
1704 		[Test]
StructLayoutAttribute()1705 		public void StructLayoutAttribute ()
1706 		{
1707 			StructLayoutAttribute attr1 = typeof (TypeTest).StructLayoutAttribute;
1708 			Assert.AreEqual (LayoutKind.Auto, attr1.Value);
1709 
1710 			StructLayoutAttribute attr2 = typeof (Class1).StructLayoutAttribute;
1711 			Assert.AreEqual (LayoutKind.Explicit, attr2.Value);
1712 			Assert.AreEqual (4, attr2.Pack);
1713 			Assert.AreEqual (64, attr2.Size);
1714 
1715 			StructLayoutAttribute attr3 = typeof (Class2).StructLayoutAttribute;
1716 			Assert.AreEqual (LayoutKind.Explicit, attr3.Value);
1717 			Assert.AreEqual (CharSet.Unicode, attr3.CharSet);
1718 		}
1719 
1720 		[Test]
Namespace()1721 		public void Namespace ()
1722 		{
1723 			Assert.AreEqual (null, typeof (NoNamespaceClass).Namespace);
1724 		}
1725 
1726 		[Test]
GenericParameterNamespace()1727 		public void GenericParameterNamespace ()
1728 		{
1729 			var t = typeof (Foo<>).GetGenericArguments () [0];
1730 
1731 			Assert.AreEqual ("T", t.Name);
1732 			Assert.AreEqual ("MonoTests.System", t.Namespace);
1733 
1734 			var s = typeof (Gazonk).GetMethod ("Bang").GetGenericArguments () [0];
1735 
1736 			Assert.AreEqual ("S", s.Name);
1737 			Assert.AreEqual ("MonoTests.System", s.Namespace);
1738 		}
1739 
Reflected(ref int a)1740 		public static void Reflected (ref int a)
1741 		{
1742 		}
1743 
1744 		[Test]
Name()1745 		public void Name ()
1746 		{
1747 			Assert.AreEqual ("Int32&", typeof (TypeTest).GetMethod ("Reflected").GetParameters () [0].ParameterType.Name);
1748 			Assert.AreEqual ("String[*]", Array.CreateInstance (typeof(string), new int[] { 1 }, new int[] { 1 }).GetType ().Name);
1749 		}
1750 
1751 		[Test]
GetInterfaces()1752 		public void GetInterfaces ()
1753 		{
1754 			Type[] t = typeof (Duper).GetInterfaces ();
1755 			Assert.AreEqual (1, t.Length);
1756 			Assert.AreEqual (typeof (ICloneable), t[0]);
1757 
1758 			Type[] t2 = typeof (IFace3).GetInterfaces ();
1759 			Assert.AreEqual (2, t2.Length);
1760 		}
1761 
1762 		[Test]
GetInterfacesGenericVarWithConstraints()1763 		public void GetInterfacesGenericVarWithConstraints ()
1764 		{
1765 			var a = typeof (TypeTest).GetMethod ("GenericMethod");
1766 
1767 			var p = a.GetParameters ();
1768 			var i = p[0].ParameterType.GetElementType ();
1769 			i.GetInterfaces ();
1770 		}
1771 
1772 		public static void GenericMethod<T, T2> (T[] arr) where T: IComparable<T> {
1773 		}
1774 
1775 		public int AField;
1776 
1777 		[Test]
GetFieldIgnoreCase()1778 		public void GetFieldIgnoreCase ()
1779 		{
1780 			Assert.IsNotNull (typeof (TypeTest).GetField ("afield", BindingFlags.Instance|BindingFlags.Public|BindingFlags.IgnoreCase));
1781 		}
1782 
1783 		public int Count {
1784 			internal get {
1785 				return 0;
1786 			}
1787 
1788 			set {
1789 			}
1790 		}
1791 
1792 		[Test]
GetPropertyAccessorModifiers()1793 		public void GetPropertyAccessorModifiers ()
1794 		{
1795 			Assert.IsNotNull (typeof (TypeTest).GetProperty ("Count", BindingFlags.Instance | BindingFlags.Public));
1796 			Assert.IsNull (typeof (TypeTest).GetProperty ("Count", BindingFlags.Instance | BindingFlags.NonPublic));
1797 		}
1798 
1799 		[Test]
IsAbstract()1800 		public void IsAbstract ()
1801 		{
1802 			Assert.IsFalse (typeof (string).IsAbstract, "#1");
1803 			Assert.IsTrue (typeof (ICloneable).IsAbstract, "#2");
1804 			Assert.IsTrue (typeof (ValueType).IsAbstract, "#3");
1805 			Assert.IsTrue (typeof (Enum).IsAbstract, "#4");
1806 			Assert.IsFalse (typeof (TimeSpan).IsAbstract, "#5");
1807 			Assert.IsTrue (typeof (TextReader).IsAbstract, "#6");
1808 
1809 			// LAMESPEC:
1810 			// https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=286308
1811 			Type [] typeArgs = typeof (List<>).GetGenericArguments ();
1812 			Assert.IsFalse (typeArgs [0].IsAbstract, "#7");
1813 		}
1814 #if !MOBILE
1815 		[Test]
IsCOMObject()1816 		public void IsCOMObject ()
1817 		{
1818 			Type type = typeof (string);
1819 			Assert.IsFalse (type.IsCOMObject, "#1");
1820 
1821 			TypeBuilder tb = module.DefineType (genTypeName ());
1822 			type = tb.CreateType ();
1823 			Assert.IsFalse (type.IsCOMObject, "#2");
1824 		}
1825 
1826 		[Test]
IsImport()1827 		public void IsImport ()
1828 		{
1829 			Type type = typeof (string);
1830 			Assert.IsFalse (type.IsImport, "#1");
1831 
1832 			TypeBuilder tb = module.DefineType (genTypeName ());
1833 			type = tb.CreateType ();
1834 			Assert.IsFalse (type.IsImport, "#2");
1835 
1836 			tb = module.DefineType (genTypeName (), TypeAttributes.Import |
1837 				TypeAttributes.Interface | TypeAttributes.Abstract);
1838 			type = tb.CreateType ();
1839 			Assert.IsTrue (type.IsImport, "#3");
1840 		}
1841 #endif
1842 		[Test]
IsInterface()1843 		public void IsInterface ()
1844 		{
1845 			Assert.IsFalse (typeof (string).IsInterface, "#1");
1846 			Assert.IsTrue (typeof (ICloneable).IsInterface, "#2");
1847 		}
1848 
1849 		[Test]
IsPrimitive()1850 		public void IsPrimitive () {
1851 			Assert.IsTrue (typeof (IntPtr).IsPrimitive, "#1");
1852 			Assert.IsTrue (typeof (int).IsPrimitive, "#2");
1853 			Assert.IsFalse (typeof (string).IsPrimitive, "#2");
1854 		}
1855 
1856 		[Test]
IsValueType()1857 		public void IsValueType ()
1858 		{
1859 			Assert.IsTrue (typeof (int).IsValueType, "#1");
1860 			Assert.IsFalse (typeof (Enum).IsValueType, "#2");
1861 			Assert.IsFalse (typeof (ValueType).IsValueType, "#3");
1862 			Assert.IsTrue (typeof (AttributeTargets).IsValueType, "#4");
1863 			Assert.IsFalse (typeof (string).IsValueType, "#5");
1864 			Assert.IsTrue (typeof (TimeSpan).IsValueType, "#6");
1865 		}
1866 
1867 		[Test]
IsVisible()1868 		public void IsVisible ()
1869 		{
1870 			Assert.IsTrue (typeof (int).IsVisible, "#1");
1871 			Assert.IsTrue (typeof (Nested).IsVisible, "#2");
1872 		}
1873 
1874 		[Test]
GetTypeNonVectorArray()1875 		public void GetTypeNonVectorArray ()
1876 		{
1877 			Type t = Type.GetType ("System.String[*]");
1878 			Assert.AreEqual ("System.String[*]", t.ToString ());
1879 		}
1880 
1881 #if MONO_COM
1882 		[Test]
TypeFromCLSID()1883 		public void TypeFromCLSID ()
1884 		{
1885 			Guid CLSID_ShellDesktop = new Guid("00021400-0000-0000-c000-000000000046");
1886 			Guid CLSID_Bogus = new Guid("1ea9d7a9-f7ab-443b-b486-30d285b21f1b");
1887 
1888 			Type t1 = Type.GetTypeFromCLSID (CLSID_ShellDesktop);
1889 
1890 			Type t2 = Type.GetTypeFromCLSID (CLSID_Bogus);
1891 
1892 			Assert.AreEqual (t1.FullName, "System.__ComObject");
1893 
1894 			if (!isMono && (Environment.OSVersion.Platform == PlatformID.Win32Windows ||
1895 				Environment.OSVersion.Platform == PlatformID.Win32NT))
1896 				Activator.CreateInstance(t1);
1897 
1898 			Assert.AreEqual (t2.FullName, "System.__ComObject");
1899 
1900 			Assert.AreNotEqual (t1, t2);
1901 		}
1902 
1903 		[Test]
1904 		[Category("NotWorking")] // Mono throws TargetInvokationException
1905 		[ExpectedException("System.Runtime.InteropServices.COMException")]
TypeFromCLSIDBogus()1906 		public void TypeFromCLSIDBogus ()
1907 		{
1908 			Guid CLSID_Bogus = new Guid("1ea9d7a9-f7ab-443b-b486-30d285b21f1b");
1909 			Type t = Type.GetTypeFromCLSID (CLSID_Bogus);
1910 			if (Environment.OSVersion.Platform == PlatformID.Win32Windows ||
1911 				Environment.OSVersion.Platform == PlatformID.Win32NT)
1912 				Activator.CreateInstance(t);
1913 			else
1914 				throw new COMException ();
1915 		}
1916 #endif
1917 		[Test]
ExerciseFilterName()1918 		public void ExerciseFilterName ()
1919 		{
1920 			MemberInfo[] mi = typeof(Base).FindMembers(
1921 				MemberTypes.Method,
1922 				BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1923 				BindingFlags.Instance | BindingFlags.DeclaredOnly,
1924 				Type.FilterName, "*");
1925 			Assert.AreEqual (4, mi.Length);
1926 			mi = typeof(Base).FindMembers(
1927 				MemberTypes.Method,
1928 				BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1929 				BindingFlags.Instance | BindingFlags.DeclaredOnly,
1930 				Type.FilterName, "Test*");
1931 			Assert.AreEqual (2, mi.Length);
1932 			mi = typeof(Base).FindMembers(
1933 				MemberTypes.Method,
1934 				BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1935 				BindingFlags.Instance | BindingFlags.DeclaredOnly,
1936 				Type.FilterName, "TestVoid");
1937 			Assert.AreEqual (1, mi.Length);
1938 			mi = typeof(Base).FindMembers(
1939 				MemberTypes.Method,
1940 				BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1941 				BindingFlags.Instance | BindingFlags.DeclaredOnly,
1942 				Type.FilterName, "NonExistingMethod");
1943 			Assert.AreEqual (0, mi.Length);
1944 		}
1945 
1946 		[Test]
ExerciseFilterNameIgnoreCase()1947 		public void ExerciseFilterNameIgnoreCase ()
1948 		{
1949 			MemberInfo[] mi = typeof(Base).FindMembers(
1950 				MemberTypes.Method,
1951 				BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1952 				BindingFlags.Instance | BindingFlags.DeclaredOnly,
1953 				Type.FilterNameIgnoreCase, "*");
1954 			Assert.AreEqual (4, mi.Length);
1955 			mi = typeof(Base).FindMembers(
1956 				MemberTypes.Method,
1957 				BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1958 				BindingFlags.Instance | BindingFlags.DeclaredOnly,
1959 				Type.FilterNameIgnoreCase, "test*");
1960 			Assert.AreEqual (2, mi.Length);
1961 			mi = typeof(Base).FindMembers(
1962 				MemberTypes.Method,
1963 				BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1964 				BindingFlags.Instance | BindingFlags.DeclaredOnly,
1965 				Type.FilterNameIgnoreCase, "TESTVOID");
1966 			Assert.AreEqual (1, mi.Length);
1967 			mi = typeof(Base).FindMembers(
1968 				MemberTypes.Method,
1969 				BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1970 				BindingFlags.Instance | BindingFlags.DeclaredOnly,
1971 				Type.FilterNameIgnoreCase, "NonExistingMethod");
1972 			Assert.AreEqual (0, mi.Length);
1973 		}
1974 
1975 		[Test]
1976 		[ExpectedException (typeof (InvalidFilterCriteriaException))]
FilterAttribute_Invalid()1977 		public void FilterAttribute_Invalid ()
1978 		{
1979 			Type.FilterAttribute (MethodBase.GetCurrentMethod (), (byte) 1);
1980 		}
1981 
1982 		[Test]
GenericParameterMemberType()1983 		public void GenericParameterMemberType ()
1984 		{
1985 			var t = typeof (Foo<>).GetGenericArguments () [0];
1986 			Assert.IsNotNull (t);
1987 
1988 			Assert.AreEqual (MemberTypes.TypeInfo, t.MemberType);
1989 		}
1990 
1991 		public class ByRef0
1992 		{
1993 			public int field;
1994 			public int property {
1995 				get { return 0; }
1996 			}
ByRef0(int i)1997 			public ByRef0 (int i) {}
f(int i)1998 			public void f (int i) {}
1999 		}
2000 
2001 		[Test]
ByrefTypes()2002 		public void ByrefTypes ()
2003 		{
2004 			Type t = Type.GetType ("MonoTests.System.TypeTest+ByRef0&");
2005 			Assert.IsNotNull (t);
2006 			Assert.IsTrue (t.IsByRef);
2007 			Assert.AreEqual (0, t.GetMethods (BindingFlags.Public | BindingFlags.Instance).Length);
2008 			Assert.AreEqual (0, t.GetConstructors (BindingFlags.Public | BindingFlags.Instance).Length);
2009 			Assert.AreEqual (0, t.GetEvents (BindingFlags.Public | BindingFlags.Instance).Length);
2010 			Assert.AreEqual (0, t.GetProperties (BindingFlags.Public | BindingFlags.Instance).Length);
2011 
2012 			Assert.IsNull (t.GetMethod ("f"));
2013 			Assert.IsNull (t.GetField ("field"));
2014 			Assert.IsNull (t.GetProperty ("property"));
2015 		}
2016 
2017 		[Test]
TestAssemblyQualifiedName()2018 		public void TestAssemblyQualifiedName ()
2019 		{
2020 			Type t = Type.GetType ("System.Byte[]&");
2021 			Assert.IsTrue (t.AssemblyQualifiedName.StartsWith ("System.Byte[]&"));
2022 
2023 			t = Type.GetType ("System.Byte*&");
2024 			Assert.IsTrue (t.AssemblyQualifiedName.StartsWith ("System.Byte*&"));
2025 
2026 			t = Type.GetType ("System.Byte&");
2027 			Assert.IsTrue (t.AssemblyQualifiedName.StartsWith ("System.Byte&"));
2028 		}
2029 
2030 		struct B
2031 		{
2032 			#pragma warning disable 169
2033 			int value;
2034 			#pragma warning restore 169
2035 		}
2036 
2037 		[Test]
CreateValueTypeNoCtor()2038 		public void CreateValueTypeNoCtor ()
2039 		{
2040 			typeof(B).InvokeMember ("", BindingFlags.CreateInstance, null, null, null);
2041 		}
2042 
2043 		[Test]
2044 		[ExpectedException (typeof (MissingMethodException))]
CreateValueTypeNoCtorArgs()2045 		public void CreateValueTypeNoCtorArgs ()
2046 		{
2047 			typeof(B).InvokeMember ("", BindingFlags.CreateInstance, null, null, new object [] { 1 });
2048 		}
2049 
2050 		[Test]
2051 		[ExpectedException (typeof (MissingMethodException))]
InvokeGetPropertyMissing()2052 		public void InvokeGetPropertyMissing ()
2053 		{
2054 			typeof(B).InvokeMember ("", BindingFlags.GetProperty, null, null, new object [] { 1 });
2055 		}
2056 
2057 		[Test]
2058 		[ExpectedException (typeof (MissingMethodException))]
InvokeSetPropertyMissing()2059 		public void InvokeSetPropertyMissing ()
2060 		{
2061 			typeof(B).InvokeMember ("", BindingFlags.SetProperty, null, null, new object [] { 1 });
2062 		}
2063 
bug336841(string param1, params string [] param2)2064 		internal static string bug336841 (string param1, params string [] param2)
2065 		{
2066 			StringBuilder sb = new StringBuilder ();
2067 			sb.Append ("#A:");
2068 			sb.Append (param1);
2069 			sb.Append ("|");
2070 			for (int i = 0; i < param2.Length; i++) {
2071 				if (i > 0)
2072 					sb.Append (",");
2073 				sb.Append (param2 [i]);
2074 			}
2075 			return sb.ToString ();
2076 		}
2077 
bug336841(string param1)2078 		internal static string bug336841 (string param1)
2079 		{
2080 			return "#B:" + param1;
2081 		}
2082 
bug336841(params string [] param1)2083 		internal static string bug336841 (params string [] param1)
2084 		{
2085 			StringBuilder sb = new StringBuilder ();
2086 			sb.Append ("#C:");
2087 			for (int i = 0; i < param1.Length; i++) {
2088 				if (i > 0)
2089 					sb.Append (";");
2090 				sb.Append (param1 [i]);
2091 			}
2092 			return sb.ToString ();
2093 		}
2094 
2095 		[Test]
InvokeMember_GetSetField()2096 		public void InvokeMember_GetSetField ()
2097 		{
2098 			typeof (X).InvokeMember ("Value", BindingFlags.Public |
2099 				BindingFlags.Static | BindingFlags.FlattenHierarchy |
2100 				BindingFlags.SetField, null, null, new object [] { 5 });
2101 
2102 			Assert.AreEqual (5, X.Value, "#A1");
2103 			Assert.AreEqual (5, typeof (X).InvokeMember ("Value",
2104 				BindingFlags.Public | BindingFlags.Static |
2105 				BindingFlags.FlattenHierarchy | BindingFlags.GetField,
2106 				null, null, new object [0]), "#A2");
2107 			Assert.AreEqual (5, Y.Value, "#A3");
2108 			Assert.AreEqual (5, typeof (Y).InvokeMember ("Value",
2109 				BindingFlags.Public | BindingFlags.Static |
2110 				BindingFlags.FlattenHierarchy | BindingFlags.GetField,
2111 				null, null, new object [0]), "#A4");
2112 
2113 			try {
2114 				typeof (X).InvokeMember ("Value", BindingFlags.Public |
2115 					BindingFlags.Static | BindingFlags.FlattenHierarchy |
2116 					BindingFlags.GetField | BindingFlags.SetField,
2117 					null, null, new object [] { 5 });
2118 				Assert.Fail ("#B1");
2119 			} catch (ArgumentException ex) {
2120 				// Cannot specify both Get and Set on a field
2121 				Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
2122 				Assert.IsNull (ex.InnerException, "#B3");
2123 				Assert.IsNotNull (ex.Message, "#B4");
2124 				Assert.IsNotNull (ex.ParamName, "#B5");
2125 				Assert.AreEqual ("bindingFlags", ex.ParamName, "#B6");
2126 			}
2127 		}
2128 
2129 		[Test]
InvokeMember_GetSetProperty()2130 		public void InvokeMember_GetSetProperty ()
2131 		{
2132 			try {
2133 				typeof (ArrayList).InvokeMember ("Item",
2134 					BindingFlags.GetProperty | BindingFlags.SetProperty |
2135 					BindingFlags.Instance | BindingFlags.Public,
2136 					null, new ArrayList (), new object [] { 0, "bar" });
2137 				Assert.Fail ("#1");
2138 			} catch (ArgumentException ex) {
2139 				// Cannot specify both Get and Set on a property
2140 				Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
2141 				Assert.IsNull (ex.InnerException, "#3");
2142 				Assert.IsNotNull (ex.Message, "#4");
2143 				Assert.IsNotNull (ex.ParamName, "#5");
2144 				Assert.AreEqual ("bindingFlags", ex.ParamName, "#6");
2145 			}
2146 		}
2147 
2148 
2149 		[Test]
InvokeMember_InvokeMethod_Set()2150 		public void InvokeMember_InvokeMethod_Set ()
2151 		{
2152 			try {
2153 				typeof (ArrayList).InvokeMember ("ToString",
2154 					BindingFlags.InvokeMethod | BindingFlags.SetField |
2155 					BindingFlags.Instance | BindingFlags.Public,
2156 					null, new ArrayList (), new object [0]);
2157 				Assert.Fail ("#A1");
2158 			} catch (ArgumentException ex) {
2159 				// Cannot specify Set on a field and Invoke on a method
2160 				Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
2161 				Assert.IsNull (ex.InnerException, "#A3");
2162 				Assert.IsNotNull (ex.Message, "#A4");
2163 				Assert.IsNotNull (ex.ParamName, "#A5");
2164 				Assert.AreEqual ("bindingFlags", ex.ParamName, "#A6");
2165 			}
2166 
2167 			try {
2168 				typeof (ArrayList).InvokeMember ("ToString",
2169 					BindingFlags.InvokeMethod | BindingFlags.SetProperty |
2170 					BindingFlags.Instance | BindingFlags.Public,
2171 					null, new ArrayList (), new object [0]);
2172 				Assert.Fail ("#B1");
2173 			} catch (ArgumentException ex) {
2174 				// Cannot specify Set on a property and Invoke on a method
2175 				Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
2176 				Assert.IsNull (ex.InnerException, "#B3");
2177 				Assert.IsNotNull (ex.Message, "#B4");
2178 				Assert.IsNotNull (ex.ParamName, "#B5");
2179 				Assert.AreEqual ("bindingFlags", ex.ParamName, "#B6");
2180 			}
2181 		}
2182 
2183 		[Test]
InvokeMember_MatchPrimitiveTypeWithInterface()2184 		public void InvokeMember_MatchPrimitiveTypeWithInterface ()
2185 		{
2186 			object [] invokeargs = { 1 };
2187 			typeof (Z).InvokeMember ("", BindingFlags.DeclaredOnly |
2188 				BindingFlags.Public | BindingFlags.NonPublic |
2189 				BindingFlags.Instance | BindingFlags.CreateInstance,
2190 				null, null, invokeargs);
2191 		}
2192 
2193 		[Test]
InvokeMember_Name_Null()2194 		public void InvokeMember_Name_Null ()
2195 		{
2196 			try {
2197 				typeof (X).InvokeMember ((string) null,
2198 					BindingFlags.Public | BindingFlags.Static |
2199 					BindingFlags.FlattenHierarchy | BindingFlags.SetField,
2200 					null, null, new object [] { 5 });
2201 				Assert.Fail ("#1");
2202 			} catch (ArgumentNullException ex) {
2203 				Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2204 				Assert.IsNull (ex.InnerException, "#3");
2205 				Assert.IsNotNull (ex.Message, "#4");
2206 				Assert.IsNotNull (ex.ParamName, "#5");
2207 				Assert.AreEqual ("name", ex.ParamName, "#6");
2208 			}
2209 		}
2210 
2211 		[Test]
InvokeMember_NoOperation()2212 		public void InvokeMember_NoOperation ()
2213 		{
2214 			try {
2215 				typeof (TypeTest).InvokeMember ("Run", BindingFlags.Public |
2216 					BindingFlags.Static, null, null, new object [0]);
2217 				Assert.Fail ("#1");
2218 			} catch (ArgumentException ex) {
2219 				// Must specify binding flags describing the
2220 				// invoke operation required
2221 				Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
2222 				Assert.IsNull (ex.InnerException, "#3");
2223 				Assert.IsNotNull (ex.Message, "#4");
2224 				Assert.IsNotNull (ex.ParamName, "#5");
2225 				Assert.AreEqual ("bindingFlags", ex.ParamName, "#6");
2226 			}
2227 		}
2228 
2229 		[Test] // bug #321735
InvokeMember_SetFieldProperty()2230 		public void InvokeMember_SetFieldProperty ()
2231 		{
2232 			ArrayList list = new ArrayList ();
2233 			list.Add ("foo");
2234 			list.GetType ().InvokeMember ("Item",
2235 				BindingFlags.SetField | BindingFlags.SetProperty |
2236 				BindingFlags.Instance | BindingFlags.Public,
2237 				null, list, new object [] { 0, "bar" });
2238 			Assert.AreEqual ("bar", list [0]);
2239 		}
2240 
2241 		[Test]
InvokeMember_SetField_ProvidedArgs()2242 		public void InvokeMember_SetField_ProvidedArgs ()
2243 		{
2244 			try {
2245 				typeof (X).InvokeMember ("Value", BindingFlags.Public |
2246 					BindingFlags.Static | BindingFlags.SetField,
2247 					null, null, new object [0]);
2248 				Assert.Fail ("#A1");
2249 			} catch (ArgumentException ex) {
2250 				// Only the field value can be specified to set
2251 				// a field value
2252 				Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
2253 				Assert.IsNull (ex.InnerException, "#A3");
2254 				Assert.IsNotNull (ex.Message, "#A4");
2255 				Assert.IsNotNull (ex.ParamName, "#A5");
2256 				Assert.AreEqual ("bindingFlags", ex.ParamName, "#6");
2257 			}
2258 
2259 			try {
2260 				typeof (X).InvokeMember ("Value", BindingFlags.Public |
2261 					BindingFlags.Static | BindingFlags.SetField,
2262 					null, null, null);
2263 				Assert.Fail ("#B1");
2264 			} catch (ArgumentNullException ex) {
2265 				Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
2266 				Assert.IsNull (ex.InnerException, "#B3");
2267 				Assert.IsNotNull (ex.Message, "#B4");
2268 				Assert.IsNotNull (ex.ParamName, "#B5");
2269 				Assert.AreEqual ("providedArgs", ex.ParamName, "#B6");
2270 			}
2271 		}
2272 
2273 		[Test] // bug #336841
2274 		[Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=306797
InvokeMember_VarArgs()2275 		public void InvokeMember_VarArgs ()
2276 		{
2277 			BindingFlags flags = BindingFlags.InvokeMethod | BindingFlags.Public |
2278 				BindingFlags.NonPublic | BindingFlags.OptionalParamBinding |
2279 				BindingFlags.Static | BindingFlags.FlattenHierarchy |
2280 				BindingFlags.Instance;
2281 
2282 			Type type = typeof (TypeTest);
2283 			string result = (string) type.InvokeMember ("bug336841",
2284 				flags, null, null, new object [] { "1" });
2285 			Assert.IsNotNull (result, "#A1");
2286 			Assert.AreEqual ("#B:1", result, "#A2");
2287 
2288 			result = (string) type.InvokeMember ("bug336841", flags,
2289 				null, null, new object [] { "1", "2", "3", "4" });
2290 			Assert.IsNotNull (result, "#B1");
2291 			Assert.AreEqual ("#A:1|2,3,4", result, "#B2");
2292 		}
2293 
2294 
2295 		[Test] // bug #348522
InvokeMember_WithoutDefaultValue()2296 		public void InvokeMember_WithoutDefaultValue ()
2297 		{
2298 			BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod;
2299 			try {
2300 				typeof (Bug348522).InvokeMember ("Test", flags, new FirstMethodBinder (), new Bug348522(),
2301 					new object [] {Missing.Value}, null, null, null);
2302 				Assert.Fail ("#1");
2303 			} catch (ArgumentException ex) {
2304 				// Missing parameter does not have a default value
2305 				Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
2306 				Assert.IsNull (ex.InnerException, "#3");
2307 				Assert.IsNotNull (ex.Message, "#4");
2308 				Assert.IsNotNull (ex.ParamName, "#5");
2309 				Assert.AreEqual ("parameters", ex.ParamName, "#6");
2310 			}
2311 		}
2312 
2313 	    [Test]
TestMissing()2314 		public void TestMissing () {
2315 			Assert.AreEqual (Type.Missing, Missing.Value);
2316 		}
2317 
2318 		[Test]
GetGenericMethodDefinitionOverInflatedMethodOnGTD()2319 		public void GetGenericMethodDefinitionOverInflatedMethodOnGTD () {
2320 			var s = new List<int> () { 1, 2, 3 }.ConvertAll ( i => i.ToString () );
2321 			Assert.AreEqual (3, s.Count);
2322 			var l = typeof (List<>);
2323 			var m = l.GetMethod ("ConvertAll");
2324 			var infl = m.MakeGenericMethod (typeof (int));
2325 			var res = m.GetGenericMethodDefinition ();
2326 			Assert.AreEqual (m, res, "#1");
2327 			Assert.AreEqual (1, infl.GetGenericArguments().Length, "#2");
2328 		}
2329 
2330 		[Test]
InvokeMember_OutParam()2331 		public void InvokeMember_OutParam ()
2332 		{
2333 			object[] args = new object[] { new string [0] };
2334 			typeof (TypeTest).InvokeMember ("OutTest", BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.Public, null, null, args);
2335 			Assert.IsTrue (args [0] is string[]);
2336 			Assert.AreEqual (10, ((string[])args[0]).Length);
2337 		}
2338 
OutTest(out string[] a1)2339 		public static void OutTest (out string[] a1)
2340 		{
2341 			a1 = new string [10];
2342 		}
2343 
2344 		public class X
2345 		{
2346 			public static int Value;
2347 		}
2348 
2349 		class Y : X
2350 		{
2351 		}
2352 
2353 		class Z
2354 		{
Z(IComparable value)2355 			public Z (IComparable value)
2356 			{
2357 			}
2358 		}
2359 
Run()2360 		public static void Run ()
2361 		{
2362 		}
2363 
2364 		class TakesInt
2365 		{
2366 			private int i;
2367 
TakesInt(int x)2368 			public TakesInt (int x)
2369 			{
2370 				i = x;
2371 			}
2372 
2373 			public int Integer {
2374 				get { return i; }
2375 			}
2376 		}
2377 
2378 		class TakesObject
2379 		{
TakesObject(object x)2380 			public TakesObject (object x) {}
2381 		}
2382 
2383 		[Test] // bug #75241
GetConstructorNullInTypes()2384 		public void GetConstructorNullInTypes ()
2385 		{
2386 			// This ends up calling type.GetConstructor ()
2387 			Activator.CreateInstance (typeof (TakesInt), new object [] { null });
2388 			Activator.CreateInstance (typeof (TakesObject), new object [] { null });
2389 		}
2390 
2391 		[Test]
GetConstructor_TakeInt_Object()2392 		public void GetConstructor_TakeInt_Object ()
2393 		{
2394 			Assert.IsNull (typeof (TakesInt).GetConstructor (new Type[1] { typeof (object) }));
2395 		}
2396 
2397 		[Test]
GetCustomAttributes_All()2398 		public void GetCustomAttributes_All ()
2399 		{
2400 			object [] attrs = typeof (A).GetCustomAttributes (false);
2401 			Assert.AreEqual (2, attrs.Length, "#A1");
2402 			Assert.IsTrue (HasAttribute (attrs, typeof (FooAttribute)), "#A2");
2403 			Assert.IsTrue (HasAttribute (attrs, typeof (VolatileModifier)), "#A3");
2404 
2405 			attrs = typeof (BA).GetCustomAttributes (false);
2406 			Assert.AreEqual (1, attrs.Length, "#B1");
2407 			Assert.AreEqual (typeof (BarAttribute), attrs [0].GetType (), "#B2");
2408 
2409 			attrs = typeof (BA).GetCustomAttributes (true);
2410 			Assert.AreEqual (2, attrs.Length, "#C1");
2411 			Assert.IsTrue (HasAttribute (attrs, typeof (BarAttribute)), "#C2");
2412 			Assert.IsTrue (HasAttribute (attrs, typeof (VolatileModifier)), "#C3");
2413 
2414 			attrs = typeof (CA).GetCustomAttributes (false);
2415 			Assert.AreEqual (0, attrs.Length, "#D");
2416 
2417 			attrs = typeof (CA).GetCustomAttributes (true);
2418 			Assert.AreEqual (1, attrs.Length, "#E1");
2419 			Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#E2");
2420 		}
2421 
HasAttribute(object [] attrs, Type attributeType)2422 		static bool HasAttribute (object [] attrs, Type attributeType)
2423 		{
2424 			foreach (object attr in attrs)
2425 				if (attr.GetType () == attributeType)
2426 					return true;
2427 			return false;
2428 		}
2429 
2430 		[Test]
GetCustomAttributes_Type()2431 		public void GetCustomAttributes_Type ()
2432 		{
2433 			object [] attrs = null;
2434 
2435 			attrs = typeof (A).GetCustomAttributes (
2436 				typeof (VolatileModifier), false);
2437 			Assert.AreEqual (1, attrs.Length, "#A1");
2438 			Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#A2");
2439 			attrs = typeof (A).GetCustomAttributes (
2440 				typeof (VolatileModifier), true);
2441 			Assert.AreEqual (1, attrs.Length, "#A3");
2442 			Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#A4");
2443 
2444 			attrs = typeof (A).GetCustomAttributes (
2445 				typeof (NemerleAttribute), false);
2446 			Assert.AreEqual (1, attrs.Length, "#B1");
2447 			Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#B2");
2448 			attrs = typeof (A).GetCustomAttributes (
2449 				typeof (NemerleAttribute), true);
2450 			Assert.AreEqual (1, attrs.Length, "#B3");
2451 			Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#B4");
2452 
2453 			attrs = typeof (A).GetCustomAttributes (
2454 				typeof (FooAttribute), false);
2455 			Assert.AreEqual (1, attrs.Length, "#C1");
2456 			Assert.AreEqual (typeof (FooAttribute), attrs [0].GetType (), "#C2");
2457 			attrs = typeof (A).GetCustomAttributes (
2458 				typeof (FooAttribute), false);
2459 			Assert.AreEqual (1, attrs.Length, "#C3");
2460 			Assert.AreEqual (typeof (FooAttribute), attrs [0].GetType (), "#C4");
2461 
2462 			attrs = typeof (BA).GetCustomAttributes (
2463 				typeof (VolatileModifier), false);
2464 			Assert.AreEqual (0, attrs.Length, "#D1");
2465 			attrs = typeof (BA).GetCustomAttributes (
2466 				typeof (VolatileModifier), true);
2467 			Assert.AreEqual (1, attrs.Length, "#D2");
2468 			Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#D3");
2469 
2470 			attrs = typeof (BA).GetCustomAttributes (
2471 				typeof (NemerleAttribute), false);
2472 			Assert.AreEqual (0, attrs.Length, "#E1");
2473 			attrs = typeof (BA).GetCustomAttributes (
2474 				typeof (NemerleAttribute), true);
2475 			Assert.AreEqual (1, attrs.Length, "#E2");
2476 			Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#E3");
2477 
2478 			attrs = typeof (BA).GetCustomAttributes (
2479 				typeof (FooAttribute), false);
2480 			Assert.AreEqual (1, attrs.Length, "#F1");
2481 			Assert.AreEqual (typeof (BarAttribute), attrs [0].GetType (), "#F2");
2482 			attrs = typeof (BA).GetCustomAttributes (
2483 				typeof (FooAttribute), true);
2484 			Assert.AreEqual (1, attrs.Length, "#F3");
2485 			Assert.AreEqual (typeof (BarAttribute), attrs [0].GetType (), "#F4");
2486 
2487 			attrs = typeof (bug82431A1).GetCustomAttributes (
2488 				typeof (InheritAttribute), false);
2489 			Assert.AreEqual (1, attrs.Length, "#G1");
2490 			Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#G2");
2491 			attrs = typeof (bug82431A1).GetCustomAttributes (
2492 				typeof (InheritAttribute), true);
2493 			Assert.AreEqual (1, attrs.Length, "#G3");
2494 			Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#G4");
2495 
2496 			attrs = typeof (bug82431A1).GetCustomAttributes (
2497 				typeof (NotInheritAttribute), false);
2498 			Assert.AreEqual (1, attrs.Length, "#H1");
2499 			Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#H2");
2500 			attrs = typeof (bug82431A1).GetCustomAttributes (
2501 				typeof (InheritAttribute), true);
2502 			Assert.AreEqual (1, attrs.Length, "#H3");
2503 			Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#H4");
2504 
2505 			attrs = typeof (bug82431A2).GetCustomAttributes (
2506 				typeof (InheritAttribute), false);
2507 			Assert.AreEqual (0, attrs.Length, "#I1");
2508 			attrs = typeof (bug82431A2).GetCustomAttributes (
2509 				typeof (InheritAttribute), true);
2510 			Assert.AreEqual (0, attrs.Length, "#I2");
2511 
2512 			attrs = typeof (bug82431A2).GetCustomAttributes (
2513 				typeof (NotInheritAttribute), false);
2514 			Assert.AreEqual (0, attrs.Length, "#J1");
2515 			attrs = typeof (bug82431A2).GetCustomAttributes (
2516 				typeof (NotInheritAttribute), true);
2517 			Assert.AreEqual (0, attrs.Length, "#J2");
2518 
2519 			attrs = typeof (bug82431A3).GetCustomAttributes (
2520 				typeof (InheritAttribute), false);
2521 			Assert.AreEqual (2, attrs.Length, "#K1");
2522 			Assert.IsTrue (HasAttribute (attrs, typeof (InheritAttribute)), "#K2");
2523 			Assert.IsTrue (HasAttribute (attrs, typeof (NotInheritAttribute)), "#K3");
2524 			attrs = typeof (bug82431A3).GetCustomAttributes (
2525 				typeof (InheritAttribute), true);
2526 			Assert.AreEqual (2, attrs.Length, "#K4");
2527 			Assert.IsTrue (HasAttribute (attrs, typeof (InheritAttribute)), "#K5");
2528 			Assert.IsTrue (HasAttribute (attrs, typeof (NotInheritAttribute)), "#K6");
2529 
2530 			attrs = typeof (bug82431A3).GetCustomAttributes (
2531 				typeof (NotInheritAttribute), false);
2532 			Assert.AreEqual (1, attrs.Length, "#L1");
2533 			Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#L2");
2534 			attrs = typeof (bug82431A3).GetCustomAttributes (
2535 				typeof (NotInheritAttribute), true);
2536 			Assert.AreEqual (1, attrs.Length, "#L3");
2537 			Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#L4");
2538 
2539 			attrs = typeof (bug82431B1).GetCustomAttributes (
2540 				typeof (InheritAttribute), false);
2541 			Assert.AreEqual (1, attrs.Length, "#M1");
2542 			Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#M2");
2543 			attrs = typeof (bug82431B1).GetCustomAttributes (
2544 				typeof (InheritAttribute), true);
2545 			Assert.AreEqual (1, attrs.Length, "#M3");
2546 			Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#M4");
2547 
2548 			attrs = typeof (bug82431B1).GetCustomAttributes (
2549 				typeof (NotInheritAttribute), false);
2550 			Assert.AreEqual (0, attrs.Length, "#N1");
2551 			attrs = typeof (bug82431B1).GetCustomAttributes (
2552 				typeof (NotInheritAttribute), true);
2553 			Assert.AreEqual (0, attrs.Length, "#N2");
2554 
2555 			attrs = typeof (bug82431B2).GetCustomAttributes (
2556 				typeof (InheritAttribute), false);
2557 			Assert.AreEqual (0, attrs.Length, "#O1");
2558 			attrs = typeof (bug82431B2).GetCustomAttributes (
2559 				typeof (InheritAttribute), true);
2560 			Assert.AreEqual (1, attrs.Length, "#O2");
2561 			Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#O3");
2562 
2563 			attrs = typeof (bug82431B2).GetCustomAttributes (
2564 				typeof (NotInheritAttribute), false);
2565 			Assert.AreEqual (0, attrs.Length, "#P1");
2566 			attrs = typeof (bug82431B2).GetCustomAttributes (
2567 				typeof (NotInheritAttribute), true);
2568 			Assert.AreEqual (0, attrs.Length, "#P2");
2569 
2570 			attrs = typeof (bug82431B3).GetCustomAttributes (
2571 				typeof (InheritAttribute), false);
2572 			Assert.AreEqual (1, attrs.Length, "#Q1");
2573 			Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#Q2");
2574 			attrs = typeof (bug82431B3).GetCustomAttributes (
2575 				typeof (InheritAttribute), true);
2576 			Assert.AreEqual (2, attrs.Length, "#Q3");
2577 			Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#Q4");
2578 			Assert.AreEqual (typeof (InheritAttribute), attrs [1].GetType (), "#Q5");
2579 
2580 			attrs = typeof (bug82431B3).GetCustomAttributes (
2581 				typeof (NotInheritAttribute), false);
2582 			Assert.AreEqual (1, attrs.Length, "#R1");
2583 			Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#R2");
2584 			attrs = typeof (bug82431B3).GetCustomAttributes (
2585 				typeof (NotInheritAttribute), true);
2586 			Assert.AreEqual (1, attrs.Length, "#R3");
2587 			Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#R4");
2588 
2589 			attrs = typeof (bug82431B4).GetCustomAttributes (
2590 				typeof (InheritAttribute), false);
2591 			Assert.AreEqual (0, attrs.Length, "#S1");
2592 			attrs = typeof (bug82431B4).GetCustomAttributes (
2593 				typeof (InheritAttribute), true);
2594 			Assert.AreEqual (1, attrs.Length, "#S2");
2595 			Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#S3");
2596 
2597 			attrs = typeof (bug82431B4).GetCustomAttributes (
2598 				typeof (NotInheritAttribute), false);
2599 			Assert.AreEqual (0, attrs.Length, "#T1");
2600 			attrs = typeof (bug82431B4).GetCustomAttributes (
2601 				typeof (NotInheritAttribute), true);
2602 			Assert.AreEqual (0, attrs.Length, "#T2");
2603 
2604 			attrs = typeof (A).GetCustomAttributes (
2605 				typeof (string), false);
2606 			Assert.AreEqual (0, attrs.Length, "#U1");
2607 			attrs = typeof (A).GetCustomAttributes (
2608 				typeof (string), true);
2609 			Assert.AreEqual (0, attrs.Length, "#U2");
2610 		}
2611 
2612 		[Test] // bug #76150
IsDefined()2613 		public void IsDefined ()
2614 		{
2615 			Assert.IsTrue (typeof (A).IsDefined (typeof (NemerleAttribute), false), "#A1");
2616 			Assert.IsTrue (typeof (A).IsDefined (typeof (VolatileModifier), false), "#A2");
2617 			Assert.IsTrue (typeof (A).IsDefined (typeof (FooAttribute), false), "#A3");
2618 			Assert.IsFalse (typeof (A).IsDefined (typeof (BarAttribute), false), "#A4");
2619 
2620 			Assert.IsFalse (typeof (BA).IsDefined (typeof (NemerleAttribute), false), "#B1");
2621 			Assert.IsFalse (typeof (BA).IsDefined (typeof (VolatileModifier), false), "#B2");
2622 			Assert.IsTrue (typeof (BA).IsDefined (typeof (FooAttribute), false), "#B3");
2623 			Assert.IsTrue (typeof (BA).IsDefined (typeof (BarAttribute), false), "#B4");
2624 			Assert.IsFalse (typeof (BA).IsDefined (typeof (string), false), "#B5");
2625 			Assert.IsFalse (typeof (BA).IsDefined (typeof (int), false), "#B6");
2626 			Assert.IsTrue (typeof (BA).IsDefined (typeof (NemerleAttribute), true), "#B7");
2627 			Assert.IsTrue (typeof (BA).IsDefined (typeof (VolatileModifier), true), "#B8");
2628 			Assert.IsTrue (typeof (BA).IsDefined (typeof (FooAttribute), true), "#B9");
2629 			Assert.IsTrue (typeof (BA).IsDefined (typeof (BarAttribute), true), "#B10");
2630 			Assert.IsFalse (typeof (BA).IsDefined (typeof (string), true), "#B11");
2631 			Assert.IsFalse (typeof (BA).IsDefined (typeof (int), true), "#B12");
2632 		}
2633 
2634 		[Test]
IsDefined_AttributeType_Null()2635 		public void IsDefined_AttributeType_Null ()
2636 		{
2637 			try {
2638 				typeof (BA).IsDefined ((Type) null, false);
2639 				Assert.Fail ("#1");
2640 			} catch (ArgumentNullException ex) {
2641 				Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2642 				Assert.IsNull (ex.InnerException, "#3");
2643 				Assert.IsNotNull (ex.Message, "#4");
2644 				Assert.IsNotNull (ex.ParamName, "#5");
2645 				Assert.AreEqual ("attributeType", ex.ParamName, "#6");
2646 			}
2647 		}
2648 
2649 		[Test] // bug #82431
2650 		[Category ("NotWorking")]
IsDefined_Inherited()2651 		public void IsDefined_Inherited ()
2652 		{
2653 			Assert.IsFalse (typeof (CA).IsDefined (typeof (NemerleAttribute), false), "#C1");
2654 			Assert.IsFalse (typeof (CA).IsDefined (typeof (VolatileModifier), false), "#C2");
2655 			Assert.IsFalse (typeof (CA).IsDefined (typeof (FooAttribute), false), "#C3");
2656 			Assert.IsFalse (typeof (CA).IsDefined (typeof (BarAttribute), false), "#C4");
2657 			Assert.IsTrue (typeof (CA).IsDefined (typeof (NemerleAttribute), true), "#C5");
2658 			Assert.IsTrue (typeof (CA).IsDefined (typeof (VolatileModifier), true), "#C6");
2659 			Assert.IsFalse (typeof (CA).IsDefined (typeof (FooAttribute), true), "#C7");
2660 			Assert.IsFalse (typeof (CA).IsDefined (typeof (BarAttribute), true), "#C8");
2661 
2662 			Assert.IsFalse (typeof (BBA).IsDefined (typeof (NemerleAttribute), false), "#D1");
2663 			Assert.IsFalse (typeof (BBA).IsDefined (typeof (VolatileModifier), false), "#D2");
2664 			Assert.IsFalse (typeof (BBA).IsDefined (typeof (FooAttribute), false), "#D3");
2665 			Assert.IsFalse (typeof (BBA).IsDefined (typeof (BarAttribute), false), "#D4");
2666 			Assert.IsTrue (typeof (BBA).IsDefined (typeof (NemerleAttribute), true), "#D5");
2667 			Assert.IsTrue (typeof (BBA).IsDefined (typeof (VolatileModifier), true), "#D6");
2668 			Assert.IsTrue (typeof (BBA).IsDefined (typeof (FooAttribute), true), "#D7");
2669 			Assert.IsTrue (typeof (BBA).IsDefined (typeof (BarAttribute), true), "#D8");
2670 
2671 			Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (InheritAttribute), false), "#E1");
2672 			Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (NotInheritAttribute), false), "#E2");
2673 			Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (InheritAttribute), true), "#E3");
2674 			Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (NotInheritAttribute), true), "#E4");
2675 
2676 			Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (InheritAttribute), false), "#F1");
2677 			Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (NotInheritAttribute), false), "#F2");
2678 			Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (InheritAttribute), true), "#F3");
2679 			Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (NotInheritAttribute), true), "#F4");
2680 
2681 			Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (InheritAttribute), false), "#G1");
2682 			Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (NotInheritAttribute), false), "#G2");
2683 			Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (InheritAttribute), true), "#G3");
2684 			Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (NotInheritAttribute), true), "#G4");
2685 
2686 			Assert.IsTrue (typeof (bug82431B1).IsDefined (typeof (InheritAttribute), false), "#H1");
2687 			Assert.IsFalse (typeof (bug82431B1).IsDefined (typeof (NotInheritAttribute), false), "#H2");
2688 			Assert.IsTrue (typeof (bug82431B1).IsDefined (typeof (InheritAttribute), true), "#H3");
2689 			Assert.IsFalse (typeof (bug82431B1).IsDefined (typeof (NotInheritAttribute), true), "#H4");
2690 
2691 			Assert.IsFalse (typeof (bug82431B2).IsDefined (typeof (InheritAttribute), false), "#I1");
2692 			Assert.IsFalse (typeof (bug82431B2).IsDefined (typeof (NotInheritAttribute), false), "#I2");
2693 			Assert.IsTrue (typeof (bug82431B2).IsDefined (typeof (InheritAttribute), true), "#I3");
2694 			Assert.IsFalse (typeof (bug82431B2).IsDefined (typeof (NotInheritAttribute), true), "#I4");
2695 
2696 			Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (InheritAttribute), false), "#J1");
2697 			Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (NotInheritAttribute), false), "#J2");
2698 			Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (InheritAttribute), true), "#J3");
2699 			Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (NotInheritAttribute), true), "#J4");
2700 
2701 			Assert.IsFalse (typeof (bug82431B4).IsDefined (typeof (InheritAttribute), false), "#K2");
2702 			Assert.IsFalse (typeof (bug82431B4).IsDefined (typeof (NotInheritAttribute), false), "#K2");
2703 			Assert.IsTrue (typeof (bug82431B4).IsDefined (typeof (InheritAttribute), true), "#K3");
2704 			Assert.IsFalse (typeof (bug82431B4).IsDefined (typeof (NotInheritAttribute), true), "#K4");
2705 		}
2706 
2707 		class Bug13767Attribute : Attribute
2708 		{
2709 			public object[] field;
2710 
Bug13767Attribute(params object[] args)2711 			public Bug13767Attribute (params object[] args)
2712 			{
2713 				field = args;
2714 			}
2715 		}
2716 
2717 		public enum Bug13767Enum
2718 		{
2719 			Value0,
2720 			Value1,
2721 		}
2722 
2723 		[Bug13767("Demo", new[] { Bug13767Enum.Value1, Bug13767Enum.Value0 })]
Bug13767Method(string attributeName, Bug13767Enum[]options)2724 		public void Bug13767Method(string attributeName, Bug13767Enum[]options)
2725 		{
2726 
2727 		}
2728 
2729 		[Test] //Bug 13767
CustomAttributeWithNestedArrayOfEnum()2730 		public void CustomAttributeWithNestedArrayOfEnum ()
2731 		{
2732 			var m = GetType ().GetMethod ("Bug13767Method");
2733 
2734 			var attr = m.GetCustomAttributes (false);
2735 			Assert.AreEqual (1, attr.Length, "#1");
2736 
2737 			var tc = (Bug13767Attribute)attr[0];
2738 			Assert.AreEqual (2, tc.field.Length, "#2");
2739 			Assert.AreEqual ("Demo", tc.field[0], "#3");
2740 			Assert.IsNotNull (tc.field[1], "#4");
2741 
2742 			var arr = (Bug13767Enum[])tc.field [1];
2743 			Assert.AreEqual (2, arr.Length, "#5");
2744 			Assert.AreEqual (Bug13767Enum.Value1, arr [0], "#6");
2745 			Assert.AreEqual (Bug13767Enum.Value0, arr [1], "#7");
2746 		}
2747 
2748 		[Test] // GetType (String)
GetType1_TypeName_Null()2749 		public void GetType1_TypeName_Null ()
2750 		{
2751 			try {
2752 				Type.GetType ((string) null);
2753 				Assert.Fail ("#1");
2754 			} catch (ArgumentNullException ex) {
2755 				Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2756 				Assert.IsNull (ex.InnerException, "#3");
2757 				Assert.IsNotNull (ex.Message, "#4");
2758 				Assert.AreEqual ("TypeName", ex.ParamName, "#5");
2759 			}
2760 		}
2761 
2762 		[Test] // GetType (String, Boolean)
GetType2_TypeName_Null()2763 		public void GetType2_TypeName_Null ()
2764 		{
2765 			try {
2766 				Type.GetType ((string) null, false);
2767 				Assert.Fail ("#1");
2768 			} catch (ArgumentNullException ex) {
2769 				Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2770 				Assert.IsNull (ex.InnerException, "#3");
2771 				Assert.IsNotNull (ex.Message, "#4");
2772 				Assert.AreEqual ("TypeName", ex.ParamName, "#5");
2773 			}
2774 		}
2775 
2776 		[Test] // GetType (String, Boolean, Boolean)
GetType3_TypeName_Null()2777 		public void GetType3_TypeName_Null ()
2778 		{
2779 			try {
2780 				Type.GetType ((string) null, false, false);
2781 				Assert.Fail ("#1");
2782 			} catch (ArgumentNullException ex) {
2783 				Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2784 				Assert.IsNull (ex.InnerException, "#3");
2785 				Assert.IsNotNull (ex.Message, "#4");
2786 				Assert.AreEqual ("TypeName", ex.ParamName, "#5");
2787 			}
2788 		}
2789 
2790 		[Test]
GetType1_TypeName_Empty_nothrow()2791 		public void GetType1_TypeName_Empty_nothrow ()
2792 		{
2793 			var t = Type.GetType ("");
2794 			Assert.IsNull (t);
2795 		}
2796 
2797 		[Test]
2798 		[ExpectedException (typeof (TypeLoadException))]
GetType2_TypeName_Empty()2799 		public void GetType2_TypeName_Empty ()
2800 		{
2801 			Type.GetType ("", true);
2802 		}
2803 
2804 		[Test]
GetType2_TypeName_Empty_nothrow()2805 		public void GetType2_TypeName_Empty_nothrow ()
2806 		{
2807 			var t = Type.GetType ("", false);
2808 			Assert.IsNull (t);
2809 		}
2810 
2811 		[Test]
2812 		[ExpectedException (typeof (TypeLoadException))]
GetType3_TypeName_Empty()2813 		public void GetType3_TypeName_Empty ()
2814 		{
2815 			Type.GetType ("", true, false);
2816 		}
2817 
2818 		[Test]
GetType3_TypeName_Empty_nothrow()2819 		public void GetType3_TypeName_Empty_nothrow ()
2820 		{
2821 			var t = Type.GetType ("", false, false);
2822 			Assert.IsNull (t);
2823 		}
2824 
2825 		[Test]
GetTypeArray_Args_Null()2826 		public void GetTypeArray_Args_Null ()
2827 		{
2828 			try {
2829 				Type.GetTypeArray ((object []) null);
2830 				Assert.Fail ("#1");
2831 			} catch (ArgumentNullException ex) {
2832 				Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2833 				Assert.IsNull (ex.InnerException, "#3");
2834 				Assert.IsNotNull (ex.Message, "#4");
2835 				Assert.AreEqual ("args", ex.ParamName, "#5");
2836 			}
2837 		}
2838 
2839 		[Test]
GetTypeCode()2840 		public void GetTypeCode ()
2841 		{
2842 			Assert.AreEqual (TypeCode.Boolean, Type.GetTypeCode (typeof (bool)), "#1");
2843 			Assert.AreEqual (TypeCode.Byte, Type.GetTypeCode (typeof (byte)), "#2");
2844 			Assert.AreEqual (TypeCode.Char, Type.GetTypeCode (typeof (char)), "#3");
2845 			Assert.AreEqual (TypeCode.DateTime, Type.GetTypeCode (typeof (DateTime)), "#4");
2846 			Assert.AreEqual (TypeCode.DBNull, Type.GetTypeCode (typeof (DBNull)), "#5");
2847 			Assert.AreEqual (TypeCode.Decimal, Type.GetTypeCode (typeof (decimal)), "#6");
2848 			Assert.AreEqual (TypeCode.Double, Type.GetTypeCode (typeof (double)), "#7");
2849 			Assert.AreEqual (TypeCode.Empty, Type.GetTypeCode (null), "#8");
2850 			Assert.AreEqual (TypeCode.Int16, Type.GetTypeCode (typeof (short)), "#9");
2851 			Assert.AreEqual (TypeCode.Int32, Type.GetTypeCode (typeof (int)), "#10");
2852 			Assert.AreEqual (TypeCode.Int64, Type.GetTypeCode (typeof (long)), "#11");
2853 			Assert.AreEqual (TypeCode.Object, Type.GetTypeCode (typeof (TakesInt)), "#12");
2854 			Assert.AreEqual (TypeCode.SByte, Type.GetTypeCode (typeof (sbyte)), "#13");
2855 			Assert.AreEqual (TypeCode.Single, Type.GetTypeCode (typeof (float)), "#14");
2856 			Assert.AreEqual (TypeCode.String, Type.GetTypeCode (typeof (string)), "#15");
2857 			Assert.AreEqual (TypeCode.UInt16, Type.GetTypeCode (typeof (ushort)), "#16");
2858 			Assert.AreEqual (TypeCode.UInt32, Type.GetTypeCode (typeof (uint)), "#17");
2859 			Assert.AreEqual (TypeCode.UInt64, Type.GetTypeCode (typeof (ulong)), "#18");
2860 		}
2861 
2862 		[Test]
GetTypeFromHandle_Handle_Zero()2863 		public void GetTypeFromHandle_Handle_Zero ()
2864 		{
2865 			RuntimeTypeHandle handle = new RuntimeTypeHandle ();
2866 
2867 			Assert.IsNull (Type.GetTypeFromHandle (handle));
2868 		}
2869 
2870 		[Test]
GetTypeHandle_O_Null()2871 		public void GetTypeHandle_O_Null ()
2872 		{
2873 			try {
2874 				Type.GetTypeHandle (null);
2875 				Assert.Fail ("#1");
2876 			} catch (ArgumentNullException ex) {
2877 				Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2878 				Assert.IsNull (ex.InnerException, "#3");
2879 				Assert.IsNotNull (ex.Message, "#4");
2880 				Assert.IsNull (ex.ParamName, "#5");
2881 			}
2882 		}
2883 
2884 		[Test] // GetConstructor (Type [])
GetConstructor1()2885 		public void GetConstructor1 ()
2886 		{
2887 			Type type;
2888 			ConstructorInfo ctor;
2889 
2890 			type = typeof (CtorsA);
2891 			ctor = type.GetConstructor (Type.EmptyTypes);
2892 			Assert.IsNotNull (ctor, "#A1");
2893 			Assert.AreEqual (0, ctor.GetParameters ().Length, "#A2");
2894 			Assert.IsFalse (ctor.IsStatic, "#A3");
2895 			Assert.IsTrue (ctor.IsPublic, "#A4");
2896 			Assert.AreEqual (".ctor", ctor.Name, "#A5");
2897 
2898 			type = typeof (CtorsB);
2899 			ctor = type.GetConstructor (Type.EmptyTypes);
2900 			Assert.IsNotNull (ctor, "#B1");
2901 			Assert.AreEqual (0, ctor.GetParameters ().Length, "#B2");
2902 			Assert.IsFalse (ctor.IsStatic, "#B3");
2903 			Assert.IsTrue (ctor.IsPublic, "#B4");
2904 			Assert.AreEqual (".ctor", ctor.Name, "#B5");
2905 
2906 			type = typeof (CtorsC);
2907 			ctor = type.GetConstructor (Type.EmptyTypes);
2908 			Assert.IsNull (ctor, "#C");
2909 
2910 			type = typeof (CtorsC);
2911 			ctor = type.GetConstructor (new Type [] { typeof (int) });
2912 			Assert.IsNotNull (ctor, "#D1");
2913 			Assert.AreEqual (1, ctor.GetParameters ().Length, "#D2");
2914 			Assert.IsFalse (ctor.IsStatic, "#D3");
2915 			Assert.IsTrue (ctor.IsPublic, "#D4");
2916 			Assert.AreEqual (".ctor", ctor.Name, "#D5");
2917 		}
2918 
2919 		[Test] // GetConstructor (Type [])
GetConstructor1_Types_Null()2920 		public void GetConstructor1_Types_Null ()
2921 		{
2922 			try {
2923 				typeof (BindingFlags).GetConstructor (null);
2924 				Assert.Fail ("#1");
2925 			} catch (ArgumentNullException ex) {
2926 				Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2927 				Assert.IsNull (ex.InnerException, "#3");
2928 				Assert.IsNotNull (ex.Message, "#4");
2929 				Assert.IsNotNull (ex.ParamName, "#5");
2930 				Assert.AreEqual ("types", ex.ParamName, "#6");
2931 			}
2932 		}
2933 
2934 		[Test] // GetConstructor (Type [])
GetConstructor1_Types_ItemNull()2935 		public void GetConstructor1_Types_ItemNull ()
2936 		{
2937 			Type type = typeof (BindingFlags);
2938 			try {
2939 				type.GetConstructor (new Type[1] { null });
2940 				Assert.Fail ("#A1");
2941 			} catch (ArgumentNullException ex) {
2942 				Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
2943 				Assert.IsNull (ex.InnerException, "#A3");
2944 				Assert.IsNotNull (ex.Message, "#A4");
2945 				Assert.IsNotNull (ex.ParamName, "#A5");
2946 				Assert.AreEqual ("types", ex.ParamName, "#A6");
2947 			}
2948 
2949 			type = typeof (TakesInt);
2950 			try {
2951 				type.GetConstructor (new Type [1] { null });
2952 				Assert.Fail ("#B1");
2953 			} catch (ArgumentNullException ex) {
2954 				Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
2955 				Assert.IsNull (ex.InnerException, "#B3");
2956 				Assert.IsNotNull (ex.Message, "#B4");
2957 				Assert.IsNotNull (ex.ParamName, "#B5");
2958 				Assert.AreEqual ("types", ex.ParamName, "#B6");
2959 			}
2960 		}
2961 
2962 		[Test] // GetConstructor (BindingFlags, Binder, Type [], ParameterModifier [])
GetConstructor2_Types_ItemNull()2963 		public void GetConstructor2_Types_ItemNull ()
2964 		{
2965 			Type type = typeof (BindingFlags);
2966 			try {
2967 				type.GetConstructor (BindingFlags.Default, null,
2968 					new Type[1] { null }, null);
2969 				Assert.Fail ("#1");
2970 			} catch (ArgumentNullException ex) {
2971 				Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2972 				Assert.IsNull (ex.InnerException, "#3");
2973 				Assert.IsNotNull (ex.Message, "#4");
2974 				Assert.IsNotNull (ex.ParamName, "#5");
2975 				Assert.AreEqual ("types", ex.ParamName, "#6");
2976 			}
2977 		}
2978 
2979 		[Test] // GetConstructor (BindingFlags, Binder, CallingConventions, Type [], ParameterModifier [])
GetConstructor3_Types_ItemNull()2980 		public void GetConstructor3_Types_ItemNull ()
2981 		{
2982 			Type type = typeof (BindingFlags);
2983 			try {
2984 				type.GetConstructor (BindingFlags.Default,
2985 					null, CallingConventions.Any,
2986 					new Type[1] { null }, null);
2987 				Assert.Fail ("#1");
2988 			} catch (ArgumentNullException ex) {
2989 				Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2990 				Assert.IsNull (ex.InnerException, "#3");
2991 				Assert.IsNotNull (ex.Message, "#4");
2992 				Assert.IsNotNull (ex.ParamName, "#5");
2993 				Assert.AreEqual ("types", ex.ParamName, "#6");
2994 			}
2995 		}
2996 
2997 		[Test]
GetMethod_Bug77367()2998 		public void GetMethod_Bug77367 ()
2999 		{
3000 			MethodInfo i = typeof (Bug77367).GetMethod ("Run", Type.EmptyTypes);
3001 			Assert.IsNull (i);
3002 		}
3003 
3004 #if !MOBILE
3005 		[Test]
EqualsUnderlyingType()3006 		public void EqualsUnderlyingType ()
3007 		{
3008 			AssemblyBuilderAccess access = AssemblyBuilderAccess.RunAndSave;
3009 			TypeAttributes attribs = TypeAttributes.Public;
3010 
3011 			AssemblyName name = new AssemblyName ();
3012 			name.Name = "enumtest";
3013 			AssemblyBuilder assembly =
3014 				AppDomain.CurrentDomain.DefineDynamicAssembly (
3015 					name, access);
3016 
3017 			ModuleBuilder module = assembly.DefineDynamicModule
3018 				("m", "enumtest.dll");
3019 			EnumBuilder e = module.DefineEnum ("E", attribs, typeof (int));
3020 
3021 			Assert.IsTrue (typeof (int).Equals (e));
3022 		}
3023 #endif
3024 
3025 		[Test]
Equals_Type_Null()3026 		public void Equals_Type_Null ()
3027 		{
3028 			Assert.IsFalse (typeof (int).Equals ((Type) null), "#1");
3029 			Assert.IsFalse (typeof (int).Equals ((object) null), "#2");
3030 		}
3031 
3032 		[Test]
GetElementType_Bug63841()3033 		public void GetElementType_Bug63841 ()
3034 		{
3035 			Assert.IsNull (typeof (TheEnum).GetElementType (), "#1");
3036 		}
3037 
3038 		[Test]
FullNameGenerics()3039 		public void FullNameGenerics ()
3040 		{
3041 			Type fooType = typeof (Foo<>);
3042 			FieldInfo [] fields = fooType.GetFields ();
3043 
3044 			Assert.AreEqual (1, fields.Length, "#0");
3045 
3046 			Assert.IsNotNull (fooType.FullName, "#1");
3047 			Assert.IsNotNull (fooType.AssemblyQualifiedName, "#1a");
3048 
3049 			FieldInfo field = fooType.GetField ("Whatever");
3050 			Assert.IsNotNull (field, "#2");
3051 			Assert.AreEqual (field, fields [0], "#2a");
3052 			Assert.IsNull (field.FieldType.FullName, "#3");
3053 			Assert.IsNull (field.FieldType.AssemblyQualifiedName, "#3a");
3054 			Assert.IsNotNull (field.FieldType.ToString (), "#4");
3055 
3056 			PropertyInfo prop = fooType.GetProperty ("Test");
3057 			Assert.IsNotNull (prop, "#5");
3058 			Assert.IsNull (prop.PropertyType.FullName, "#6");
3059 			Assert.IsNull (prop.PropertyType.AssemblyQualifiedName, "#6a");
3060 			Assert.IsNotNull (prop.PropertyType.ToString (), "#7");
3061 
3062 			MethodInfo method = fooType.GetMethod("Execute");
3063 			Assert.IsNotNull (method, "#8");
3064 			Assert.IsNull (method.ReturnType.FullName, "#9");
3065 			Assert.IsNull (method.ReturnType.AssemblyQualifiedName, "#9a");
3066 			Assert.IsNotNull (method.ReturnType.ToString (), "#10");
3067 
3068 			ParameterInfo[] parameters = method.GetParameters();
3069 			Assert.AreEqual (1, parameters.Length, "#11");
3070 			Assert.IsNull (parameters[0].ParameterType.FullName, "#12");
3071 			Assert.IsNull (parameters[0].ParameterType.AssemblyQualifiedName, "#12a");
3072 			Assert.IsNotNull (parameters[0].ParameterType.ToString (), "#13");
3073 		}
3074 
3075 		[Test]
TypeParameterIsNotGeneric()3076 		public void TypeParameterIsNotGeneric ()
3077 		{
3078 			Type fooType = typeof (Foo<>);
3079 			Type type_param = fooType.GetGenericArguments () [0];
3080 			Assert.IsTrue (type_param.IsGenericParameter);
3081 			Assert.IsFalse (type_param.IsGenericType);
3082 			Assert.IsFalse (type_param.IsGenericTypeDefinition);
3083 
3084 			// LAMESPEC: MSDN claims that this should be false, but .NET v2.0.50727 says it's true
3085 			// http://msdn2.microsoft.com/en-us/library/system.type.isgenerictype.aspx
3086 			Assert.IsTrue (type_param.ContainsGenericParameters);
3087 		}
3088 
3089 		[Test]
IsAssignable()3090 		public void IsAssignable ()
3091 		{
3092 			Type foo_type = typeof (Foo<>);
3093 			Type foo_int_type = typeof (Foo<int>);
3094 			Assert.IsFalse (foo_type.IsAssignableFrom (foo_int_type), "Foo<int> -!-> Foo<>");
3095 			Assert.IsFalse (foo_int_type.IsAssignableFrom (foo_type), "Foo<> -!-> Foo<int>");
3096 
3097 			Type ibar_short_type = typeof (IBar<short>);
3098 			Type ibar_int_type = typeof (IBar<int>);
3099 			Type baz_short_type = typeof (Baz<short>);
3100 			Type baz_int_type = typeof (Baz<int>);
3101 
3102 			Assert.IsTrue (ibar_int_type.IsAssignableFrom (baz_int_type), "Baz<int> -> IBar<int>");
3103 			Assert.IsTrue (ibar_short_type.IsAssignableFrom (baz_short_type), "Baz<short> -> IBar<short>");
3104 
3105 			Assert.IsFalse (ibar_int_type.IsAssignableFrom (baz_short_type), "Baz<short> -!-> IBar<int>");
3106 			Assert.IsFalse (ibar_short_type.IsAssignableFrom (baz_int_type), "Baz<int> -!-> IBar<short>");
3107 
3108 			// Nullable tests
3109 			Assert.IsTrue (typeof (Nullable<int>).IsAssignableFrom (typeof (int)));
3110 			Assert.IsFalse (typeof (int).IsAssignableFrom (typeof (Nullable<int>)));
3111 			Assert.IsTrue (typeof (Nullable<FooStruct>).IsAssignableFrom (typeof (FooStruct)));
3112 		}
3113 
3114 		[Test]
IsInstanceOf()3115 		public void IsInstanceOf ()
3116 		{
3117 			Assert.IsTrue (typeof (Nullable<int>).IsInstanceOfType (5));
3118 		}
3119 
3120 		[Test]
IsInstanceOfArrayOfNullable()3121 		public void IsInstanceOfArrayOfNullable ()
3122 		{
3123 			Assert.IsTrue (typeof (Nullable<int>[]).IsInstanceOfType (new Nullable<int> [0]));
3124 		}
3125 
3126 		[Test]
IsInstanceOfType_Null()3127 		public void IsInstanceOfType_Null ()
3128 		{
3129 			Assert.IsFalse (typeof (int).IsInstanceOfType (null), "int");
3130 			Assert.IsFalse (typeof (object).IsInstanceOfType (null), "object");
3131 			Assert.IsFalse (typeof (int?).IsInstanceOfType (null), "int?");
3132 		}
3133 
3134 		[Test]
ByrefType()3135 		public void ByrefType ()
3136 		{
3137 			Type foo_type = typeof (Foo<>);
3138 			Type type_param = foo_type.GetGenericArguments () [0];
3139 			Type byref_type_param = type_param.MakeByRefType ();
3140 			Assert.IsFalse (byref_type_param.IsGenericParameter);
3141 			Assert.IsNull (byref_type_param.DeclaringType);
3142 		}
3143 
3144 		[Test]
3145 		[ExpectedException (typeof (TypeLoadException))]
MakeByRefByRef()3146 		public void MakeByRefByRef ()
3147 		{
3148 			typeof (int).MakeByRefType ().MakeByRefType ();
3149 		}
3150 
3151 		[Test]
MakeArrayTypeTest()3152 		public void MakeArrayTypeTest ()
3153 		{
3154 			// This should not crash:
3155 			Type t = typeof (void).MakeArrayType ();
3156 		}
3157 
3158 		[Test]
3159 		[ExpectedException (typeof (InvalidProgramException))]
MakeArrayTypedReferenceInstanceTest()3160 		public void MakeArrayTypedReferenceInstanceTest ()
3161 		{
3162 			object o = Array.CreateInstance (typeof (global::System.TypedReference), 1);
3163 		}
3164 
3165 		[Test]
MakeArrayTypeLargeRank()3166 		public void MakeArrayTypeLargeRank ()
3167 		{
3168 			Assert.Throws<TypeLoadException> (delegate () {
3169 					typeof (int).MakeArrayType (33);
3170 				});
3171 		}
3172 
3173 		[ComVisible (true)]
3174 		public class ComFoo<T> {
3175 		}
3176 
3177 		[Test]
GetCustomAttributesGenericInstance()3178 		public void GetCustomAttributesGenericInstance ()
3179 		{
3180 			Assert.AreEqual (1, typeof (ComFoo<int>).GetCustomAttributes (typeof (ComVisibleAttribute), true).Length);
3181 		}
3182 
f(ref T t)3183 		interface ByRef1<T> { void f (ref T t); }
f(ref T t)3184 		interface ByRef2 { void f<T> (ref T t); }
3185 
3186 		interface ByRef3<T> where T:struct { void f (ref T? t); }
3187 		interface ByRef4 { void f<T> (ref T? t) where T:struct; }
3188 
CheckGenericByRef(Type t)3189 		void CheckGenericByRef (Type t)
3190 		{
3191 			string name = t.Name;
3192 			t = t.GetMethod ("f").GetParameters () [0].ParameterType;
3193 
3194 			Assert.IsFalse (t.IsGenericType, name);
3195 			Assert.IsFalse (t.IsGenericTypeDefinition, name);
3196 			Assert.IsFalse (t.IsGenericParameter, name);
3197 		}
3198 
3199 		[Test]
GenericByRef()3200 		public void GenericByRef ()
3201 		{
3202 			CheckGenericByRef (typeof (ByRef1<>));
3203 			CheckGenericByRef (typeof (ByRef2));
3204 			CheckGenericByRef (typeof (ByRef3<>));
3205 			CheckGenericByRef (typeof (ByRef4));
3206 		}
3207 
3208 		public class Bug80242<T> {
3209 			public interface IFoo { }
3210 			public class Bar : IFoo { }
3211 			public class Baz : Bar { }
3212 		}
3213 
3214 		[Test]
TestNestedTypes()3215 		public void TestNestedTypes ()
3216 		{
3217 			Type t = typeof (Bug80242<object>);
3218 			Assert.IsFalse (t.IsGenericTypeDefinition);
3219 			foreach (Type u in t.GetNestedTypes ()) {
3220 				Assert.IsTrue (u.IsGenericTypeDefinition, "{0} isn't a generic definition", u);
3221 				Assert.AreEqual (u, u.GetGenericArguments () [0].DeclaringType);
3222 			}
3223 		}
3224 
3225 		[Test] // bug #82211
GetMembers_GenericArgument()3226 		public void GetMembers_GenericArgument ()
3227 		{
3228 			Type argType = typeof (ComFoo<>).GetGenericArguments () [0];
3229 			MemberInfo [] members = argType.GetMembers ();
3230 			Assert.IsNotNull (members, "#1");
3231 			Assert.AreEqual (4, members.Length, "#2");
3232 		}
3233 
3234 		[Test]
3235 		[ExpectedException (typeof (ArgumentNullException))]
ReflectionOnlyGetTypeNullTypeName()3236 		public void ReflectionOnlyGetTypeNullTypeName ()
3237 		{
3238 			Type.ReflectionOnlyGetType (null, false, false);
3239 		}
3240 
3241 		[Test]
ReflectionOnlyGetTypeDoNotThrow()3242 		public void ReflectionOnlyGetTypeDoNotThrow ()
3243 		{
3244 			Assert.IsNull (Type.ReflectionOnlyGetType ("a, nonexistent.dll", false, false));
3245 		}
3246 
3247 		[Test]
3248 		[ExpectedException (typeof (FileNotFoundException))]
ReflectionOnlyGetTypeThrow()3249 		public void ReflectionOnlyGetTypeThrow ()
3250 		{
3251 			Type.ReflectionOnlyGetType ("a, nonexistent.dll", true, false);
3252 		}
3253 
3254 		[Test]
ReflectionOnlyGetType()3255 		public void ReflectionOnlyGetType ()
3256 		{
3257 			Type t = Type.ReflectionOnlyGetType (typeof (int).AssemblyQualifiedName.ToString (), true, true);
3258 			Assert.AreEqual ("System.Int32", t.FullName);
3259 		}
3260 
3261 		[Test]
3262 #if MONOTOUCH || FULL_AOT_RUNTIME
3263 		[ExpectedException (typeof (NotSupportedException))]
3264 #endif
MakeGenericType_UserDefinedType()3265 		public void MakeGenericType_UserDefinedType ()
3266 		{
3267 			Type ut = new UserType (typeof (int));
3268 			Type t = typeof (Foo<>).MakeGenericType (ut);
3269 			Assert.IsTrue (t.IsGenericType, "#A1");
3270 			Assert.AreEqual (1, t.GetGenericArguments ().Length, "#A2");
3271 
3272 			Type arg = t.GetGenericArguments () [0];
3273 			Assert.IsNotNull (arg, "#B1");
3274 			Assert.IsFalse (arg.IsGenericType, "#B2");
3275 			Assert.AreEqual (ut, arg, "#B3");
3276 		}
3277 
3278 		[Test]
3279 #if MONOTOUCH || FULL_AOT_RUNTIME
3280 		[ExpectedException (typeof (NotSupportedException))]
3281 #endif
MakeGenericType_NestedUserDefinedType()3282 		public void MakeGenericType_NestedUserDefinedType ()
3283 		{
3284 			Type ut = new UserType (new UserType (typeof (int)));
3285 			Type t = typeof (Foo<>).MakeGenericType (ut);
3286 			Assert.IsTrue (t.IsGenericType, "#A1");
3287 			Assert.AreEqual (1, t.GetGenericArguments ().Length, "#A2");
3288 
3289 			Type arg = t.GetGenericArguments () [0];
3290 			Assert.IsNotNull (arg, "#B1");
3291 			Assert.IsFalse (arg.IsGenericType, "#B2");
3292 			Assert.AreEqual (ut, arg, "#B3");
3293 		}
3294 
3295 		[Test]
3296 #if MONOTOUCH || FULL_AOT_RUNTIME
3297 		[ExpectedException (typeof (NotSupportedException))]
3298 #endif
TestMakeGenericType_UserDefinedType_DotNet20SP1()3299 		public void TestMakeGenericType_UserDefinedType_DotNet20SP1 ()
3300 		{
3301 			Type ut = new UserType(typeof(int));
3302 			Type t = typeof(Foo<>).MakeGenericType(ut);
3303 			Assert.IsTrue (t.IsGenericType, "#1");
3304 
3305 			Assert.AreEqual (ut, t.GetGenericArguments()[0], "#2");
3306 		}
3307 
3308 		[Test]
3309 #if MONOTOUCH || FULL_AOT_RUNTIME
3310 		[ExpectedException (typeof (NotSupportedException))]
3311 #endif
MakeGenericType_BadUserType()3312 		public void MakeGenericType_BadUserType ()
3313 		{
3314 			Type ut = new UserType (null);
3315 			Type t = typeof (Foo<>).MakeGenericType (ut);
3316 			var g0 = t.GetGenericArguments () [0];
3317 			Assert.AreSame (g0, ut, "#1");
3318 		}
3319 
3320 		[Test]
MakeGenericType_WrongNumOfArguments()3321 		public void MakeGenericType_WrongNumOfArguments ()
3322 		{
3323 			try {
3324 				Type t = typeof (Foo<,>).MakeGenericType (new Type [] { typeof (int) });
3325 				Assert.Fail ("#1");
3326 			} catch (ArgumentException) {
3327 			}
3328 		}
3329 
3330 		[AttributeUsage (AttributeTargets.All)]
3331 		public class DocAttribute : Attribute {
DocAttribute(string docs)3332 			public DocAttribute (string docs) {}
3333 		}
3334 
3335 		class GenericClassWithAttributes<[Doc ("T")] T, [Doc ("B")] B>
3336 			where T : class, new ()
3337 			where B : Attribute
3338 		{
3339 			public T Bar { get{return null;}}
3340 
M(X x)3341 			public void M<[Doc ("X")] X> (X x)
3342 			{
3343 			}
3344 		}
3345 
3346 		[Test] //bug #377596
GetGenericArguments_ArgumentsHaveAttributes()3347 		public void GetGenericArguments_ArgumentsHaveAttributes ()
3348 		{
3349 			Type type = typeof(GenericClassWithAttributes<,>);
3350 			Type[] tArgs = type.GetGenericArguments ();
3351 			MethodInfo m = type.GetMethod ("M");
3352 			Type[] mArgs = m.GetGenericArguments ();
3353 			Assert.AreEqual(1, tArgs[0].GetCustomAttributes (typeof (DocAttribute), true).Length, "#1");
3354 			Assert.AreEqual(1, tArgs[1].GetCustomAttributes (typeof (DocAttribute), true).Length, "#1");
3355 			Assert.AreEqual(1, mArgs[0].GetCustomAttributes (typeof (DocAttribute), true).Length, "#1");
3356 		}
3357 
3358 		[Test] //bug #471255
GetTypeCalledUsingReflection()3359 		public void GetTypeCalledUsingReflection ()
3360 		{
3361 			Type expectedType = Type.GetType ("NoNamespaceClass");
3362 			Assert.IsNotNull (expectedType, "#1");
3363 			MethodInfo m = typeof (Type).GetMethod ("GetType",  BindingFlags.Public | BindingFlags.Static, null, new Type [] { typeof (string) },  null);
3364 			object r = m.Invoke (null, BindingFlags.Default, null, new object [] { "NoNamespaceClass" }, CultureInfo.InvariantCulture);
3365 			Assert.AreSame (expectedType, r, "#2");
3366 		}
3367 
3368 		public class BConstrained<Y> where Y : BConstrained<Y> {
3369 		}
3370 
3371 		public class AConstrained<X> : BConstrained<AConstrained<X>> {
3372 		}
3373 
3374 		[Test] // Bug https://bugzilla.xamarin.com/show_bug.cgi?id=54485
MakeGenericType_GTD_Constraint()3375 		public void MakeGenericType_GTD_Constraint ()
3376 		{
3377 			// This is pretty weird, but match .NET behavior (note
3378 			// that typeof(BConstrained<AConstrained<>>) is a
3379 			// compile-time error with roslyn, but it's apparently
3380 			// an ok thing to make with reflection.
3381 			var tb = typeof (BConstrained<>);
3382 			var ta = typeof (AConstrained<>);
3383 			var result = tb.MakeGenericType (ta);
3384 			Assert.IsNotNull (result, "#1");
3385 			// lock down the answer to match what .NET makes
3386 			Assert.IsTrue (result.IsGenericType, "#2");
3387 			Assert.AreEqual (tb, result.GetGenericTypeDefinition (), "#3");
3388 			var bargs = result.GetGenericArguments ();
3389 			Assert.AreEqual (1, bargs.Length, "#4");
3390 			var arg = bargs [0];
3391 			Assert.IsTrue (arg.IsGenericType, "#5");
3392 			// N.B. evidently AConstrained`1 and AConstrained`1<!0> are the same type
3393 			Assert.IsTrue (arg.IsGenericTypeDefinition, "#6");
3394 			Assert.AreEqual (ta, arg.GetGenericTypeDefinition (), "#7");
3395 			var aargs = arg.GetGenericArguments ();
3396 			Assert.AreEqual (1, aargs.Length, "#8");
3397 			Assert.AreEqual (ta.GetGenericArguments () [0], aargs [0], "#9");
3398 		}
3399 
3400 	[Test]
EqualsUserType()3401 	public void EqualsUserType () {
3402 		UserType2 t1 = new UserType2(null);
3403 		UserType2 t2 = new UserType2(t1);
3404 		Assert.IsTrue (t1.Equals(t2));
3405 	}
3406 
3407 	[Test]
GetHashCodeUserType()3408 	public void GetHashCodeUserType () {
3409 		UserType2 t1 = new UserType2(null);
3410 		UserType2 t2 = new UserType2(t1);
3411 		Assert.AreEqual (42, t2.GetHashCode());
3412 	}
3413 
3414 	[Test]
IsGenericTypeDefinitionUserType()3415 	public void IsGenericTypeDefinitionUserType () {
3416 		Assert.IsFalse (new UserType(null).IsGenericTypeDefinition);
3417 	}
3418 
3419 	[Test]
IsGenericTypeUserType()3420 	public void IsGenericTypeUserType () {
3421 		Assert.IsFalse (new UserType(null).IsGenericType);
3422 	}
3423 
3424 	[Test]
3425 	[ExpectedException (typeof (NotSupportedException))]
GetGenericTypeDefinitionUserType()3426 	public void GetGenericTypeDefinitionUserType () {
3427 		new UserType(null).GetGenericTypeDefinition ();
3428 	}
3429 
3430 	[ExpectedException (typeof (NotSupportedException))]
GetGenericArgumentsUserType()3431 	public void GetGenericArgumentsUserType () {
3432 		new UserType(null).GetGenericArguments ();
3433 	}
3434 
3435 	[Test]
3436 	[ExpectedException (typeof (InvalidOperationException))]
GenericParameterPositionUserType()3437 	public void GenericParameterPositionUserType () {
3438 		Assert.IsTrue (new UserType(null).GenericParameterPosition == 0);
3439 	}
3440 
3441 		[Test]
TypeGetMemberReturnTypeTest()3442 		public void TypeGetMemberReturnTypeTest ()
3443 		{
3444 			object obj;
3445 			MemberTypes memtype;
3446 			Type testtype;
3447 			object [] flagsandtypes = new object [] {
3448 				MemberTypes.All, typeof (MemberInfo []),
3449 				MemberTypes.Constructor, typeof (ConstructorInfo []),
3450 				MemberTypes.Custom, typeof (MemberInfo []),
3451 				MemberTypes.Event, typeof (EventInfo []),
3452 				MemberTypes.Field, typeof (FieldInfo []),
3453 				MemberTypes.Method, typeof (MethodInfo []),
3454 				MemberTypes.NestedType, typeof (Type []),
3455 				MemberTypes.Property, typeof (PropertyInfo []),
3456 				MemberTypes.TypeInfo, typeof (Type [])};
3457 
3458 			for (int i=0; i < flagsandtypes.Length; i+=2) {
3459 				memtype = (MemberTypes)flagsandtypes [i];
3460 				testtype = (Type)flagsandtypes [i+1];
3461 				obj = GetType ().GetMember ("DummyMember", memtype,
3462 						BindingFlags.Public | BindingFlags.Instance);
3463 				Assert.AreEqual (testtype.GetHashCode (), obj.GetType ().GetHashCode (),
3464 						"Expected #" + i + " " + testtype.FullName);
3465 			}
3466 
3467 		}
3468 
3469  		[Test]
TypeNameStartsWithSpace()3470  		public void TypeNameStartsWithSpace ()
3471 		{
3472 			Type t1 = Type.GetType ("System.Type, mscorlib");
3473 			Type t2 = Type.GetType (" System.Type, mscorlib");
3474 			Assert.AreEqual (t1, t2);
3475 		}
3476 
3477 #if !MONOTOUCH && !FULL_AOT_RUNTIME
3478 		[Test]
SpaceAfterComma()3479 		public void SpaceAfterComma () {
3480 			string strType = "System.Collections.Generic.Dictionary`2[[System.Int32,mscorlib], [System.String,mscorlib]],mscorlib";
3481 			Assert.IsTrue (Type.GetType (strType) != null);
3482 		}
3483 #endif
3484 
3485 #if !MONOTOUCH && !FULL_AOT_RUNTIME
3486 		[Test]
Bug506757()3487 		public void Bug506757 ()
3488 		{
3489 			AssemblyName assemblyName = new AssemblyName ();
3490 			assemblyName.Name = "customMod";
3491 			assemblyName.Version = new Version (1, 2, 3, 4);
3492 
3493 			AssemblyBuilder assembly
3494 				= Thread.GetDomain().DefineDynamicAssembly(
3495 					  assemblyName, AssemblyBuilderAccess.RunAndSave);
3496 
3497 			ModuleBuilder module = assembly.DefineDynamicModule("res.exe", "res.exe");
3498 
3499 			TypeBuilder type0 = module.DefineType ("Base", TypeAttributes.Public, typeof (object));
3500 			TypeBuilder type1 = module.DefineType ("Middle", TypeAttributes.Public, type0);
3501 			TypeBuilder type2 = module.DefineType ("End", TypeAttributes.Public, type1);
3502 
3503 			MethodAttributes attrs0 = MethodAttributes.Virtual | MethodAttributes.HideBySig |
3504 						  MethodAttributes.NewSlot | MethodAttributes.FamORAssem;
3505 
3506 			MethodAttributes attrs1 = MethodAttributes.Virtual | MethodAttributes.HideBySig |
3507 						  MethodAttributes.FamORAssem;
3508 
3509 			MethodAttributes attrs2 = MethodAttributes.Virtual | MethodAttributes.HideBySig |
3510 						  MethodAttributes.Public;
3511 
3512 
3513 			MethodBuilder m0 = type0.DefineMethod ("Tst", attrs0, typeof (void), null);
3514 			m0.GetILGenerator ().Emit (OpCodes.Ret);
3515 
3516 			MethodBuilder m1 = type1.DefineMethod ("Tst", attrs1, typeof (void), null);
3517 			m1.GetILGenerator ().Emit (OpCodes.Ret);
3518 
3519 			MethodBuilder m2 = type2.DefineMethod ("Tst", attrs2, typeof (void), null);
3520 			m2.GetILGenerator ().Emit (OpCodes.Ret);
3521 
3522 
3523 			type0.CreateType ();
3524 			type1.CreateType ();
3525 			Type t2 = type2.CreateType ();
3526 
3527 			foreach (var m in t2.GetMethods (BindingFlags.Instance | BindingFlags.NonPublic))
3528 				Assert.IsTrue (m.DeclaringType == typeof (object), String.Format ("{0}::{1}", m.DeclaringType, m.Name));
3529 		}
3530 #endif
3531 		[Test]
MakeArrayTypeOfOneDimension()3532 		public void MakeArrayTypeOfOneDimension ()
3533 		{
3534 			Type vector = typeof (int).MakeArrayType ();
3535 			Type szarray = typeof (int).MakeArrayType (1);
3536 
3537 			Assert.AreNotEqual (vector, szarray, "#1");
3538 			Assert.AreEqual ("Int32[]", vector.Name, "#2");
3539 			Assert.AreEqual ("Int32[*]", szarray.Name, "#3");
3540 		}
3541 
3542 		public class DeclaringMethodFoo {
Test(T t)3543 			public void Test<T> (T t) {}
Test2(ref T t)3544 			public void Test2<T> (ref T t) {}
3545 		}
3546 
3547 		public class DeclaringMethodBar<T> {
Test2(ref T t)3548 			public void Test2 (ref T t) {}
3549 		}
3550 
3551 		[Test]
DeclaringMethodOnlyWorksWithGenericArgs()3552 		public void DeclaringMethodOnlyWorksWithGenericArgs ()
3553 		{
3554 	        MethodInfo testMethod = typeof (DeclaringMethodFoo).GetMethod ("Test");
3555 	        MethodBase otherMethod = testMethod.GetParameters ()[0].ParameterType.DeclaringMethod;
3556 
3557 			Assert.AreEqual (testMethod, otherMethod,"#1");
3558 
3559 			Assert.IsNull (typeof (DeclaringMethodBar<>).GetGenericArguments ()[0].DeclaringMethod, "#2");
3560 
3561 			try {
3562 				var x = typeof (int).DeclaringMethod;
3563 				Assert.Fail ("#3");
3564 			} catch (InvalidOperationException) {}
3565 
3566 			try {
3567 				var x = typeof (DeclaringMethodFoo).GetMethod ("Test2").GetParameters () [0].ParameterType.DeclaringMethod;
3568 				Assert.Fail ("#4");
3569 			} catch (InvalidOperationException) {}
3570 
3571 			try {
3572 				var x = typeof (DeclaringMethodBar<>).GetMethod ("Test2").GetParameters () [0].ParameterType.DeclaringMethod;
3573 				Assert.Fail ("#5");
3574 			} catch (InvalidOperationException) {}
3575 
3576 		}
3577 
3578 		[Test]
GetArrayRankThrowsForNonArrayType()3579 		public void GetArrayRankThrowsForNonArrayType ()
3580 		{
3581 			Assert.AreEqual (1, typeof (int[]).GetArrayRank (), "#1");
3582 			Assert.AreEqual (2, typeof (int[,]).GetArrayRank (), "#2");
3583 			try {
3584 				typeof (int).GetArrayRank ();
3585 				Assert.Fail ("#3");
3586 			} catch (ArgumentException) {}
3587 		}
3588 
3589 		[Test] //Bug #564379
GetMethodsReturnPublicMethodsInInterfaces()3590 		public void GetMethodsReturnPublicMethodsInInterfaces ()
3591 		{
3592 			Type t = typeof (NonClosingStream);
3593 			MethodInfo[] methods = t.GetMethods (BindingFlags.Public | BindingFlags.Instance);
3594 
3595 			Assert.AreEqual (5, methods.Length, "#1");
3596 			int id = 2;
3597 
3598 			foreach (var m in methods) {
3599 				if (m.Name.Equals ("ToString"))
3600 					Assert.IsTrue (m.DeclaringType == typeof (NonClosingStream), "#" + id);
3601 				else if (m.Name.Equals ("Dispose") && m.GetParameters ().Length == 0)
3602 					Assert.IsTrue (m.DeclaringType == typeof (Stream), "#" + id);
3603 				else if (m.Name.Equals ("Equals") || m.Name.Equals ("GetHashCode") || m.Name.Equals ("GetType"))
3604 					Assert.IsTrue (m.DeclaringType == typeof (object), "#" + id);
3605 				else
3606 					Assert.Fail ("invalid method " + m);
3607 				++id;
3608 			}
3609 		}
3610 
3611 		[Test] // Bug #574696
GetMember_DoesntReturnPrivatePropOfParent()3612 		public void GetMember_DoesntReturnPrivatePropOfParent ()
3613 		{
3614 			BindingFlags flags = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance;
3615 			Assert.AreEqual (1, typeof (Bar).GetMember ("PrivInst", flags).Length);
3616 			Assert.AreEqual (0, typeof (Bar).GetMember ("PrivInstBase", flags).Length);
3617 			Assert.AreEqual (1, typeof (Foo).GetMember ("PrivInstBase", flags).Length);
3618 		}
3619 
3620 		[Test] // Bug #484246
GetInterfaceCompareAgainstGTDNames()3621 		public void GetInterfaceCompareAgainstGTDNames ()
3622 		{
3623 			var t = typeof (Dictionary<string,string>);
3624 			var iface = typeof (IDictionary<string,string>);
3625 
3626 			Assert.AreSame (iface, t.GetInterface ("System.Collections.Generic.IDictionary`2"), "#1");
3627 
3628 			string name = "System.Collections.Generic.IDictionary`2[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]";
3629 
3630 			Assert.IsNull (t.GetInterface (name), "#2");
3631 		}
3632 
3633 		[Test]
RuntimeCorrectlyNormalizeGenericTypes()3634 		public void RuntimeCorrectlyNormalizeGenericTypes ()
3635 		{
3636 			Type lst = typeof (MList<>);
3637 			Type arg = lst.GetGenericArguments ()[0];
3638 
3639 			Type sup = lst.BaseType;
3640 			Type sa0 = sup.GetGenericArguments ()[0];
3641 			Type sa1 = sup.GetGenericArguments ()[1];
3642 
3643 			Assert.IsTrue (sa1 == lst, "#1");
3644 			Assert.IsTrue (sa0 == arg, "#2");
3645 
3646 			Type inst = typeof (Cons<,>).MakeGenericType (arg, lst.MakeGenericType (arg));
3647 			Assert.IsTrue (inst == sup, "#3");
3648 		}
3649 
3650 		class Cons<T,U>
3651 		{
3652 
3653 		}
3654 
3655 		class MList<A> : Cons<A, MList<A>>
3656 		{
3657 
3658 		}
3659 
3660 		[Test] // Bug #331126
IsAssignableFromWorksCorrectlyWithByRefs()3661 		public void IsAssignableFromWorksCorrectlyWithByRefs ()
3662 		{
3663 			Type int_byref = typeof (int).MakeByRefType ();
3664 			Type obj_byref = typeof (object).MakeByRefType ();
3665 			Type long_byref = typeof (long).MakeByRefType ();
3666 			Type enum1_byref = typeof (AttributeTargets).MakeByRefType ();
3667 			Type enum2_byref = typeof (PlatformID).MakeByRefType ();
3668 			Type uint_byref = typeof (uint).MakeByRefType ();
3669 			Type string_byref = typeof (object).MakeByRefType ();
3670 			Type struct0_byref = typeof (Size4).MakeByRefType ();
3671 			Type struct1_byref = typeof (Size4b).MakeByRefType ();
3672 			Type mvar0_byref = typeof (TypeTest).GetMethod ("Bug331126").GetGenericArguments ()[0].MakeByRefType ();
3673 			Type mvar1_byref = typeof (TypeTest).GetMethod ("Bug331126").GetGenericArguments ()[1].MakeByRefType ();
3674 
3675 			Assert.IsFalse (typeof (int).IsAssignableFrom (int_byref), "#1");
3676 			Assert.IsFalse (int_byref.IsAssignableFrom (typeof (int)), "#2");
3677 			Assert.IsFalse (obj_byref.IsAssignableFrom (long_byref), "#3");
3678 			Assert.IsFalse (long_byref.IsAssignableFrom (obj_byref), "#4");
3679 			Assert.IsTrue (enum1_byref.IsAssignableFrom (enum2_byref), "#5");
3680 			Assert.IsTrue (enum2_byref.IsAssignableFrom (enum1_byref), "#6");
3681 			Assert.IsTrue (int_byref.IsAssignableFrom (enum2_byref), "#7");
3682 			Assert.IsTrue (enum2_byref.IsAssignableFrom (int_byref), "#8");
3683 			Assert.IsTrue (enum2_byref.IsAssignableFrom (uint_byref), "#9");
3684 			Assert.IsTrue (uint_byref.IsAssignableFrom (enum2_byref), "#10");
3685 			Assert.IsTrue (int_byref.IsAssignableFrom (uint_byref), "#11");
3686 			Assert.IsTrue (uint_byref.IsAssignableFrom (int_byref), "#12");
3687 
3688 			Assert.IsTrue (typeof (object).IsAssignableFrom (typeof (long)), "#13");
3689 
3690 			Assert.IsTrue (obj_byref.IsAssignableFrom (string_byref), "#14");
3691 			Assert.IsTrue (string_byref.IsAssignableFrom (obj_byref), "#15");
3692 
3693 			Assert.IsFalse (uint_byref.IsAssignableFrom (struct0_byref), "#16");
3694 			Assert.IsFalse (struct0_byref.IsAssignableFrom (int_byref), "#17");
3695 			Assert.IsFalse (struct0_byref.IsAssignableFrom (struct1_byref), "#18");
3696 
3697 			Assert.IsFalse (obj_byref.IsAssignableFrom (mvar0_byref), "#19");
3698 			Assert.IsFalse (mvar0_byref.IsAssignableFrom (mvar1_byref), "#20");
3699 			Assert.IsTrue (mvar0_byref.IsAssignableFrom (mvar0_byref), "#21");
3700 			Assert.IsFalse (mvar0_byref.IsAssignableFrom (obj_byref), "#22");
3701 		}
3702 
Bug331126()3703 		public void Bug331126<T,K> () {}
3704 
3705 		public struct Size4 {
3706 			public int field;
3707 		}
3708 
3709 		public struct Size4b {
3710 			public int field;
3711 		}
3712 
3713 		[Test]
IsAssignableFromGenericArgumentsWithConstraints()3714 		public void IsAssignableFromGenericArgumentsWithConstraints ()
3715 		{
3716 			// Regression test for #58809
3717 
3718 			// Generic Parameters of a gtd should have their
3719 			// constraints respected even when those constraints
3720 			// are other generic parameters themselves.
3721 
3722 			var ps = typeof (GenericWithParamConstraints<,,>).GetGenericArguments ();
3723 
3724 			var a = ps[0];
3725 			var b = ps[1];
3726 			var c = ps[2];
3727 
3728 			// Foo<C>
3729 			var fooOfC = typeof (Foo<>).MakeGenericType (c);
3730 
3731 			// constraint B : Foo <C>
3732 			Assert.IsTrue (fooOfC.IsAssignableFrom (b), "#1");
3733 
3734 			// constraint A : B
3735 			Assert.IsTrue (b.IsAssignableFrom (a), "#2");
3736 
3737 			// A : Foo<C> since A : B and B : Foo<C>
3738 			Assert.IsTrue (fooOfC.IsAssignableFrom (a), "#3");
3739 		}
3740 
3741 		class GenericWithParamConstraints<A, B, C> where B : Foo<C> where A : B
3742 		{
3743 		}
3744 
3745 		[Test]
IsAssignableFromArraySpecialInterfaceGtd()3746 		public void IsAssignableFromArraySpecialInterfaceGtd ()
3747 		{
3748 			// Regression test for https://github.com/mono/mono/issues/7095
3749 			// An "array special interface" is a Mono name for some
3750 			// interfaces that are implemented by arrays.
3751 			// Check that an array special interface GTD (ie, IList<> not IList<Foo>) work
3752 			// correctly with IsAssignableFrom.
3753 			var il = typeof (IList<>);
3754 			var ie = typeof (IEnumerable<>);
3755 			var ilparam = il.GetTypeInfo ().GenericTypeParameters [0];
3756 			var ilparr = ilparam.MakeArrayType ();
3757 
3758 			Assert.IsTrue (ie.IsAssignableFrom (ie), "IList<> ---> IEnumerable<>");
3759 			Assert.IsTrue (il.IsAssignableFrom (ilparr), "!0[] ---> IList<>");
3760 
3761 			var ilparrarr = ilparr.MakeArrayType ();
3762 
3763 			Assert.IsFalse (il.IsAssignableFrom (ilparrarr), "!0[][] -!-> IList<>");
3764 
3765 			Assert.IsFalse (il.IsAssignableFrom (typeof (Array)), "System.Array -!-> IList<>");
3766 		}
3767 
3768 		[Test]
IsAssignableFromArrayEnumerator()3769 		public void IsAssignableFromArrayEnumerator ()
3770 		{
3771 			// Regression test for https://github.com/mono/mono/issues/7093
3772 			// An array does not implement IEnumerator`1
3773 
3774 			var arrStr = typeof (string[]);
3775 			var ieStr = typeof (IEnumerator<string>);
3776 			var ieEqStr = typeof (IEnumerator<IEquatable<string>>);
3777 			Assert.IsFalse (ieStr.IsAssignableFrom (arrStr), "string[] -!-> IEnumerator<string>");
3778 			Assert.IsFalse (ieEqStr.IsAssignableFrom (arrStr), "string[] -!-> IEnumerator<IEquatable<string>>");
3779 
3780 			var arrInt = typeof (int[]);
3781 			var ieInt = typeof (IEnumerator<int>);
3782 			var ieEqInt = typeof (IEnumerator<IEquatable<int>>);
3783 			Assert.IsFalse (ieInt.IsAssignableFrom (arrInt), "int[] -!-> IEnumerator<int>");
3784 			Assert.IsFalse (ieEqInt.IsAssignableFrom (arrInt), "int[] -!-> IEnumerator<IEquatable<int>>");
3785 		}
3786 
3787 		[Test] // Bug #612780
CannotMakeDerivedTypesFromTypedByRef()3788 		public void CannotMakeDerivedTypesFromTypedByRef ()
3789 		{
3790 		try {
3791 	        typeof (global::System.TypedReference).MakeArrayType ();
3792 	        Assert.Fail ("#1");
3793 		} catch (TypeLoadException) { }
3794 
3795 		try {
3796 	        typeof (global::System.TypedReference).MakeByRefType ();
3797 	        Assert.Fail ("#2");
3798 		} catch (TypeLoadException) { }
3799 
3800 		try {
3801 	        typeof (global::System.TypedReference).MakePointerType ();
3802 	        Assert.Fail ("#3");
3803 		} catch (TypeLoadException) { }
3804 
3805 		}
3806 
3807 		[Test] //Bug643890
DeclaringTypeOfGenericNestedTypeInstanceIsOpen()3808 		public void DeclaringTypeOfGenericNestedTypeInstanceIsOpen ()
3809 		{
3810 			var type = typeof (Foo<int>.Nested<string>);
3811 			Assert.AreSame (typeof (Foo<>), type.DeclaringType, "#1");
3812 		}
3813 
3814 		interface IGetInterfaceMap<in T>
3815 		{
Bar(T t)3816 		    string Bar (T t);
3817 		}
3818 
3819 		class GetInterfaceMap : IGetInterfaceMap<object>
3820 		{
Bar(object t)3821 		    public string Bar (object t)
3822 		    {
3823 		        return t.GetType ().FullName;
3824 		    }
3825 		}
3826 
3827 		[Test]
GetInterfaceMapWorksWithVariantIfaces()3828 		public void GetInterfaceMapWorksWithVariantIfaces ()
3829 		{
3830 			InterfaceMapping res = typeof (GetInterfaceMap).GetInterfaceMap (typeof (IGetInterfaceMap <object>));
3831 			Assert.AreEqual (typeof (IGetInterfaceMap <object>), res.InterfaceType);
3832 			Assert.AreEqual (typeof (object), res.InterfaceMethods [0].GetParameters () [0].ParameterType);
3833 
3834 			res = typeof (GetInterfaceMap).GetInterfaceMap (typeof (IGetInterfaceMap <string>));
3835 			Assert.AreEqual (typeof (IGetInterfaceMap <string>), res.InterfaceType);
3836 			Assert.AreEqual (typeof (string), res.InterfaceMethods [0].GetParameters () [0].ParameterType);
3837 		}
3838 
3839 
3840 		public class MyType : TypeDelegator {
3841 			public int eq, ust;
3842 
Equals(Type t)3843 			public override bool Equals (Type t) {
3844 				++eq;
3845 				return base.Equals (t);
3846 			}
3847 
3848 			public override Type UnderlyingSystemType  {
3849 				get {
3850 					++ust;
3851 					return typeof (int);
3852 				}
3853 			}
3854 		}
3855 
3856 		[Test]
NewV4EqualsBehavior()3857 		public void NewV4EqualsBehavior ()
3858 		{
3859 			var ta = new MyType ();
3860 			var tb = new MyType ();
3861 			object a = ta, b = tb;
3862 
3863 			a.Equals (a);
3864 			Assert.AreEqual (1, ta.eq, "#1");
3865 			Assert.AreEqual (2, ta.ust, "#2");
3866 			a.Equals (b);
3867 			Assert.AreEqual (2, ta.eq, "#3");
3868 			Assert.AreEqual (3, ta.ust, "#4");
3869 			Assert.AreEqual (0, tb.eq, "#5");
3870 			Assert.AreEqual (1, tb.ust, "#6");
3871 		}
3872 
3873 		public enum MyRealEnum : short {
3874 			A,B,C
3875 		}
3876 
3877 
3878 		public enum MyRealEnum2 : byte {
3879 			A,B,C
3880 		}
3881 
3882 		public enum MyRealEnum3 : short {
3883 			A,B,C
3884 		}
3885 
3886 		public class MyEnum : TypeDelegator {
3887 			public bool is_enum { get; set; }
3888 			public int fields { get; set; }
3889 
IsSubclassOf(Type c)3890 			public override bool IsSubclassOf (Type c) {
3891 				return c == typeof (Enum) && is_enum;
3892 			}
3893 
GetFields(BindingFlags bindingAttr)3894 			public override FieldInfo[] GetFields (BindingFlags bindingAttr) {
3895 				if (fields == 0)
3896 					return null;
3897 				FieldInfo[] res = new FieldInfo [fields];
3898 				for (int i = 0; i < fields; ++i) {
3899 					if ((bindingAttr & BindingFlags.Instance) != 0)
3900 						res [i] = typeof (MyRealEnum).GetField ("value__");
3901 					else
3902 						res [i] = typeof (MyRealEnum).GetField ("A");
3903 				}
3904 				return res;
3905 			}
3906 		}
3907 
3908 		[Test]
GetEnumUnderlyingType()3909 		public void GetEnumUnderlyingType () {
3910 
3911 			try {
3912 				new MyEnum () { is_enum = false }.GetEnumUnderlyingType ();
3913 				Assert.Fail ("#1");
3914 			} catch (ArgumentException) {}
3915 
3916 			try {
3917 				new MyEnum () { is_enum = true, fields = 0 }.GetEnumUnderlyingType ();
3918 				Assert.Fail ("#2");
3919 			} catch (ArgumentException) {}
3920 
3921 			try {
3922 				new MyEnum () { is_enum = true, fields = 2 }.GetEnumUnderlyingType ();
3923 				Assert.Fail ("#3");
3924 			} catch (ArgumentException) {}
3925 
3926 			Assert.AreSame (typeof (short), new MyEnum () { is_enum = true, fields = 1 }.GetEnumUnderlyingType ());
3927 		}
3928 
3929 		[Test]
GetEnumNames()3930 		public void GetEnumNames () {
3931 			try {
3932 				new MyEnum () { is_enum = false }.GetEnumNames ();
3933 				Assert.Fail ("#1");
3934 			} catch (ArgumentException) {}
3935 
3936 			var res = new MyEnum () { is_enum = true, fields = 1 }.GetEnumNames ();
3937 			Assert.AreEqual (1, res.Length, "#2");
3938 			Assert.AreEqual ("A", res [0], "#3");
3939 
3940 			res = typeof (MyRealEnum).GetEnumNames ();
3941 			Assert.AreEqual (3, res.Length, "#4");
3942 			Assert.AreEqual ("A", res [0], "#5");
3943 			Assert.AreEqual ("B", res [1], "#6");
3944 			Assert.AreEqual ("C", res [2], "#7");
3945 		}
3946 
3947 		public enum OutOfOrderEnum : sbyte
3948 		{
3949 			D = -1, C = 2, B = 1, A = 0
3950 		}
3951 
3952 		[Test]
GetEnumNamesSortsByUnsignedValue()3953 		public void GetEnumNamesSortsByUnsignedValue ()
3954 		{
3955 			string[] names = typeof (OutOfOrderEnum).GetEnumNames ();
3956 			Assert.AreEqual (4, names.Length);
3957 			Assert.AreEqual ("A", names [0]);
3958 			Assert.AreEqual ("B", names [1]);
3959 			Assert.AreEqual ("C", names [2]);
3960 			Assert.AreEqual ("D", names [3]);
3961 		}
3962 
3963 		[Test]
GetEnumValues()3964 		public void GetEnumValues () {
3965 			try {
3966 				new MyEnum () { is_enum = false }.GetEnumValues ();
3967 				Assert.Fail ("#1");
3968 			} catch (ArgumentException) {}
3969 
3970 			try {
3971 				new MyEnum () { is_enum = true }.GetEnumValues ();
3972 				Assert.Fail ("#2");
3973 			} catch (NotImplementedException) {}
3974 
3975 			var array = typeof (MyRealEnum).GetEnumValues ();
3976 			Assert.AreEqual (typeof (MyRealEnum[]), array.GetType (), "#3");
3977 			MyRealEnum[] res = (MyRealEnum[])array;
3978 
3979 			Assert.AreEqual (3, res.Length, "#4");
3980 			Assert.AreEqual (MyRealEnum.A, res [0], "#5");
3981 			Assert.AreEqual (MyRealEnum.B, res [1], "#6");
3982 			Assert.AreEqual (MyRealEnum.C, res [2], "#7");
3983 		}
3984 
3985 		[Test]
GetEnumValue()3986 		public void GetEnumValue () {
3987 			try {
3988 				typeof (MyRealEnum).GetEnumName (null);
3989 				Assert.Fail ("#1");
3990 			} catch (ArgumentException) { }
3991 
3992 			try {
3993 				new MyEnum () { is_enum = false }.GetEnumName (99);
3994 				Assert.Fail ("#2");
3995 			} catch (ArgumentException) { }
3996 
3997 
3998 			Assert.IsNull (new MyEnum () { fields = 1, is_enum = true }.GetEnumName (77), "#3");
3999 			Assert.AreEqual ("A", new MyEnum () { fields = 1, is_enum = true }.GetEnumName (0), "#4");
4000 			Assert.AreEqual ("A", new MyEnum () { fields = 1, is_enum = true }.GetEnumName (MyRealEnum.A), "#5");
4001 			Assert.AreEqual ("A", new MyEnum () { fields = 1, is_enum = true }.GetEnumName (MyRealEnum2.A), "#6");
4002 
4003 			Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName (MyRealEnum.A), "#7");
4004 			Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((short)0), "#8");
4005 			Assert.AreEqual ("C", typeof (MyRealEnum).GetEnumName (2), "#9");
4006 			Assert.IsNull (typeof (MyRealEnum).GetEnumName (9), "#10");
4007 
4008 			Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((byte)0), "#11");
4009 			Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((sbyte)0), "#12");
4010 			Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName (false), "#13");
4011 			Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((short)0), "#14");
4012 			Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((ushort)0), "#15");
4013 			Assert.IsNull (typeof (MyRealEnum).GetEnumName ('c'), "#16");
4014 
4015 			Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((int)0), "#17");
4016 			Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((uint)0), "#18");
4017 
4018 			Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((long)0), "#19");
4019 			Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((ulong)0), "#20");
4020 
4021 			try {
4022 				typeof (MyRealEnum).GetEnumName ((float)0);
4023 				Assert.Fail ("#21");
4024 			} catch (ArgumentException) { }
4025 			try {
4026 				typeof (MyRealEnum).GetEnumName ((double)0);
4027 				Assert.Fail ("#22");
4028 			} catch (ArgumentException) { }
4029 
4030 
4031 			Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((byte)0), "#23");
4032 			Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((sbyte)0), "#24");
4033 			Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName (false), "#25");
4034 
4035 			Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((short)0), "#26");
4036 			Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((ushort)0), "#27");
4037 
4038 			Assert.IsNull (typeof (MyRealEnum2).GetEnumName ('c'), "#28");
4039 
4040 			Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((int)0), "#29");
4041 			Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((uint)0), "#30");
4042 
4043 			Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((long)0), "#31");
4044 			Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((ulong)0), "#32");
4045 
4046 			try {
4047 				typeof (MyRealEnum2).GetEnumName ((float)0);
4048 				Assert.Fail ("#33");
4049 			} catch (ArgumentException) { }
4050 			try {
4051 				typeof (MyRealEnum2).GetEnumName ((double)0);
4052 				Assert.Fail ("#34");
4053 			} catch (ArgumentException) { }
4054 
4055 			Assert.IsNull (typeof (MyRealEnum2).GetEnumName (12345), "#35");
4056 		}
4057 
4058 		[Test]
IsEnumDefined()4059 		public void IsEnumDefined () {
4060 			try {
4061 				typeof (MyRealEnum).IsEnumDefined (null);
4062 				Assert.Fail ("#1");
4063 			} catch (ArgumentException) { }
4064 
4065 			try {
4066 				new MyEnum () { is_enum = false }.IsEnumDefined (99);
4067 				Assert.Fail ("#2");
4068 			} catch (ArgumentException) { }
4069 
4070 			try {
4071 				typeof (MyRealEnum).IsEnumDefined (0);
4072 				Assert.Fail ("#3");
4073 			} catch (ArgumentException) { }
4074 
4075 			try {
4076 				typeof (MyRealEnum).IsEnumDefined ((ushort)0);
4077 				Assert.Fail ("#4");
4078 			} catch (ArgumentException) { }
4079 
4080 			try {
4081 				typeof (MyRealEnum).IsEnumDefined (MyRealEnum3.A);
4082 				Assert.Fail ("#5");
4083 			} catch (ArgumentException) { }
4084 
4085 			try {
4086 				typeof (MyRealEnum).IsEnumDefined (true);
4087 				Assert.Fail ("#6");
4088 			} catch (ArgumentException) { }
4089 
4090 			try {
4091 				typeof (MyRealEnum).IsEnumDefined (MyRealEnum2.A);
4092 				Assert.Fail ("#7");
4093 			} catch (ArgumentException) { }
4094 
4095 			try {
4096 				typeof (MyRealEnum).IsEnumDefined (typeof (MyRealEnum));
4097 				Assert.Fail ("#8");
4098 			} catch (InvalidOperationException) { }
4099 
4100 			Assert.IsTrue (typeof (MyRealEnum).IsEnumDefined ((short)0), "#9");
4101 			Assert.IsFalse (typeof (MyRealEnum).IsEnumDefined ((short)88), "#10");
4102 			Assert.IsTrue (typeof (MyRealEnum).IsEnumDefined (MyRealEnum.A), "#11");
4103 			Assert.IsFalse (typeof (MyRealEnum).IsEnumDefined ("d"), "#12");
4104 			Assert.IsTrue  (typeof (MyRealEnum).IsEnumDefined ("A"), "#13");
4105 			Assert.IsFalse  (new MyEnum () { is_enum = true, fields = 1 }.IsEnumDefined ((short)99), "#14");
4106 		}
4107 
4108 
4109 
4110 		public class Outer {
4111 			public class Inner {}
4112 		}
4113 
4114 
4115 		public class Outer<T> {
4116 			public class Inner {}
4117 		}
4118 
4119 		[Test]
GetTypeWithDelegates()4120 		public void GetTypeWithDelegates () {
4121 			var tname = typeof (MyRealEnum).AssemblyQualifiedName;
4122 			var res = Type.GetType (tname, name => {
4123 					return Assembly.Load (name);
4124 				},(asm,name,ignore) => {
4125 					return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4126 				}, false, false);
4127 			Assert.AreEqual (typeof (MyRealEnum), res, "#1");
4128 
4129 
4130 			tname = typeof (Dictionary<int, string>).AssemblyQualifiedName;
4131 			res = Type.GetType (tname, name => {
4132 					return Assembly.Load (name);
4133 				},(asm,name,ignore) => {
4134 					return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4135 				}, false, false);
4136 			Assert.AreEqual (typeof (Dictionary<int, string>), res, "#2");
4137 
4138 
4139 			tname = typeof (Foo<int>).AssemblyQualifiedName;
4140 			res = Type.GetType (tname, name => {
4141 					return Assembly.Load (name);
4142 				},(asm,name,ignore) => {
4143 					return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4144 				}, false, false);
4145 			Assert.AreEqual (typeof (Foo<int>), res, "#3");
4146 
4147 
4148 			tname = typeof (Outer.Inner).AssemblyQualifiedName;
4149 			res = Type.GetType (tname, name => {
4150 					return Assembly.Load (name);
4151 				},(asm,name,ignore) => {
4152 					return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4153 				}, false, false);
4154 			Assert.AreEqual (typeof (Outer.Inner), res, "#4");
4155 
4156 
4157 			tname = typeof (Outer<double>.Inner).AssemblyQualifiedName;
4158 			res = Type.GetType (tname, name => {
4159 					return Assembly.Load (name);
4160 				},(asm,name,ignore) => {
4161 					return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4162 				}, false, false);
4163 			Assert.AreEqual (typeof (Outer<double>.Inner), res, "#5");
4164 
4165 
4166 			tname = "System.Collections.Generic.List`1[System.Int32]";
4167 			res = Type.GetType (tname, name => {
4168 					return Assembly.Load (name);
4169 				},(asm,name,ignore) => {
4170 					return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4171 				}, false, false);
4172 			Assert.AreEqual (typeof (List<int>), res, "#6");
4173 
4174 
4175 			tname = typeof (Foo<>).FullName + "[,][]";
4176 			res = Type.GetType (tname, name => {
4177 					Console.WriteLine ("resolve-asm name {0}", name);
4178 					return Assembly.Load (name);
4179 				},(asm,name,ignore) => {
4180 					return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4181 				}, false, false);
4182 			Assert.AreEqual (typeof (Foo<>).MakeArrayType (2).MakeArrayType (), res, "#7");
4183 
4184 			tname = string.Format("{0}[{1}][]*&", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName);
4185 			res = Type.GetType (tname, name => {
4186 					return Assembly.Load (name);
4187 				},(asm,name,ignore) => {
4188 					return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4189 				}, false, false);
4190 			Assert.AreEqual (typeof (Foo<MyRealEnum>[]).MakePointerType ().MakeByRefType (), res, "#8");
4191 
4192 
4193 			tname = typeof (MyRealEnum).FullName + "[][]";
4194 			res = Type.GetType (tname, name => {
4195 					return Assembly.Load (name);
4196 				},(asm,name,ignore) => {
4197 					return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4198 				}, false, false);
4199 			Assert.AreEqual (typeof (MyRealEnum[][]), res, "#9");
4200 
4201 
4202 			tname = typeof (MyRealEnum).FullName + "[*]";
4203 			res = Type.GetType (tname, name => {
4204 					return Assembly.Load (name);
4205 				},(asm,name,ignore) => {
4206 					return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4207 				}, false, false);
4208 			Assert.AreEqual (typeof (MyRealEnum).MakeArrayType (1), res, "#10");
4209 
4210 
4211 			tname = typeof (MyRealEnum).FullName + "&";
4212 			res = Type.GetType (tname, name => {
4213 					return Assembly.Load (name);
4214 				},(asm,name,ignore) => {
4215 					return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4216 				}, false, false);
4217 			Assert.AreEqual (typeof (MyRealEnum).MakeByRefType (), res, "#11");
4218 
4219 
4220 			tname = typeof (MyRealEnum).FullName + "*";
4221 			res = Type.GetType (tname, name => {
4222 					return Assembly.Load (name);
4223 				},(asm,name,ignore) => {
4224 					return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4225 				}, false, false);
4226 			Assert.AreEqual (typeof (MyRealEnum).MakePointerType (), res, "#12");
4227 
4228 			tname = typeof (MyRealEnum).FullName + "*&";
4229 			res = Type.GetType (tname, name => {
4230 					return Assembly.Load (name);
4231 				},(asm,name,ignore) => {
4232 					return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4233 				}, false, false);
4234 			Assert.AreEqual (typeof (MyRealEnum).MakePointerType ().MakeByRefType(),
4235 					 res, "#13");
4236 
4237 			tname = typeof (MyRealEnum).FullName + "[,]&";
4238 			res = Type.GetType (tname, name => {
4239 					return Assembly.Load (name);
4240 				},(asm,name,ignore) => {
4241 					return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4242 				}, false, false);
4243 			Assert.AreEqual (typeof (MyRealEnum).MakeArrayType (2).MakeByRefType (),
4244 					 res, "#14");
4245 
4246 			tname = typeof (MyRealEnum).FullName + "*[]";
4247 			res = Type.GetType (tname, name => {
4248 					return Assembly.Load (name);
4249 				},(asm,name,ignore) => {
4250 					return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4251 				}, false, false);
4252 			Assert.AreEqual (typeof (MyRealEnum).MakePointerType().MakeArrayType(),
4253 					 res, "#15");
4254 
4255 			// not a very useful type, but ought to be parsed correctly
4256 			tname = typeof (MyRealEnum).FullName + "[]**[]*&";
4257 			res = Type.GetType (tname, name => {
4258 					return Assembly.Load (name);
4259 				},(asm,name,ignore) => {
4260 					return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4261 				}, false, false);
4262 			Assert.AreEqual (typeof (MyRealEnum).MakeArrayType().MakePointerType().MakePointerType().MakeArrayType().MakePointerType().MakeByRefType(),
4263 					 res, "#16");
4264 
4265 			// assembly resolve without type resolve
4266 			res = Type.GetType ("System.String,mscorlib", delegate (AssemblyName aname) { return typeof (int).Assembly; }, null);
4267 			Assert.AreEqual (typeof (string), res);
4268 		}
4269 
4270 
4271 		public class CustomGetType : TypeDelegator {
4272 			string name;
4273 
CustomGetType(string name)4274 			public CustomGetType (string name) { this.name = name; }
4275 
MakeGenericType(Type[] args)4276 			public override Type MakeGenericType (Type[] args) {
4277 				return new CustomGetType ("GINST");
4278 			}
4279 
GetNestedType(String name, BindingFlags bidingAttr)4280 		 	public override Type GetNestedType(String name, BindingFlags bidingAttr) {
4281 				return new CustomGetType ("NESTED");
4282 			}
4283 
ToString()4284 			public override string ToString () { return "UT_" + name; }
4285 
4286 			public override string Name {
4287 				get { return  "UT_" + name; }
4288 			}
4289 		}
4290 
4291 		[Test]
GetTypeWithDelegatesAndUserTypes()4292 		public void GetTypeWithDelegatesAndUserTypes ()
4293 		{
4294 			var tname = "Magic[System.Int32]";
4295 			var res = Type.GetType (tname, name => {
4296 					return Assembly.Load (name);
4297 				},(asm,name,ignore) => {
4298 					if (name == "Magic") return new CustomGetType ("MAGIC");
4299 					return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4300 				}, false, false);
4301 			Assert.AreEqual ("UT_GINST", res.Name, "#1");
4302 
4303 
4304 			tname = "Magic+MyRealEnum";
4305 			res = Type.GetType (tname, name => {
4306 					return Assembly.Load (name);
4307 				},(asm,name,ignore) => {
4308 					if (name == "Magic") return new CustomGetType ("MAGIC");
4309 					return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4310 				}, false, false);
4311 			Assert.AreEqual ("UT_NESTED", res.Name, "#2");
4312 		}
4313 
MustTLE(string tname)4314 		void MustTLE (string tname) {
4315 			try {
4316 				var res = Type.GetType (tname, name => {
4317 					return Assembly.Load (name);
4318 				},(asm,name,ignore) => {
4319 					return (object)asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4320 				}, true, false);
4321 				Assert.Fail (tname);
4322 			} catch (TypeLoadException) {}
4323 		}
4324 
MustANE(string tname)4325 		void MustANE (string tname) {
4326 			try {
4327 				var res = Type.GetType (tname, name => {
4328 					return Assembly.Load (name);
4329 				},(asm,name,ignore) => {
4330 					return (object)asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4331 				}, true, false);
4332 				Assert.Fail (tname);
4333 			} catch (ArgumentNullException) {}
4334 		}
4335 
MustAE_general(string tname, Func<string,Type> getType)4336 		void MustAE_general (string tname, Func<string,Type> getType) {
4337 			try {
4338 				var res = getType (tname);
4339 				Assert.Fail (tname);
4340 			} catch (ArgumentException) {}
4341 		}
4342 
MustAE(string typename)4343 		void MustAE (string typename) {
4344 			MustAE_general (typename, tname => {
4345 					return Type.GetType (tname, name => {
4346 							return Assembly.Load (name);
4347 						},(asm,name,ignore) => {
4348 							return (object)asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4349 						}, true, false);
4350 				});
4351 		}
4352 
MustAEnn(string typename)4353 		void MustAEnn (string typename) {
4354 			MustAE_general (typename, tname => Type.GetType (tname, null, null));
4355 		}
4356 
MustFNFE(string tname)4357 		void MustFNFE (string tname) {
4358 			try {
4359 				var res = Type.GetType (tname, name => {
4360 					return Assembly.Load (name);
4361 				},(asm,name,ignore) => {
4362 					return (object)asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4363 				}, true, false);
4364 				Assert.Fail (tname);
4365 			} catch (FileNotFoundException) {}
4366 		}
4367 
4368 		[Test]
NewGetTypeErrors()4369 		public void NewGetTypeErrors () {
4370 			MustANE (null);
4371 			MustTLE ("");
4372 			MustAE ("!@#$%^&*");
4373 			MustAE (string.Format ("{0}[{1}&]", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4374 			MustAE (string.Format ("{0}[{1}*]", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4375 			MustAE (string.Format ("{0}&&", typeof (MyRealEnum).FullName));
4376 			MustAE (string.Format ("{0}&*", typeof (MyRealEnum).FullName));
4377 			MustAE (string.Format ("{0}&[{1}]", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4378 			MustAE (string.Format ("{0}[,", typeof (MyRealEnum).FullName));
4379 			MustAE (string.Format ("{0}[*", typeof (MyRealEnum).FullName));
4380 
4381 			MustAE (string.Format ("{0}[[{1},", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4382 			MustAE (string.Format ("{0}[[{1}]", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4383 			MustAE (string.Format ("{0}[[{1}],", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4384 			MustAE (string.Format ("{0}[[{1}]_", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4385 
4386 			MustAE (string.Format ("{0}[{1}", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4387 			MustAE (string.Format ("{0}[{1},", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4388 			MustAE (string.Format ("{0}[{1},,", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4389 			MustAE (string.Format ("{0}[{1} (", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4390 			MustAE (string.Format ("{0}[", typeof (Foo<>).FullName));
4391 
4392 			MustAE (string.Format ("{0}[**]", typeof (MyRealEnum).FullName));
4393 			MustAE (string.Format ("{0}[*,*]", typeof (MyRealEnum).FullName));
4394 			MustAE (string.Format ("{0}[*,]", typeof (MyRealEnum).FullName));
4395 			MustAE (string.Format ("{0}[,*]", typeof (MyRealEnum).FullName));
4396 			MustAE (string.Format ("{0}[,-]", typeof (MyRealEnum).FullName));
4397 			MustAE (string.Format ("{0}[,{0}]", typeof (MyRealEnum).FullName));
4398 
4399 			MustAE (string.Format ("{0}[{1}]]", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4400 			MustAE (string.Format ("{0}[,]]", typeof (MyRealEnum).FullName));
4401 
4402 
4403 			string aqn = typeof (MyRealEnum).Assembly.FullName;
4404 			MustFNFE (string.Format ("{0}, ZZZ{1}", typeof (MyRealEnum).FullName, aqn));
4405 			MustTLE (string.Format ("{0}ZZZZ", typeof (MyRealEnum).FullName));
4406 			MustTLE (string.Format ("{0}ZZZZ,{1}", typeof (MyRealEnum).FullName, aqn));
4407 		}
4408 
4409 		[Test]
GetTypeExceptionMsg()4410 		public void GetTypeExceptionMsg () {
4411 			string typeName = "system.int32, foo";
4412 			try {
4413 				Type.GetType(typeName, true, false);
4414 			} catch (TypeLoadException ex) {
4415 				Assert.IsTrue (ex.Message.Contains ("system.int32"));
4416 				Assert.IsTrue (ex.Message.Contains ("foo"));
4417 			}
4418 		}
4419 
MyAction(T ag)4420 	   	delegate void MyAction<in T>(T ag);
4421 
4422 		[Test] //bug #668506
IsAssignableFromWithVariantDelegate()4423 		public void IsAssignableFromWithVariantDelegate () {
4424 			Assert.IsFalse (typeof(MyAction<string>).IsAssignableFrom(typeof(MyAction<>)), "#1");
4425 		}
4426 
4427 		[Test] //bug #124
IsAssignableFromWithNullable()4428 		public void IsAssignableFromWithNullable () {
4429             Console.WriteLine(typeof(IEnumerable<int?>).IsAssignableFrom(typeof(IEnumerable<int>)));
4430 		}
4431 
4432 		[Test]
GetTypeParseGenericCorrectly()4433 		public void GetTypeParseGenericCorrectly () { //Bug #15124
4434 			Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1"), typeof (Foo<>), "#1");
4435 			Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32]"), typeof (Foo<int>), "#2");
4436 			Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[[System.Int32]]"), typeof (Foo<int>), "#3");
4437 			Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32][]"), typeof (Foo<int>[]), "#4");
4438 			Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[][System.Int32]"), null, "#5");
4439 			Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32][,]"), typeof (Foo<int>[,]), "#6");
4440 			Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[]"), typeof (Foo<>).MakeArrayType(), "#7");
4441 			Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[,]"), typeof (Foo<>).MakeArrayType (2), "#8");
4442 			Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[][]"), typeof (Foo<>).MakeArrayType ().MakeArrayType (), "#9");
4443 			Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1["), null, "#10");
4444 			Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[["), null, "#11");
4445 			Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[[]"), null, "#12");
4446 			Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[,"), null, "#13");
4447 			Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[*"), null, "#14");
4448 			Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32"), null, "#15");
4449 		}
4450 
4451 		[Test]
GetTypeNullDelegatesParseGenericCorrectly()4452 		public void GetTypeNullDelegatesParseGenericCorrectly () {
4453 			Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1", null, null), typeof (Foo<>), "#1");
4454 			Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32]", null, null), typeof (Foo<int>), "#2");
4455 			Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[[System.Int32]]", null, null), typeof (Foo<int>), "#3");
4456 			Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32][]", null, null), typeof (Foo<int>[]), "#4");
4457 			Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32][,]", null, null), typeof (Foo<int>[,]), "#5");
4458 			Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[]", null, null), typeof (Foo<>).MakeArrayType(), "#6");
4459 			Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[,]", null, null), typeof (Foo<>).MakeArrayType (2), "#7");
4460 			Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[][]", null, null), typeof (Foo<>).MakeArrayType ().MakeArrayType (), "#8");
4461 
4462 			MustAEnn ("MonoTests.System.Foo`1[][System.Int32]");
4463 			MustAEnn ("MonoTests.System.Foo`1[");
4464 			MustAEnn ("MonoTests.System.Foo`1[[");
4465 			MustAEnn ("MonoTests.System.Foo`1[[]");
4466 			MustAEnn ("MonoTests.System.Foo`1[,");
4467 			MustAEnn ("MonoTests.System.Foo`1[*");
4468 			MustAEnn ("MonoTests.System.Foo`1[System.Int32");
4469 		}
4470 
MakeDictHelper(T[] arr)4471 		Dictionary<int, T> MakeDictHelper<T> (T[] arr) {
4472 			return new Dictionary<int, T>();
4473 		}
4474 
4475 		[Test]
GetTypeAnonymousParseCorrectly()4476 		public void GetTypeAnonymousParseCorrectly () {
4477 			var x = new { X = 1 };
4478 			var a = new [] { x };
4479 			var d = MakeDictHelper (a);
4480 
4481 			var x_type = x.GetType ();
4482 			var a_type = a.GetType ();
4483 			var d_type = d.GetType ();
4484 
4485 			Assert.AreEqual (Type.GetType (x_type.ToString ()), x_type, "#1");
4486 			Assert.AreEqual (Type.GetType (x_type.ToString (), null, null), x_type, "#2");
4487 			Assert.AreEqual (Type.GetType (a_type.ToString ()), a_type, "#3");
4488 			Assert.AreEqual (Type.GetType (a_type.ToString (), null, null), a_type, "#4");
4489 			Assert.AreEqual (Type.GetType (d_type.ToString ()), d_type, "#5");
4490 			Assert.AreEqual (Type.GetType (d_type.ToString (), null, null), d_type, "#6");
4491 
4492 			Assert.AreEqual (Type.GetType (x_type.FullName), x_type, "#7");
4493 			Assert.AreEqual (Type.GetType (x_type.FullName, null, null), x_type, "#8");
4494 			Assert.AreEqual (Type.GetType (a_type.FullName), a_type, "#9");
4495 			Assert.AreEqual (Type.GetType (a_type.FullName, null, null), a_type, "#10");
4496 			Assert.AreEqual (Type.GetType (d_type.FullName), d_type, "#11");
4497 			Assert.AreEqual (Type.GetType (d_type.FullName, null, null), d_type, "#12");
4498 
4499 		}
4500 
4501 #if !MONOTOUCH && !FULL_AOT_RUNTIME && !MONOMAC
4502 		[Test]
4503 		[Category ("AndroidNotWorking")] // requires symbol writer
FullNameGetTypeParseEscapeRoundtrip()4504 		public void FullNameGetTypeParseEscapeRoundtrip () // bug #26384
4505 		{
4506 			var nm = new AssemblyName ("asm");
4507 			var ab = AssemblyBuilder.DefineDynamicAssembly (nm,
4508 									AssemblyBuilderAccess.Run);
4509 			var mb = ab.DefineDynamicModule("m", false);
4510 			var tb = mb.DefineType ("NameSpace,+*&[]\\.Type,+*&[]\\",
4511 						TypeAttributes.Class | TypeAttributes.Public);
4512 
4513 			var nestedTb = tb.DefineNestedType("Nested,+*&[]\\",
4514 							  TypeAttributes.Class | TypeAttributes.NestedPublic);
4515 
4516 			var ty = tb.CreateType();
4517 
4518 			var nestedTy = nestedTb.CreateType();
4519 
4520 			var escapedNestedName =
4521 				"NameSpace\\,\\+\\*\\&\\[\\]\\\\"
4522 				+ "."
4523 				+ "Type\\,\\+\\*\\&\\[\\]\\\\"
4524 				+ "+"
4525 				+ "Nested\\,\\+\\*\\&\\[\\]\\\\";
4526 
4527 			Assert.AreEqual(escapedNestedName, nestedTy.FullName);
4528 
4529 			var lookupNestedTy =
4530 				Type.GetType(escapedNestedName + "," + nm.FullName,
4531 					     asmName => {
4532 						     if (asmName.FullName.Equals(nm.FullName)) return ab;
4533 						     else return Assembly.Load (asmName);
4534 					     },
4535 					     (asm,name,ignore) => {
4536 						     if (asm == null)
4537 							     return Type.GetType(name, true, ignore);
4538 						     else return asm.GetType(name, true, ignore);
4539 					     },
4540 					     true,
4541 					     false);
4542 			Assert.AreEqual(nestedTy, lookupNestedTy);
4543 
4544 		}
4545 #endif
4546 
4547 
4548 		[Test]
GetTypeBadArity()4549 		public void GetTypeBadArity()
4550 		{
4551 			// Regression test for #46250
4552 			try {
4553 				Type.GetType ("System.Collections.Generic.Dictionary`2[System.String]", true);
4554 				Assert.Fail ("Did not throw an exception (#1)");
4555 			} catch (ArgumentException) {
4556 			}
4557 
4558 			try {
4559 				Type.GetType ("System.Collections.Generic.Dictionary`2[System.String,System.Int32,System.Int64]", true);
4560 				Assert.Fail ("Did not throw an exception (#2)");
4561 			} catch (ArgumentException) {
4562 			}
4563 		}
4564 
4565 		public abstract class Stream : IDisposable
4566 		{
Dispose()4567 			public void Dispose ()
4568 			{
4569 				Console.WriteLine ("stream::dispose");
4570 			}
4571 
Dispose(bool disposing)4572 			protected virtual void Dispose (bool disposing)
4573 			{
4574 			}
4575 		}
4576 
4577 		public class NonClosingStream
4578 			: Stream, IDisposable
4579 		{
IDisposable.Dispose()4580 			void  IDisposable.Dispose()
4581 			{
4582 				Console.WriteLine ("ncs::dispose");
4583 			}
4584 
ToString()4585 			public override string ToString () { return ""; }
4586 		}
4587 
ContainsProperty(PropertyInfo [] props, string name)4588 		static bool ContainsProperty (PropertyInfo [] props, string name)
4589 		{
4590 			foreach (PropertyInfo p in props)
4591 				if (p.Name == name)
4592 					return true;
4593 			return false;
4594 		}
4595 
4596 		public class NemerleAttribute : Attribute
4597 		{
4598 		}
4599 
4600 		public class VolatileModifier : NemerleAttribute
4601 		{
4602 		}
4603 
4604 		[VolatileModifier]
4605 		[FooAttribute]
4606 		class A
4607 		{
4608 		}
4609 
4610 		[AttributeUsage (AttributeTargets.Class, Inherited=false)]
4611 		public class FooAttribute : Attribute
4612 		{
4613 		}
4614 
4615 		public class BarAttribute : FooAttribute
4616 		{
4617 		}
4618 
4619 		[BarAttribute]
4620 		class BA : A
4621 		{
4622 		}
4623 
4624 		class BBA : BA
4625 		{
4626 		}
4627 
4628 		class CA : A
4629 		{
4630 		}
4631 
4632 		[AttributeUsage (AttributeTargets.Class, Inherited=true)]
4633 		public class InheritAttribute : Attribute
4634 		{
4635 		}
4636 
4637 		[AttributeUsage (AttributeTargets.Class, Inherited=false)]
4638 		public class NotInheritAttribute : InheritAttribute
4639 		{
4640 		}
4641 
4642 		[NotInheritAttribute]
4643 		public class bug82431A1
4644 		{
4645 		}
4646 
4647 		public class bug82431A2 : bug82431A1
4648 		{
4649 		}
4650 
4651 		[NotInheritAttribute]
4652 		[InheritAttribute]
4653 		public class bug82431A3 : bug82431A1
4654 		{
4655 		}
4656 
4657 		[InheritAttribute]
4658 		public class bug82431B1
4659 		{
4660 		}
4661 
4662 		public class bug82431B2 : bug82431B1
4663 		{
4664 		}
4665 
4666 		[NotInheritAttribute]
4667 		public class bug82431B3 : bug82431B2
4668 		{
4669 		}
4670 
4671 		public class bug82431B4 : bug82431B3
4672 		{
4673 		}
4674 
4675 		struct FooStruct
4676 		{
4677 		}
4678 
4679 		public class Bug77367
4680 		{
Run(bool b)4681 			public void Run (bool b)
4682 			{
4683 			}
4684 		}
4685 
4686 		public class Blue
4687 		{
4688 			private string PrivInstBlue
4689 			{
4690 				get { return null; }
4691 			}
4692 
4693 			protected string ProtInstBlue
4694 			{
4695 				get { return null; }
4696 			}
4697 
4698 			protected internal string ProIntInstBlue
4699 			{
4700 				get { return null; }
4701 			}
4702 
4703 			public long PubInstBlue
4704 			{
4705 				get
4706 				{
4707 					if (PrivInstBlue == null)
4708 						return 0;
4709 					return long.MaxValue;
4710 				}
4711 			}
4712 
4713 			internal int IntInstBlue
4714 			{
4715 				get { return 0; }
4716 			}
4717 
4718 			private static string PrivStatBlue
4719 			{
4720 				get { return null; }
4721 			}
4722 
4723 			protected static string ProtStatBlue
4724 			{
4725 				get { return null; }
4726 			}
4727 
4728 			protected static internal string ProIntStatBlue
4729 			{
4730 				get { return null; }
4731 			}
4732 
4733 			public static long PubStatBlue
4734 			{
4735 				get
4736 				{
4737 					if (PrivStatBlue == null)
4738 						return 0;
4739 					return long.MaxValue;
4740 				}
4741 			}
4742 
4743 			internal static int IntStatBlue
4744 			{
4745 				get { return 0; }
4746 			}
4747 		}
4748 
4749 		public class Foo : Blue
4750 		{
4751 			private string PrivInstBase
4752 			{
4753 				get { return null; }
4754 			}
4755 
4756 			protected string ProtInstBase
4757 			{
4758 				get { return null; }
4759 			}
4760 
4761 			protected internal string ProIntInstBase
4762 			{
4763 				get { return null; }
4764 			}
4765 
4766 			public long PubInstBase
4767 			{
4768 				get
4769 				{
4770 					if (PrivInstBase == null)
4771 						return 0;
4772 					return long.MaxValue;
4773 				}
4774 			}
4775 
4776 			internal int IntInstBase
4777 			{
4778 				get { return 0; }
4779 			}
4780 
4781 			private static string PrivStatBase
4782 			{
4783 				get { return null; }
4784 			}
4785 
4786 			protected static string ProtStatBase
4787 			{
4788 				get { return null; }
4789 			}
4790 
4791 			protected static internal string ProIntStatBase
4792 			{
4793 				get { return null; }
4794 			}
4795 
4796 			public static long PubStatBase
4797 			{
4798 				get
4799 				{
4800 					if (PrivStatBase == null)
4801 						return 0;
4802 					return long.MaxValue;
4803 				}
4804 			}
4805 
4806 			internal static int IntStatBase
4807 			{
4808 				get { return 0; }
4809 			}
4810 		}
4811 
4812 		public class Bar : Foo
4813 		{
4814 			private string PrivInst
4815 			{
4816 				get { return null; }
4817 			}
4818 
4819 			protected string ProtInst
4820 			{
4821 				get { return null; }
4822 			}
4823 
4824 			protected internal string ProIntInst
4825 			{
4826 				get { return null; }
4827 			}
4828 
4829 			public long PubInst
4830 			{
4831 				get
4832 				{
4833 					if (PrivInst == null)
4834 						return 0;
4835 					return long.MaxValue;
4836 				}
4837 			}
4838 
4839 			internal int IntInst
4840 			{
4841 				get { return 0; }
4842 			}
4843 
4844 			private static string PrivStat
4845 			{
4846 				get { return null; }
4847 			}
4848 
4849 			protected static string ProtStat
4850 			{
4851 				get { return null; }
4852 			}
4853 
4854 			protected static internal string ProIntStat
4855 			{
4856 				get { return null; }
4857 			}
4858 
4859 			public static long PubStat
4860 			{
4861 				get
4862 				{
4863 					if (PrivStat == null)
4864 						return 0;
4865 					return long.MaxValue;
4866 				}
4867 			}
4868 
4869 			internal static int IntStat
4870 			{
4871 				get { return 0; }
4872 			}
4873 		}
4874 
4875 		class CtorsA
4876 		{
CtorsA()4877 			static CtorsA ()
4878 			{
4879 			}
4880 		}
4881 
4882 		class CtorsB
4883 		{
CtorsB()4884 			public CtorsB ()
4885 			{
4886 			}
4887 		}
4888 
4889 		class CtorsC
4890 		{
CtorsC()4891 			static CtorsC ()
4892 			{
4893 			}
4894 
CtorsC(int x)4895 			public CtorsC (int x)
4896 			{
4897 			}
4898 		}
4899 
4900 		// https://bugzilla.xamarin.com/show_bug.cgi?id=57938
4901 		[Test]
NullFullNameForSpecificGenericTypes()4902 		public void NullFullNameForSpecificGenericTypes()
4903 		{
4904 			var expected = new [] {
4905 				(
4906 					typeof(Bug59738Class<>).GetFields()[0].FieldType,
4907 					"Bug59738Interface`1", (string)null,
4908 					"MonoTests.System.TypeTest+Bug59738Interface`1[U]"
4909 				),
4910 				(
4911 					typeof(Bug59738Derived<>).BaseType,
4912 					"Bug59738Class`1", (string)null,
4913 					"MonoTests.System.TypeTest+Bug59738Class`1[U]"
4914 				),
4915 				(
4916 					typeof(Bug59738Class<int>),
4917 					"Bug59738Class`1",
4918 					$"MonoTests.System.TypeTest+Bug59738Class`1[[System.Int32, {typeof (int).Assembly.FullName}]]",
4919 					"MonoTests.System.TypeTest+Bug59738Class`1[System.Int32]"
4920 				)
4921 			};
4922 
4923 			for (var i = 0; i < expected.Length; i++) {
4924 				var (t, name, fullname, tostring) = expected[i];
4925 				Assert.AreEqual(name, t.Name, $"{i}.Name");
4926 				Assert.AreEqual(fullname, t.FullName, $"{i}.FullName");
4927 				Assert.AreEqual(tostring, t.ToString(), $"{i}.ToString()");
4928 			}
4929 		}
4930 
4931 		interface Bug59738Interface<T> {
4932 		}
4933 
4934 		class Bug59738Class<U> {
4935 			public Bug59738Interface<U> Iface;
4936 		}
4937 
4938 		class Bug59738Derived<U> : Bug59738Class<U> {
4939 		}
4940 	}
4941 
4942 	class UserType : Type
4943 	{
4944 		protected Type type;
4945 
UserType(Type type)4946 		public UserType(Type type) {
4947 			this.type = type;
4948 		}
4949 
4950 		public override Type UnderlyingSystemType { get { return this.type; } }
4951 
4952 		public override Assembly Assembly { get { return this.type == null ? null : this.type.Assembly; } }
4953 
4954 		public override string AssemblyQualifiedName { get { return null; } }
4955 
4956 		public override Type BaseType { get { return null; } }
4957 
4958 		public override Module Module { get { return this.type.Module; } }
4959 
4960 		public override string Namespace { get { return null; } }
4961 
4962 		public override bool IsGenericParameter { get { return true; } }
4963 
4964 		public override RuntimeTypeHandle TypeHandle { get { throw new NotSupportedException(); } }
4965 
4966 		public override bool ContainsGenericParameters { get { return true; } }
4967 
4968 		public override string FullName { get { return this.type.Name; } }
4969 
4970 		public override Guid GUID { get { throw new NotSupportedException(); } }
4971 
4972 
IsArrayImpl()4973 		protected override bool IsArrayImpl() {
4974 			return false;
4975 		}
4976 
IsByRefImpl()4977 		protected override bool IsByRefImpl()
4978 		{
4979 			return false;
4980 		}
4981 
IsCOMObjectImpl()4982 		protected override bool IsCOMObjectImpl()
4983 		{
4984 			return false;
4985 		}
4986 
IsPointerImpl()4987 		protected override bool IsPointerImpl()
4988 		{
4989 			return false;
4990 		}
4991 
IsPrimitiveImpl()4992 		protected override bool IsPrimitiveImpl()
4993 		{
4994 			return false;
4995 		}
4996 
4997 
GetAttributeFlagsImpl()4998 		protected override TypeAttributes GetAttributeFlagsImpl()
4999 		{
5000 			return 0;
5001 		}
5002 
GetConstructorImpl(BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)5003 		protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder,
5004 									   CallingConventions callConvention, Type[] types,
5005 									   ParameterModifier[] modifiers)
5006 		{
5007 			return null;
5008 		}
5009 
GetConstructors(BindingFlags bindingAttr)5010 		public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr)
5011 		{
5012 			return null;
5013 		}
5014 
GetElementType()5015 		public override Type GetElementType()
5016 		{
5017 			return null;
5018 		}
5019 
GetEvent(string name, BindingFlags bindingAttr)5020 		public override EventInfo GetEvent(string name, BindingFlags bindingAttr)
5021 		{
5022 			return null;
5023 		}
5024 
5025 
GetField(string name, BindingFlags bindingAttr)5026 		public override FieldInfo GetField(string name, BindingFlags bindingAttr)
5027 		{
5028 			return null;
5029 		}
5030 
5031 
GetInterface(string name, bool ignoreCase)5032 		public override Type GetInterface(string name, bool ignoreCase)
5033 		{
5034 			return null;
5035 		}
5036 
GetInterfaces()5037 		public override Type[] GetInterfaces()
5038 		{
5039 			return null;
5040 		}
5041 
GetMembers(BindingFlags bindingAttr)5042 		public override MemberInfo[] GetMembers(BindingFlags bindingAttr)
5043 		{
5044 			return null;
5045 		}
5046 
GetCustomAttributes(Type attributeType, bool inherit)5047 		public override object[] GetCustomAttributes(Type attributeType, bool inherit)
5048 		{
5049 			return null;
5050 		}
5051 
GetCustomAttributes(bool inherit)5052 		public override object[] GetCustomAttributes(bool inherit)
5053 		{
5054 			return null;
5055 		}
5056 
IsDefined(Type attributeType, bool inherit)5057 		public override bool IsDefined(Type attributeType, bool inherit)
5058 		{
5059 			return false;
5060 		}
5061 
5062 		public override string Name { get { return this.type.Name; } }
5063 
GetEvents(BindingFlags bindingAttr)5064 		public override EventInfo[] GetEvents(BindingFlags bindingAttr)
5065 		{
5066 			throw new NotImplementedException();
5067 		}
5068 
GetFields(BindingFlags bindingAttr)5069 		public override FieldInfo[] GetFields(BindingFlags bindingAttr)
5070 		{
5071 			throw new NotImplementedException();
5072 		}
5073 
GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)5074 		protected override MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder,
5075 								 CallingConventions callConvention, Type[] types,
5076 								 ParameterModifier[] modifiers)
5077 		{
5078 			return null;
5079 		}
5080 
GetMethods(BindingFlags bindingAttr)5081 		public override MethodInfo[] GetMethods(BindingFlags bindingAttr)
5082 		{
5083 			return null;
5084 		}
5085 
GetNestedType(string name, BindingFlags bindingAttr)5086 		public override Type GetNestedType(string name, BindingFlags bindingAttr)
5087 		{
5088 			return null;
5089 		}
5090 
GetNestedTypes(BindingFlags bindingAttr)5091 		public override Type[] GetNestedTypes(BindingFlags bindingAttr)
5092 		{
5093 			return null;
5094 		}
5095 
GetProperties(BindingFlags bindingAttr)5096 		public override PropertyInfo[] GetProperties(BindingFlags bindingAttr)
5097 		{
5098 			return null;
5099 		}
5100 
GetPropertyImpl(string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers)5101 		protected override PropertyInfo GetPropertyImpl(string name, BindingFlags bindingAttr, Binder binder,
5102 								 Type returnType, Type[] types, ParameterModifier[] modifiers)
5103 		{
5104 			return null;
5105 		}
5106 
HasElementTypeImpl()5107 		protected override bool HasElementTypeImpl()
5108 		{
5109 			return false;
5110 		}
5111 
InvokeMember(string name, BindingFlags invokeAttr, Binder binder, object target, object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters)5112 		public override object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, object target,
5113 							 object[] args, ParameterModifier[] modifiers, CultureInfo culture,
5114 							 string[] namedParameters)
5115 		{
5116 			throw new NotSupportedException();
5117 		}
5118 	}
5119 
5120     class UserType2 : UserType {
UserType2(Type type)5121 		public UserType2 (Type type) : base (type) {
5122 		}
5123 
5124 		public override Type UnderlyingSystemType { get { return this.type ?? this; } }
5125 
GetHashCode()5126 		public override int GetHashCode()
5127 		{
5128 			if (type == null)
5129 				return 42;
5130 			return type.GetHashCode();
5131 		}
5132 	}
5133 }
5134