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