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