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