[test] Add gparam Type.IsAssignableFrom and Type.BaseType tests
[mono.git] / mcs / class / corlib / Test / System / TypeTest.cs
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         {
33                 public virtual object Clone ()
34                 {
35                         return null;
36                 }
37         }
38
39         class Duper: Super
40         {
41         }
42
43         interface IFace1
44         {
45                 void foo ();
46         }
47
48         interface IFace2 : IFace1
49         {
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
76                 public abstract void TestVoid ();
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
90                 public override void TestVoid ()
91                 {
92                         level = 1;
93                 }
94
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
111                 public new void TestVoid ()
112                 {
113                         level = 2;
114                 }
115
116                 public new void TestInt (int i)
117                 {
118                         level = 2;
119                 }
120
121                 public void Overload ()
122                 {
123                 }
124
125                 public void Overload (int i)
126                 {
127                 }
128
129                 public NewVTable (out int i)
130                 {
131                         i = 0;
132                 }
133
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;
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;
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
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
205                 public static void Bang<S> () {}
206         }
207
208         public class Bug348522
209         {
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         {
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                 
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
241                 public override FieldInfo BindToField (BindingFlags a, FieldInfo[] b, object c, CultureInfo d)
242                 {
243                         return null;
244                 }
245                 
246                 public override void ReorderArgumentArray(ref object[] a, object b)
247                 {
248                 }
249                 
250                 public override MethodBase SelectMethod(BindingFlags a, MethodBase[] b, Type[] c, ParameterModifier[] d)
251                 {
252                     return null;
253                 }
254                 
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]
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
283                 private string genTypeName ()
284                 {
285                         return "t" + (typeIndexer++);
286                 }
287
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]
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]
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))]
432                 public void GetInterfaceMapOnInterface ()
433                 {
434                         typeof (IList).GetInterfaceMap (typeof (ICollection));
435                 }
436
437                 [Test]
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]
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]
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]
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]
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]
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)
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)
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)
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)
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)
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 [])
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 [])
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 [])
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 [])
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]
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]
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]
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]
1721                 public void Namespace ()
1722                 {
1723                         Assert.AreEqual (null, typeof (NoNamespaceClass).Namespace);
1724                 }
1725
1726                 [Test]
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
1740                 public static void Reflected (ref int a)
1741                 {
1742                 }
1743
1744                 [Test]
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]
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]
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]
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]
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]
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]
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]
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]
1843                 public void IsInterface ()
1844                 {
1845                         Assert.IsFalse (typeof (string).IsInterface, "#1");
1846                         Assert.IsTrue (typeof (ICloneable).IsInterface, "#2");
1847                 }
1848
1849                 [Test]
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]
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]
1868                 public void IsVisible ()
1869                 {
1870                         Assert.IsTrue (typeof (int).IsVisible, "#1");
1871                         Assert.IsTrue (typeof (Nested).IsVisible, "#2");
1872                 }
1873
1874                 [Test]
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]
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")]
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]
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]
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))]
1977                 public void FilterAttribute_Invalid ()
1978                 {
1979                         Type.FilterAttribute (MethodBase.GetCurrentMethod (), (byte) 1);
1980                 }
1981
1982                 [Test]
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                         }
1997                         public ByRef0 (int i) {}
1998                         public void f (int i) {}
1999                 }
2000
2001                 [Test]
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]
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]
2038                 public void CreateValueTypeNoCtor ()
2039                 {
2040                         typeof(B).InvokeMember ("", BindingFlags.CreateInstance, null, null, null);
2041                 }
2042
2043                 [Test]
2044                 [ExpectedException (typeof (MissingMethodException))]
2045                 public void CreateValueTypeNoCtorArgs ()
2046                 {
2047                         typeof(B).InvokeMember ("", BindingFlags.CreateInstance, null, null, new object [] { 1 });
2048                 }
2049
2050                 [Test]
2051                 [ExpectedException (typeof (MissingMethodException))]
2052                 public void InvokeGetPropertyMissing ()
2053                 {
2054                         typeof(B).InvokeMember ("", BindingFlags.GetProperty, null, null, new object [] { 1 });
2055                 }
2056
2057                 [Test]
2058                 [ExpectedException (typeof (MissingMethodException))]
2059                 public void InvokeSetPropertyMissing ()
2060                 {
2061                         typeof(B).InvokeMember ("", BindingFlags.SetProperty, null, null, new object [] { 1 });
2062                 }
2063
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
2078                 internal static string bug336841 (string param1)
2079                 {
2080                         return "#B:" + param1;
2081                 }
2082
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]
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]
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]
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]
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]
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]
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
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]
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
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
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]
2314                 public void TestMissing () {
2315                         Assert.AreEqual (Type.Missing, Missing.Value);
2316                 }
2317
2318                 [Test]
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]
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
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                 {
2355                         public Z (IComparable value)
2356                         {
2357                         }
2358                 }
2359         
2360                 public static void Run ()
2361                 {
2362                 }
2363
2364                 class TakesInt
2365                 {
2366                         private int i;
2367
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                 {
2380                         public TakesObject (object x) {}
2381                 }
2382
2383                 [Test] // bug #75241
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]
2392                 public void GetConstructor_TakeInt_Object ()
2393                 {
2394                         Assert.IsNull (typeof (TakesInt).GetConstructor (new Type[1] { typeof (object) }));
2395                 }
2396
2397                 [Test]
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
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]
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
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]
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")]
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
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 })]
2724                 public void Bug13767Method(string attributeName, Bug13767Enum[]options)
2725                 {
2726
2727                 }
2728
2729                 [Test] //Bug 13767
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)
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)
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)
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]
2791                 public void GetTypeArray_Args_Null ()
2792                 {
2793                         try {
2794                                 Type.GetTypeArray ((object []) null);
2795                                 Assert.Fail ("#1");
2796                         } catch (ArgumentNullException ex) {
2797                                 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2798                                 Assert.IsNull (ex.InnerException, "#3");
2799                                 Assert.IsNotNull (ex.Message, "#4");
2800                                 Assert.AreEqual ("args", ex.ParamName, "#5");
2801                         }
2802                 }
2803
2804                 [Test]
2805                 public void GetTypeCode ()
2806                 {
2807                         Assert.AreEqual (TypeCode.Boolean, Type.GetTypeCode (typeof (bool)), "#1");
2808                         Assert.AreEqual (TypeCode.Byte, Type.GetTypeCode (typeof (byte)), "#2");
2809                         Assert.AreEqual (TypeCode.Char, Type.GetTypeCode (typeof (char)), "#3");
2810                         Assert.AreEqual (TypeCode.DateTime, Type.GetTypeCode (typeof (DateTime)), "#4");
2811                         Assert.AreEqual (TypeCode.DBNull, Type.GetTypeCode (typeof (DBNull)), "#5");
2812                         Assert.AreEqual (TypeCode.Decimal, Type.GetTypeCode (typeof (decimal)), "#6");
2813                         Assert.AreEqual (TypeCode.Double, Type.GetTypeCode (typeof (double)), "#7");
2814                         Assert.AreEqual (TypeCode.Empty, Type.GetTypeCode (null), "#8");
2815                         Assert.AreEqual (TypeCode.Int16, Type.GetTypeCode (typeof (short)), "#9");
2816                         Assert.AreEqual (TypeCode.Int32, Type.GetTypeCode (typeof (int)), "#10");
2817                         Assert.AreEqual (TypeCode.Int64, Type.GetTypeCode (typeof (long)), "#11");
2818                         Assert.AreEqual (TypeCode.Object, Type.GetTypeCode (typeof (TakesInt)), "#12");
2819                         Assert.AreEqual (TypeCode.SByte, Type.GetTypeCode (typeof (sbyte)), "#13");
2820                         Assert.AreEqual (TypeCode.Single, Type.GetTypeCode (typeof (float)), "#14");
2821                         Assert.AreEqual (TypeCode.String, Type.GetTypeCode (typeof (string)), "#15");
2822                         Assert.AreEqual (TypeCode.UInt16, Type.GetTypeCode (typeof (ushort)), "#16");
2823                         Assert.AreEqual (TypeCode.UInt32, Type.GetTypeCode (typeof (uint)), "#17");
2824                         Assert.AreEqual (TypeCode.UInt64, Type.GetTypeCode (typeof (ulong)), "#18");
2825                 }
2826
2827                 [Test]
2828                 public void GetTypeFromHandle_Handle_Zero ()
2829                 {
2830                         RuntimeTypeHandle handle = new RuntimeTypeHandle ();
2831
2832                         Assert.IsNull (Type.GetTypeFromHandle (handle));
2833                 }
2834
2835                 [Test]
2836                 public void GetTypeHandle_O_Null ()
2837                 {
2838                         try {
2839                                 Type.GetTypeHandle (null);
2840                                 Assert.Fail ("#1");
2841                         } catch (ArgumentNullException ex) {
2842                                 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2843                                 Assert.IsNull (ex.InnerException, "#3");
2844                                 Assert.IsNotNull (ex.Message, "#4");
2845                                 Assert.IsNull (ex.ParamName, "#5");
2846                         }
2847                 }
2848
2849                 [Test] // GetConstructor (Type [])
2850                 public void GetConstructor1 ()
2851                 {
2852                         Type type;
2853                         ConstructorInfo ctor;
2854
2855                         type = typeof (CtorsA);
2856                         ctor = type.GetConstructor (Type.EmptyTypes);
2857                         Assert.IsNotNull (ctor, "#A1");
2858                         Assert.AreEqual (0, ctor.GetParameters ().Length, "#A2");
2859                         Assert.IsFalse (ctor.IsStatic, "#A3");
2860                         Assert.IsTrue (ctor.IsPublic, "#A4");
2861                         Assert.AreEqual (".ctor", ctor.Name, "#A5");
2862
2863                         type = typeof (CtorsB);
2864                         ctor = type.GetConstructor (Type.EmptyTypes);
2865                         Assert.IsNotNull (ctor, "#B1");
2866                         Assert.AreEqual (0, ctor.GetParameters ().Length, "#B2");
2867                         Assert.IsFalse (ctor.IsStatic, "#B3");
2868                         Assert.IsTrue (ctor.IsPublic, "#B4");
2869                         Assert.AreEqual (".ctor", ctor.Name, "#B5");
2870
2871                         type = typeof (CtorsC);
2872                         ctor = type.GetConstructor (Type.EmptyTypes);
2873                         Assert.IsNull (ctor, "#C");
2874
2875                         type = typeof (CtorsC);
2876                         ctor = type.GetConstructor (new Type [] { typeof (int) });
2877                         Assert.IsNotNull (ctor, "#D1");
2878                         Assert.AreEqual (1, ctor.GetParameters ().Length, "#D2");
2879                         Assert.IsFalse (ctor.IsStatic, "#D3");
2880                         Assert.IsTrue (ctor.IsPublic, "#D4");
2881                         Assert.AreEqual (".ctor", ctor.Name, "#D5");
2882                 }
2883
2884                 [Test] // GetConstructor (Type [])
2885                 public void GetConstructor1_Types_Null ()
2886                 {
2887                         try {
2888                                 typeof (BindingFlags).GetConstructor (null);
2889                                 Assert.Fail ("#1");
2890                         } catch (ArgumentNullException ex) {
2891                                 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2892                                 Assert.IsNull (ex.InnerException, "#3");
2893                                 Assert.IsNotNull (ex.Message, "#4");
2894                                 Assert.IsNotNull (ex.ParamName, "#5");
2895                                 Assert.AreEqual ("types", ex.ParamName, "#6");
2896                         }
2897                 }
2898
2899                 [Test] // GetConstructor (Type [])
2900                 public void GetConstructor1_Types_ItemNull ()
2901                 {
2902                         Type type = typeof (BindingFlags);
2903                         try {
2904                                 type.GetConstructor (new Type[1] { null });
2905                                 Assert.Fail ("#A1");
2906                         } catch (ArgumentNullException ex) {
2907                                 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
2908                                 Assert.IsNull (ex.InnerException, "#A3");
2909                                 Assert.IsNotNull (ex.Message, "#A4");
2910                                 Assert.IsNotNull (ex.ParamName, "#A5");
2911                                 Assert.AreEqual ("types", ex.ParamName, "#A6");
2912                         }
2913
2914                         type = typeof (TakesInt);
2915                         try {
2916                                 type.GetConstructor (new Type [1] { null });
2917                                 Assert.Fail ("#B1");
2918                         } catch (ArgumentNullException ex) {
2919                                 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
2920                                 Assert.IsNull (ex.InnerException, "#B3");
2921                                 Assert.IsNotNull (ex.Message, "#B4");
2922                                 Assert.IsNotNull (ex.ParamName, "#B5");
2923                                 Assert.AreEqual ("types", ex.ParamName, "#B6");
2924                         }
2925                 }
2926
2927                 [Test] // GetConstructor (BindingFlags, Binder, Type [], ParameterModifier [])
2928                 public void GetConstructor2_Types_ItemNull ()
2929                 {
2930                         Type type = typeof (BindingFlags);
2931                         try {
2932                                 type.GetConstructor (BindingFlags.Default, null,
2933                                         new Type[1] { null }, null);
2934                                 Assert.Fail ("#1");
2935                         } catch (ArgumentNullException ex) {
2936                                 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2937                                 Assert.IsNull (ex.InnerException, "#3");
2938                                 Assert.IsNotNull (ex.Message, "#4");
2939                                 Assert.IsNotNull (ex.ParamName, "#5");
2940                                 Assert.AreEqual ("types", ex.ParamName, "#6");
2941                         }
2942                 }
2943
2944                 [Test] // GetConstructor (BindingFlags, Binder, CallingConventions, Type [], ParameterModifier [])
2945                 public void GetConstructor3_Types_ItemNull ()
2946                 {
2947                         Type type = typeof (BindingFlags);
2948                         try {
2949                                 type.GetConstructor (BindingFlags.Default,
2950                                         null, CallingConventions.Any,
2951                                         new Type[1] { null }, null);
2952                                 Assert.Fail ("#1");
2953                         } catch (ArgumentNullException ex) {
2954                                 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2955                                 Assert.IsNull (ex.InnerException, "#3");
2956                                 Assert.IsNotNull (ex.Message, "#4");
2957                                 Assert.IsNotNull (ex.ParamName, "#5");
2958                                 Assert.AreEqual ("types", ex.ParamName, "#6");
2959                         }
2960                 }
2961
2962                 [Test]
2963                 public void GetMethod_Bug77367 ()
2964                 {
2965                         MethodInfo i = typeof (Bug77367).GetMethod ("Run", Type.EmptyTypes);
2966                         Assert.IsNull (i);
2967                 }
2968
2969 #if !MOBILE
2970                 [Test]
2971                 public void EqualsUnderlyingType ()
2972                 {
2973                         AssemblyBuilderAccess access = AssemblyBuilderAccess.RunAndSave;
2974                         TypeAttributes attribs = TypeAttributes.Public;
2975
2976                         AssemblyName name = new AssemblyName ();
2977                         name.Name = "enumtest";
2978                         AssemblyBuilder assembly = 
2979                                 AppDomain.CurrentDomain.DefineDynamicAssembly (
2980                                         name, access);
2981
2982                         ModuleBuilder module = assembly.DefineDynamicModule 
2983                                 ("m", "enumtest.dll");
2984                         EnumBuilder e = module.DefineEnum ("E", attribs, typeof (int));
2985
2986                         Assert.IsTrue (typeof (int).Equals (e));
2987                 }
2988 #endif
2989
2990                 [Test]
2991                 public void Equals_Type_Null ()
2992                 {
2993                         Assert.IsFalse (typeof (int).Equals ((Type) null), "#1");
2994                         Assert.IsFalse (typeof (int).Equals ((object) null), "#2");
2995                 }
2996
2997                 [Test]
2998                 public void GetElementType_Bug63841 ()
2999                 {
3000                         Assert.IsNull (typeof (TheEnum).GetElementType (), "#1");
3001                 }
3002
3003                 [Test]
3004                 public void FullNameGenerics ()
3005                 {
3006                         Type fooType = typeof (Foo<>);
3007                         FieldInfo [] fields = fooType.GetFields ();
3008
3009                         Assert.AreEqual (1, fields.Length, "#0");
3010
3011                         Assert.IsNotNull (fooType.FullName, "#1");
3012                         Assert.IsNotNull (fooType.AssemblyQualifiedName, "#1a");
3013
3014                         FieldInfo field = fooType.GetField ("Whatever");
3015                         Assert.IsNotNull (field, "#2");
3016                         Assert.AreEqual (field, fields [0], "#2a");
3017                         Assert.IsNull (field.FieldType.FullName, "#3");
3018                         Assert.IsNull (field.FieldType.AssemblyQualifiedName, "#3a");
3019                         Assert.IsNotNull (field.FieldType.ToString (), "#4");
3020
3021                         PropertyInfo prop = fooType.GetProperty ("Test");
3022                         Assert.IsNotNull (prop, "#5");
3023                         Assert.IsNull (prop.PropertyType.FullName, "#6");
3024                         Assert.IsNull (prop.PropertyType.AssemblyQualifiedName, "#6a");
3025                         Assert.IsNotNull (prop.PropertyType.ToString (), "#7");
3026
3027                         MethodInfo method = fooType.GetMethod("Execute");
3028                         Assert.IsNotNull (method, "#8");
3029                         Assert.IsNull (method.ReturnType.FullName, "#9");
3030                         Assert.IsNull (method.ReturnType.AssemblyQualifiedName, "#9a");
3031                         Assert.IsNotNull (method.ReturnType.ToString (), "#10");
3032
3033                         ParameterInfo[] parameters = method.GetParameters();
3034                         Assert.AreEqual (1, parameters.Length, "#11");
3035                         Assert.IsNull (parameters[0].ParameterType.FullName, "#12");
3036                         Assert.IsNull (parameters[0].ParameterType.AssemblyQualifiedName, "#12a");
3037                         Assert.IsNotNull (parameters[0].ParameterType.ToString (), "#13");
3038                 }
3039
3040                 [Test]
3041                 public void TypeParameterIsNotGeneric ()
3042                 {
3043                         Type fooType = typeof (Foo<>);
3044                         Type type_param = fooType.GetGenericArguments () [0];
3045                         Assert.IsTrue (type_param.IsGenericParameter);
3046                         Assert.IsFalse (type_param.IsGenericType);
3047                         Assert.IsFalse (type_param.IsGenericTypeDefinition);
3048
3049                         // LAMESPEC: MSDN claims that this should be false, but .NET v2.0.50727 says it's true
3050                         // http://msdn2.microsoft.com/en-us/library/system.type.isgenerictype.aspx
3051                         Assert.IsTrue (type_param.ContainsGenericParameters);
3052                 }
3053
3054                 [Test]
3055                 public void IsAssignable ()
3056                 {
3057                         Type foo_type = typeof (Foo<>);
3058                         Type foo_int_type = typeof (Foo<int>);
3059                         Assert.IsFalse (foo_type.IsAssignableFrom (foo_int_type), "Foo<int> -!-> Foo<>");
3060                         Assert.IsFalse (foo_int_type.IsAssignableFrom (foo_type), "Foo<> -!-> Foo<int>");
3061
3062                         Type ibar_short_type = typeof (IBar<short>);
3063                         Type ibar_int_type = typeof (IBar<int>);
3064                         Type baz_short_type = typeof (Baz<short>);
3065                         Type baz_int_type = typeof (Baz<int>);
3066
3067                         Assert.IsTrue (ibar_int_type.IsAssignableFrom (baz_int_type), "Baz<int> -> IBar<int>");
3068                         Assert.IsTrue (ibar_short_type.IsAssignableFrom (baz_short_type), "Baz<short> -> IBar<short>");
3069
3070                         Assert.IsFalse (ibar_int_type.IsAssignableFrom (baz_short_type), "Baz<short> -!-> IBar<int>");
3071                         Assert.IsFalse (ibar_short_type.IsAssignableFrom (baz_int_type), "Baz<int> -!-> IBar<short>");
3072
3073                         // Nullable tests
3074                         Assert.IsTrue (typeof (Nullable<int>).IsAssignableFrom (typeof (int)));
3075                         Assert.IsFalse (typeof (int).IsAssignableFrom (typeof (Nullable<int>)));
3076                         Assert.IsTrue (typeof (Nullable<FooStruct>).IsAssignableFrom (typeof (FooStruct)));
3077                 }
3078
3079                 [Test]
3080                 public void IsInstanceOf ()
3081                 {
3082                         Assert.IsTrue (typeof (Nullable<int>).IsInstanceOfType (5));
3083                 }
3084
3085                 [Test]
3086                 public void IsInstanceOfArrayOfNullable ()
3087                 {
3088                         Assert.IsTrue (typeof (Nullable<int>[]).IsInstanceOfType (new Nullable<int> [0]));
3089                 }
3090
3091                 [Test]
3092                 public void IsInstanceOfType_Null ()
3093                 {
3094                         Assert.IsFalse (typeof (int).IsInstanceOfType (null), "int");
3095                         Assert.IsFalse (typeof (object).IsInstanceOfType (null), "object");
3096                         Assert.IsFalse (typeof (int?).IsInstanceOfType (null), "int?");
3097                 }
3098
3099                 [Test]
3100                 public void ByrefType ()
3101                 {
3102                         Type foo_type = typeof (Foo<>);
3103                         Type type_param = foo_type.GetGenericArguments () [0];
3104                         Type byref_type_param = type_param.MakeByRefType ();
3105                         Assert.IsFalse (byref_type_param.IsGenericParameter);
3106                         Assert.IsNull (byref_type_param.DeclaringType);
3107                 }
3108
3109                 [Test]
3110                 [ExpectedException (typeof (TypeLoadException))]
3111                 public void MakeByRefByRef ()
3112                 {
3113                         typeof (int).MakeByRefType ().MakeByRefType ();
3114                 }
3115
3116                 [Test]
3117                 public void MakeArrayTypeTest ()
3118                 {
3119                         // This should not crash:
3120                         Type t = typeof (void).MakeArrayType ();
3121                 }
3122                 
3123                 [Test]
3124                 [ExpectedException (typeof (InvalidProgramException))]
3125                 public void MakeArrayTypedReferenceInstanceTest ()
3126                 {
3127                         object o = Array.CreateInstance (typeof (global::System.TypedReference), 1);
3128                 }
3129
3130                 [Test]
3131                 public void MakeArrayTypeLargeRank ()
3132                 {
3133                         Assert.Throws<TypeLoadException> (delegate () {
3134                                         typeof (int).MakeArrayType (33);
3135                                 });
3136                 }
3137
3138                 [ComVisible (true)]
3139                 public class ComFoo<T> {
3140                 }
3141
3142                 [Test]
3143                 public void GetCustomAttributesGenericInstance ()
3144                 {
3145                         Assert.AreEqual (1, typeof (ComFoo<int>).GetCustomAttributes (typeof (ComVisibleAttribute), true).Length);
3146                 }
3147
3148                 interface ByRef1<T> { void f (ref T t); }
3149                 interface ByRef2 { void f<T> (ref T t); }
3150
3151                 interface ByRef3<T> where T:struct { void f (ref T? t); }
3152                 interface ByRef4 { void f<T> (ref T? t) where T:struct; }
3153
3154                 void CheckGenericByRef (Type t)
3155                 {
3156                         string name = t.Name;
3157                         t = t.GetMethod ("f").GetParameters () [0].ParameterType;
3158
3159                         Assert.IsFalse (t.IsGenericType, name);
3160                         Assert.IsFalse (t.IsGenericTypeDefinition, name);
3161                         Assert.IsFalse (t.IsGenericParameter, name);
3162                 }
3163
3164                 [Test]
3165                 public void GenericByRef ()
3166                 {
3167                         CheckGenericByRef (typeof (ByRef1<>));
3168                         CheckGenericByRef (typeof (ByRef2));
3169                         CheckGenericByRef (typeof (ByRef3<>));
3170                         CheckGenericByRef (typeof (ByRef4));
3171                 }
3172
3173                 public class Bug80242<T> {
3174                         public interface IFoo { }
3175                         public class Bar : IFoo { }
3176                         public class Baz : Bar { }
3177                 }
3178
3179                 [Test]
3180                 public void TestNestedTypes ()
3181                 {
3182                         Type t = typeof (Bug80242<object>);
3183                         Assert.IsFalse (t.IsGenericTypeDefinition);
3184                         foreach (Type u in t.GetNestedTypes ()) {
3185                                 Assert.IsTrue (u.IsGenericTypeDefinition, "{0} isn't a generic definition", u);
3186                                 Assert.AreEqual (u, u.GetGenericArguments () [0].DeclaringType);
3187                         }
3188                 }
3189
3190                 [Test] // bug #82211
3191                 public void GetMembers_GenericArgument ()
3192                 {
3193                         Type argType = typeof (ComFoo<>).GetGenericArguments () [0];
3194                         MemberInfo [] members = argType.GetMembers ();
3195                         Assert.IsNotNull (members, "#1");
3196                         Assert.AreEqual (4, members.Length, "#2");
3197                 }
3198
3199                 [Test]
3200                 [ExpectedException (typeof (ArgumentNullException))]
3201                 public void ReflectionOnlyGetTypeNullTypeName ()
3202                 {
3203                         Type.ReflectionOnlyGetType (null, false, false);
3204                 }
3205
3206                 [Test]
3207                 public void ReflectionOnlyGetTypeDoNotThrow ()
3208                 {
3209                         Assert.IsNull (Type.ReflectionOnlyGetType ("a, nonexistent.dll", false, false));
3210                 }
3211
3212                 [Test]
3213                 [ExpectedException (typeof (FileNotFoundException))]
3214                 public void ReflectionOnlyGetTypeThrow ()
3215                 {
3216                         Type.ReflectionOnlyGetType ("a, nonexistent.dll", true, false);
3217                 }
3218
3219                 [Test]
3220                 public void ReflectionOnlyGetType ()
3221                 {
3222                         Type t = Type.ReflectionOnlyGetType (typeof (int).AssemblyQualifiedName.ToString (), true, true);
3223                         Assert.AreEqual ("System.Int32", t.FullName);
3224                 }
3225
3226                 [Test]
3227 #if MONOTOUCH || FULL_AOT_RUNTIME
3228                 [ExpectedException (typeof (NotSupportedException))]
3229 #endif
3230                 public void MakeGenericType_UserDefinedType ()
3231                 {
3232                         Type ut = new UserType (typeof (int));
3233                         Type t = typeof (Foo<>).MakeGenericType (ut);
3234                         Assert.IsTrue (t.IsGenericType, "#A1");
3235                         Assert.AreEqual (1, t.GetGenericArguments ().Length, "#A2");
3236
3237                         Type arg = t.GetGenericArguments () [0];
3238                         Assert.IsNotNull (arg, "#B1");
3239                         Assert.IsFalse (arg.IsGenericType, "#B2");
3240                         Assert.AreEqual (ut, arg, "#B3");
3241                 }
3242
3243                 [Test]
3244 #if MONOTOUCH || FULL_AOT_RUNTIME
3245                 [ExpectedException (typeof (NotSupportedException))]
3246 #endif
3247                 public void MakeGenericType_NestedUserDefinedType ()
3248                 {
3249                         Type ut = new UserType (new UserType (typeof (int)));
3250                         Type t = typeof (Foo<>).MakeGenericType (ut);
3251                         Assert.IsTrue (t.IsGenericType, "#A1");
3252                         Assert.AreEqual (1, t.GetGenericArguments ().Length, "#A2");
3253
3254                         Type arg = t.GetGenericArguments () [0];
3255                         Assert.IsNotNull (arg, "#B1");
3256                         Assert.IsFalse (arg.IsGenericType, "#B2");
3257                         Assert.AreEqual (ut, arg, "#B3");
3258                 }
3259                 
3260                 [Test]
3261 #if MONOTOUCH || FULL_AOT_RUNTIME
3262                 [ExpectedException (typeof (NotSupportedException))]
3263 #endif
3264                 public void TestMakeGenericType_UserDefinedType_DotNet20SP1 () 
3265                 {
3266                         Type ut = new UserType(typeof(int));
3267                         Type t = typeof(Foo<>).MakeGenericType(ut);
3268                         Assert.IsTrue (t.IsGenericType, "#1");
3269
3270                         Assert.AreEqual (ut, t.GetGenericArguments()[0], "#2");
3271                 }
3272                 
3273                 [Test]
3274 #if MONOTOUCH || FULL_AOT_RUNTIME
3275                 [ExpectedException (typeof (NotSupportedException))]
3276 #endif
3277                 public void MakeGenericType_BadUserType ()
3278                 {
3279                         Type ut = new UserType (null);
3280                         Type t = typeof (Foo<>).MakeGenericType (ut);
3281                         var g0 = t.GetGenericArguments () [0];
3282                         Assert.AreSame (g0, ut, "#1");
3283                 }
3284
3285                 [Test]
3286                 public void MakeGenericType_WrongNumOfArguments ()
3287                 {
3288                         try {
3289                                 Type t = typeof (Foo<,>).MakeGenericType (new Type [] { typeof (int) });
3290                                 Assert.Fail ("#1");
3291                         } catch (ArgumentException) {
3292                         }
3293                 }
3294
3295                 [AttributeUsage (AttributeTargets.All)]
3296                 public class DocAttribute : Attribute {
3297                         public DocAttribute (string docs) {}
3298                 }
3299                 
3300                 class GenericClassWithAttributes<[Doc ("T")] T, [Doc ("B")] B> 
3301                         where T : class, new ()
3302                         where B : Attribute
3303                 {
3304                         public T Bar { get{return null;}}
3305
3306                         public void M<[Doc ("X")] X> (X x)
3307                         {
3308                         }
3309                 }
3310         
3311                 [Test] //bug #377596
3312                 public void GetGenericArguments_ArgumentsHaveAttributes ()
3313                 {
3314                         Type type = typeof(GenericClassWithAttributes<,>);
3315                         Type[] tArgs = type.GetGenericArguments ();
3316                         MethodInfo m = type.GetMethod ("M");
3317                         Type[] mArgs = m.GetGenericArguments ();
3318                         Assert.AreEqual(1, tArgs[0].GetCustomAttributes (typeof (DocAttribute), true).Length, "#1");
3319                         Assert.AreEqual(1, tArgs[1].GetCustomAttributes (typeof (DocAttribute), true).Length, "#1");
3320                         Assert.AreEqual(1, mArgs[0].GetCustomAttributes (typeof (DocAttribute), true).Length, "#1");
3321                 }
3322
3323                 [Test] //bug #471255
3324                 public void GetTypeCalledUsingReflection ()
3325                 {
3326                         Type expectedType = Type.GetType ("NoNamespaceClass");
3327                         Assert.IsNotNull (expectedType, "#1");
3328                         MethodInfo m = typeof (Type).GetMethod ("GetType",  BindingFlags.Public | BindingFlags.Static, null, new Type [] { typeof (string) },  null);
3329                         object r = m.Invoke (null, BindingFlags.Default, null, new object [] { "NoNamespaceClass" }, CultureInfo.InvariantCulture);
3330                         Assert.AreSame (expectedType, r, "#2");
3331                 }
3332
3333                 public class BConstrained<Y> where Y : BConstrained<Y> {
3334                 }
3335
3336                 public class AConstrained<X> : BConstrained<AConstrained<X>> {
3337                 }
3338
3339                 [Test] // Bug https://bugzilla.xamarin.com/show_bug.cgi?id=54485
3340                 public void MakeGenericType_GTD_Constraint ()
3341                 {
3342                         // This is pretty weird, but match .NET behavior (note
3343                         // that typeof(BConstrained<AConstrained<>>) is a
3344                         // compile-time error with roslyn, but it's apparently
3345                         // an ok thing to make with reflection.
3346                         var tb = typeof (BConstrained<>);
3347                         var ta = typeof (AConstrained<>);
3348                         var result = tb.MakeGenericType (ta);
3349                         Assert.IsNotNull (result, "#1");
3350                         // lock down the answer to match what .NET makes
3351                         Assert.IsTrue (result.IsGenericType, "#2");
3352                         Assert.AreEqual (tb, result.GetGenericTypeDefinition (), "#3");
3353                         var bargs = result.GetGenericArguments ();
3354                         Assert.AreEqual (1, bargs.Length, "#4");
3355                         var arg = bargs [0];
3356                         Assert.IsTrue (arg.IsGenericType, "#5");
3357                         // N.B. evidently AConstrained`1 and AConstrained`1<!0> are the same type
3358                         Assert.IsTrue (arg.IsGenericTypeDefinition, "#6");
3359                         Assert.AreEqual (ta, arg.GetGenericTypeDefinition (), "#7");
3360                         var aargs = arg.GetGenericArguments ();
3361                         Assert.AreEqual (1, aargs.Length, "#8");
3362                         Assert.AreEqual (ta.GetGenericArguments () [0], aargs [0], "#9");
3363                 }
3364
3365         [Test]
3366         public void EqualsUserType () {
3367                 UserType2 t1 = new UserType2(null);
3368                 UserType2 t2 = new UserType2(t1);
3369                 Assert.IsTrue (t1.Equals(t2));
3370         }
3371
3372         [Test]
3373         public void GetHashCodeUserType () {
3374                 UserType2 t1 = new UserType2(null);
3375                 UserType2 t2 = new UserType2(t1);
3376                 Assert.AreEqual (42, t2.GetHashCode());
3377         }
3378         
3379         [Test]
3380         public void IsGenericTypeDefinitionUserType () {
3381                 Assert.IsFalse (new UserType(null).IsGenericTypeDefinition);
3382         }
3383         
3384         [Test]
3385         public void IsGenericTypeUserType () {
3386                 Assert.IsFalse (new UserType(null).IsGenericType);
3387         }
3388
3389         [Test]
3390         [ExpectedException (typeof (NotSupportedException))]
3391         public void GetGenericTypeDefinitionUserType () {
3392                 new UserType(null).GetGenericTypeDefinition ();
3393         }
3394
3395         [ExpectedException (typeof (NotSupportedException))]
3396         public void GetGenericArgumentsUserType () {
3397                 new UserType(null).GetGenericArguments ();
3398         }
3399         
3400         [Test]
3401         [ExpectedException (typeof (InvalidOperationException))]
3402         public void GenericParameterPositionUserType () {
3403                 Assert.IsTrue (new UserType(null).GenericParameterPosition == 0);
3404         }
3405
3406                 [Test]
3407                 public void TypeGetMemberReturnTypeTest ()
3408                 {
3409                         object obj;
3410                         MemberTypes memtype;
3411                         Type testtype;
3412                         object [] flagsandtypes = new object [] {
3413                                 MemberTypes.All, typeof (MemberInfo []),
3414                                 MemberTypes.Constructor, typeof (ConstructorInfo []),
3415                                 MemberTypes.Custom, typeof (MemberInfo []),
3416                                 MemberTypes.Event, typeof (EventInfo []),
3417                                 MemberTypes.Field, typeof (FieldInfo []),
3418                                 MemberTypes.Method, typeof (MethodInfo []),
3419                                 MemberTypes.NestedType, typeof (Type []),
3420                                 MemberTypes.Property, typeof (PropertyInfo []),
3421                                 MemberTypes.TypeInfo, typeof (Type [])};
3422
3423                         for (int i=0; i < flagsandtypes.Length; i+=2) {
3424                                 memtype = (MemberTypes)flagsandtypes [i];
3425                                 testtype = (Type)flagsandtypes [i+1];
3426                                 obj = GetType ().GetMember ("DummyMember", memtype,
3427                                                 BindingFlags.Public | BindingFlags.Instance);
3428                                 Assert.AreEqual (testtype.GetHashCode (), obj.GetType ().GetHashCode (),
3429                                                 "Expected #" + i + " " + testtype.FullName);
3430                         }
3431
3432                 }
3433  
3434                 [Test]
3435                 public void TypeNameStartsWithSpace ()
3436                 {
3437                         Type t1 = Type.GetType ("System.Type, mscorlib");
3438                         Type t2 = Type.GetType (" System.Type, mscorlib");
3439                         Assert.AreEqual (t1, t2);
3440                 }
3441
3442 #if !MONOTOUCH && !FULL_AOT_RUNTIME
3443                 [Test]
3444                 public void SpaceAfterComma () {
3445                         string strType = "System.Collections.Generic.Dictionary`2[[System.Int32,mscorlib], [System.String,mscorlib]],mscorlib";
3446                         Assert.IsTrue (Type.GetType (strType) != null);
3447                 }
3448 #endif
3449
3450 #if !MONOTOUCH && !FULL_AOT_RUNTIME
3451                 [Test]
3452                 public void Bug506757 ()
3453                 {
3454                         AssemblyName assemblyName = new AssemblyName ();
3455                         assemblyName.Name = "customMod";
3456                         assemblyName.Version = new Version (1, 2, 3, 4);
3457         
3458                         AssemblyBuilder assembly 
3459                                 = Thread.GetDomain().DefineDynamicAssembly(
3460                                           assemblyName, AssemblyBuilderAccess.RunAndSave);
3461         
3462                         ModuleBuilder module = assembly.DefineDynamicModule("res.exe", "res.exe");
3463         
3464                         TypeBuilder type0 = module.DefineType ("Base", TypeAttributes.Public, typeof (object));
3465                         TypeBuilder type1 = module.DefineType ("Middle", TypeAttributes.Public, type0);
3466                         TypeBuilder type2 = module.DefineType ("End", TypeAttributes.Public, type1);
3467         
3468                         MethodAttributes attrs0 = MethodAttributes.Virtual | MethodAttributes.HideBySig |
3469                                                   MethodAttributes.NewSlot | MethodAttributes.FamORAssem;
3470         
3471                         MethodAttributes attrs1 = MethodAttributes.Virtual | MethodAttributes.HideBySig |
3472                                                   MethodAttributes.FamORAssem;
3473         
3474                         MethodAttributes attrs2 = MethodAttributes.Virtual | MethodAttributes.HideBySig |
3475                                                   MethodAttributes.Public;
3476         
3477         
3478                         MethodBuilder m0 = type0.DefineMethod ("Tst", attrs0, typeof (void), null);
3479                         m0.GetILGenerator ().Emit (OpCodes.Ret);
3480         
3481                         MethodBuilder m1 = type1.DefineMethod ("Tst", attrs1, typeof (void), null);
3482                         m1.GetILGenerator ().Emit (OpCodes.Ret);
3483         
3484                         MethodBuilder m2 = type2.DefineMethod ("Tst", attrs2, typeof (void), null);
3485                         m2.GetILGenerator ().Emit (OpCodes.Ret);
3486         
3487         
3488                         type0.CreateType ();
3489                         type1.CreateType ();
3490                         Type t2 = type2.CreateType ();
3491         
3492                         foreach (var m in t2.GetMethods (BindingFlags.Instance | BindingFlags.NonPublic))
3493                                 Assert.IsTrue (m.DeclaringType == typeof (object), String.Format ("{0}::{1}", m.DeclaringType, m.Name));
3494                 }
3495 #endif
3496                 [Test]
3497                 public void MakeArrayTypeOfOneDimension ()
3498                 {
3499                         Type vector = typeof (int).MakeArrayType ();
3500                         Type szarray = typeof (int).MakeArrayType (1);
3501
3502                         Assert.AreNotEqual (vector, szarray, "#1");
3503                         Assert.AreEqual ("Int32[]", vector.Name, "#2");
3504                         Assert.AreEqual ("Int32[*]", szarray.Name, "#3");
3505                 }
3506
3507                 public class DeclaringMethodFoo {
3508                         public void Test<T> (T t) {}
3509                         public void Test2<T> (ref T t) {}
3510                 }
3511
3512                 public class DeclaringMethodBar<T> {
3513                         public void Test2 (ref T t) {}
3514                 }
3515
3516                 [Test]
3517                 public void DeclaringMethodOnlyWorksWithGenericArgs ()
3518                 {
3519                 MethodInfo testMethod = typeof (DeclaringMethodFoo).GetMethod ("Test");
3520                 MethodBase otherMethod = testMethod.GetParameters ()[0].ParameterType.DeclaringMethod;
3521
3522                         Assert.AreEqual (testMethod, otherMethod,"#1");
3523
3524                         Assert.IsNull (typeof (DeclaringMethodBar<>).GetGenericArguments ()[0].DeclaringMethod, "#2");
3525
3526                         try {
3527                                 var x = typeof (int).DeclaringMethod;
3528                                 Assert.Fail ("#3");
3529                         } catch (InvalidOperationException) {}
3530
3531                         try {
3532                                 var x = typeof (DeclaringMethodFoo).GetMethod ("Test2").GetParameters () [0].ParameterType.DeclaringMethod;
3533                                 Assert.Fail ("#4");
3534                         } catch (InvalidOperationException) {}
3535
3536                         try {
3537                                 var x = typeof (DeclaringMethodBar<>).GetMethod ("Test2").GetParameters () [0].ParameterType.DeclaringMethod;
3538                                 Assert.Fail ("#5");
3539                         } catch (InvalidOperationException) {}
3540
3541                 }
3542
3543                 [Test]
3544                 public void GetArrayRankThrowsForNonArrayType ()
3545                 {
3546                         Assert.AreEqual (1, typeof (int[]).GetArrayRank (), "#1");
3547                         Assert.AreEqual (2, typeof (int[,]).GetArrayRank (), "#2");
3548                         try {
3549                                 typeof (int).GetArrayRank ();
3550                                 Assert.Fail ("#3");
3551                         } catch (ArgumentException) {}
3552                 }
3553
3554                 [Test] //Bug #564379
3555                 public void GetMethodsReturnPublicMethodsInInterfaces ()
3556                 {
3557                         Type t = typeof (NonClosingStream);
3558                         MethodInfo[] methods = t.GetMethods (BindingFlags.Public | BindingFlags.Instance);
3559
3560                         Assert.AreEqual (5, methods.Length, "#1");
3561                         int id = 2;
3562
3563                         foreach (var m in methods) {
3564                                 if (m.Name.Equals ("ToString"))
3565                                         Assert.IsTrue (m.DeclaringType == typeof (NonClosingStream), "#" + id);
3566                                 else if (m.Name.Equals ("Dispose") && m.GetParameters ().Length == 0)
3567                                         Assert.IsTrue (m.DeclaringType == typeof (Stream), "#" + id);
3568                                 else if (m.Name.Equals ("Equals") || m.Name.Equals ("GetHashCode") || m.Name.Equals ("GetType"))
3569                                         Assert.IsTrue (m.DeclaringType == typeof (object), "#" + id);
3570                                 else
3571                                         Assert.Fail ("invalid method " + m);
3572                                 ++id;
3573                         }
3574                 }
3575
3576                 [Test] // Bug #574696
3577                 public void GetMember_DoesntReturnPrivatePropOfParent ()
3578                 {
3579                         BindingFlags flags = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance;
3580                         Assert.AreEqual (1, typeof (Bar).GetMember ("PrivInst", flags).Length);
3581                         Assert.AreEqual (0, typeof (Bar).GetMember ("PrivInstBase", flags).Length);
3582                         Assert.AreEqual (1, typeof (Foo).GetMember ("PrivInstBase", flags).Length);
3583                 }
3584
3585                 [Test] // Bug #484246
3586                 public void GetInterfaceCompareAgainstGTDNames ()
3587                 {
3588                         var t = typeof (Dictionary<string,string>);
3589                         var iface = typeof (IDictionary<string,string>);
3590
3591                         Assert.AreSame (iface, t.GetInterface ("System.Collections.Generic.IDictionary`2"), "#1");
3592
3593                         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]]";
3594
3595                         Assert.IsNull (t.GetInterface (name), "#2");
3596                 } 
3597
3598                 [Test]
3599                 public void RuntimeCorrectlyNormalizeGenericTypes ()
3600                 {
3601                         Type lst = typeof (MList<>);
3602                         Type arg = lst.GetGenericArguments ()[0];
3603
3604                         Type sup = lst.BaseType;
3605                         Type sa0 = sup.GetGenericArguments ()[0];
3606                         Type sa1 = sup.GetGenericArguments ()[1];
3607
3608                         Assert.IsTrue (sa1 == lst, "#1");
3609                         Assert.IsTrue (sa0 == arg, "#2");
3610
3611                         Type inst = typeof (Cons<,>).MakeGenericType (arg, lst.MakeGenericType (arg));
3612                         Assert.IsTrue (inst == sup, "#3");
3613                 }
3614
3615                 class Cons<T,U>
3616                 {
3617
3618                 }
3619
3620                 class MList<A> : Cons<A, MList<A>>
3621                 {
3622
3623                 }
3624
3625                 [Test] // Bug #331126
3626                 public void IsAssignableFromWorksCorrectlyWithByRefs ()
3627                 {
3628                         Type int_byref = typeof (int).MakeByRefType ();
3629                         Type obj_byref = typeof (object).MakeByRefType ();
3630                         Type long_byref = typeof (long).MakeByRefType ();
3631                         Type enum1_byref = typeof (AttributeTargets).MakeByRefType ();
3632                         Type enum2_byref = typeof (PlatformID).MakeByRefType ();
3633                         Type uint_byref = typeof (uint).MakeByRefType ();
3634                         Type string_byref = typeof (object).MakeByRefType ();
3635                         Type struct0_byref = typeof (Size4).MakeByRefType ();
3636                         Type struct1_byref = typeof (Size4b).MakeByRefType ();
3637                         Type mvar0_byref = typeof (TypeTest).GetMethod ("Bug331126").GetGenericArguments ()[0].MakeByRefType ();
3638                         Type mvar1_byref = typeof (TypeTest).GetMethod ("Bug331126").GetGenericArguments ()[1].MakeByRefType ();
3639
3640                         Assert.IsFalse (typeof (int).IsAssignableFrom (int_byref), "#1");
3641                         Assert.IsFalse (int_byref.IsAssignableFrom (typeof (int)), "#2");
3642                         Assert.IsFalse (obj_byref.IsAssignableFrom (long_byref), "#3");
3643                         Assert.IsFalse (long_byref.IsAssignableFrom (obj_byref), "#4");
3644                         Assert.IsTrue (enum1_byref.IsAssignableFrom (enum2_byref), "#5");
3645                         Assert.IsTrue (enum2_byref.IsAssignableFrom (enum1_byref), "#6");
3646                         Assert.IsTrue (int_byref.IsAssignableFrom (enum2_byref), "#7");
3647                         Assert.IsTrue (enum2_byref.IsAssignableFrom (int_byref), "#8");
3648                         Assert.IsTrue (enum2_byref.IsAssignableFrom (uint_byref), "#9");
3649                         Assert.IsTrue (uint_byref.IsAssignableFrom (enum2_byref), "#10");
3650                         Assert.IsTrue (int_byref.IsAssignableFrom (uint_byref), "#11");
3651                         Assert.IsTrue (uint_byref.IsAssignableFrom (int_byref), "#12");
3652
3653                         Assert.IsTrue (typeof (object).IsAssignableFrom (typeof (long)), "#13");
3654
3655                         Assert.IsTrue (obj_byref.IsAssignableFrom (string_byref), "#14");
3656                         Assert.IsTrue (string_byref.IsAssignableFrom (obj_byref), "#15");
3657
3658                         Assert.IsFalse (uint_byref.IsAssignableFrom (struct0_byref), "#16");
3659                         Assert.IsFalse (struct0_byref.IsAssignableFrom (int_byref), "#17");
3660                         Assert.IsFalse (struct0_byref.IsAssignableFrom (struct1_byref), "#18");
3661
3662                         Assert.IsFalse (obj_byref.IsAssignableFrom (mvar0_byref), "#19");
3663                         Assert.IsFalse (mvar0_byref.IsAssignableFrom (mvar1_byref), "#20");
3664                         Assert.IsTrue (mvar0_byref.IsAssignableFrom (mvar0_byref), "#21");
3665                         Assert.IsFalse (mvar0_byref.IsAssignableFrom (obj_byref), "#22");
3666                 }
3667
3668                 public void Bug331126<T,K> () {}
3669
3670                 public struct Size4 {
3671                         public int field;
3672                 }
3673
3674                 public struct Size4b {
3675                         public int field;
3676                 }
3677
3678                 [Test]
3679                 public void IsAssignableFromGenericArgumentsWithConstraints ()
3680                 {
3681                         // Regression test for #58809
3682
3683                         // Generic Parameters of a gtd should have their
3684                         // constraints respected even when those constraints
3685                         // are other generic parameters themselves.
3686
3687                         var ps = typeof (GenericWithParamConstraints<,,>).GetGenericArguments ();
3688
3689                         var a = ps[0];
3690                         var b = ps[1];
3691                         var c = ps[2];
3692
3693                         // Foo<C>
3694                         var fooOfC = typeof (Foo<>).MakeGenericType (c);
3695
3696                         // constraint B : Foo <C>
3697                         Assert.IsTrue (fooOfC.IsAssignableFrom (b), "#1");
3698
3699                         // constraint A : B
3700                         Assert.IsTrue (b.IsAssignableFrom (a), "#2");
3701
3702                         // A : Foo<C> since A : B and B : Foo<C>
3703                         Assert.IsTrue (fooOfC.IsAssignableFrom (a), "#3");
3704                 }
3705
3706                 class GenericWithParamConstraints<A, B, C> where B : Foo<C> where A : B
3707                 {
3708                 }
3709
3710                 [Test] // Bug #612780
3711                 public void CannotMakeDerivedTypesFromTypedByRef ()
3712                 {
3713                 try {
3714                 typeof (global::System.TypedReference).MakeArrayType ();
3715                 Assert.Fail ("#1");
3716                 } catch (TypeLoadException) { }
3717
3718                 try {
3719                 typeof (global::System.TypedReference).MakeByRefType ();
3720                 Assert.Fail ("#2");
3721                 } catch (TypeLoadException) { }
3722
3723                 try {
3724                 typeof (global::System.TypedReference).MakePointerType ();
3725                 Assert.Fail ("#3");
3726                 } catch (TypeLoadException) { }
3727
3728                 }
3729                 
3730                 [Test] //Bug643890
3731                 public void DeclaringTypeOfGenericNestedTypeInstanceIsOpen ()
3732                 {
3733                         var type = typeof (Foo<int>.Nested<string>);
3734                         Assert.AreSame (typeof (Foo<>), type.DeclaringType, "#1");
3735                 }
3736
3737                 interface IGetInterfaceMap<in T>
3738                 {
3739                     string Bar (T t);
3740                 }
3741
3742                 class GetInterfaceMap : IGetInterfaceMap<object>
3743                 {
3744                     public string Bar (object t)
3745                     {
3746                         return t.GetType ().FullName;
3747                     }
3748                 }
3749
3750                 [Test]
3751                 public void GetInterfaceMapWorksWithVariantIfaces ()
3752                 {
3753                         InterfaceMapping res = typeof (GetInterfaceMap).GetInterfaceMap (typeof (IGetInterfaceMap <object>));
3754                         Assert.AreEqual (typeof (IGetInterfaceMap <object>), res.InterfaceType);
3755                         Assert.AreEqual (typeof (object), res.InterfaceMethods [0].GetParameters () [0].ParameterType);
3756
3757                         res = typeof (GetInterfaceMap).GetInterfaceMap (typeof (IGetInterfaceMap <string>));
3758                         Assert.AreEqual (typeof (IGetInterfaceMap <string>), res.InterfaceType);
3759                         Assert.AreEqual (typeof (string), res.InterfaceMethods [0].GetParameters () [0].ParameterType);
3760                 }
3761
3762
3763                 public class MyType : TypeDelegator {
3764                         public int eq, ust;
3765
3766                         public override bool Equals (Type t) {
3767                                 ++eq;
3768                                 return base.Equals (t);
3769                         }
3770
3771                         public override Type UnderlyingSystemType  {
3772                                 get { 
3773                                         ++ust;
3774                                         return typeof (int);
3775                                 }
3776                         }
3777                 }
3778
3779                 [Test]
3780                 public void NewV4EqualsBehavior ()
3781                 {
3782                         var ta = new MyType ();
3783                         var tb = new MyType ();
3784                         object a = ta, b = tb;
3785
3786                         a.Equals (a);
3787                         Assert.AreEqual (1, ta.eq, "#1");
3788                         Assert.AreEqual (2, ta.ust, "#2");
3789                         a.Equals (b);
3790                         Assert.AreEqual (2, ta.eq, "#3");
3791                         Assert.AreEqual (3, ta.ust, "#4");
3792                         Assert.AreEqual (0, tb.eq, "#5");
3793                         Assert.AreEqual (1, tb.ust, "#6");
3794                 }
3795
3796                 public enum MyRealEnum : short {
3797                         A,B,C
3798                 }
3799
3800
3801                 public enum MyRealEnum2 : byte {
3802                         A,B,C
3803                 }
3804
3805                 public enum MyRealEnum3 : short {
3806                         A,B,C
3807                 }
3808
3809                 public class MyEnum : TypeDelegator {
3810                         public bool is_enum { get; set; }
3811                         public int fields { get; set; }
3812
3813                         public override bool IsSubclassOf (Type c) {
3814                                 return c == typeof (Enum) && is_enum;
3815                         }
3816
3817                         public override FieldInfo[] GetFields (BindingFlags bindingAttr) {
3818                                 if (fields == 0)
3819                                         return null;
3820                                 FieldInfo[] res = new FieldInfo [fields];
3821                                 for (int i = 0; i < fields; ++i) {
3822                                         if ((bindingAttr & BindingFlags.Instance) != 0)
3823                                                 res [i] = typeof (MyRealEnum).GetField ("value__");
3824                                         else
3825                                                 res [i] = typeof (MyRealEnum).GetField ("A");
3826                                 }
3827                                 return res;
3828                         }
3829                 }
3830
3831                 [Test]
3832                 public void GetEnumUnderlyingType () {
3833
3834                         try {
3835                                 new MyEnum () { is_enum = false }.GetEnumUnderlyingType ();
3836                                 Assert.Fail ("#1");
3837                         } catch (ArgumentException) {}
3838
3839                         try {
3840                                 new MyEnum () { is_enum = true, fields = 0 }.GetEnumUnderlyingType ();
3841                                 Assert.Fail ("#2");
3842                         } catch (ArgumentException) {}
3843
3844                         try {
3845                                 new MyEnum () { is_enum = true, fields = 2 }.GetEnumUnderlyingType ();
3846                                 Assert.Fail ("#3");
3847                         } catch (ArgumentException) {}
3848
3849                         Assert.AreSame (typeof (short), new MyEnum () { is_enum = true, fields = 1 }.GetEnumUnderlyingType ());
3850                 }
3851
3852                 [Test]
3853                 public void GetEnumNames () {
3854                         try {
3855                                 new MyEnum () { is_enum = false }.GetEnumNames ();
3856                                 Assert.Fail ("#1");
3857                         } catch (ArgumentException) {}
3858
3859                         var res = new MyEnum () { is_enum = true, fields = 1 }.GetEnumNames ();
3860                         Assert.AreEqual (1, res.Length, "#2");
3861                         Assert.AreEqual ("A", res [0], "#3");
3862
3863                         res = typeof (MyRealEnum).GetEnumNames ();
3864                         Assert.AreEqual (3, res.Length, "#4");
3865                         Assert.AreEqual ("A", res [0], "#5");
3866                         Assert.AreEqual ("B", res [1], "#6");
3867                         Assert.AreEqual ("C", res [2], "#7");
3868                 }
3869
3870                 public enum OutOfOrderEnum : sbyte
3871                 {
3872                         D = -1, C = 2, B = 1, A = 0
3873                 }
3874                                 
3875                 [Test]
3876                 public void GetEnumNamesSortsByUnsignedValue ()
3877                 {
3878                         string[] names = typeof (OutOfOrderEnum).GetEnumNames ();
3879                         Assert.AreEqual (4, names.Length);
3880                         Assert.AreEqual ("A", names [0]);
3881                         Assert.AreEqual ("B", names [1]);
3882                         Assert.AreEqual ("C", names [2]);
3883                         Assert.AreEqual ("D", names [3]);
3884                 }
3885                 
3886                 [Test]
3887                 public void GetEnumValues () {
3888                         try {
3889                                 new MyEnum () { is_enum = false }.GetEnumValues ();
3890                                 Assert.Fail ("#1");
3891                         } catch (ArgumentException) {}
3892
3893                         try {
3894                                 new MyEnum () { is_enum = true }.GetEnumValues ();
3895                                 Assert.Fail ("#2");
3896                         } catch (NotImplementedException) {}
3897
3898                         var array = typeof (MyRealEnum).GetEnumValues ();
3899                         Assert.AreEqual (typeof (MyRealEnum[]), array.GetType (), "#3");
3900                         MyRealEnum[] res = (MyRealEnum[])array;
3901
3902                         Assert.AreEqual (3, res.Length, "#4");
3903                         Assert.AreEqual (MyRealEnum.A, res [0], "#5");
3904                         Assert.AreEqual (MyRealEnum.B, res [1], "#6");
3905                         Assert.AreEqual (MyRealEnum.C, res [2], "#7");
3906                 }
3907
3908                 [Test]
3909                 public void GetEnumValue () {
3910                         try {
3911                                 typeof (MyRealEnum).GetEnumName (null);
3912                                 Assert.Fail ("#1");
3913                         } catch (ArgumentException) { }
3914
3915                         try {
3916                                 new MyEnum () { is_enum = false }.GetEnumName (99);
3917                                 Assert.Fail ("#2");
3918                         } catch (ArgumentException) { }
3919
3920
3921                         Assert.IsNull (new MyEnum () { fields = 1, is_enum = true }.GetEnumName (77), "#3");
3922                         Assert.AreEqual ("A", new MyEnum () { fields = 1, is_enum = true }.GetEnumName (0), "#4");
3923                         Assert.AreEqual ("A", new MyEnum () { fields = 1, is_enum = true }.GetEnumName (MyRealEnum.A), "#5");
3924                         Assert.AreEqual ("A", new MyEnum () { fields = 1, is_enum = true }.GetEnumName (MyRealEnum2.A), "#6");
3925
3926                         Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName (MyRealEnum.A), "#7");
3927                         Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((short)0), "#8");
3928                         Assert.AreEqual ("C", typeof (MyRealEnum).GetEnumName (2), "#9");
3929                         Assert.IsNull (typeof (MyRealEnum).GetEnumName (9), "#10");
3930
3931                         Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((byte)0), "#11");
3932                         Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((sbyte)0), "#12");
3933                         Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName (false), "#13");
3934                         Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((short)0), "#14");
3935                         Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((ushort)0), "#15");
3936                         Assert.IsNull (typeof (MyRealEnum).GetEnumName ('c'), "#16");
3937
3938                         Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((int)0), "#17");
3939                         Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((uint)0), "#18");
3940
3941                         Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((long)0), "#19");
3942                         Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((ulong)0), "#20");
3943
3944                         try {
3945                                 typeof (MyRealEnum).GetEnumName ((float)0);
3946                                 Assert.Fail ("#21");
3947                         } catch (ArgumentException) { }
3948                         try {
3949                                 typeof (MyRealEnum).GetEnumName ((double)0);
3950                                 Assert.Fail ("#22");
3951                         } catch (ArgumentException) { }
3952
3953
3954                         Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((byte)0), "#23");
3955                         Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((sbyte)0), "#24");
3956                         Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName (false), "#25");
3957
3958                         Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((short)0), "#26");
3959                         Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((ushort)0), "#27");
3960
3961                         Assert.IsNull (typeof (MyRealEnum2).GetEnumName ('c'), "#28");
3962
3963                         Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((int)0), "#29");
3964                         Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((uint)0), "#30");
3965
3966                         Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((long)0), "#31");
3967                         Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((ulong)0), "#32");
3968
3969                         try {
3970                                 typeof (MyRealEnum2).GetEnumName ((float)0);
3971                                 Assert.Fail ("#33");
3972                         } catch (ArgumentException) { }
3973                         try {
3974                                 typeof (MyRealEnum2).GetEnumName ((double)0);
3975                                 Assert.Fail ("#34");
3976                         } catch (ArgumentException) { }
3977
3978                         Assert.IsNull (typeof (MyRealEnum2).GetEnumName (12345), "#35");
3979                 }
3980
3981                 [Test]
3982                 public void IsEnumDefined () {
3983                         try {
3984                                 typeof (MyRealEnum).IsEnumDefined (null);
3985                                 Assert.Fail ("#1");
3986                         } catch (ArgumentException) { }
3987
3988                         try {
3989                                 new MyEnum () { is_enum = false }.IsEnumDefined (99);
3990                                 Assert.Fail ("#2");
3991                         } catch (ArgumentException) { }
3992
3993                         try {
3994                                 typeof (MyRealEnum).IsEnumDefined (0);
3995                                 Assert.Fail ("#3");
3996                         } catch (ArgumentException) { }
3997
3998                         try {
3999                                 typeof (MyRealEnum).IsEnumDefined ((ushort)0);
4000                                 Assert.Fail ("#4");
4001                         } catch (ArgumentException) { }
4002
4003                         try {
4004                                 typeof (MyRealEnum).IsEnumDefined (MyRealEnum3.A);
4005                                 Assert.Fail ("#5");
4006                         } catch (ArgumentException) { }
4007
4008                         try {
4009                                 typeof (MyRealEnum).IsEnumDefined (true);
4010                                 Assert.Fail ("#6");
4011                         } catch (ArgumentException) { }
4012
4013                         try {
4014                                 typeof (MyRealEnum).IsEnumDefined (MyRealEnum2.A);
4015                                 Assert.Fail ("#7");
4016                         } catch (ArgumentException) { }
4017
4018                         try {
4019                                 typeof (MyRealEnum).IsEnumDefined (typeof (MyRealEnum));
4020                                 Assert.Fail ("#8");
4021                         } catch (InvalidOperationException) { }
4022
4023                         Assert.IsTrue (typeof (MyRealEnum).IsEnumDefined ((short)0), "#9");
4024                         Assert.IsFalse (typeof (MyRealEnum).IsEnumDefined ((short)88), "#10");
4025                         Assert.IsTrue (typeof (MyRealEnum).IsEnumDefined (MyRealEnum.A), "#11");
4026                         Assert.IsFalse (typeof (MyRealEnum).IsEnumDefined ("d"), "#12");
4027                         Assert.IsTrue  (typeof (MyRealEnum).IsEnumDefined ("A"), "#13");
4028                         Assert.IsFalse  (new MyEnum () { is_enum = true, fields = 1 }.IsEnumDefined ((short)99), "#14");
4029                 }
4030
4031
4032
4033                 public class Outer {
4034                         public class Inner {}
4035                 }
4036
4037
4038                 public class Outer<T> {
4039                         public class Inner {}
4040                 }
4041
4042                 [Test]
4043                 public void GetTypeWithDelegates () {
4044                         var tname = typeof (MyRealEnum).AssemblyQualifiedName;
4045                         var res = Type.GetType (tname, name => {
4046                                         return Assembly.Load (name);
4047                                 },(asm,name,ignore) => {
4048                                         return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4049                                 }, false, false);
4050                         Assert.AreEqual (typeof (MyRealEnum), res, "#1");
4051
4052
4053                         tname = typeof (Dictionary<int, string>).AssemblyQualifiedName;
4054                         res = Type.GetType (tname, name => {
4055                                         return Assembly.Load (name);
4056                                 },(asm,name,ignore) => {
4057                                         return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4058                                 }, false, false);
4059                         Assert.AreEqual (typeof (Dictionary<int, string>), res, "#2");
4060
4061
4062                         tname = typeof (Foo<int>).AssemblyQualifiedName;
4063                         res = Type.GetType (tname, name => {
4064                                         return Assembly.Load (name);
4065                                 },(asm,name,ignore) => {
4066                                         return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4067                                 }, false, false);
4068                         Assert.AreEqual (typeof (Foo<int>), res, "#3");
4069
4070
4071                         tname = typeof (Outer.Inner).AssemblyQualifiedName;
4072                         res = Type.GetType (tname, name => {
4073                                         return Assembly.Load (name);
4074                                 },(asm,name,ignore) => {
4075                                         return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4076                                 }, false, false);
4077                         Assert.AreEqual (typeof (Outer.Inner), res, "#4");
4078
4079
4080                         tname = typeof (Outer<double>.Inner).AssemblyQualifiedName;
4081                         res = Type.GetType (tname, name => {
4082                                         return Assembly.Load (name);
4083                                 },(asm,name,ignore) => {
4084                                         return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4085                                 }, false, false);
4086                         Assert.AreEqual (typeof (Outer<double>.Inner), res, "#5");
4087
4088
4089                         tname = "System.Collections.Generic.List`1[System.Int32]";
4090                         res = Type.GetType (tname, name => {
4091                                         return Assembly.Load (name);
4092                                 },(asm,name,ignore) => {
4093                                         return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4094                                 }, false, false);
4095                         Assert.AreEqual (typeof (List<int>), res, "#6");
4096
4097
4098                         tname = typeof (Foo<>).FullName + "[,][]";
4099                         res = Type.GetType (tname, name => {
4100                                         Console.WriteLine ("resolve-asm name {0}", name);
4101                                         return Assembly.Load (name);
4102                                 },(asm,name,ignore) => {
4103                                         return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4104                                 }, false, false);
4105                         Assert.AreEqual (typeof (Foo<>).MakeArrayType (2).MakeArrayType (), res, "#7");
4106
4107                         tname = string.Format("{0}[{1}][]*&", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName);
4108                         res = Type.GetType (tname, name => {
4109                                         return Assembly.Load (name);
4110                                 },(asm,name,ignore) => {
4111                                         return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4112                                 }, false, false);
4113                         Assert.AreEqual (typeof (Foo<MyRealEnum>[]).MakePointerType ().MakeByRefType (), res, "#8");
4114
4115
4116                         tname = typeof (MyRealEnum).FullName + "[][]";
4117                         res = Type.GetType (tname, name => {
4118                                         return Assembly.Load (name);
4119                                 },(asm,name,ignore) => {
4120                                         return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4121                                 }, false, false);
4122                         Assert.AreEqual (typeof (MyRealEnum[][]), res, "#9");
4123
4124
4125                         tname = typeof (MyRealEnum).FullName + "[*]";
4126                         res = Type.GetType (tname, name => {
4127                                         return Assembly.Load (name);
4128                                 },(asm,name,ignore) => {
4129                                         return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4130                                 }, false, false);
4131                         Assert.AreEqual (typeof (MyRealEnum).MakeArrayType (1), res, "#10");
4132
4133
4134                         tname = typeof (MyRealEnum).FullName + "&";
4135                         res = Type.GetType (tname, name => {
4136                                         return Assembly.Load (name);
4137                                 },(asm,name,ignore) => {
4138                                         return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4139                                 }, false, false);
4140                         Assert.AreEqual (typeof (MyRealEnum).MakeByRefType (), res, "#11");
4141
4142
4143                         tname = typeof (MyRealEnum).FullName + "*";
4144                         res = Type.GetType (tname, name => {
4145                                         return Assembly.Load (name);
4146                                 },(asm,name,ignore) => {
4147                                         return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4148                                 }, false, false);
4149                         Assert.AreEqual (typeof (MyRealEnum).MakePointerType (), res, "#12");
4150
4151                         tname = typeof (MyRealEnum).FullName + "*&";
4152                         res = Type.GetType (tname, name => {
4153                                         return Assembly.Load (name);
4154                                 },(asm,name,ignore) => {
4155                                         return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4156                                 }, false, false);
4157                         Assert.AreEqual (typeof (MyRealEnum).MakePointerType ().MakeByRefType(),
4158                                          res, "#13");
4159
4160                         tname = typeof (MyRealEnum).FullName + "[,]&";
4161                         res = Type.GetType (tname, name => {
4162                                         return Assembly.Load (name);
4163                                 },(asm,name,ignore) => {
4164                                         return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4165                                 }, false, false);
4166                         Assert.AreEqual (typeof (MyRealEnum).MakeArrayType (2).MakeByRefType (),
4167                                          res, "#14");
4168
4169                         tname = typeof (MyRealEnum).FullName + "*[]";
4170                         res = Type.GetType (tname, name => {
4171                                         return Assembly.Load (name);
4172                                 },(asm,name,ignore) => {
4173                                         return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4174                                 }, false, false);
4175                         Assert.AreEqual (typeof (MyRealEnum).MakePointerType().MakeArrayType(),
4176                                          res, "#15");
4177
4178                         // not a very useful type, but ought to be parsed correctly
4179                         tname = typeof (MyRealEnum).FullName + "[]**[]*&";
4180                         res = Type.GetType (tname, name => {
4181                                         return Assembly.Load (name);
4182                                 },(asm,name,ignore) => {
4183                                         return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4184                                 }, false, false);
4185                         Assert.AreEqual (typeof (MyRealEnum).MakeArrayType().MakePointerType().MakePointerType().MakeArrayType().MakePointerType().MakeByRefType(),
4186                                          res, "#16");
4187
4188                         // assembly resolve without type resolve
4189                         res = Type.GetType ("System.String,mscorlib", delegate (AssemblyName aname) { return typeof (int).Assembly; }, null);
4190                         Assert.AreEqual (typeof (string), res);
4191                 }
4192
4193
4194                 public class CustomGetType : TypeDelegator {
4195                         string name;
4196
4197                         public CustomGetType (string name) { this.name = name; }
4198
4199                         public override Type MakeGenericType (Type[] args) {
4200                                 return new CustomGetType ("GINST");
4201                         }
4202
4203                         public override Type GetNestedType(String name, BindingFlags bidingAttr) {
4204                                 return new CustomGetType ("NESTED");
4205                         }
4206
4207                         public override string ToString () { return "UT_" + name; }
4208
4209                         public override string Name {
4210                                 get { return  "UT_" + name; }
4211                         }
4212                 }
4213
4214                 [Test]
4215                 public void GetTypeWithDelegatesAndUserTypes ()
4216                 {
4217                         var tname = "Magic[System.Int32]";
4218                         var res = Type.GetType (tname, name => {
4219                                         return Assembly.Load (name);
4220                                 },(asm,name,ignore) => {
4221                                         if (name == "Magic") return new CustomGetType ("MAGIC");
4222                                         return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4223                                 }, false, false);
4224                         Assert.AreEqual ("UT_GINST", res.Name, "#1");
4225
4226
4227                         tname = "Magic+MyRealEnum";
4228                         res = Type.GetType (tname, name => {
4229                                         return Assembly.Load (name);
4230                                 },(asm,name,ignore) => {
4231                                         if (name == "Magic") return new CustomGetType ("MAGIC");
4232                                         return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4233                                 }, false, false);
4234                         Assert.AreEqual ("UT_NESTED", res.Name, "#2");
4235                 }
4236
4237                 void MustTLE (string tname) {
4238                         try {
4239                                 var res = Type.GetType (tname, name => {
4240                                         return Assembly.Load (name);
4241                                 },(asm,name,ignore) => {
4242                                         return (object)asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4243                                 }, true, false);
4244                                 Assert.Fail (tname);
4245                         } catch (TypeLoadException) {}
4246                 }
4247
4248                 void MustANE (string tname) {
4249                         try {
4250                                 var res = Type.GetType (tname, name => {
4251                                         return Assembly.Load (name);
4252                                 },(asm,name,ignore) => {
4253                                         return (object)asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4254                                 }, true, false);
4255                                 Assert.Fail (tname);
4256                         } catch (ArgumentNullException) {}
4257                 }
4258
4259                 void MustAE_general (string tname, Func<string,Type> getType) {
4260                         try {
4261                                 var res = getType (tname);
4262                                 Assert.Fail (tname);
4263                         } catch (ArgumentException) {}
4264                 }
4265
4266                 void MustAE (string typename) {
4267                         MustAE_general (typename, tname => {
4268                                         return Type.GetType (tname, name => {
4269                                                         return Assembly.Load (name);
4270                                                 },(asm,name,ignore) => {
4271                                                         return (object)asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4272                                                 }, true, false);
4273                                 });
4274                 }
4275
4276                 void MustAEnn (string typename) {
4277                         MustAE_general (typename, tname => Type.GetType (tname, null, null));
4278                 }
4279
4280                 void MustFNFE (string tname) {
4281                         try {
4282                                 var res = Type.GetType (tname, name => {
4283                                         return Assembly.Load (name);
4284                                 },(asm,name,ignore) => {
4285                                         return (object)asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4286                                 }, true, false);
4287                                 Assert.Fail (tname);
4288                         } catch (FileNotFoundException) {}
4289                 }
4290
4291                 [Test]
4292                 public void NewGetTypeErrors () {
4293                         MustANE (null);
4294                         MustAE ("!@#$%^&*");
4295                         MustAE (string.Format ("{0}[{1}&]", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4296                         MustAE (string.Format ("{0}[{1}*]", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4297                         MustAE (string.Format ("{0}&&", typeof (MyRealEnum).FullName));
4298                         MustAE (string.Format ("{0}&*", typeof (MyRealEnum).FullName));
4299                         MustAE (string.Format ("{0}&[{1}]", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4300                         MustAE (string.Format ("{0}[,", typeof (MyRealEnum).FullName));
4301                         MustAE (string.Format ("{0}[*", typeof (MyRealEnum).FullName));
4302
4303                         MustAE (string.Format ("{0}[[{1},", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4304                         MustAE (string.Format ("{0}[[{1}]", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4305                         MustAE (string.Format ("{0}[[{1}],", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4306                         MustAE (string.Format ("{0}[[{1}]_", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4307
4308                         MustAE (string.Format ("{0}[{1}", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4309                         MustAE (string.Format ("{0}[{1},", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4310                         MustAE (string.Format ("{0}[{1},,", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4311                         MustAE (string.Format ("{0}[{1} (", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4312                         MustAE (string.Format ("{0}[", typeof (Foo<>).FullName));
4313
4314                         MustAE (string.Format ("{0}[**]", typeof (MyRealEnum).FullName));
4315                         MustAE (string.Format ("{0}[*,*]", typeof (MyRealEnum).FullName));
4316                         MustAE (string.Format ("{0}[*,]", typeof (MyRealEnum).FullName));
4317                         MustAE (string.Format ("{0}[,*]", typeof (MyRealEnum).FullName));
4318                         MustAE (string.Format ("{0}[,-]", typeof (MyRealEnum).FullName));
4319                         MustAE (string.Format ("{0}[,{0}]", typeof (MyRealEnum).FullName));
4320
4321                         MustAE (string.Format ("{0}[{1}]]", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4322                         MustAE (string.Format ("{0}[,]]", typeof (MyRealEnum).FullName));
4323
4324
4325                         string aqn = typeof (MyRealEnum).Assembly.FullName;
4326                         MustFNFE (string.Format ("{0}, ZZZ{1}", typeof (MyRealEnum).FullName, aqn));
4327                         MustTLE (string.Format ("{0}ZZZZ", typeof (MyRealEnum).FullName));
4328                         MustTLE (string.Format ("{0}ZZZZ,{1}", typeof (MyRealEnum).FullName, aqn));
4329                 }
4330
4331                 [Test]
4332                 public void GetTypeExceptionMsg () {
4333                         string typeName = "system.int32, foo";
4334                         try {
4335                                 Type.GetType(typeName, true, false);
4336                         } catch (TypeLoadException ex) {
4337                                 Assert.IsTrue (ex.Message.Contains ("system.int32"));
4338                                 Assert.IsTrue (ex.Message.Contains ("foo"));
4339                         }
4340                 }
4341
4342                 delegate void MyAction<in T>(T ag);
4343
4344                 [Test] //bug #668506
4345                 public void IsAssignableFromWithVariantDelegate () {
4346                         Assert.IsFalse (typeof(MyAction<string>).IsAssignableFrom(typeof(MyAction<>)), "#1");
4347                 }
4348
4349                 [Test] //bug #124
4350                 public void IsAssignableFromWithNullable () {
4351             Console.WriteLine(typeof(IEnumerable<int?>).IsAssignableFrom(typeof(IEnumerable<int>)));
4352                 }
4353
4354                 [Test]
4355                 public void GetTypeParseGenericCorrectly () { //Bug #15124
4356                         Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1"), typeof (Foo<>), "#1");
4357                         Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32]"), typeof (Foo<int>), "#2");
4358                         Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[[System.Int32]]"), typeof (Foo<int>), "#3");
4359                         Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32][]"), typeof (Foo<int>[]), "#4");
4360                         Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[][System.Int32]"), null, "#5");
4361                         Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32][,]"), typeof (Foo<int>[,]), "#6");
4362                         Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[]"), typeof (Foo<>).MakeArrayType(), "#7");
4363                         Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[,]"), typeof (Foo<>).MakeArrayType (2), "#8");
4364                         Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[][]"), typeof (Foo<>).MakeArrayType ().MakeArrayType (), "#9");
4365                         Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1["), null, "#10");
4366                         Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[["), null, "#11");
4367                         Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[[]"), null, "#12");
4368                         Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[,"), null, "#13");
4369                         Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[*"), null, "#14");
4370                         Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32"), null, "#15");
4371                 }
4372
4373                 [Test]
4374                 public void GetTypeNullDelegatesParseGenericCorrectly () {
4375                         Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1", null, null), typeof (Foo<>), "#1");
4376                         Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32]", null, null), typeof (Foo<int>), "#2");
4377                         Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[[System.Int32]]", null, null), typeof (Foo<int>), "#3");
4378                         Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32][]", null, null), typeof (Foo<int>[]), "#4");
4379                         Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32][,]", null, null), typeof (Foo<int>[,]), "#5");
4380                         Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[]", null, null), typeof (Foo<>).MakeArrayType(), "#6");
4381                         Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[,]", null, null), typeof (Foo<>).MakeArrayType (2), "#7");
4382                         Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[][]", null, null), typeof (Foo<>).MakeArrayType ().MakeArrayType (), "#8");
4383
4384                         MustAEnn ("MonoTests.System.Foo`1[][System.Int32]");
4385                         MustAEnn ("MonoTests.System.Foo`1[");
4386                         MustAEnn ("MonoTests.System.Foo`1[[");
4387                         MustAEnn ("MonoTests.System.Foo`1[[]");
4388                         MustAEnn ("MonoTests.System.Foo`1[,");
4389                         MustAEnn ("MonoTests.System.Foo`1[*");
4390                         MustAEnn ("MonoTests.System.Foo`1[System.Int32");
4391                 }
4392
4393                 Dictionary<int, T> MakeDictHelper<T> (T[] arr) {
4394                         return new Dictionary<int, T>();
4395                 }
4396
4397                 [Test]
4398                 public void GetTypeAnonymousParseCorrectly () {
4399                         var x = new { X = 1 };
4400                         var a = new [] { x };
4401                         var d = MakeDictHelper (a);
4402
4403                         var x_type = x.GetType ();
4404                         var a_type = a.GetType ();
4405                         var d_type = d.GetType ();
4406
4407                         Assert.AreEqual (Type.GetType (x_type.ToString ()), x_type, "#1");
4408                         Assert.AreEqual (Type.GetType (x_type.ToString (), null, null), x_type, "#2");
4409                         Assert.AreEqual (Type.GetType (a_type.ToString ()), a_type, "#3");
4410                         Assert.AreEqual (Type.GetType (a_type.ToString (), null, null), a_type, "#4");
4411                         Assert.AreEqual (Type.GetType (d_type.ToString ()), d_type, "#5");
4412                         Assert.AreEqual (Type.GetType (d_type.ToString (), null, null), d_type, "#6");
4413
4414                         Assert.AreEqual (Type.GetType (x_type.FullName), x_type, "#7");
4415                         Assert.AreEqual (Type.GetType (x_type.FullName, null, null), x_type, "#8");
4416                         Assert.AreEqual (Type.GetType (a_type.FullName), a_type, "#9");
4417                         Assert.AreEqual (Type.GetType (a_type.FullName, null, null), a_type, "#10");
4418                         Assert.AreEqual (Type.GetType (d_type.FullName), d_type, "#11");
4419                         Assert.AreEqual (Type.GetType (d_type.FullName, null, null), d_type, "#12");
4420
4421                 }
4422
4423 #if !MONOTOUCH && !FULL_AOT_RUNTIME && !MONOMAC
4424                 [Test]
4425                 [Category ("AndroidNotWorking")] // requires symbol writer
4426                 public void FullNameGetTypeParseEscapeRoundtrip () // bug #26384
4427                 {
4428                         var nm = new AssemblyName ("asm");
4429                         var ab = AssemblyBuilder.DefineDynamicAssembly (nm,
4430                                                                         AssemblyBuilderAccess.Run);
4431                         var mb = ab.DefineDynamicModule("m", false);
4432                         var tb = mb.DefineType ("NameSpace,+*&[]\\.Type,+*&[]\\",
4433                                                 TypeAttributes.Class | TypeAttributes.Public);
4434
4435                         var nestedTb = tb.DefineNestedType("Nested,+*&[]\\",
4436                                                           TypeAttributes.Class | TypeAttributes.NestedPublic);
4437
4438                         var ty = tb.CreateType();
4439
4440                         var nestedTy = nestedTb.CreateType();
4441
4442                         var escapedNestedName =
4443                                 "NameSpace\\,\\+\\*\\&\\[\\]\\\\"
4444                                 + "."
4445                                 + "Type\\,\\+\\*\\&\\[\\]\\\\"
4446                                 + "+"
4447                                 + "Nested\\,\\+\\*\\&\\[\\]\\\\";
4448
4449                         Assert.AreEqual(escapedNestedName, nestedTy.FullName);
4450
4451                         var lookupNestedTy =
4452                                 Type.GetType(escapedNestedName + "," + nm.FullName,
4453                                              asmName => {
4454                                                      if (asmName.FullName.Equals(nm.FullName)) return ab;
4455                                                      else return Assembly.Load (asmName);
4456                                              },
4457                                              (asm,name,ignore) => {
4458                                                      if (asm == null)
4459                                                              return Type.GetType(name, true, ignore);
4460                                                      else return asm.GetType(name, true, ignore);
4461                                              },
4462                                              true,
4463                                              false);
4464                         Assert.AreEqual(nestedTy, lookupNestedTy);
4465
4466                 }
4467 #endif
4468
4469
4470                 [Test]
4471                 public void GetTypeBadArity()
4472                 {
4473                         // Regression test for #46250
4474                         try {
4475                                 Type.GetType ("System.Collections.Generic.Dictionary`2[System.String]", true);
4476                                 Assert.Fail ("Did not throw an exception (#1)");
4477                         } catch (ArgumentException) {
4478                         }
4479
4480                         try {
4481                                 Type.GetType ("System.Collections.Generic.Dictionary`2[System.String,System.Int32,System.Int64]", true);
4482                                 Assert.Fail ("Did not throw an exception (#2)");
4483                         } catch (ArgumentException) {
4484                         }
4485                 }
4486
4487                 public abstract class Stream : IDisposable
4488                 {
4489                         public void Dispose ()
4490                         {
4491                                 Console.WriteLine ("stream::dispose");
4492                         }
4493
4494                         protected virtual void Dispose (bool disposing)
4495                         {
4496                         }
4497                 }
4498
4499                 public class NonClosingStream 
4500                         : Stream, IDisposable
4501                 {
4502                         void  IDisposable.Dispose()
4503                         {
4504                                 Console.WriteLine ("ncs::dispose");
4505                         }
4506
4507                         public override string ToString () { return ""; }
4508                 }
4509
4510                 static bool ContainsProperty (PropertyInfo [] props, string name)
4511                 {
4512                         foreach (PropertyInfo p in props)
4513                                 if (p.Name == name)
4514                                         return true;
4515                         return false;
4516                 }
4517
4518                 public class NemerleAttribute : Attribute
4519                 {
4520                 }
4521
4522                 public class VolatileModifier : NemerleAttribute
4523                 {
4524                 }
4525
4526                 [VolatileModifier]
4527                 [FooAttribute]
4528                 class A
4529                 {
4530                 }
4531
4532                 [AttributeUsage (AttributeTargets.Class, Inherited=false)]
4533                 public class FooAttribute : Attribute
4534                 {
4535                 }
4536
4537                 public class BarAttribute : FooAttribute
4538                 {
4539                 }
4540
4541                 [BarAttribute]
4542                 class BA : A
4543                 {
4544                 }
4545
4546                 class BBA : BA
4547                 {
4548                 }
4549
4550                 class CA : A
4551                 {
4552                 }
4553
4554                 [AttributeUsage (AttributeTargets.Class, Inherited=true)]
4555                 public class InheritAttribute : Attribute
4556                 {
4557                 }
4558
4559                 [AttributeUsage (AttributeTargets.Class, Inherited=false)]
4560                 public class NotInheritAttribute : InheritAttribute
4561                 {
4562                 }
4563
4564                 [NotInheritAttribute]
4565                 public class bug82431A1
4566                 {
4567                 }
4568
4569                 public class bug82431A2 : bug82431A1
4570                 {
4571                 }
4572
4573                 [NotInheritAttribute]
4574                 [InheritAttribute]
4575                 public class bug82431A3 : bug82431A1
4576                 {
4577                 }
4578
4579                 [InheritAttribute]
4580                 public class bug82431B1
4581                 {
4582                 }
4583
4584                 public class bug82431B2 : bug82431B1
4585                 {
4586                 }
4587
4588                 [NotInheritAttribute]
4589                 public class bug82431B3 : bug82431B2
4590                 {
4591                 }
4592
4593                 public class bug82431B4 : bug82431B3
4594                 {
4595                 }
4596
4597                 struct FooStruct
4598                 {
4599                 }
4600
4601                 public class Bug77367
4602                 {
4603                         public void Run (bool b)
4604                         {
4605                         }
4606                 }
4607
4608                 public class Blue
4609                 {
4610                         private string PrivInstBlue
4611                         {
4612                                 get { return null; }
4613                         }
4614
4615                         protected string ProtInstBlue
4616                         {
4617                                 get { return null; }
4618                         }
4619
4620                         protected internal string ProIntInstBlue
4621                         {
4622                                 get { return null; }
4623                         }
4624
4625                         public long PubInstBlue
4626                         {
4627                                 get
4628                                 {
4629                                         if (PrivInstBlue == null)
4630                                                 return 0;
4631                                         return long.MaxValue;
4632                                 }
4633                         }
4634
4635                         internal int IntInstBlue
4636                         {
4637                                 get { return 0; }
4638                         }
4639
4640                         private static string PrivStatBlue
4641                         {
4642                                 get { return null; }
4643                         }
4644
4645                         protected static string ProtStatBlue
4646                         {
4647                                 get { return null; }
4648                         }
4649
4650                         protected static internal string ProIntStatBlue
4651                         {
4652                                 get { return null; }
4653                         }
4654
4655                         public static long PubStatBlue
4656                         {
4657                                 get
4658                                 {
4659                                         if (PrivStatBlue == null)
4660                                                 return 0;
4661                                         return long.MaxValue;
4662                                 }
4663                         }
4664
4665                         internal static int IntStatBlue
4666                         {
4667                                 get { return 0; }
4668                         }
4669                 }
4670
4671                 public class Foo : Blue
4672                 {
4673                         private string PrivInstBase
4674                         {
4675                                 get { return null; }
4676                         }
4677
4678                         protected string ProtInstBase
4679                         {
4680                                 get { return null; }
4681                         }
4682
4683                         protected internal string ProIntInstBase
4684                         {
4685                                 get { return null; }
4686                         }
4687
4688                         public long PubInstBase
4689                         {
4690                                 get
4691                                 {
4692                                         if (PrivInstBase == null)
4693                                                 return 0;
4694                                         return long.MaxValue;
4695                                 }
4696                         }
4697
4698                         internal int IntInstBase
4699                         {
4700                                 get { return 0; }
4701                         }
4702
4703                         private static string PrivStatBase
4704                         {
4705                                 get { return null; }
4706                         }
4707
4708                         protected static string ProtStatBase
4709                         {
4710                                 get { return null; }
4711                         }
4712
4713                         protected static internal string ProIntStatBase
4714                         {
4715                                 get { return null; }
4716                         }
4717
4718                         public static long PubStatBase
4719                         {
4720                                 get
4721                                 {
4722                                         if (PrivStatBase == null)
4723                                                 return 0;
4724                                         return long.MaxValue;
4725                                 }
4726                         }
4727
4728                         internal static int IntStatBase
4729                         {
4730                                 get { return 0; }
4731                         }
4732                 }
4733
4734                 public class Bar : Foo
4735                 {
4736                         private string PrivInst
4737                         {
4738                                 get { return null; }
4739                         }
4740
4741                         protected string ProtInst
4742                         {
4743                                 get { return null; }
4744                         }
4745
4746                         protected internal string ProIntInst
4747                         {
4748                                 get { return null; }
4749                         }
4750
4751                         public long PubInst
4752                         {
4753                                 get
4754                                 {
4755                                         if (PrivInst == null)
4756                                                 return 0;
4757                                         return long.MaxValue;
4758                                 }
4759                         }
4760
4761                         internal int IntInst
4762                         {
4763                                 get { return 0; }
4764                         }
4765
4766                         private static string PrivStat
4767                         {
4768                                 get { return null; }
4769                         }
4770
4771                         protected static string ProtStat
4772                         {
4773                                 get { return null; }
4774                         }
4775
4776                         protected static internal string ProIntStat
4777                         {
4778                                 get { return null; }
4779                         }
4780
4781                         public static long PubStat
4782                         {
4783                                 get
4784                                 {
4785                                         if (PrivStat == null)
4786                                                 return 0;
4787                                         return long.MaxValue;
4788                                 }
4789                         }
4790
4791                         internal static int IntStat
4792                         {
4793                                 get { return 0; }
4794                         }
4795                 }
4796
4797                 class CtorsA
4798                 {
4799                         static CtorsA ()
4800                         {
4801                         }
4802                 }
4803
4804                 class CtorsB
4805                 {
4806                         public CtorsB ()
4807                         {
4808                         }
4809                 }
4810
4811                 class CtorsC
4812                 {
4813                         static CtorsC ()
4814                         {
4815                         }
4816
4817                         public CtorsC (int x)
4818                         {
4819                         }
4820                 }
4821         }
4822
4823         class UserType : Type
4824         {
4825                 protected Type type;
4826         
4827                 public UserType(Type type) {
4828                         this.type = type;
4829                 }
4830         
4831                 public override Type UnderlyingSystemType { get { return this.type; } }
4832         
4833                 public override Assembly Assembly { get { return this.type == null ? null : this.type.Assembly; } }
4834         
4835                 public override string AssemblyQualifiedName { get { return null; } }
4836         
4837                 public override Type BaseType { get { return null; } }
4838         
4839                 public override Module Module { get { return this.type.Module; } }
4840         
4841                 public override string Namespace { get { return null; } }
4842         
4843                 public override bool IsGenericParameter { get { return true; } }
4844          
4845                 public override RuntimeTypeHandle TypeHandle { get { throw new NotSupportedException(); } }
4846         
4847                 public override bool ContainsGenericParameters { get { return true; } }
4848         
4849                 public override string FullName { get { return this.type.Name; } }
4850         
4851                 public override Guid GUID { get { throw new NotSupportedException(); } }
4852         
4853         
4854                 protected override bool IsArrayImpl() {
4855                         return false;
4856                 }
4857         
4858                 protected override bool IsByRefImpl()
4859                 {
4860                         return false;
4861                 }
4862         
4863                 protected override bool IsCOMObjectImpl()
4864                 {
4865                         return false;
4866                 }
4867         
4868                 protected override bool IsPointerImpl()
4869                 {
4870                         return false;
4871                 }
4872         
4873                 protected override bool IsPrimitiveImpl()
4874                 {
4875                         return false;
4876                 }
4877         
4878         
4879                 protected override TypeAttributes GetAttributeFlagsImpl()
4880                 {
4881                         return 0;
4882                 }
4883         
4884                 protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder,
4885                                                                            CallingConventions callConvention, Type[] types,
4886                                                                            ParameterModifier[] modifiers)
4887                 {
4888                         return null;
4889                 }
4890         
4891                 public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr)
4892                 {
4893                         return null;
4894                 }
4895         
4896                 public override Type GetElementType()
4897                 {
4898                         return null;
4899                 }
4900         
4901                 public override EventInfo GetEvent(string name, BindingFlags bindingAttr)
4902                 {
4903                         return null;
4904                 }
4905         
4906         
4907                 public override FieldInfo GetField(string name, BindingFlags bindingAttr)
4908                 {
4909                         return null;
4910                 }
4911         
4912         
4913                 public override Type GetInterface(string name, bool ignoreCase)
4914                 {
4915                         return null;
4916                 }
4917         
4918                 public override Type[] GetInterfaces()
4919                 {
4920                         return null;
4921                 }
4922         
4923                 public override MemberInfo[] GetMembers(BindingFlags bindingAttr)
4924                 {
4925                         return null;
4926                 }
4927         
4928                 public override object[] GetCustomAttributes(Type attributeType, bool inherit)
4929                 {
4930                         return null;
4931                 }
4932         
4933                 public override object[] GetCustomAttributes(bool inherit)
4934                 {
4935                         return null;
4936                 }
4937         
4938                 public override bool IsDefined(Type attributeType, bool inherit)
4939                 {
4940                         return false;
4941                 }
4942         
4943                 public override string Name { get { return this.type.Name; } }
4944         
4945                 public override EventInfo[] GetEvents(BindingFlags bindingAttr)
4946                 {
4947                         throw new NotImplementedException();
4948                 }
4949         
4950                 public override FieldInfo[] GetFields(BindingFlags bindingAttr)
4951                 {
4952                         throw new NotImplementedException();
4953                 }
4954         
4955                 protected override MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder,
4956                                                                  CallingConventions callConvention, Type[] types,
4957                                                                  ParameterModifier[] modifiers)
4958                 {
4959                         return null;
4960                 }
4961         
4962                 public override MethodInfo[] GetMethods(BindingFlags bindingAttr)
4963                 {
4964                         return null;
4965                 }
4966         
4967                 public override Type GetNestedType(string name, BindingFlags bindingAttr)
4968                 {
4969                         return null;
4970                 }
4971         
4972                 public override Type[] GetNestedTypes(BindingFlags bindingAttr)
4973                 {
4974                         return null;
4975                 }
4976         
4977                 public override PropertyInfo[] GetProperties(BindingFlags bindingAttr)
4978                 {
4979                         return null;
4980                 }
4981         
4982                 protected override PropertyInfo GetPropertyImpl(string name, BindingFlags bindingAttr, Binder binder,
4983                                                                  Type returnType, Type[] types, ParameterModifier[] modifiers)
4984                 {
4985                         return null;
4986                 }
4987         
4988                 protected override bool HasElementTypeImpl()
4989                 {
4990                         return false;
4991                 }
4992         
4993                 public override object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, object target,
4994                                                          object[] args, ParameterModifier[] modifiers, CultureInfo culture,
4995                                                          string[] namedParameters)
4996                 {
4997                         throw new NotSupportedException();
4998                 }
4999         }
5000
5001     class UserType2 : UserType {
5002                 public UserType2 (Type type) : base (type) {
5003                 }
5004
5005                 public override Type UnderlyingSystemType { get { return this.type ?? this; } }
5006
5007                 public override int GetHashCode()
5008                 {
5009                         if (type == null)
5010                                 return 42;
5011                         return type.GetHashCode();
5012                 }
5013         }
5014 }