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