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