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