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