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