2009-01-27 Zoltan Varga <vargaz@gmail.com>
[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.Collections;
13 #if NET_2_0
14 using System.Collections.Generic;
15 #endif
16 using System.IO;
17 using System.Reflection;
18 using System.Reflection.Emit;
19 using System.Runtime.InteropServices;
20 using System.Text;
21 using System.Globalization;
22
23 class NoNamespaceClass {
24 }
25
26 namespace MonoTests.System
27 {
28         class Super : ICloneable
29         {
30                 public virtual object Clone ()
31                 {
32                         return null;
33                 }
34         }
35
36         class Duper: Super
37         {
38         }
39
40         interface IFace1
41         {
42                 void foo ();
43         }
44
45         interface IFace2 : IFace1
46         {
47                 void bar ();
48         }
49
50         interface IFace3 : IFace2
51         {
52         }
53
54         enum TheEnum
55         {
56                 A,
57                 B,
58                 C
59         };
60
61         abstract class Base
62         {
63                 public int level;
64
65                 public abstract int this [byte i] {
66                         get;
67                 }
68
69                 public abstract int this [int i] {
70                         get;
71                 }
72
73                 public abstract void TestVoid ();
74                 public abstract void TestInt (int i);
75         }
76
77         class DeriveVTable : Base
78         {
79                 public override int this [byte i] {
80                         get { return 1; }
81                 }
82
83                 public override int this [int i] {
84                         get { return 1; }
85                 }
86
87                 public override void TestVoid ()
88                 {
89                         level = 1;
90                 }
91
92                 public override void TestInt (int i)
93                 {
94                         level = 1;
95                 }
96         }
97
98         class NewVTable : DeriveVTable
99         {
100                 public new int this [byte i] {
101                         get { return 2; }
102                 }
103
104                 public new int this [int i] {
105                         get { return 2; }
106                 }
107
108                 public new void TestVoid ()
109                 {
110                         level = 2;
111                 }
112
113                 public new void TestInt (int i)
114                 {
115                         level = 2;
116                 }
117
118                 public void Overload ()
119                 {
120                 }
121
122                 public void Overload (int i)
123                 {
124                 }
125
126                 public NewVTable (out int i)
127                 {
128                         i = 0;
129                 }
130
131                 public void byref_method (out int i)
132                 {
133                         i = 0;
134                 }
135         }
136
137         class Base1
138         {
139                 public virtual int Foo {
140                         get { return 1; }
141                         set { }
142                 }
143         }
144
145         class Derived1 : Base1
146         {
147                 public override int Foo {
148                         set { }
149                 }
150         }
151
152         class Derived2 : Base1
153         {
154                 public new int Foo {
155                         get { return 1; }
156                         set { }
157                 }
158         }
159
160 #if NET_2_0
161         public class Foo<T>
162         {
163                 public T Whatever;
164         
165                 public T Test {
166                         get { throw new NotImplementedException (); }
167                 }
168
169                 public T Execute (T a)
170                 {
171                         return a;
172                 }
173         }
174         
175         class Foo<T, U>
176         {
177         }
178
179         public interface IBar<T>
180         {
181         }
182
183         public class Baz<T> : IBar<T>
184         {
185         }
186 #endif
187         public class Bug348522
188         {
189                 public void Test (int __argument)
190                 {
191                 }
192         }
193
194         public class FirstMethodBinder : Binder
195         {
196                 public override MethodBase BindToMethod (BindingFlags bindingAttr, MethodBase [] match, ref object [] args,
197                                                          ParameterModifier [] modifiers, CultureInfo culture, string [] names,
198                                                          out object state)
199                 {
200                         state = null;
201                         return match [0];
202                 }
203                 
204                 public override object ChangeType (object value, Type type1, CultureInfo culture)
205                 {
206                         return value;
207                 }
208                 
209                 // The rest is just to please the compiler
210                 public override FieldInfo BindToField (BindingFlags a, FieldInfo[] b, object c, CultureInfo d)
211                 {
212                         return null;
213                 }
214                 
215                 public override void ReorderArgumentArray(ref object[] a, object b)
216                 {
217                 }
218                 
219                 public override MethodBase SelectMethod(BindingFlags a, MethodBase[] b, Type[] c, ParameterModifier[] d)
220                 {
221                     return null;
222                 }
223                 
224                 public override PropertyInfo SelectProperty(BindingFlags a, PropertyInfo[] b, Type c, Type[] d, ParameterModifier[] e)
225                 {
226                         return null;
227                 }
228         }
229
230
231         [TestFixture]
232         public class TypeTest
233         {
234                 private AssemblyBuilder assembly;
235                 private ModuleBuilder module;
236                 const string ASSEMBLY_NAME = "MonoTests.System.TypeTest";
237                 static int typeIndexer = 0;
238
239                 [SetUp]
240                 public void SetUp ()
241                 {
242                         AssemblyName assemblyName = new AssemblyName ();
243                         assemblyName.Name = ASSEMBLY_NAME;
244                         assembly = AppDomain.CurrentDomain.DefineDynamicAssembly (
245                                         assemblyName, AssemblyBuilderAccess.RunAndSave, Path.GetTempPath ());
246                         module = assembly.DefineDynamicModule ("module1");
247                 }
248
249                 private string genTypeName ()
250                 {
251                         return "t" + (typeIndexer++);
252                 }
253
254                 private void ByrefMethod (ref int i, ref Derived1 j, ref Base1 k)
255                 {
256                 }
257 #if NET_2_0
258                 private void GenericMethod<Q> (Q q)
259                 {
260                 }
261 #endif
262                 [Test]
263                 public void TestIsAssignableFrom ()
264                 {
265                         // Simple tests for inheritance
266                         Assert.AreEqual (typeof (Super).IsAssignableFrom (typeof (Duper)) , true, "#01");
267                         Assert.AreEqual (typeof (Duper).IsAssignableFrom (typeof (Duper)), true, "#02");
268                         Assert.AreEqual (typeof (Object).IsAssignableFrom (typeof (Duper)), true, "#03");
269                         Assert.AreEqual (typeof (ICloneable).IsAssignableFrom (typeof (Duper)), true, "#04");
270
271                         // Tests for arrays
272                         Assert.AreEqual (typeof (Super[]).IsAssignableFrom (typeof (Duper[])), true, "#05");
273                         Assert.AreEqual (typeof (Duper[]).IsAssignableFrom (typeof (Super[])), false, "#06");
274                         Assert.AreEqual (typeof (Object[]).IsAssignableFrom (typeof (Duper[])), true, "#07");
275                         Assert.AreEqual (typeof (ICloneable[]).IsAssignableFrom (typeof (Duper[])), true, "#08");
276
277                         // Tests for multiple dimensional arrays
278                         Assert.AreEqual (typeof (Super[][]).IsAssignableFrom (typeof (Duper[][])), true, "#09");
279                         Assert.AreEqual (typeof (Duper[][]).IsAssignableFrom (typeof (Super[][])), false, "#10");
280                         Assert.AreEqual (typeof (Object[][]).IsAssignableFrom (typeof (Duper[][])), true, "#11");
281                         Assert.AreEqual (typeof (ICloneable[][]).IsAssignableFrom (typeof (Duper[][])), true, "#12");
282
283                         // Tests for vectors<->one dimensional arrays */
284 #if TARGET_JVM // Lower bounds arrays are not supported for TARGET_JVM.
285                         Array arr1 = Array.CreateInstance (typeof (int), new int[] {1});
286                         Assert.AreEqual (typeof (int[]).IsAssignableFrom (arr1.GetType ()), true, "#13");
287 #else
288                         Array arr1 = Array.CreateInstance (typeof (int), new int[] {1}, new int[] {0});
289                         Array arr2 = Array.CreateInstance (typeof (int), new int[] {1}, new int[] {10});
290
291                         Assert.AreEqual (typeof (int[]).IsAssignableFrom (arr1.GetType ()), true, "#13");
292                         Assert.AreEqual (typeof (int[]).IsAssignableFrom (arr2.GetType ()), false, "#14");
293 #endif // TARGET_JVM
294
295                         // Test that arrays of enums can be cast to their base types
296                         Assert.AreEqual (typeof (int[]).IsAssignableFrom (typeof (TypeCode[])), true, "#15");
297
298                         // Test that arrays of valuetypes can't be cast to arrays of
299                         // references
300                         Assert.AreEqual (typeof (object[]).IsAssignableFrom (typeof (TypeCode[])), false, "#16");
301                         Assert.AreEqual (typeof (ValueType[]).IsAssignableFrom (typeof (TypeCode[])), false, "#17");
302                         Assert.AreEqual (typeof (Enum[]).IsAssignableFrom (typeof (TypeCode[])), false, "#18");
303
304                         // Test that arrays of enums can't be cast to arrays of references
305                         Assert.AreEqual (typeof (object[]).IsAssignableFrom (typeof (TheEnum[])), false, "#19");
306                         Assert.AreEqual (typeof (ValueType[]).IsAssignableFrom (typeof (TheEnum[])), false, "#20");
307                         Assert.AreEqual (typeof (Enum[]).IsAssignableFrom (typeof (TheEnum[])), false, "#21");
308
309                         // Check that ValueType and Enum are recognized as reference types
310                         Assert.AreEqual (typeof (object).IsAssignableFrom (typeof (ValueType)), true, "#22");
311                         Assert.AreEqual (typeof (object).IsAssignableFrom (typeof (Enum)), true, "#23");
312                         Assert.AreEqual (typeof (ValueType).IsAssignableFrom (typeof (Enum)), true, "#24");
313
314                         Assert.AreEqual (typeof (object[]).IsAssignableFrom (typeof (ValueType[])), true, "#25");
315                         Assert.AreEqual (typeof (ValueType[]).IsAssignableFrom (typeof (ValueType[])), true, "#26");
316                         Assert.AreEqual (typeof (Enum[]).IsAssignableFrom (typeof (ValueType[])), false, "#27");
317
318                         Assert.AreEqual (typeof (object[]).IsAssignableFrom (typeof (Enum[])), true, "#28");
319                         Assert.AreEqual (typeof (ValueType[]).IsAssignableFrom (typeof (Enum[])), true, "#29");
320                         Assert.AreEqual (typeof (Enum[]).IsAssignableFrom (typeof (Enum[])), true, "#30");
321
322                         // Tests for byref types
323                         MethodInfo mi = typeof (TypeTest).GetMethod ("ByrefMethod", BindingFlags.Instance|BindingFlags.NonPublic);
324                         Assert.IsTrue (mi.GetParameters ()[2].ParameterType.IsAssignableFrom (mi.GetParameters ()[1].ParameterType));
325                         Assert.IsTrue (mi.GetParameters ()[1].ParameterType.IsAssignableFrom (mi.GetParameters ()[1].ParameterType));
326
327                         // Tests for type parameters
328 #if NET_2_0
329                         mi = typeof (TypeTest).GetMethod ("GenericMethod", BindingFlags.Instance|BindingFlags.NonPublic);
330                         Assert.IsTrue (mi.GetParameters ()[0].ParameterType.IsAssignableFrom (mi.GetParameters ()[0].ParameterType));
331                         Assert.IsFalse (mi.GetParameters ()[0].ParameterType.IsAssignableFrom (typeof (int)));
332 #endif
333                 }
334
335                 [Test]
336                 public void TestIsSubclassOf ()
337                 {
338                         Assert.IsTrue (typeof (ICloneable).IsSubclassOf (typeof (object)), "#01");
339
340                         // Tests for byref types
341                         Type paramType = typeof (TypeTest).GetMethod ("ByrefMethod", BindingFlags.Instance|BindingFlags.NonPublic).GetParameters () [0].ParameterType;
342                         Assert.IsTrue (!paramType.IsSubclassOf (typeof (ValueType)), "#02");
343                         //Assert.IsTrue (paramType.IsSubclassOf (typeof (Object)), "#03");
344                         Assert.IsTrue (!paramType.IsSubclassOf (paramType), "#04");
345                 }
346
347                 [Test]
348                 public void TestGetMethodImpl ()
349                 {
350                         // Test binding of new slot methods (using no types)
351                         Assert.AreEqual (typeof (Base), typeof (Base).GetMethod("TestVoid").DeclaringType, "#01");
352                         Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetMethod ("TestVoid").DeclaringType, "#02");
353
354                         // Test binding of new slot methods (using types)
355                         Assert.AreEqual (typeof (Base), typeof (Base).GetMethod ("TestInt", new Type[] { typeof (int) }).DeclaringType, "#03");
356                         Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetMethod ("TestInt", new Type[] { typeof (int) }).DeclaringType, "#04");
357
358                         // Test overload resolution
359                         Assert.AreEqual (0, typeof (NewVTable).GetMethod ("Overload", new Type[0]).GetParameters ().Length, "#05");
360
361                         // Test byref parameters
362                         Assert.AreEqual (null, typeof (NewVTable).GetMethod ("byref_method", new Type[] { typeof (int) }), "#06");
363                         Type byrefInt = typeof (NewVTable).GetMethod ("byref_method").GetParameters ()[0].ParameterType;
364                         Assert.IsNotNull (typeof (NewVTable).GetMethod ("byref_method", new Type[] { byrefInt }), "#07");
365                 }
366
367                 [Test]
368                 [Category ("TargetJvmNotWorking")]
369                 public void TestGetPropertyImpl ()
370                 {
371                         // Test getting property that is exact
372                         Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetProperty ("Item", new Type[1] { typeof (Int32) }).DeclaringType, "#01");
373
374                         // Test getting property that is not exact
375                         Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetProperty ("Item", new Type[1] { typeof (Int16) }).DeclaringType, "#02");
376
377                         // Test overriding of properties when only the set accessor is overriden
378                         Assert.AreEqual (1, typeof (Derived1).GetProperties ().Length, "#03");
379                 }
380
381                 [Test]
382                 public void GetProperties ()
383                 {
384                         // Test hide-by-name-and-signature
385                         Assert.AreEqual (1, typeof (Derived2).GetProperties ().Length);
386                         Assert.AreEqual (typeof (Derived2), typeof (Derived2).GetProperties ()[0].DeclaringType);
387                 }
388
389                 [Test] // GetProperties (BindingFlags)
390                 public void GetProperties_Flags ()
391                 {
392                         PropertyInfo [] props;
393                         Type type = typeof (Bar);
394                         BindingFlags flags;
395
396                         flags = BindingFlags.Instance | BindingFlags.NonPublic;
397                         props = type.GetProperties (flags);
398
399                         Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#A1");
400                         Assert.IsTrue (ContainsProperty (props, "ProtInstBase"), "#A2");
401                         Assert.IsTrue (ContainsProperty (props, "ProIntInstBase"), "#A3");
402                         Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#A4");
403 #if NET_2_0
404                         Assert.IsTrue (ContainsProperty (props, "IntInstBase"), "#A5");
405 #else
406                         Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#A5");
407 #endif
408                         Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#A6");
409                         Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#A7");
410                         Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#A8");
411                         Assert.IsFalse (ContainsProperty (props, "PubInst"), "#A9");
412                         Assert.IsTrue (ContainsProperty (props, "IntInst"), "#A10");
413                         Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#A11");
414                         Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#A12");
415                         Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#A13");
416                         Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#A14");
417                         Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#A15");
418                         Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#A16");
419                         Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#A17");
420                         Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#A18");
421                         Assert.IsFalse (ContainsProperty (props, "PubStat"), "#A19");
422                         Assert.IsFalse (ContainsProperty (props, "IntStat"), "#A20");
423                         Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#A21");
424                         Assert.IsTrue (ContainsProperty (props, "ProtInstBlue"), "#A22");
425                         Assert.IsTrue (ContainsProperty (props, "ProIntInstBlue"), "#A23");
426                         Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#A24");
427 #if NET_2_0
428                         Assert.IsTrue (ContainsProperty (props, "IntInstBlue"), "#A25");
429 #else
430                         Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#A25");
431 #endif
432                         Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#A26");
433                         Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#A27");
434                         Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#A28");
435                         Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#A29");
436                         Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#A30");
437
438                         flags = BindingFlags.Instance | BindingFlags.Public;
439                         props = type.GetProperties (flags);
440
441                         Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#B1");
442                         Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#B2");
443                         Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#B3");
444                         Assert.IsTrue (ContainsProperty (props, "PubInstBase"), "#B4");
445                         Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#B5");
446                         Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#B6");
447                         Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#B7");
448                         Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#B8");
449                         Assert.IsTrue (ContainsProperty (props, "PubInst"), "#B9");
450                         Assert.IsFalse (ContainsProperty (props, "IntInst"), "#B10");
451                         Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#B11");
452                         Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#B12");
453                         Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#B13");
454                         Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#B14");
455                         Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#B15");
456                         Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#B16");
457                         Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#B17");
458                         Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#B18");
459                         Assert.IsFalse (ContainsProperty (props, "PubStat"), "#B19");
460                         Assert.IsFalse (ContainsProperty (props, "IntStat"), "#B20");
461                         Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#B21");
462                         Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#B22");
463                         Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#B23");
464                         Assert.IsTrue (ContainsProperty (props, "PubInstBlue"), "#B24");
465                         Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#B25");
466                         Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#B26");
467                         Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#B27");
468                         Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#B28");
469                         Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#B29");
470                         Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#B30");
471
472                         flags = BindingFlags.Static | BindingFlags.Public;
473                         props = type.GetProperties (flags);
474
475                         Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#C1");
476                         Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#C2");
477                         Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#C3");
478                         Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#C4");
479                         Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#C5");
480                         Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#C6");
481                         Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#C7");
482                         Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#C8");
483                         Assert.IsFalse (ContainsProperty (props, "PubInst"), "#C9");
484                         Assert.IsFalse (ContainsProperty (props, "IntInst"), "#C10");
485                         Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#C11");
486                         Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#C12");
487                         Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#C13");
488                         Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#C14");
489                         Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#C15");
490                         Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#C16");
491                         Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#C17");
492                         Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#C18");
493                         Assert.IsTrue (ContainsProperty (props, "PubStat"), "#C19");
494                         Assert.IsFalse (ContainsProperty (props, "IntStat"), "#C20");
495                         Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#C21");
496                         Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#C22");
497                         Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#C23");
498                         Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#C24");
499                         Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#C25");
500                         Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#C26");
501                         Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#C27");
502                         Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#C28");
503                         Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#C29");
504                         Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#C30");
505
506                         flags = BindingFlags.Static | BindingFlags.NonPublic;
507                         props = type.GetProperties (flags);
508
509                         Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#D1");
510                         Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#D2");
511                         Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#D3");
512                         Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#D4");
513                         Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#D5");
514                         Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#D6");
515                         Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#D7");
516                         Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#D8");
517                         Assert.IsFalse (ContainsProperty (props, "PubInst"), "#D9");
518                         Assert.IsFalse (ContainsProperty (props, "IntInst"), "#D10");
519                         Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#D11");
520                         Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#D12");
521                         Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#D13");
522                         Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#D14");
523                         Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#D15");
524                         Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#D16");
525                         Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#D17");
526                         Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#D18");
527                         Assert.IsFalse (ContainsProperty (props, "PubStat"), "#D19");
528                         Assert.IsTrue (ContainsProperty (props, "IntStat"), "#D20");
529                         Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#D21");
530                         Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#D22");
531                         Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#D23");
532                         Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#D24");
533                         Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#D25");
534                         Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#D26");
535                         Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#D27");
536                         Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#D28");
537                         Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#D29");
538                         Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#D30");
539
540                         flags = BindingFlags.Instance | BindingFlags.NonPublic |
541                                 BindingFlags.FlattenHierarchy;
542                         props = type.GetProperties (flags);
543
544                         Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#E1");
545                         Assert.IsTrue (ContainsProperty (props, "ProtInstBase"), "#E2");
546                         Assert.IsTrue (ContainsProperty (props, "ProIntInstBase"), "#E3");
547                         Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#E4");
548 #if NET_2_0
549                         Assert.IsTrue (ContainsProperty (props, "IntInstBase"), "#E5");
550 #else
551                         Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#E5");
552 #endif
553                         Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#E6");
554                         Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#E7");
555                         Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#E8");
556                         Assert.IsFalse (ContainsProperty (props, "PubInst"), "#E9");
557                         Assert.IsTrue (ContainsProperty (props, "IntInst"), "#E10");
558                         Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#E11");
559                         Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#E12");
560                         Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#E13");
561                         Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#E14");
562                         Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#E15");
563                         Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#E16");
564                         Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#E17");
565                         Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#E18");
566                         Assert.IsFalse (ContainsProperty (props, "PubStat"), "#E19");
567                         Assert.IsFalse (ContainsProperty (props, "IntStat"), "#E20");
568                         Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#E21");
569                         Assert.IsTrue (ContainsProperty (props, "ProtInstBlue"), "#E22");
570                         Assert.IsTrue (ContainsProperty (props, "ProIntInstBlue"), "#E23");
571                         Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#E24");
572 #if NET_2_0
573                         Assert.IsTrue (ContainsProperty (props, "IntInstBlue"), "#E25");
574 #else
575                         Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#E25");
576 #endif
577                         Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#E26");
578                         Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#E27");
579                         Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#E28");
580                         Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#E29");
581                         Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#E30");
582
583                         flags = BindingFlags.Instance | BindingFlags.Public |
584                                 BindingFlags.FlattenHierarchy;
585                         props = type.GetProperties (flags);
586
587                         Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#F1");
588                         Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#F2");
589                         Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#F3");
590                         Assert.IsTrue (ContainsProperty (props, "PubInstBase"), "#F4");
591                         Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#F5");
592                         Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#F6");
593                         Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#F7");
594                         Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#F8");
595                         Assert.IsTrue (ContainsProperty (props, "PubInst"), "#F9");
596                         Assert.IsFalse (ContainsProperty (props, "IntInst"), "#F10");
597                         Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#F11");
598                         Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#F12");
599                         Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#F13");
600                         Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#F14");
601                         Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#F15");
602                         Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#F16");
603                         Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#F17");
604                         Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#F18");
605                         Assert.IsFalse (ContainsProperty (props, "PubStat"), "#F19");
606                         Assert.IsFalse (ContainsProperty (props, "IntStat"), "#F20");
607                         Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#F21");
608                         Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#F22");
609                         Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#F23");
610                         Assert.IsTrue (ContainsProperty (props, "PubInstBlue"), "#F24");
611                         Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#F25");
612                         Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#F26");
613                         Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#F27");
614                         Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#F28");
615                         Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#F29");
616                         Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#F30");
617
618                         flags = BindingFlags.Static | BindingFlags.Public |
619                                 BindingFlags.FlattenHierarchy;
620                         props = type.GetProperties (flags);
621
622                         Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#G1");
623                         Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#G2");
624                         Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#G3");
625                         Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#G4");
626                         Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#G5");
627                         Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#G6");
628                         Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#G7");
629                         Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#G8");
630                         Assert.IsFalse (ContainsProperty (props, "PubInst"), "#G9");
631                         Assert.IsFalse (ContainsProperty (props, "IntInst"), "#G10");
632                         Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#G11");
633                         Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#G12");
634                         Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#G13");
635                         Assert.IsTrue (ContainsProperty (props, "PubStatBase"), "#G14");
636                         Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#G15");
637                         Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#G16");
638                         Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#G17");
639                         Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#G18");
640                         Assert.IsTrue (ContainsProperty (props, "PubStat"), "#G19");
641                         Assert.IsFalse (ContainsProperty (props, "IntStat"), "#G20");
642                         Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#G21");
643                         Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#G22");
644                         Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#G23");
645                         Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#G24");
646                         Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#G25");
647                         Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#G26");
648                         Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#G27");
649                         Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#G28");
650                         Assert.IsTrue (ContainsProperty (props, "PubStatBlue"), "#G29");
651                         Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#G30");
652
653                         flags = BindingFlags.Static | BindingFlags.NonPublic |
654                                 BindingFlags.FlattenHierarchy;
655                         props = type.GetProperties (flags);
656
657                         Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#H1");
658                         Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#H2");
659                         Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#H3");
660                         Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#H4");
661                         Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#H5");
662                         Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#H6");
663                         Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#H7");
664                         Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#H8");
665                         Assert.IsFalse (ContainsProperty (props, "PubInst"), "#H9");
666                         Assert.IsFalse (ContainsProperty (props, "IntInst"), "#H10");
667                         Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#H11");
668                         Assert.IsTrue (ContainsProperty (props, "ProtStatBase"), "#H12");
669                         Assert.IsTrue (ContainsProperty (props, "ProIntStatBase"), "#H13");
670                         Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#H14");
671 #if NET_2_0
672                         Assert.IsTrue (ContainsProperty (props, "IntStatBase"), "#H15");
673 #else
674                         Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#H15");
675 #endif
676                         Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#H16");
677                         Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#H17");
678                         Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#H18");
679                         Assert.IsFalse (ContainsProperty (props, "PubStat"), "#H19");
680                         Assert.IsTrue (ContainsProperty (props, "IntStat"), "#H20");
681                         Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#H21");
682                         Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#H22");
683                         Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#H23");
684                         Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#H24");
685                         Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#H25");
686                         Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#H26");
687                         Assert.IsTrue (ContainsProperty (props, "ProtStatBlue"), "#H27");
688                         Assert.IsTrue (ContainsProperty (props, "ProIntStatBlue"), "#H28");
689                         Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#H29");
690 #if NET_2_0
691                         Assert.IsTrue (ContainsProperty (props, "IntStatBlue"), "#H30");
692 #else
693                         Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#H50");
694 #endif
695
696                         flags = BindingFlags.Instance | BindingFlags.NonPublic |
697                                 BindingFlags.DeclaredOnly;
698                         props = type.GetProperties (flags);
699
700                         Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#I1");
701                         Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#I2");
702                         Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#I3");
703                         Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#I4");
704                         Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#I5");
705                         Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#I6");
706                         Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#I7");
707                         Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#I8");
708                         Assert.IsFalse (ContainsProperty (props, "PubInst"), "#I9");
709                         Assert.IsTrue (ContainsProperty (props, "IntInst"), "#I10");
710                         Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#I11");
711                         Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#I12");
712                         Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#I13");
713                         Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#I14");
714                         Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#I15");
715                         Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#I16");
716                         Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#I17");
717                         Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#I18");
718                         Assert.IsFalse (ContainsProperty (props, "PubStat"), "#I19");
719                         Assert.IsFalse (ContainsProperty (props, "IntStat"), "#I20");
720                         Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#I21");
721                         Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#I22");
722                         Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#I23");
723                         Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#I24");
724                         Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#I25");
725                         Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#I26");
726                         Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#I27");
727                         Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#I28");
728                         Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#I29");
729                         Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#I30");
730
731                         flags = BindingFlags.Instance | BindingFlags.Public |
732                                 BindingFlags.DeclaredOnly;
733                         props = type.GetProperties (flags);
734
735                         Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#J1");
736                         Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#J2");
737                         Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#J3");
738                         Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#J4");
739                         Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#J5");
740                         Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#J6");
741                         Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#J7");
742                         Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#J8");
743                         Assert.IsTrue (ContainsProperty (props, "PubInst"), "#J9");
744                         Assert.IsFalse (ContainsProperty (props, "IntInst"), "#J10");
745                         Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#J11");
746                         Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#J12");
747                         Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#J13");
748                         Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#J14");
749                         Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#J15");
750                         Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#J16");
751                         Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#J17");
752                         Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#J18");
753                         Assert.IsFalse (ContainsProperty (props, "PubStat"), "#J19");
754                         Assert.IsFalse (ContainsProperty (props, "IntStat"), "#J20");
755                         Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#J21");
756                         Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#J22");
757                         Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#J23");
758                         Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#J24");
759                         Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#J25");
760                         Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#J26");
761                         Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#J27");
762                         Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#J28");
763                         Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#J29");
764                         Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#J30");
765
766                         flags = BindingFlags.Static | BindingFlags.Public |
767                                 BindingFlags.DeclaredOnly;
768                         props = type.GetProperties (flags);
769
770                         Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#K1");
771                         Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#K2");
772                         Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#K3");
773                         Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#K4");
774                         Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#K5");
775                         Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#K6");
776                         Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#K7");
777                         Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#K8");
778                         Assert.IsFalse (ContainsProperty (props, "PubInst"), "#K9");
779                         Assert.IsFalse (ContainsProperty (props, "IntInst"), "#K10");
780                         Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#K11");
781                         Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#K12");
782                         Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#K13");
783                         Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#K14");
784                         Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#K15");
785                         Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#K16");
786                         Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#K17");
787                         Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#K18");
788                         Assert.IsTrue (ContainsProperty (props, "PubStat"), "#K19");
789                         Assert.IsFalse (ContainsProperty (props, "IntStat"), "#K20");
790                         Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#K21");
791                         Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#K22");
792                         Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#K23");
793                         Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#K24");
794                         Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#K25");
795                         Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#K26");
796                         Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#K27");
797                         Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#K28");
798                         Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#K29");
799                         Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#K30");
800
801                         flags = BindingFlags.Static | BindingFlags.NonPublic |
802                                 BindingFlags.DeclaredOnly;
803                         props = type.GetProperties (flags);
804
805                         Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#L1");
806                         Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#L2");
807                         Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#L3");
808                         Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#L4");
809                         Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#L5");
810                         Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#L6");
811                         Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#L7");
812                         Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#L8");
813                         Assert.IsFalse (ContainsProperty (props, "PubInst"), "#L9");
814                         Assert.IsFalse (ContainsProperty (props, "IntInst"), "#L10");
815                         Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#L11");
816                         Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#L12");
817                         Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#L13");
818                         Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#L14");
819                         Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#L15");
820                         Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#L16");
821                         Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#L17");
822                         Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#L18");
823                         Assert.IsFalse (ContainsProperty (props, "PubStat"), "#L19");
824                         Assert.IsTrue (ContainsProperty (props, "IntStat"), "#L20");
825                         Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#L21");
826                         Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#L22");
827                         Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#L23");
828                         Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#L24");
829                         Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#L25");
830                         Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#L26");
831                         Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#L27");
832                         Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#L28");
833                         Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#L29");
834                         Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#L30");
835
836                         flags = BindingFlags.Instance | BindingFlags.NonPublic |
837                                 BindingFlags.Public;
838                         props = type.GetProperties (flags);
839
840                         Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#M1");
841                         Assert.IsTrue (ContainsProperty (props, "ProtInstBase"), "#M2");
842                         Assert.IsTrue (ContainsProperty (props, "ProIntInstBase"), "#M3");
843                         Assert.IsTrue (ContainsProperty (props, "PubInstBase"), "#M4");
844 #if NET_2_0
845                         Assert.IsTrue (ContainsProperty (props, "IntInstBase"), "#M5");
846 #else
847                         Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#M5");
848 #endif
849                         Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#M6");
850                         Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#M7");
851                         Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#M8");
852                         Assert.IsTrue (ContainsProperty (props, "PubInst"), "#M9");
853                         Assert.IsTrue (ContainsProperty (props, "IntInst"), "#M10");
854                         Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#M11");
855                         Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#M12");
856                         Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#M13");
857                         Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#M14");
858                         Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#M15");
859                         Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#M16");
860                         Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#M17");
861                         Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#M18");
862                         Assert.IsFalse (ContainsProperty (props, "PubStat"), "#M19");
863                         Assert.IsFalse (ContainsProperty (props, "IntStat"), "#M20");
864                         Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#M21");
865                         Assert.IsTrue (ContainsProperty (props, "ProtInstBlue"), "#M22");
866                         Assert.IsTrue (ContainsProperty (props, "ProIntInstBlue"), "#M23");
867                         Assert.IsTrue (ContainsProperty (props, "PubInstBlue"), "#M24");
868 #if NET_2_0
869                         Assert.IsTrue (ContainsProperty (props, "IntInstBlue"), "#M25");
870 #else
871                         Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#M25");
872 #endif
873                         Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#M26");
874                         Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#M27");
875                         Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#M28");
876                         Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#M29");
877                         Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#M30");
878
879                         flags = BindingFlags.Static | BindingFlags.NonPublic |
880                                 BindingFlags.Public;
881                         props = type.GetProperties (flags);
882
883                         Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#N1");
884                         Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#N2");
885                         Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#N3");
886                         Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#N4");
887                         Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#N5");
888                         Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#N6");
889                         Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#N7");
890                         Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#N8");
891                         Assert.IsFalse (ContainsProperty (props, "PubInst"), "#N9");
892                         Assert.IsFalse (ContainsProperty (props, "IntInst"), "#N10");
893                         Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#N11");
894                         Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#N12");
895                         Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#N13");
896                         Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#N14");
897                         Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#N15");
898                         Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#N16");
899                         Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#N17");
900                         Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#N18");
901                         Assert.IsTrue (ContainsProperty (props, "PubStat"), "#N19");
902                         Assert.IsTrue (ContainsProperty (props, "IntStat"), "#N20");
903                         Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#N21");
904                         Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#N22");
905                         Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#N23");
906                         Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#N24");
907                         Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#N25");
908                         Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#N26");
909                         Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#N27");
910                         Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#N28");
911                         Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#N29");
912                         Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#N30");
913                 }
914
915                 [Test] // GetProperty (String)
916                 public void GetProperty1_Name_Null ()
917                 {
918                         Type type = typeof (Bar);
919                         try {
920                                 type.GetProperty ((string) null);
921                                 Assert.Fail ("#1");
922                         } catch (ArgumentNullException ex) {
923                                 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
924                                 Assert.IsNull (ex.InnerException, "#3");
925                                 Assert.IsNotNull (ex.Message, "#4");
926                                 Assert.IsNotNull (ex.ParamName, "#5");
927                                 Assert.AreEqual ("name", ex.ParamName, "#6");
928                         }
929                 }
930
931                 [Test] // GetProperty (String, BindingFlags)
932                 public void GetProperty2 ()
933                 {
934                         Type type = typeof (Bar);
935                         BindingFlags flags;
936
937                         flags = BindingFlags.Instance | BindingFlags.NonPublic;
938
939                         Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#A1");
940                         Assert.IsNotNull (type.GetProperty ("ProtInstBase", flags), "#A2");
941                         Assert.IsNotNull (type.GetProperty ("ProIntInstBase", flags), "#A3");
942                         Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#A4");
943 #if NET_2_0
944                         Assert.IsNotNull (type.GetProperty ("IntInstBase", flags), "#A5");
945 #else
946                         Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#A5");
947 #endif
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 #if NET_2_0
968                         Assert.IsNotNull (type.GetProperty ("IntInstBlue", flags), "#A25");
969 #else
970                         Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#A25");
971 #endif
972                         Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#A26");
973                         Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#A27");
974                         Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#A28");
975                         Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#A29");
976                         Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#A30");
977
978                         flags = BindingFlags.Instance | BindingFlags.Public;
979
980                         Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#B1");
981                         Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#B2");
982                         Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#B3");
983                         Assert.IsNotNull (type.GetProperty ("PubInstBase", flags), "#B4");
984                         Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#B5");
985                         Assert.IsNull (type.GetProperty ("PrivInst", flags), "#B6");
986                         Assert.IsNull (type.GetProperty ("ProtInst", flags), "#B7");
987                         Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#B8");
988                         Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#B9");
989                         Assert.IsNull (type.GetProperty ("IntInst", flags), "#B10");
990                         Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#B11");
991                         Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#B12");
992                         Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#B13");
993                         Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#B14");
994                         Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#B15");
995                         Assert.IsNull (type.GetProperty ("PrivStat", flags), "#B16");
996                         Assert.IsNull (type.GetProperty ("ProtStat", flags), "#B17");
997                         Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#B18");
998                         Assert.IsNull (type.GetProperty ("PubStat", flags), "#B19");
999                         Assert.IsNull (type.GetProperty ("IntStat", flags), "#B20");
1000                         Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#B21");
1001                         Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#B22");
1002                         Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#B23");
1003                         Assert.IsNotNull (type.GetProperty ("PubInstBlue", flags), "#B24");
1004                         Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#B25");
1005                         Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#B26");
1006                         Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#B27");
1007                         Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#B28");
1008                         Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#B29");
1009                         Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#B30");
1010
1011                         flags = BindingFlags.Static | BindingFlags.Public;
1012
1013                         Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#C1");
1014                         Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#C2");
1015                         Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#C3");
1016                         Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#C4");
1017                         Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#C5");
1018                         Assert.IsNull (type.GetProperty ("PrivInst", flags), "#C6");
1019                         Assert.IsNull (type.GetProperty ("ProtInst", flags), "#C7");
1020                         Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#C8");
1021                         Assert.IsNull (type.GetProperty ("PubInst", flags), "#C9");
1022                         Assert.IsNull (type.GetProperty ("IntInst", flags), "#C10");
1023                         Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#C11");
1024                         Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#C12");
1025                         Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#C13");
1026                         Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#C14");
1027                         Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#C15");
1028                         Assert.IsNull (type.GetProperty ("PrivStat", flags), "#C16");
1029                         Assert.IsNull (type.GetProperty ("ProtStat", flags), "#C17");
1030                         Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#C18");
1031                         Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#C19");
1032                         Assert.IsNull (type.GetProperty ("IntStat", flags), "#C20");
1033                         Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#C21");
1034                         Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#C22");
1035                         Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#C23");
1036                         Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#C24");
1037                         Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#C25");
1038                         Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#C26");
1039                         Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#C27");
1040                         Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#C28");
1041                         Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#C29");
1042                         Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#C30");
1043
1044                         flags = BindingFlags.Static | BindingFlags.NonPublic;
1045
1046                         Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#D1");
1047                         Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#D2");
1048                         Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#D3");
1049                         Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#D4");
1050                         Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#D5");
1051                         Assert.IsNull (type.GetProperty ("PrivInst", flags), "#D6");
1052                         Assert.IsNull (type.GetProperty ("ProtInst", flags), "#D7");
1053                         Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#D8");
1054                         Assert.IsNull (type.GetProperty ("PubInst", flags), "#D9");
1055                         Assert.IsNull (type.GetProperty ("IntInst", flags), "#D10");
1056                         Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#D11");
1057                         Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#D12");
1058                         Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#D13");
1059                         Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#D14");
1060                         Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#D15");
1061                         Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#D16");
1062                         Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#D17");
1063                         Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#D18");
1064                         Assert.IsNull (type.GetProperty ("PubStat", flags), "#D19");
1065                         Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#D20");
1066                         Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#D21");
1067                         Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#D22");
1068                         Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#D23");
1069                         Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#D24");
1070                         Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#D25");
1071                         Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#D26");
1072                         Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#D27");
1073                         Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#D28");
1074                         Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#D29");
1075                         Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#D30");
1076
1077                         flags = BindingFlags.Instance | BindingFlags.NonPublic |
1078                                 BindingFlags.FlattenHierarchy;
1079
1080                         Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#E1");
1081                         Assert.IsNotNull (type.GetProperty ("ProtInstBase", flags), "#E2");
1082                         Assert.IsNotNull (type.GetProperty ("ProIntInstBase", flags), "#E3");
1083                         Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#E4");
1084 #if NET_2_0
1085                         Assert.IsNotNull (type.GetProperty ("IntInstBase", flags), "#E5");
1086 #else
1087                         Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#E5");
1088 #endif
1089                         Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#E6");
1090                         Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#E7");
1091                         Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#E8");
1092                         Assert.IsNull (type.GetProperty ("PubInst", flags), "#E9");
1093                         Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#E10");
1094                         Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#E11");
1095                         Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#E12");
1096                         Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#E13");
1097                         Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#E14");
1098                         Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#E15");
1099                         Assert.IsNull (type.GetProperty ("PrivStat", flags), "#E16");
1100                         Assert.IsNull (type.GetProperty ("ProtStat", flags), "#E17");
1101                         Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#E18");
1102                         Assert.IsNull (type.GetProperty ("PubStat", flags), "#E19");
1103                         Assert.IsNull (type.GetProperty ("IntStat", flags), "#E20");
1104                         Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#E21");
1105                         Assert.IsNotNull (type.GetProperty ("ProtInstBlue", flags), "#E22");
1106                         Assert.IsNotNull (type.GetProperty ("ProIntInstBlue", flags), "#E23");
1107                         Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#E24");
1108 #if NET_2_0
1109                         Assert.IsNotNull (type.GetProperty ("IntInstBlue", flags), "#E25");
1110 #else
1111                         Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#E25");
1112 #endif
1113                         Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#E26");
1114                         Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#E27");
1115                         Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#E28");
1116                         Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#E29");
1117                         Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#E30");
1118
1119                         flags = BindingFlags.Instance | BindingFlags.Public |
1120                                 BindingFlags.FlattenHierarchy;
1121
1122                         Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#F1");
1123                         Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#F2");
1124                         Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#F3");
1125                         Assert.IsNotNull (type.GetProperty ("PubInstBase", flags), "#F4");
1126                         Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#F5");
1127                         Assert.IsNull (type.GetProperty ("PrivInst", flags), "#F6");
1128                         Assert.IsNull (type.GetProperty ("ProtInst", flags), "#F7");
1129                         Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#F8");
1130                         Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#F9");
1131                         Assert.IsNull (type.GetProperty ("IntInst", flags), "#F10");
1132                         Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#F11");
1133                         Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#F12");
1134                         Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#F13");
1135                         Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#F14");
1136                         Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#F15");
1137                         Assert.IsNull (type.GetProperty ("PrivStat", flags), "#F16");
1138                         Assert.IsNull (type.GetProperty ("ProtStat", flags), "#F17");
1139                         Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#F18");
1140                         Assert.IsNull (type.GetProperty ("PubStat", flags), "#F19");
1141                         Assert.IsNull (type.GetProperty ("IntStat", flags), "#F20");
1142                         Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#F21");
1143                         Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#F22");
1144                         Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#F23");
1145                         Assert.IsNotNull (type.GetProperty ("PubInstBlue", flags), "#F24");
1146                         Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#F25");
1147                         Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#F26");
1148                         Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#F27");
1149                         Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#F28");
1150                         Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#F29");
1151                         Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#F30");
1152
1153                         flags = BindingFlags.Static | BindingFlags.Public |
1154                                 BindingFlags.FlattenHierarchy;
1155
1156                         Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#G1");
1157                         Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#G2");
1158                         Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#G3");
1159                         Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#G4");
1160                         Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#G5");
1161                         Assert.IsNull (type.GetProperty ("PrivInst", flags), "#G6");
1162                         Assert.IsNull (type.GetProperty ("ProtInst", flags), "#G7");
1163                         Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#G8");
1164                         Assert.IsNull (type.GetProperty ("PubInst", flags), "#G9");
1165                         Assert.IsNull (type.GetProperty ("IntInst", flags), "#G10");
1166                         Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#G11");
1167                         Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#G12");
1168                         Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#G13");
1169                         Assert.IsNotNull (type.GetProperty ("PubStatBase", flags), "#G14");
1170                         Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#G15");
1171                         Assert.IsNull (type.GetProperty ("PrivStat", flags), "#G16");
1172                         Assert.IsNull (type.GetProperty ("ProtStat", flags), "#G17");
1173                         Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#G18");
1174                         Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#G19");
1175                         Assert.IsNull (type.GetProperty ("IntStat", flags), "#G20");
1176                         Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#G21");
1177                         Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#G22");
1178                         Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#G23");
1179                         Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#G24");
1180                         Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#G25");
1181                         Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#G26");
1182                         Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#G27");
1183                         Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#G28");
1184                         Assert.IsNotNull (type.GetProperty ("PubStatBlue", flags), "#G29");
1185                         Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#G30");
1186
1187                         flags = BindingFlags.Static | BindingFlags.NonPublic |
1188                                 BindingFlags.FlattenHierarchy;
1189
1190                         Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#H1");
1191                         Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#H2");
1192                         Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#H3");
1193                         Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#H4");
1194                         Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#H5");
1195                         Assert.IsNull (type.GetProperty ("PrivInst", flags), "#H6");
1196                         Assert.IsNull (type.GetProperty ("ProtInst", flags), "#H7");
1197                         Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#H8");
1198                         Assert.IsNull (type.GetProperty ("PubInst", flags), "#H9");
1199                         Assert.IsNull (type.GetProperty ("IntInst", flags), "#H10");
1200                         Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#H11");
1201                         Assert.IsNotNull (type.GetProperty ("ProtStatBase", flags), "#H12");
1202                         Assert.IsNotNull (type.GetProperty ("ProIntStatBase", flags), "#H13");
1203                         Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#H14");
1204 #if NET_2_0
1205                         Assert.IsNotNull (type.GetProperty ("IntStatBase", flags), "#H15");
1206 #else
1207                         Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#H15");
1208 #endif
1209                         Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#H16");
1210                         Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#H17");
1211                         Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#H18");
1212                         Assert.IsNull (type.GetProperty ("PubStat", flags), "#H19");
1213                         Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#H20");
1214                         Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#H21");
1215                         Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#H22");
1216                         Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#H23");
1217                         Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#H24");
1218                         Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#H25");
1219                         Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#H26");
1220                         Assert.IsNotNull (type.GetProperty ("ProtStatBlue", flags), "#H27");
1221                         Assert.IsNotNull (type.GetProperty ("ProIntStatBlue", flags), "#H28");
1222                         Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#H29");
1223 #if NET_2_0
1224                         Assert.IsNotNull (type.GetProperty ("IntStatBlue", flags), "#H30");
1225 #else
1226                         Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#H60");
1227 #endif
1228
1229                         flags = BindingFlags.Instance | BindingFlags.NonPublic |
1230                                 BindingFlags.DeclaredOnly;
1231
1232                         Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#I1");
1233                         Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#I2");
1234                         Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#I3");
1235                         Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#I4");
1236                         Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#I5");
1237                         Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#I6");
1238                         Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#I7");
1239                         Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#I8");
1240                         Assert.IsNull (type.GetProperty ("PubInst", flags), "#I9");
1241                         Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#I10");
1242                         Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#I11");
1243                         Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#I12");
1244                         Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#I13");
1245                         Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#I14");
1246                         Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#I15");
1247                         Assert.IsNull (type.GetProperty ("PrivStat", flags), "#I16");
1248                         Assert.IsNull (type.GetProperty ("ProtStat", flags), "#I17");
1249                         Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#I18");
1250                         Assert.IsNull (type.GetProperty ("PubStat", flags), "#I19");
1251                         Assert.IsNull (type.GetProperty ("IntStat", flags), "#I20");
1252                         Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#I21");
1253                         Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#I22");
1254                         Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#I23");
1255                         Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#I24");
1256                         Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#I25");
1257                         Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#I26");
1258                         Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#I27");
1259                         Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#I28");
1260                         Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#I29");
1261                         Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#I30");
1262
1263                         flags = BindingFlags.Instance | BindingFlags.Public |
1264                                 BindingFlags.DeclaredOnly;
1265
1266                         Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#J1");
1267                         Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#J2");
1268                         Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#J3");
1269                         Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#J4");
1270                         Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#J5");
1271                         Assert.IsNull (type.GetProperty ("PrivInst", flags), "#J6");
1272                         Assert.IsNull (type.GetProperty ("ProtInst", flags), "#J7");
1273                         Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#J8");
1274                         Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#J9");
1275                         Assert.IsNull (type.GetProperty ("IntInst", flags), "#J10");
1276                         Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#J11");
1277                         Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#J12");
1278                         Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#J13");
1279                         Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#J14");
1280                         Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#J15");
1281                         Assert.IsNull (type.GetProperty ("PrivStat", flags), "#J16");
1282                         Assert.IsNull (type.GetProperty ("ProtStat", flags), "#J17");
1283                         Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#J18");
1284                         Assert.IsNull (type.GetProperty ("PubStat", flags), "#J19");
1285                         Assert.IsNull (type.GetProperty ("IntStat", flags), "#J20");
1286                         Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#J21");
1287                         Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#J22");
1288                         Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#J23");
1289                         Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#J24");
1290                         Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#J25");
1291                         Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#J26");
1292                         Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#J27");
1293                         Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#J28");
1294                         Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#J29");
1295                         Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#J30");
1296
1297                         flags = BindingFlags.Static | BindingFlags.Public |
1298                                 BindingFlags.DeclaredOnly;
1299
1300                         Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#K1");
1301                         Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#K2");
1302                         Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#K3");
1303                         Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#K4");
1304                         Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#K5");
1305                         Assert.IsNull (type.GetProperty ("PrivInst", flags), "#K6");
1306                         Assert.IsNull (type.GetProperty ("ProtInst", flags), "#K7");
1307                         Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#K8");
1308                         Assert.IsNull (type.GetProperty ("PubInst", flags), "#K9");
1309                         Assert.IsNull (type.GetProperty ("IntInst", flags), "#K10");
1310                         Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#K11");
1311                         Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#K12");
1312                         Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#K13");
1313                         Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#K14");
1314                         Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#K15");
1315                         Assert.IsNull (type.GetProperty ("PrivStat", flags), "#K16");
1316                         Assert.IsNull (type.GetProperty ("ProtStat", flags), "#K17");
1317                         Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#K18");
1318                         Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#K19");
1319                         Assert.IsNull (type.GetProperty ("IntStat", flags), "#K20");
1320                         Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#K21");
1321                         Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#K22");
1322                         Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#K23");
1323                         Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#K24");
1324                         Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#K25");
1325                         Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#K26");
1326                         Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#K27");
1327                         Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#K28");
1328                         Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#K29");
1329                         Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#K30");
1330
1331                         flags = BindingFlags.Static | BindingFlags.NonPublic |
1332                                 BindingFlags.DeclaredOnly;
1333
1334                         Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#L1");
1335                         Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#L2");
1336                         Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#L3");
1337                         Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#L4");
1338                         Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#L5");
1339                         Assert.IsNull (type.GetProperty ("PrivInst", flags), "#L6");
1340                         Assert.IsNull (type.GetProperty ("ProtInst", flags), "#L7");
1341                         Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#L8");
1342                         Assert.IsNull (type.GetProperty ("PubInst", flags), "#L9");
1343                         Assert.IsNull (type.GetProperty ("IntInst", flags), "#L10");
1344                         Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#L11");
1345                         Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#L12");
1346                         Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#L13");
1347                         Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#L14");
1348                         Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#L15");
1349                         Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#L16");
1350                         Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#L17");
1351                         Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#L18");
1352                         Assert.IsNull (type.GetProperty ("PubStat", flags), "#L19");
1353                         Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#L20");
1354                         Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#L21");
1355                         Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#L22");
1356                         Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#L23");
1357                         Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#L24");
1358                         Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#L25");
1359                         Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#L26");
1360                         Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#L27");
1361                         Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#L28");
1362                         Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#L29");
1363                         Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#L30");
1364
1365                         flags = BindingFlags.Instance | BindingFlags.NonPublic |
1366                                 BindingFlags.Public;
1367
1368                         Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#M1");
1369                         Assert.IsNotNull (type.GetProperty ("ProtInstBase", flags), "#M2");
1370                         Assert.IsNotNull (type.GetProperty ("ProIntInstBase", flags), "#M3");
1371                         Assert.IsNotNull (type.GetProperty ("PubInstBase", flags), "#M4");
1372 #if NET_2_0
1373                         Assert.IsNotNull (type.GetProperty ("IntInstBase", flags), "#M5");
1374 #else
1375                         Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#M5");
1376 #endif
1377                         Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#M6");
1378                         Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#M7");
1379                         Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#M8");
1380                         Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#M9");
1381                         Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#M10");
1382                         Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#M11");
1383                         Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#M12");
1384                         Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#M13");
1385                         Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#M14");
1386                         Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#M15");
1387                         Assert.IsNull (type.GetProperty ("PrivStat", flags), "#M16");
1388                         Assert.IsNull (type.GetProperty ("ProtStat", flags), "#M17");
1389                         Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#M18");
1390                         Assert.IsNull (type.GetProperty ("PubStat", flags), "#M19");
1391                         Assert.IsNull (type.GetProperty ("IntStat", flags), "#M20");
1392                         Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#M21");
1393                         Assert.IsNotNull (type.GetProperty ("ProtInstBlue", flags), "#M22");
1394                         Assert.IsNotNull (type.GetProperty ("ProIntInstBlue", flags), "#M23");
1395                         Assert.IsNotNull (type.GetProperty ("PubInstBlue", flags), "#M24");
1396 #if NET_2_0
1397                         Assert.IsNotNull (type.GetProperty ("IntInstBlue", flags), "#M25");
1398 #else
1399                         Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#M25");
1400 #endif
1401                         Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#M26");
1402                         Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#M27");
1403                         Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#M28");
1404                         Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#M29");
1405                         Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#M30");
1406
1407                         flags = BindingFlags.Static | BindingFlags.NonPublic |
1408                                 BindingFlags.Public;
1409
1410                         Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#N1");
1411                         Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#N2");
1412                         Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#N3");
1413                         Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#N4");
1414                         Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#N5");
1415                         Assert.IsNull (type.GetProperty ("PrivInst", flags), "#N6");
1416                         Assert.IsNull (type.GetProperty ("ProtInst", flags), "#N7");
1417                         Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#N8");
1418                         Assert.IsNull (type.GetProperty ("PubInst", flags), "#N9");
1419                         Assert.IsNull (type.GetProperty ("IntInst", flags), "#N10");
1420                         Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#N11");
1421                         Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#N12");
1422                         Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#N13");
1423                         Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#N14");
1424                         Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#N15");
1425                         Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#N16");
1426                         Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#N17");
1427                         Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#N18");
1428                         Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#N19");
1429                         Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#N20");
1430                         Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#N21");
1431                         Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#N22");
1432                         Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#N23");
1433                         Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#N24");
1434                         Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#N25");
1435                         Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#N26");
1436                         Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#N27");
1437                         Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#N28");
1438                         Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#N29");
1439                         Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#N30");
1440                 }
1441
1442                 [Test] // GetProperty (String, BindingFlags)
1443                 public void GetProperty2_Name_Null ()
1444                 {
1445                         Type type = typeof (Bar);
1446                         try {
1447                                 type.GetProperty ((string) null);
1448                                 Assert.Fail ("#1");
1449                         } catch (ArgumentNullException ex) {
1450                                 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1451                                 Assert.IsNull (ex.InnerException, "#3");
1452                                 Assert.IsNotNull (ex.Message, "#4");
1453                                 Assert.IsNotNull (ex.ParamName, "#5");
1454                                 Assert.AreEqual ("name", ex.ParamName, "#6");
1455                         }
1456                 }
1457
1458                 [Test] // GetProperty (String, Type)
1459                 public void GetProperty3_Name_Null ()
1460                 {
1461                         Type type = typeof (Bar);
1462                         try {
1463                                 type.GetProperty ((string) null, typeof (int));
1464                                 Assert.Fail ("#1");
1465                         } catch (ArgumentNullException ex) {
1466                                 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1467                                 Assert.IsNull (ex.InnerException, "#3");
1468                                 Assert.IsNotNull (ex.Message, "#4");
1469                                 Assert.IsNotNull (ex.ParamName, "#5");
1470                                 Assert.AreEqual ("name", ex.ParamName, "#6");
1471                         }
1472                 }
1473
1474                 [Test] // GetProperty (String, Type [])
1475                 public void GetProperty4_Name_Null ()
1476                 {
1477                         Type type = typeof (Bar);
1478                         try {
1479                                 type.GetProperty ((string) null, Type.EmptyTypes);
1480                                 Assert.Fail ("#1");
1481                         } catch (ArgumentNullException ex) {
1482                                 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1483                                 Assert.IsNull (ex.InnerException, "#3");
1484                                 Assert.IsNotNull (ex.Message, "#4");
1485                                 Assert.IsNotNull (ex.ParamName, "#5");
1486                                 Assert.AreEqual ("name", ex.ParamName, "#6");
1487                         }
1488                 }
1489
1490                 [Test] // GetProperty (String, Type, Type [])
1491                 public void GetProperty5_Name_Null ()
1492                 {
1493                         Type type = typeof (Bar);
1494                         try {
1495                                 type.GetProperty ((string) null, typeof (int),
1496                                         Type.EmptyTypes);
1497                                 Assert.Fail ("#1");
1498                         } catch (ArgumentNullException ex) {
1499                                 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1500                                 Assert.IsNull (ex.InnerException, "#3");
1501                                 Assert.IsNotNull (ex.Message, "#4");
1502                                 Assert.IsNotNull (ex.ParamName, "#5");
1503                                 Assert.AreEqual ("name", ex.ParamName, "#6");
1504                         }
1505                 }
1506
1507                 [Test] // GetProperty (String, Type, Type [], ParameterModifier [])
1508                 public void GetProperty6_Name_Null ()
1509                 {
1510                         Type type = typeof (Bar);
1511                         try {
1512                                 type.GetProperty ((string) null, typeof (int),
1513                                         Type.EmptyTypes, null);
1514                                 Assert.Fail ("#1");
1515                         } catch (ArgumentNullException ex) {
1516                                 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1517                                 Assert.IsNull (ex.InnerException, "#3");
1518                                 Assert.IsNotNull (ex.Message, "#4");
1519                                 Assert.IsNotNull (ex.ParamName, "#5");
1520                                 Assert.AreEqual ("name", ex.ParamName, "#6");
1521                         }
1522                 }
1523
1524                 [Test] // GetProperty (String, BindingFlags, Binder, Type, Type [], ParameterModifier [])
1525                 public void GetProperty7_Name_Null ()
1526                 {
1527                         Type type = typeof (Bar);
1528                         try {
1529                                 type.GetProperty ((string) null, BindingFlags.Public,
1530                                         null, typeof (int), Type.EmptyTypes, null);
1531                                 Assert.Fail ("#1");
1532                         } catch (ArgumentNullException ex) {
1533                                 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1534                                 Assert.IsNull (ex.InnerException, "#3");
1535                                 Assert.IsNotNull (ex.Message, "#4");
1536                                 Assert.IsNotNull (ex.ParamName, "#5");
1537                                 Assert.AreEqual ("name", ex.ParamName, "#6");
1538                         }
1539                 }
1540
1541                 [Test]
1542                 public void GetProperty8_PropertyType ()
1543                 {
1544                         Type type = typeof (Bar);
1545                         Assert.IsNull (type.GetProperty ("PubInst", BindingFlags.Public | BindingFlags.Instance,
1546                                                          null, typeof (int), Type.EmptyTypes, null), "#1");
1547                         Assert.IsNotNull (type.GetProperty ("PubInst", BindingFlags.Public | BindingFlags.Instance, null, 
1548                                                             typeof (long), new Type[0], null), "#2");
1549                 }
1550
1551 #if !TARGET_JVM // StructLayout not supported for TARGET_JVM
1552                 [StructLayout(LayoutKind.Explicit, Pack = 4, Size = 64)]
1553                 public class Class1
1554                 {
1555                 }
1556
1557                 [StructLayout(LayoutKind.Explicit, CharSet=CharSet.Unicode)]
1558                 public class Class2
1559                 {
1560                 }
1561
1562 #if NET_2_0
1563                 [Test]
1564                 public void StructLayoutAttribute ()
1565                 {
1566                         StructLayoutAttribute attr1 = typeof (TypeTest).StructLayoutAttribute;
1567                         Assert.AreEqual (LayoutKind.Auto, attr1.Value);
1568
1569                         StructLayoutAttribute attr2 = typeof (Class1).StructLayoutAttribute;
1570                         Assert.AreEqual (LayoutKind.Explicit, attr2.Value);
1571                         Assert.AreEqual (4, attr2.Pack);
1572                         Assert.AreEqual (64, attr2.Size);
1573
1574                         StructLayoutAttribute attr3 = typeof (Class2).StructLayoutAttribute;
1575                         Assert.AreEqual (LayoutKind.Explicit, attr3.Value);
1576                         Assert.AreEqual (CharSet.Unicode, attr3.CharSet);
1577                 }
1578 #endif
1579 #endif // TARGET_JVM
1580
1581                 [Test]
1582                 public void Namespace ()
1583                 {
1584                         Assert.AreEqual (null, typeof (NoNamespaceClass).Namespace);
1585                 }
1586
1587                 public static void Reflected (ref int a)
1588                 {
1589                 }
1590
1591                 [Test]
1592                 public void Name ()
1593                 {
1594                         Assert.AreEqual ("Int32&", typeof (TypeTest).GetMethod ("Reflected").GetParameters () [0].ParameterType.Name);
1595                         Assert.AreEqual ("String[*]", Array.CreateInstance (typeof(string), new int[] { 1 }, new int[] { 1 }).GetType ().Name);
1596                 }
1597
1598                 [Test]
1599                 public void GetInterfaces ()
1600                 {
1601                         Type[] t = typeof (Duper).GetInterfaces ();
1602                         Assert.AreEqual (1, t.Length);
1603                         Assert.AreEqual (typeof (ICloneable), t[0]);
1604
1605                         Type[] t2 = typeof (IFace3).GetInterfaces ();
1606                         Assert.AreEqual (2, t2.Length);
1607                 }
1608
1609                 public int AField;
1610
1611                 [Test]
1612                 public void GetFieldIgnoreCase ()
1613                 {
1614                         Assert.IsNotNull (typeof (TypeTest).GetField ("afield", BindingFlags.Instance|BindingFlags.Public|BindingFlags.IgnoreCase));
1615                 }
1616
1617 #if NET_2_0
1618                 public int Count {
1619                         internal get {
1620                                 return 0;
1621                         }
1622
1623                         set {
1624                         }
1625                 }
1626
1627                 [Test]
1628                 public void GetPropertyAccessorModifiers ()
1629                 {
1630                         Assert.IsNotNull (typeof (TypeTest).GetProperty ("Count", BindingFlags.Instance | BindingFlags.Public));
1631                         Assert.IsNull (typeof (TypeTest).GetProperty ("Count", BindingFlags.Instance | BindingFlags.NonPublic));
1632                 }
1633 #endif
1634
1635                 [Test]
1636                 public void IsAbstract ()
1637                 {
1638                         Assert.IsFalse (typeof (string).IsAbstract, "#1");
1639                         Assert.IsTrue (typeof (ICloneable).IsAbstract, "#2");
1640                         Assert.IsTrue (typeof (ValueType).IsAbstract, "#3");
1641                         Assert.IsTrue (typeof (Enum).IsAbstract, "#4");
1642                         Assert.IsFalse (typeof (TimeSpan).IsAbstract, "#5");
1643                         Assert.IsTrue (typeof (TextReader).IsAbstract, "#6");
1644
1645 #if NET_2_0
1646                         // LAMESPEC:
1647                         // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=286308
1648                         Type [] typeArgs = typeof (List<>).GetGenericArguments ();
1649                         Assert.IsFalse (typeArgs [0].IsAbstract, "#7");
1650 #endif
1651                 }
1652
1653                 [Test]
1654                 public void IsCOMObject ()
1655                 {
1656                         Type type = typeof (string);
1657                         Assert.IsFalse (type.IsCOMObject, "#1");
1658
1659                         TypeBuilder tb = module.DefineType (genTypeName ());
1660                         type = tb.CreateType ();
1661                         Assert.IsFalse (type.IsCOMObject, "#2");
1662                 }
1663
1664                 [Test]
1665                 public void IsImport ()
1666                 {
1667                         Type type = typeof (string);
1668                         Assert.IsFalse (type.IsImport, "#1");
1669
1670                         TypeBuilder tb = module.DefineType (genTypeName ());
1671                         type = tb.CreateType ();
1672                         Assert.IsFalse (type.IsImport, "#2");
1673
1674                         tb = module.DefineType (genTypeName (), TypeAttributes.Import |
1675                                 TypeAttributes.Interface | TypeAttributes.Abstract);
1676                         type = tb.CreateType ();
1677                         Assert.IsTrue (type.IsImport, "#3");
1678                 }
1679
1680                 [Test]
1681                 public void IsInterface ()
1682                 {
1683                         Assert.IsFalse (typeof (string).IsInterface, "#1");
1684                         Assert.IsTrue (typeof (ICloneable).IsInterface, "#2");
1685                 }
1686
1687                 [Test]
1688                 public void IsPrimitive () {
1689                         Assert.IsTrue (typeof (IntPtr).IsPrimitive, "#1");
1690                         Assert.IsTrue (typeof (int).IsPrimitive, "#2");
1691                         Assert.IsFalse (typeof (string).IsPrimitive, "#2");
1692                 }
1693
1694                 [Test]
1695                 public void IsValueType ()
1696                 {
1697                         Assert.IsTrue (typeof (int).IsValueType, "#1");
1698                         Assert.IsFalse (typeof (Enum).IsValueType, "#2");
1699                         Assert.IsFalse (typeof (ValueType).IsValueType, "#3");
1700                         Assert.IsTrue (typeof (AttributeTargets).IsValueType, "#4");
1701                         Assert.IsFalse (typeof (string).IsValueType, "#5");
1702                         Assert.IsTrue (typeof (TimeSpan).IsValueType, "#6");
1703                 }
1704
1705                 [Test]
1706                 [Category("NotDotNet")]
1707                 // Depends on the GAC working, which it doesn't durring make distcheck.
1708                 [Category ("NotWorking")]
1709                 public void GetTypeWithWhitespace ()
1710                 {
1711                         Assert.IsNotNull (Type.GetType
1712                                                    (@"System.Configuration.NameValueSectionHandler,
1713                         System,
1714 Version=1.0.5000.0,
1715 Culture=neutral
1716 ,
1717 PublicKeyToken=b77a5c561934e089"));
1718                 }
1719
1720                 [Test]
1721                 public void GetTypeNonVectorArray ()
1722                 {
1723                         Type t = Type.GetType ("System.String[*]");
1724                         Assert.AreEqual ("System.String[*]", t.ToString ());
1725                 }
1726                 
1727                 [Test]
1728                 public void ExerciseFilterName ()
1729                 {
1730                         MemberInfo[] mi = typeof(Base).FindMembers(
1731                                 MemberTypes.Method, 
1732                                 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1733                                 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1734                                 Type.FilterName, "*");
1735                         Assert.AreEqual (4, mi.Length);
1736                         mi = typeof(Base).FindMembers(
1737                                 MemberTypes.Method, 
1738                                 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1739                                 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1740                                 Type.FilterName, "Test*");
1741                         Assert.AreEqual (2, mi.Length);
1742                         mi = typeof(Base).FindMembers(
1743                                 MemberTypes.Method, 
1744                                 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1745                                 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1746                                 Type.FilterName, "TestVoid");
1747                         Assert.AreEqual (1, mi.Length);
1748                         mi = typeof(Base).FindMembers(
1749                                 MemberTypes.Method, 
1750                                 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1751                                 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1752                                 Type.FilterName, "NonExistingMethod");
1753                         Assert.AreEqual (0, mi.Length);
1754                 }
1755                 
1756                 [Test]
1757                 public void ExerciseFilterNameIgnoreCase ()
1758                 {
1759                         MemberInfo[] mi = typeof(Base).FindMembers(
1760                                 MemberTypes.Method, 
1761                                 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1762                                 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1763                                 Type.FilterNameIgnoreCase, "*");
1764                         Assert.AreEqual (4, mi.Length);
1765                         mi = typeof(Base).FindMembers(
1766                                 MemberTypes.Method, 
1767                                 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1768                                 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1769                                 Type.FilterNameIgnoreCase, "test*");
1770                         Assert.AreEqual (2, mi.Length);
1771                         mi = typeof(Base).FindMembers(
1772                                 MemberTypes.Method, 
1773                                 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1774                                 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1775                                 Type.FilterNameIgnoreCase, "TESTVOID");
1776                         Assert.AreEqual (1, mi.Length);
1777                         mi = typeof(Base).FindMembers(
1778                                 MemberTypes.Method, 
1779                                 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1780                                 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1781                                 Type.FilterNameIgnoreCase, "NonExistingMethod");
1782                         Assert.AreEqual (0, mi.Length);
1783                 }
1784
1785                 public class ByRef0
1786                 {
1787                         public int field;
1788                         public int property {
1789                                 get { return 0; }
1790                         }
1791                         public ByRef0 (int i) {}
1792                         public void f (int i) {}
1793                 }
1794
1795                 [Test]
1796                 public void ByrefTypes ()
1797                 {
1798                         Type t = Type.GetType ("MonoTests.System.TypeTest+ByRef0&");
1799                         Assert.IsNotNull (t);
1800                         Assert.IsTrue (t.IsByRef);
1801                         Assert.AreEqual (0, t.GetMethods (BindingFlags.Public | BindingFlags.Instance).Length);
1802                         Assert.AreEqual (0, t.GetConstructors (BindingFlags.Public | BindingFlags.Instance).Length);
1803                         Assert.AreEqual (0, t.GetEvents (BindingFlags.Public | BindingFlags.Instance).Length);
1804                         Assert.AreEqual (0, t.GetProperties (BindingFlags.Public | BindingFlags.Instance).Length);
1805
1806                         Assert.IsNull (t.GetMethod ("f"));
1807                         Assert.IsNull (t.GetField ("field"));
1808                         Assert.IsNull (t.GetProperty ("property"));
1809                 }
1810                 
1811                 [Test]
1812                 public void TestAssemblyQualifiedName ()
1813                 {
1814                         Type t = Type.GetType ("System.Byte[]&");
1815                         Assert.IsTrue (t.AssemblyQualifiedName.StartsWith ("System.Byte[]&"));
1816                         
1817                         t = Type.GetType ("System.Byte*&");
1818                         Assert.IsTrue (t.AssemblyQualifiedName.StartsWith ("System.Byte*&"));
1819                         
1820                         t = Type.GetType ("System.Byte&");
1821                         Assert.IsTrue (t.AssemblyQualifiedName.StartsWith ("System.Byte&"));
1822                 }
1823
1824                 struct B
1825                 {
1826                         int value;
1827                 }
1828
1829                 [Test]
1830                 public void CreateValueTypeNoCtor ()
1831                 {
1832                         typeof(B).InvokeMember ("", BindingFlags.CreateInstance, null, null, null);
1833                 }
1834
1835                 [Test]
1836                 [ExpectedException (typeof (MissingMethodException))]
1837                 public void CreateValueTypeNoCtorArgs ()
1838                 {
1839                         typeof(B).InvokeMember ("", BindingFlags.CreateInstance, null, null, new object [] { 1 });
1840                 }
1841
1842                 internal static string bug336841 (string param1, params string [] param2)
1843                 {
1844                         StringBuilder sb = new StringBuilder ();
1845                         sb.Append ("#A:");
1846                         sb.Append (param1);
1847                         sb.Append ("|");
1848                         for (int i = 0; i < param2.Length; i++) {
1849                                 if (i > 0)
1850                                         sb.Append (",");
1851                                 sb.Append (param2 [i]);
1852                         }
1853                         return sb.ToString ();
1854                 }
1855
1856                 internal static string bug336841 (string param1)
1857                 {
1858                         return "#B:" + param1;
1859                 }
1860
1861                 internal static string bug336841 (params string [] param1)
1862                 {
1863                         StringBuilder sb = new StringBuilder ();
1864                         sb.Append ("#C:");
1865                         for (int i = 0; i < param1.Length; i++) {
1866                                 if (i > 0)
1867                                         sb.Append (";");
1868                                 sb.Append (param1 [i]);
1869                         }
1870                         return sb.ToString ();
1871                 }
1872
1873                 [Test]
1874                 public void InvokeMember_GetSetField ()
1875                 {
1876                         typeof (X).InvokeMember ("Value", BindingFlags.Public |
1877                                 BindingFlags.Static | BindingFlags.FlattenHierarchy |
1878                                 BindingFlags.SetField, null, null, new object [] { 5 });
1879
1880                         Assert.AreEqual (5, X.Value, "#A1");
1881                         Assert.AreEqual (5, typeof (X).InvokeMember ("Value",
1882                                 BindingFlags.Public | BindingFlags.Static |
1883                                 BindingFlags.FlattenHierarchy | BindingFlags.GetField,
1884                                 null, null, new object [0]), "#A2");
1885                         Assert.AreEqual (5, Y.Value, "#A3");
1886                         Assert.AreEqual (5, typeof (Y).InvokeMember ("Value",
1887                                 BindingFlags.Public | BindingFlags.Static |
1888                                 BindingFlags.FlattenHierarchy | BindingFlags.GetField,
1889                                 null, null, new object [0]), "#A4");
1890
1891                         try {
1892                                 typeof (X).InvokeMember ("Value", BindingFlags.Public |
1893                                         BindingFlags.Static | BindingFlags.FlattenHierarchy |
1894                                         BindingFlags.GetField | BindingFlags.SetField,
1895                                         null, null, new object [] { 5 });
1896                                 Assert.Fail ("#B1");
1897                         } catch (ArgumentException ex) {
1898                                 // Cannot specify both Get and Set on a field
1899                                 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1900                                 Assert.IsNull (ex.InnerException, "#B3");
1901                                 Assert.IsNotNull (ex.Message, "#B4");
1902                                 Assert.IsNotNull (ex.ParamName, "#B5");
1903 #if NET_2_0
1904                                 Assert.AreEqual ("bindingFlags", ex.ParamName, "#B6");
1905 #else
1906                                 Assert.AreEqual ("invokeAttr", ex.ParamName, "#B6");
1907 #endif
1908                         }
1909                 }
1910
1911                 [Test]
1912                 public void InvokeMember_GetSetProperty ()
1913                 {
1914                         try {
1915                                 typeof (ArrayList).InvokeMember ("Item",
1916                                         BindingFlags.GetProperty | BindingFlags.SetProperty |
1917                                         BindingFlags.Instance | BindingFlags.Public,
1918                                         null, new ArrayList (), new object [] { 0, "bar" });
1919                                 Assert.Fail ("#1");
1920                         } catch (ArgumentException ex) {
1921                                 // Cannot specify both Get and Set on a property
1922                                 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
1923                                 Assert.IsNull (ex.InnerException, "#3");
1924                                 Assert.IsNotNull (ex.Message, "#4");
1925                                 Assert.IsNotNull (ex.ParamName, "#5");
1926 #if NET_2_0
1927                                 Assert.AreEqual ("bindingFlags", ex.ParamName, "#6");
1928 #else
1929                                 Assert.AreEqual ("invokeAttr", ex.ParamName, "#6");
1930 #endif
1931                         }
1932                 }
1933
1934
1935                 [Test]
1936                 public void InvokeMember_InvokeMethod_Set ()
1937                 {
1938                         try {
1939                                 typeof (ArrayList).InvokeMember ("ToString",
1940                                         BindingFlags.InvokeMethod | BindingFlags.SetField |
1941                                         BindingFlags.Instance | BindingFlags.Public,
1942                                         null, new ArrayList (), new object [0]);
1943                                 Assert.Fail ("#A1");
1944                         } catch (ArgumentException ex) {
1945                                 // Cannot specify Set on a field and Invoke on a method
1946                                 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
1947                                 Assert.IsNull (ex.InnerException, "#A3");
1948                                 Assert.IsNotNull (ex.Message, "#A4");
1949                                 Assert.IsNotNull (ex.ParamName, "#A5");
1950 #if NET_2_0
1951                                 Assert.AreEqual ("bindingFlags", ex.ParamName, "#A6");
1952 #else
1953                                 Assert.AreEqual ("invokeAttr", ex.ParamName, "#A6");
1954 #endif
1955                         }
1956
1957                         try {
1958                                 typeof (ArrayList).InvokeMember ("ToString",
1959                                         BindingFlags.InvokeMethod | BindingFlags.SetProperty |
1960                                         BindingFlags.Instance | BindingFlags.Public,
1961                                         null, new ArrayList (), new object [0]);
1962                                 Assert.Fail ("#B1");
1963                         } catch (ArgumentException ex) {
1964                                 // Cannot specify Set on a property and Invoke on a method
1965                                 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
1966                                 Assert.IsNull (ex.InnerException, "#B3");
1967                                 Assert.IsNotNull (ex.Message, "#B4");
1968                                 Assert.IsNotNull (ex.ParamName, "#B5");
1969 #if NET_2_0
1970                                 Assert.AreEqual ("bindingFlags", ex.ParamName, "#B6");
1971 #else
1972                                 Assert.AreEqual ("invokeAttr", ex.ParamName, "#B6");
1973 #endif
1974                         }
1975                 }
1976
1977                 [Test]
1978                 public void InvokeMember_MatchPrimitiveTypeWithInterface ()
1979                 {
1980                         object [] invokeargs = { 1 };
1981                         typeof (Z).InvokeMember ("", BindingFlags.DeclaredOnly |
1982                                 BindingFlags.Public | BindingFlags.NonPublic |
1983                                 BindingFlags.Instance | BindingFlags.CreateInstance,
1984                                 null, null, invokeargs);
1985                 }
1986
1987                 [Test]
1988                 public void InvokeMember_Name_Null ()
1989                 {
1990                         try {
1991                                 typeof (X).InvokeMember ((string) null,
1992                                         BindingFlags.Public | BindingFlags.Static |
1993                                         BindingFlags.FlattenHierarchy | BindingFlags.SetField,
1994                                         null, null, new object [] { 5 });
1995                                 Assert.Fail ("#1");
1996                         } catch (ArgumentNullException ex) {
1997                                 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1998                                 Assert.IsNull (ex.InnerException, "#3");
1999                                 Assert.IsNotNull (ex.Message, "#4");
2000                                 Assert.IsNotNull (ex.ParamName, "#5");
2001                                 Assert.AreEqual ("name", ex.ParamName, "#6");
2002                         }
2003                 }
2004
2005                 [Test]
2006                 public void InvokeMember_NoOperation ()
2007                 {
2008                         try {
2009                                 typeof (TypeTest).InvokeMember ("Run", BindingFlags.Public |
2010                                         BindingFlags.Static, null, null, new object [0]);
2011                                 Assert.Fail ("#1");
2012                         } catch (ArgumentException ex) {
2013                                 // Must specify binding flags describing the
2014                                 // invoke operation required
2015                                 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
2016                                 Assert.IsNull (ex.InnerException, "#3");
2017                                 Assert.IsNotNull (ex.Message, "#4");
2018                                 Assert.IsNotNull (ex.ParamName, "#5");
2019 #if NET_2_0
2020                                 Assert.AreEqual ("bindingFlags", ex.ParamName, "#6");
2021 #else
2022                                 Assert.AreEqual ("invokeAttr", ex.ParamName, "#6");
2023 #endif
2024                         }
2025                 }
2026
2027                 [Test] // bug #321735
2028                 public void InvokeMember_SetFieldProperty ()
2029                 {
2030                         ArrayList list = new ArrayList ();
2031                         list.Add ("foo");
2032                         list.GetType ().InvokeMember ("Item",
2033                                 BindingFlags.SetField | BindingFlags.SetProperty |
2034                                 BindingFlags.Instance | BindingFlags.Public,
2035                                 null, list, new object [] { 0, "bar" });
2036                         Assert.AreEqual ("bar", list [0]);
2037                 }
2038
2039                 [Test]
2040                 public void InvokeMember_SetField_ProvidedArgs ()
2041                 {
2042                         try {
2043                                 typeof (X).InvokeMember ("Value", BindingFlags.Public |
2044                                         BindingFlags.Static | BindingFlags.SetField,
2045                                         null, null, new object [0]);
2046                                 Assert.Fail ("#A1");
2047                         } catch (ArgumentException ex) {
2048                                 // Only the field value can be specified to set
2049                                 // a field value
2050                                 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
2051                                 Assert.IsNull (ex.InnerException, "#A3");
2052                                 Assert.IsNotNull (ex.Message, "#A4");
2053                                 Assert.IsNotNull (ex.ParamName, "#A5");
2054 #if NET_2_0
2055                                 Assert.AreEqual ("bindingFlags", ex.ParamName, "#6");
2056 #else
2057                                 Assert.AreEqual ("invokeAttr", ex.ParamName, "#6");
2058 #endif
2059                         }
2060
2061                         try {
2062                                 typeof (X).InvokeMember ("Value", BindingFlags.Public |
2063                                         BindingFlags.Static | BindingFlags.SetField,
2064                                         null, null, null);
2065                                 Assert.Fail ("#B1");
2066 #if NET_2_0
2067                         } catch (ArgumentNullException ex) {
2068                                 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
2069                                 Assert.IsNull (ex.InnerException, "#B3");
2070                                 Assert.IsNotNull (ex.Message, "#B4");
2071                                 Assert.IsNotNull (ex.ParamName, "#B5");
2072                                 Assert.AreEqual ("providedArgs", ex.ParamName, "#B6");
2073                         }
2074 #else
2075                         } catch (ArgumentException ex) {
2076                                 // Only the field value can be specified to set
2077                                 // a field value
2078                                 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
2079                                 Assert.IsNull (ex.InnerException, "#B3");
2080                                 Assert.IsNotNull (ex.Message, "#B4");
2081                                 Assert.IsNotNull (ex.ParamName, "#B5");
2082 #if NET_2_0
2083                                 Assert.AreEqual ("bindingFlags", ex.ParamName, "#B6");
2084 #else
2085                                 Assert.AreEqual ("invokeAttr", ex.ParamName, "#B6");
2086 #endif
2087                         }
2088 #endif
2089                 }
2090
2091                 [Test] // bug #336841
2092                 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=306797
2093                 public void InvokeMember_VarArgs ()
2094                 {
2095                         BindingFlags flags = BindingFlags.InvokeMethod | BindingFlags.Public |
2096                                 BindingFlags.NonPublic | BindingFlags.OptionalParamBinding |
2097                                 BindingFlags.Static | BindingFlags.FlattenHierarchy |
2098                                 BindingFlags.Instance;
2099
2100                         Type type = typeof (TypeTest);
2101                         string result = (string) type.InvokeMember ("bug336841",
2102                                 flags, null, null, new object [] { "1" });
2103                         Assert.IsNotNull (result, "#A1");
2104                         Assert.AreEqual ("#B:1", result, "#A2");
2105
2106                         result = (string) type.InvokeMember ("bug336841", flags,
2107                                 null, null, new object [] { "1", "2", "3", "4" });
2108                         Assert.IsNotNull (result, "#B1");
2109                         Assert.AreEqual ("#A:1|2,3,4", result, "#B2");
2110                 }
2111
2112         
2113                 [Test] // bug #348522
2114                 public void InvokeMember_WithoutDefaultValue ()
2115                 {
2116                         BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod;;
2117                         try {
2118                                 typeof (Bug348522).InvokeMember ("Test", flags, new FirstMethodBinder (), new Bug348522(),
2119                                         new object [] {Missing.Value}, null, null, null);
2120                                 Assert.Fail ("#1");
2121                         } catch (ArgumentException ex) {
2122                                 // Missing parameter does not have a default value
2123                                 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
2124                                 Assert.IsNull (ex.InnerException, "#3");
2125                                 Assert.IsNotNull (ex.Message, "#4");
2126                                 Assert.IsNotNull (ex.ParamName, "#5");
2127                                 Assert.AreEqual ("parameters", ex.ParamName, "#6");
2128                         }
2129                 }
2130
2131                 class X
2132                 {
2133                         public static int Value;
2134                 }
2135
2136                 class Y : X
2137                 {
2138                 }
2139
2140                 class Z
2141                 {
2142                         public Z (IComparable value)
2143                         {
2144                         }
2145                 }
2146         
2147                 public static void Run ()
2148                 {
2149                 }
2150
2151                 class TakesInt
2152                 {
2153                         private int i;
2154
2155                         public TakesInt (int x)
2156                         {
2157                                 i = x;
2158                         }
2159
2160                         public int Integer {
2161                                 get { return i; }
2162                         }
2163                 }
2164
2165                 class TakesObject
2166                 {
2167                         public TakesObject (object x) {}
2168                 }
2169
2170                 [Test] // bug #75241
2171                 public void GetConstructorNullInTypes ()
2172                 {
2173                         // This ends up calling type.GetConstructor ()
2174                         Activator.CreateInstance (typeof (TakesInt), new object [] { null });
2175                         Activator.CreateInstance (typeof (TakesObject), new object [] { null });
2176                 }
2177
2178                 [Test]
2179                 public void GetConstructor_TakeInt_Object ()
2180                 {
2181                         Assert.IsNull (typeof (TakesInt).GetConstructor (new Type[1] { typeof (object) }));
2182                 }
2183
2184                 [Test]
2185                 public void GetCustomAttributes_All ()
2186                 {
2187                         object [] attrs = typeof (A).GetCustomAttributes (false);
2188                         Assert.AreEqual (2, attrs.Length, "#A1");
2189                         Assert.IsTrue (HasAttribute (attrs, typeof (FooAttribute)), "#A2");
2190                         Assert.IsTrue (HasAttribute (attrs, typeof (VolatileModifier)), "#A3");
2191
2192                         attrs = typeof (BA).GetCustomAttributes (false);
2193                         Assert.AreEqual (1, attrs.Length, "#B1");
2194                         Assert.AreEqual (typeof (BarAttribute), attrs [0].GetType (), "#B2");
2195
2196                         attrs = typeof (BA).GetCustomAttributes (true);
2197                         Assert.AreEqual (2, attrs.Length, "#C1");
2198                         Assert.IsTrue (HasAttribute (attrs, typeof (BarAttribute)), "#C2");
2199                         Assert.IsTrue (HasAttribute (attrs, typeof (VolatileModifier)), "#C3");
2200
2201                         attrs = typeof (CA).GetCustomAttributes (false);
2202                         Assert.AreEqual (0, attrs.Length, "#D");
2203
2204                         attrs = typeof (CA).GetCustomAttributes (true);
2205                         Assert.AreEqual (1, attrs.Length, "#E1");
2206                         Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#E2");
2207                 }
2208
2209                 static bool HasAttribute (object [] attrs, Type attributeType)
2210                 {
2211                         foreach (object attr in attrs)
2212                                 if (attr.GetType () == attributeType)
2213                                         return true;
2214                         return false;
2215                 }
2216
2217                 [Test]
2218                 public void GetCustomAttributes_Type ()
2219                 {
2220                         object [] attrs = null;
2221
2222                         attrs = typeof (A).GetCustomAttributes (
2223                                 typeof (VolatileModifier), false);
2224                         Assert.AreEqual (1, attrs.Length, "#A1");
2225                         Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#A2");
2226                         attrs = typeof (A).GetCustomAttributes (
2227                                 typeof (VolatileModifier), true);
2228                         Assert.AreEqual (1, attrs.Length, "#A3");
2229                         Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#A4");
2230
2231                         attrs = typeof (A).GetCustomAttributes (
2232                                 typeof (NemerleAttribute), false);
2233                         Assert.AreEqual (1, attrs.Length, "#B1");
2234                         Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#B2");
2235                         attrs = typeof (A).GetCustomAttributes (
2236                                 typeof (NemerleAttribute), true);
2237                         Assert.AreEqual (1, attrs.Length, "#B3");
2238                         Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#B4");
2239
2240                         attrs = typeof (A).GetCustomAttributes (
2241                                 typeof (FooAttribute), false);
2242                         Assert.AreEqual (1, attrs.Length, "#C1");
2243                         Assert.AreEqual (typeof (FooAttribute), attrs [0].GetType (), "#C2");
2244                         attrs = typeof (A).GetCustomAttributes (
2245                                 typeof (FooAttribute), false);
2246                         Assert.AreEqual (1, attrs.Length, "#C3");
2247                         Assert.AreEqual (typeof (FooAttribute), attrs [0].GetType (), "#C4");
2248
2249                         attrs = typeof (BA).GetCustomAttributes (
2250                                 typeof (VolatileModifier), false);
2251                         Assert.AreEqual (0, attrs.Length, "#D1");
2252                         attrs = typeof (BA).GetCustomAttributes (
2253                                 typeof (VolatileModifier), true);
2254                         Assert.AreEqual (1, attrs.Length, "#D2");
2255                         Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#D3");
2256
2257                         attrs = typeof (BA).GetCustomAttributes (
2258                                 typeof (NemerleAttribute), false);
2259                         Assert.AreEqual (0, attrs.Length, "#E1");
2260                         attrs = typeof (BA).GetCustomAttributes (
2261                                 typeof (NemerleAttribute), true);
2262                         Assert.AreEqual (1, attrs.Length, "#E2");
2263                         Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#E3");
2264
2265                         attrs = typeof (BA).GetCustomAttributes (
2266                                 typeof (FooAttribute), false);
2267                         Assert.AreEqual (1, attrs.Length, "#F1");
2268                         Assert.AreEqual (typeof (BarAttribute), attrs [0].GetType (), "#F2");
2269                         attrs = typeof (BA).GetCustomAttributes (
2270                                 typeof (FooAttribute), true);
2271                         Assert.AreEqual (1, attrs.Length, "#F3");
2272                         Assert.AreEqual (typeof (BarAttribute), attrs [0].GetType (), "#F4");
2273
2274                         attrs = typeof (bug82431A1).GetCustomAttributes (
2275                                 typeof (InheritAttribute), false);
2276                         Assert.AreEqual (1, attrs.Length, "#G1");
2277                         Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#G2");
2278                         attrs = typeof (bug82431A1).GetCustomAttributes (
2279                                 typeof (InheritAttribute), true);
2280                         Assert.AreEqual (1, attrs.Length, "#G3");
2281                         Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#G4");
2282
2283                         attrs = typeof (bug82431A1).GetCustomAttributes (
2284                                 typeof (NotInheritAttribute), false);
2285                         Assert.AreEqual (1, attrs.Length, "#H1");
2286                         Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#H2");
2287                         attrs = typeof (bug82431A1).GetCustomAttributes (
2288                                 typeof (InheritAttribute), true);
2289                         Assert.AreEqual (1, attrs.Length, "#H3");
2290                         Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#H4");
2291
2292                         attrs = typeof (bug82431A2).GetCustomAttributes (
2293                                 typeof (InheritAttribute), false);
2294                         Assert.AreEqual (0, attrs.Length, "#I1");
2295                         attrs = typeof (bug82431A2).GetCustomAttributes (
2296                                 typeof (InheritAttribute), true);
2297                         Assert.AreEqual (0, attrs.Length, "#I2");
2298
2299                         attrs = typeof (bug82431A2).GetCustomAttributes (
2300                                 typeof (NotInheritAttribute), false);
2301                         Assert.AreEqual (0, attrs.Length, "#J1");
2302                         attrs = typeof (bug82431A2).GetCustomAttributes (
2303                                 typeof (NotInheritAttribute), true);
2304                         Assert.AreEqual (0, attrs.Length, "#J2");
2305
2306                         attrs = typeof (bug82431A3).GetCustomAttributes (
2307                                 typeof (InheritAttribute), false);
2308                         Assert.AreEqual (2, attrs.Length, "#K1");
2309                         Assert.IsTrue (HasAttribute (attrs, typeof (InheritAttribute)), "#K2");
2310                         Assert.IsTrue (HasAttribute (attrs, typeof (NotInheritAttribute)), "#K3");
2311                         attrs = typeof (bug82431A3).GetCustomAttributes (
2312                                 typeof (InheritAttribute), true);
2313                         Assert.AreEqual (2, attrs.Length, "#K4");
2314                         Assert.IsTrue (HasAttribute (attrs, typeof (InheritAttribute)), "#K5");
2315                         Assert.IsTrue (HasAttribute (attrs, typeof (NotInheritAttribute)), "#K6");
2316
2317                         attrs = typeof (bug82431A3).GetCustomAttributes (
2318                                 typeof (NotInheritAttribute), false);
2319                         Assert.AreEqual (1, attrs.Length, "#L1");
2320                         Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#L2");
2321                         attrs = typeof (bug82431A3).GetCustomAttributes (
2322                                 typeof (NotInheritAttribute), true);
2323                         Assert.AreEqual (1, attrs.Length, "#L3");
2324                         Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#L4");
2325
2326                         attrs = typeof (bug82431B1).GetCustomAttributes (
2327                                 typeof (InheritAttribute), false);
2328                         Assert.AreEqual (1, attrs.Length, "#M1");
2329                         Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#M2");
2330                         attrs = typeof (bug82431B1).GetCustomAttributes (
2331                                 typeof (InheritAttribute), true);
2332                         Assert.AreEqual (1, attrs.Length, "#M3");
2333                         Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#M4");
2334
2335                         attrs = typeof (bug82431B1).GetCustomAttributes (
2336                                 typeof (NotInheritAttribute), false);
2337                         Assert.AreEqual (0, attrs.Length, "#N1");
2338                         attrs = typeof (bug82431B1).GetCustomAttributes (
2339                                 typeof (NotInheritAttribute), true);
2340                         Assert.AreEqual (0, attrs.Length, "#N2");
2341
2342                         attrs = typeof (bug82431B2).GetCustomAttributes (
2343                                 typeof (InheritAttribute), false);
2344                         Assert.AreEqual (0, attrs.Length, "#O1");
2345                         attrs = typeof (bug82431B2).GetCustomAttributes (
2346                                 typeof (InheritAttribute), true);
2347                         Assert.AreEqual (1, attrs.Length, "#O2");
2348                         Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#O3");
2349
2350                         attrs = typeof (bug82431B2).GetCustomAttributes (
2351                                 typeof (NotInheritAttribute), false);
2352                         Assert.AreEqual (0, attrs.Length, "#P1");
2353                         attrs = typeof (bug82431B2).GetCustomAttributes (
2354                                 typeof (NotInheritAttribute), true);
2355                         Assert.AreEqual (0, attrs.Length, "#P2");
2356
2357                         attrs = typeof (bug82431B3).GetCustomAttributes (
2358                                 typeof (InheritAttribute), false);
2359                         Assert.AreEqual (1, attrs.Length, "#Q1");
2360                         Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#Q2");
2361                         attrs = typeof (bug82431B3).GetCustomAttributes (
2362                                 typeof (InheritAttribute), true);
2363                         Assert.AreEqual (2, attrs.Length, "#Q3");
2364                         Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#Q4");
2365                         Assert.AreEqual (typeof (InheritAttribute), attrs [1].GetType (), "#Q5");
2366
2367                         attrs = typeof (bug82431B3).GetCustomAttributes (
2368                                 typeof (NotInheritAttribute), false);
2369                         Assert.AreEqual (1, attrs.Length, "#R1");
2370                         Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#R2");
2371                         attrs = typeof (bug82431B3).GetCustomAttributes (
2372                                 typeof (NotInheritAttribute), true);
2373                         Assert.AreEqual (1, attrs.Length, "#R3");
2374                         Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#R4");
2375
2376                         attrs = typeof (bug82431B4).GetCustomAttributes (
2377                                 typeof (InheritAttribute), false);
2378                         Assert.AreEqual (0, attrs.Length, "#S1");
2379                         attrs = typeof (bug82431B4).GetCustomAttributes (
2380                                 typeof (InheritAttribute), true);
2381                         Assert.AreEqual (1, attrs.Length, "#S2");
2382                         Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#S3");
2383
2384                         attrs = typeof (bug82431B4).GetCustomAttributes (
2385                                 typeof (NotInheritAttribute), false);
2386                         Assert.AreEqual (0, attrs.Length, "#T1");
2387                         attrs = typeof (bug82431B4).GetCustomAttributes (
2388                                 typeof (NotInheritAttribute), true);
2389                         Assert.AreEqual (0, attrs.Length, "#T2");
2390
2391                         attrs = typeof (A).GetCustomAttributes (
2392                                 typeof (string), false);
2393                         Assert.AreEqual (0, attrs.Length, "#U1");
2394                         attrs = typeof (A).GetCustomAttributes (
2395                                 typeof (string), true);
2396                         Assert.AreEqual (0, attrs.Length, "#U2");
2397                 }
2398
2399                 [Test] // bug #76150
2400                 public void IsDefined ()
2401                 {
2402                         Assert.IsTrue (typeof (A).IsDefined (typeof (NemerleAttribute), false), "#A1");
2403                         Assert.IsTrue (typeof (A).IsDefined (typeof (VolatileModifier), false), "#A2");
2404                         Assert.IsTrue (typeof (A).IsDefined (typeof (FooAttribute), false), "#A3");
2405                         Assert.IsFalse (typeof (A).IsDefined (typeof (BarAttribute), false), "#A4");
2406
2407                         Assert.IsFalse (typeof (BA).IsDefined (typeof (NemerleAttribute), false), "#B1");
2408                         Assert.IsFalse (typeof (BA).IsDefined (typeof (VolatileModifier), false), "#B2");
2409                         Assert.IsTrue (typeof (BA).IsDefined (typeof (FooAttribute), false), "#B3");
2410                         Assert.IsTrue (typeof (BA).IsDefined (typeof (BarAttribute), false), "#B4");
2411                         Assert.IsFalse (typeof (BA).IsDefined (typeof (string), false), "#B5");
2412                         Assert.IsFalse (typeof (BA).IsDefined (typeof (int), false), "#B6");
2413                         Assert.IsTrue (typeof (BA).IsDefined (typeof (NemerleAttribute), true), "#B7");
2414                         Assert.IsTrue (typeof (BA).IsDefined (typeof (VolatileModifier), true), "#B8");
2415                         Assert.IsTrue (typeof (BA).IsDefined (typeof (FooAttribute), true), "#B9");
2416                         Assert.IsTrue (typeof (BA).IsDefined (typeof (BarAttribute), true), "#B10");
2417                         Assert.IsFalse (typeof (BA).IsDefined (typeof (string), true), "#B11");
2418                         Assert.IsFalse (typeof (BA).IsDefined (typeof (int), true), "#B12");
2419                 }
2420
2421                 [Test]
2422                 public void IsDefined_AttributeType_Null ()
2423                 {
2424                         try {
2425                                 typeof (BA).IsDefined ((Type) null, false);
2426                                 Assert.Fail ("#1");
2427                         } catch (ArgumentNullException ex) {
2428                                 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2429                                 Assert.IsNull (ex.InnerException, "#3");
2430                                 Assert.IsNotNull (ex.Message, "#4");
2431                                 Assert.IsNotNull (ex.ParamName, "#5");
2432                                 Assert.AreEqual ("attributeType", ex.ParamName, "#6");
2433                         }
2434                 }
2435
2436                 [Test] // bug #82431
2437 #if NET_2_0
2438                 [Category ("NotWorking")]
2439 #endif
2440                 public void IsDefined_Inherited ()
2441                 {
2442                         Assert.IsFalse (typeof (CA).IsDefined (typeof (NemerleAttribute), false), "#C1");
2443                         Assert.IsFalse (typeof (CA).IsDefined (typeof (VolatileModifier), false), "#C2");
2444                         Assert.IsFalse (typeof (CA).IsDefined (typeof (FooAttribute), false), "#C3");
2445                         Assert.IsFalse (typeof (CA).IsDefined (typeof (BarAttribute), false), "#C4");
2446                         Assert.IsTrue (typeof (CA).IsDefined (typeof (NemerleAttribute), true), "#C5");
2447                         Assert.IsTrue (typeof (CA).IsDefined (typeof (VolatileModifier), true), "#C6");
2448                         Assert.IsFalse (typeof (CA).IsDefined (typeof (FooAttribute), true), "#C7");
2449                         Assert.IsFalse (typeof (CA).IsDefined (typeof (BarAttribute), true), "#C8");
2450
2451                         Assert.IsFalse (typeof (BBA).IsDefined (typeof (NemerleAttribute), false), "#D1");
2452                         Assert.IsFalse (typeof (BBA).IsDefined (typeof (VolatileModifier), false), "#D2");
2453                         Assert.IsFalse (typeof (BBA).IsDefined (typeof (FooAttribute), false), "#D3");
2454                         Assert.IsFalse (typeof (BBA).IsDefined (typeof (BarAttribute), false), "#D4");
2455                         Assert.IsTrue (typeof (BBA).IsDefined (typeof (NemerleAttribute), true), "#D5");
2456                         Assert.IsTrue (typeof (BBA).IsDefined (typeof (VolatileModifier), true), "#D6");
2457 #if NET_2_0
2458                         Assert.IsTrue (typeof (BBA).IsDefined (typeof (FooAttribute), true), "#D7");
2459                         Assert.IsTrue (typeof (BBA).IsDefined (typeof (BarAttribute), true), "#D8");
2460 #else
2461                         Assert.IsFalse (typeof (BBA).IsDefined (typeof (FooAttribute), true), "#D7");
2462                         Assert.IsFalse (typeof (BBA).IsDefined (typeof (BarAttribute), true), "#D8");
2463 #endif
2464
2465                         Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (InheritAttribute), false), "#E1");
2466                         Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (NotInheritAttribute), false), "#E2");
2467                         Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (InheritAttribute), true), "#E3");
2468                         Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (NotInheritAttribute), true), "#E4");
2469
2470                         Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (InheritAttribute), false), "#F1");
2471                         Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (NotInheritAttribute), false), "#F2");
2472 #if NET_2_0
2473                         Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (InheritAttribute), true), "#F3");
2474 #else
2475                         Assert.IsTrue (typeof (bug82431A2).IsDefined (typeof (InheritAttribute), true), "#F3");
2476 #endif
2477                         Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (NotInheritAttribute), true), "#F4");
2478
2479                         Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (InheritAttribute), false), "#G1");
2480                         Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (NotInheritAttribute), false), "#G2");
2481                         Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (InheritAttribute), true), "#G3");
2482                         Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (NotInheritAttribute), true), "#G4");
2483
2484                         Assert.IsTrue (typeof (bug82431B1).IsDefined (typeof (InheritAttribute), false), "#H1");
2485                         Assert.IsFalse (typeof (bug82431B1).IsDefined (typeof (NotInheritAttribute), false), "#H2");
2486                         Assert.IsTrue (typeof (bug82431B1).IsDefined (typeof (InheritAttribute), true), "#H3");
2487                         Assert.IsFalse (typeof (bug82431B1).IsDefined (typeof (NotInheritAttribute), true), "#H4");
2488
2489                         Assert.IsFalse (typeof (bug82431B2).IsDefined (typeof (InheritAttribute), false), "#I1");
2490                         Assert.IsFalse (typeof (bug82431B2).IsDefined (typeof (NotInheritAttribute), false), "#I2");
2491                         Assert.IsTrue (typeof (bug82431B2).IsDefined (typeof (InheritAttribute), true), "#I3");
2492                         Assert.IsFalse (typeof (bug82431B2).IsDefined (typeof (NotInheritAttribute), true), "#I4");
2493
2494                         Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (InheritAttribute), false), "#J1");
2495                         Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (NotInheritAttribute), false), "#J2");
2496                         Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (InheritAttribute), true), "#J3");
2497                         Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (NotInheritAttribute), true), "#J4");
2498
2499                         Assert.IsFalse (typeof (bug82431B4).IsDefined (typeof (InheritAttribute), false), "#K2");
2500                         Assert.IsFalse (typeof (bug82431B4).IsDefined (typeof (NotInheritAttribute), false), "#K2");
2501                         Assert.IsTrue (typeof (bug82431B4).IsDefined (typeof (InheritAttribute), true), "#K3");
2502                         Assert.IsFalse (typeof (bug82431B4).IsDefined (typeof (NotInheritAttribute), true), "#K4");
2503                 }
2504
2505                 [Test] // GetType (String)
2506                 public void GetType1_TypeName_Null ()
2507                 {
2508                         try {
2509                                 Type.GetType ((string) null);
2510                                 Assert.Fail ("#1");
2511                         } catch (ArgumentNullException ex) {
2512                                 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2513                                 Assert.IsNull (ex.InnerException, "#3");
2514                                 Assert.IsNotNull (ex.Message, "#4");
2515 #if NET_2_0
2516                                 Assert.AreEqual ("TypeName", ex.ParamName, "#5");
2517 #else
2518                                 Assert.AreEqual ("className", ex.ParamName, "#5");
2519 #endif
2520                         }
2521                 }
2522
2523                 [Test] // GetType (String, Boolean)
2524                 public void GetType2_TypeName_Null ()
2525                 {
2526                         try {
2527                                 Type.GetType ((string) null, false);
2528                                 Assert.Fail ("#1");
2529                         } catch (ArgumentNullException ex) {
2530                                 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2531                                 Assert.IsNull (ex.InnerException, "#3");
2532                                 Assert.IsNotNull (ex.Message, "#4");
2533 #if NET_2_0
2534                                 Assert.AreEqual ("TypeName", ex.ParamName, "#5");
2535 #else
2536                                 Assert.AreEqual ("className", ex.ParamName, "#5");
2537 #endif
2538                         }
2539                 }
2540
2541                 [Test] // GetType (String, Boolean, Boolean)
2542                 public void GetType3_TypeName_Null ()
2543                 {
2544                         try {
2545                                 Type.GetType ((string) null, false, false);
2546                                 Assert.Fail ("#1");
2547                         } catch (ArgumentNullException ex) {
2548                                 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2549                                 Assert.IsNull (ex.InnerException, "#3");
2550                                 Assert.IsNotNull (ex.Message, "#4");
2551 #if NET_2_0
2552                                 Assert.AreEqual ("TypeName", ex.ParamName, "#5");
2553 #else
2554                                 Assert.AreEqual ("className", ex.ParamName, "#5");
2555 #endif
2556                         }
2557                 }
2558
2559                 [Test]
2560                 public void GetTypeArray_Args_Null ()
2561                 {
2562                         try {
2563                                 Type.GetTypeArray ((object []) null);
2564                                 Assert.Fail ("#1");
2565                         } catch (ArgumentNullException ex) {
2566                                 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2567                                 Assert.IsNull (ex.InnerException, "#3");
2568                                 Assert.IsNotNull (ex.Message, "#4");
2569                                 Assert.AreEqual ("args", ex.ParamName, "#5");
2570                         }
2571                 }
2572
2573                 [Test]
2574                 public void GetTypeCode ()
2575                 {
2576                         Assert.AreEqual (TypeCode.Boolean, Type.GetTypeCode (typeof (bool)), "#1");
2577                         Assert.AreEqual (TypeCode.Byte, Type.GetTypeCode (typeof (byte)), "#2");
2578                         Assert.AreEqual (TypeCode.Char, Type.GetTypeCode (typeof (char)), "#3");
2579                         Assert.AreEqual (TypeCode.DateTime, Type.GetTypeCode (typeof (DateTime)), "#4");
2580                         Assert.AreEqual (TypeCode.DBNull, Type.GetTypeCode (typeof (DBNull)), "#5");
2581                         Assert.AreEqual (TypeCode.Decimal, Type.GetTypeCode (typeof (decimal)), "#6");
2582                         Assert.AreEqual (TypeCode.Double, Type.GetTypeCode (typeof (double)), "#7");
2583                         Assert.AreEqual (TypeCode.Empty, Type.GetTypeCode (null), "#8");
2584                         Assert.AreEqual (TypeCode.Int16, Type.GetTypeCode (typeof (short)), "#9");
2585                         Assert.AreEqual (TypeCode.Int32, Type.GetTypeCode (typeof (int)), "#10");
2586                         Assert.AreEqual (TypeCode.Int64, Type.GetTypeCode (typeof (long)), "#11");
2587                         Assert.AreEqual (TypeCode.Object, Type.GetTypeCode (typeof (TakesInt)), "#12");
2588                         Assert.AreEqual (TypeCode.SByte, Type.GetTypeCode (typeof (sbyte)), "#13");
2589                         Assert.AreEqual (TypeCode.Single, Type.GetTypeCode (typeof (float)), "#14");
2590                         Assert.AreEqual (TypeCode.String, Type.GetTypeCode (typeof (string)), "#15");
2591                         Assert.AreEqual (TypeCode.UInt16, Type.GetTypeCode (typeof (ushort)), "#16");
2592                         Assert.AreEqual (TypeCode.UInt32, Type.GetTypeCode (typeof (uint)), "#17");
2593                         Assert.AreEqual (TypeCode.UInt64, Type.GetTypeCode (typeof (ulong)), "#18");
2594                 }
2595
2596                 [Test]
2597                 public void GetTypeFromHandle_Handle_Zero ()
2598                 {
2599                         RuntimeTypeHandle handle = new RuntimeTypeHandle ();
2600
2601 #if NET_2_0
2602                         Assert.IsNull (Type.GetTypeFromHandle (handle));
2603 #else
2604                         try {
2605                                 Type.GetTypeFromHandle (handle);
2606                                 Assert.Fail ("#1");
2607                         } catch (ArgumentException ex) {
2608                                 // Handle is not initialized
2609                                 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
2610                                 Assert.IsNull (ex.InnerException, "#3");
2611                                 Assert.IsNotNull (ex.Message, "#4");
2612                                 Assert.IsNull (ex.ParamName, "#5");
2613                         }
2614 #endif
2615                 }
2616
2617                 [Test]
2618                 public void GetTypeHandle_O_Null ()
2619                 {
2620                         try {
2621                                 Type.GetTypeHandle (null);
2622                                 Assert.Fail ("#1");
2623                         } catch (ArgumentNullException ex) {
2624                                 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2625                                 Assert.IsNull (ex.InnerException, "#3");
2626                                 Assert.IsNotNull (ex.Message, "#4");
2627 #if NET_2_0
2628                                 Assert.IsNull (ex.ParamName, "#5");
2629 #else
2630                                 Assert.AreEqual ("o", ex.ParamName, "#5");
2631 #endif
2632                         }
2633                 }
2634
2635                 [Test] // GetConstructor (Type [])
2636                 public void GetConstructor1 ()
2637                 {
2638                         Type type;
2639                         ConstructorInfo ctor;
2640
2641                         type = typeof (CtorsA);
2642                         ctor = type.GetConstructor (Type.EmptyTypes);
2643                         Assert.IsNotNull (ctor, "#A1");
2644                         Assert.AreEqual (0, ctor.GetParameters ().Length, "#A2");
2645                         Assert.IsFalse (ctor.IsStatic, "#A3");
2646                         Assert.IsTrue (ctor.IsPublic, "#A4");
2647                         Assert.AreEqual (".ctor", ctor.Name, "#A5");
2648
2649                         type = typeof (CtorsB);
2650                         ctor = type.GetConstructor (Type.EmptyTypes);
2651                         Assert.IsNotNull (ctor, "#B1");
2652                         Assert.AreEqual (0, ctor.GetParameters ().Length, "#B2");
2653                         Assert.IsFalse (ctor.IsStatic, "#B3");
2654                         Assert.IsTrue (ctor.IsPublic, "#B4");
2655                         Assert.AreEqual (".ctor", ctor.Name, "#B5");
2656
2657                         type = typeof (CtorsC);
2658                         ctor = type.GetConstructor (Type.EmptyTypes);
2659                         Assert.IsNull (ctor, "#C");
2660
2661                         type = typeof (CtorsC);
2662                         ctor = type.GetConstructor (new Type [] { typeof (int) });
2663                         Assert.IsNotNull (ctor, "#D1");
2664                         Assert.AreEqual (1, ctor.GetParameters ().Length, "#D2");
2665                         Assert.IsFalse (ctor.IsStatic, "#D3");
2666                         Assert.IsTrue (ctor.IsPublic, "#D4");
2667                         Assert.AreEqual (".ctor", ctor.Name, "#D5");
2668                 }
2669
2670                 [Test] // GetConstructor (Type [])
2671                 public void GetConstructor1_Types_Null ()
2672                 {
2673                         try {
2674                                 typeof (BindingFlags).GetConstructor (null);
2675                                 Assert.Fail ("#1");
2676                         } catch (ArgumentNullException ex) {
2677                                 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2678                                 Assert.IsNull (ex.InnerException, "#3");
2679                                 Assert.IsNotNull (ex.Message, "#4");
2680                                 Assert.IsNotNull (ex.ParamName, "#5");
2681                                 Assert.AreEqual ("types", ex.ParamName, "#6");
2682                         }
2683                 }
2684
2685                 [Test] // GetConstructor (Type [])
2686                 public void GetConstructor1_Types_ItemNull ()
2687                 {
2688                         Type type = typeof (BindingFlags);
2689                         try {
2690                                 type.GetConstructor (new Type[1] { null });
2691                                 Assert.Fail ("#A1");
2692                         } catch (ArgumentNullException ex) {
2693                                 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
2694                                 Assert.IsNull (ex.InnerException, "#A3");
2695                                 Assert.IsNotNull (ex.Message, "#A4");
2696                                 Assert.IsNotNull (ex.ParamName, "#A5");
2697                                 Assert.AreEqual ("types", ex.ParamName, "#A6");
2698                         }
2699
2700                         type = typeof (TakesInt);
2701                         try {
2702                                 type.GetConstructor (new Type [1] { null });
2703                                 Assert.Fail ("#B1");
2704                         } catch (ArgumentNullException ex) {
2705                                 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
2706                                 Assert.IsNull (ex.InnerException, "#B3");
2707                                 Assert.IsNotNull (ex.Message, "#B4");
2708                                 Assert.IsNotNull (ex.ParamName, "#B5");
2709                                 Assert.AreEqual ("types", ex.ParamName, "#B6");
2710                         }
2711                 }
2712
2713                 [Test] // GetConstructor (BindingFlags, Binder, Type [], ParameterModifier [])
2714                 public void GetConstructor2_Types_ItemNull ()
2715                 {
2716                         Type type = typeof (BindingFlags);
2717                         try {
2718                                 type.GetConstructor (BindingFlags.Default, null,
2719                                         new Type[1] { null }, null);
2720                                 Assert.Fail ("#1");
2721                         } catch (ArgumentNullException ex) {
2722                                 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2723                                 Assert.IsNull (ex.InnerException, "#3");
2724                                 Assert.IsNotNull (ex.Message, "#4");
2725                                 Assert.IsNotNull (ex.ParamName, "#5");
2726                                 Assert.AreEqual ("types", ex.ParamName, "#6");
2727                         }
2728                 }
2729
2730                 [Test] // GetConstructor (BindingFlags, Binder, CallingConventions, Type [], ParameterModifier [])
2731                 public void GetConstructor3_Types_ItemNull ()
2732                 {
2733                         Type type = typeof (BindingFlags);
2734                         try {
2735                                 type.GetConstructor (BindingFlags.Default,
2736                                         null, CallingConventions.Any,
2737                                         new Type[1] { null }, null);
2738                                 Assert.Fail ("#1");
2739                         } catch (ArgumentNullException ex) {
2740                                 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2741                                 Assert.IsNull (ex.InnerException, "#3");
2742                                 Assert.IsNotNull (ex.Message, "#4");
2743                                 Assert.IsNotNull (ex.ParamName, "#5");
2744                                 Assert.AreEqual ("types", ex.ParamName, "#6");
2745                         }
2746                 }
2747
2748                 [Test]
2749                 public void GetMethod_Bug77367 ()
2750                 {
2751                         MethodInfo i = typeof (Bug77367).GetMethod ("Run", Type.EmptyTypes);
2752                         Assert.IsNull (i);
2753                 }
2754
2755 #if !TARGET_JVM // Reflection.Emit is not supported for TARGET_JVM
2756                 [Test]
2757                 public void EqualsUnderlyingType ()
2758                 {
2759                         AssemblyBuilderAccess access = AssemblyBuilderAccess.RunAndSave;
2760                         TypeAttributes attribs = TypeAttributes.Public;
2761
2762                         AssemblyName name = new AssemblyName ();
2763                         name.Name = "enumtest";
2764                         AssemblyBuilder assembly = 
2765                                 AppDomain.CurrentDomain.DefineDynamicAssembly (
2766                                         name, access);
2767
2768                         ModuleBuilder module = assembly.DefineDynamicModule 
2769                                 ("m", "enumtest.dll");
2770                         EnumBuilder e = module.DefineEnum ("E", attribs, typeof (int));
2771
2772                         Assert.IsTrue (typeof (int).Equals (e));
2773                 }
2774 #endif // TARGET_JVM
2775
2776                 [Test]
2777                 public void Equals_Type_Null ()
2778                 {
2779                         Assert.IsFalse (typeof (int).Equals ((Type) null), "#1");
2780                         Assert.IsFalse (typeof (int).Equals ((object) null), "#2");
2781                 }
2782
2783                 [Test]
2784                 public void GetElementType_Bug63841 ()
2785                 {
2786                         Assert.IsNull (typeof (TheEnum).GetElementType (), "#1");
2787                 }
2788
2789 #if NET_2_0
2790                 [Test]
2791                 public void FullNameGenerics ()
2792                 {
2793                         Type fooType = typeof (Foo<>);
2794                         FieldInfo [] fields = fooType.GetFields ();
2795
2796                         Assert.AreEqual (1, fields.Length, "#0");
2797
2798                         Assert.IsNotNull (fooType.FullName, "#1");
2799                         Assert.IsNotNull (fooType.AssemblyQualifiedName, "#1a");
2800
2801                         FieldInfo field = fooType.GetField ("Whatever");
2802                         Assert.IsNotNull (field, "#2");
2803                         Assert.AreEqual (field, fields [0], "#2a");
2804                         Assert.IsNull (field.FieldType.FullName, "#3");
2805                         Assert.IsNull (field.FieldType.AssemblyQualifiedName, "#3a");
2806                         Assert.IsNotNull (field.FieldType.ToString (), "#4");
2807
2808                         PropertyInfo prop = fooType.GetProperty ("Test");
2809                         Assert.IsNotNull (prop, "#5");
2810                         Assert.IsNull (prop.PropertyType.FullName, "#6");
2811                         Assert.IsNull (prop.PropertyType.AssemblyQualifiedName, "#6a");
2812                         Assert.IsNotNull (prop.PropertyType.ToString (), "#7");
2813
2814                         MethodInfo method = fooType.GetMethod("Execute");
2815                         Assert.IsNotNull (method, "#8");
2816                         Assert.IsNull (method.ReturnType.FullName, "#9");
2817                         Assert.IsNull (method.ReturnType.AssemblyQualifiedName, "#9a");
2818                         Assert.IsNotNull (method.ReturnType.ToString (), "#10");
2819
2820                         ParameterInfo[] parameters = method.GetParameters();
2821                         Assert.AreEqual (1, parameters.Length, "#11");
2822                         Assert.IsNull (parameters[0].ParameterType.FullName, "#12");
2823                         Assert.IsNull (parameters[0].ParameterType.AssemblyQualifiedName, "#12a");
2824                         Assert.IsNotNull (parameters[0].ParameterType.ToString (), "#13");
2825                 }
2826
2827                 [Test]
2828                 public void TypeParameterIsNotGeneric ()
2829                 {
2830                         Type fooType = typeof (Foo<>);
2831                         Type type_param = fooType.GetGenericArguments () [0];
2832                         Assert.IsTrue (type_param.IsGenericParameter);
2833                         Assert.IsFalse (type_param.IsGenericType);
2834                         Assert.IsFalse (type_param.IsGenericTypeDefinition);
2835
2836                         // LAMESPEC: MSDN claims that this should be false, but .NET v2.0.50727 says it's true
2837                         // http://msdn2.microsoft.com/en-us/library/system.type.isgenerictype.aspx
2838                         Assert.IsTrue (type_param.ContainsGenericParameters);
2839                 }
2840
2841                 [Test]
2842                 public void IsAssignable ()
2843                 {
2844                         Type foo_type = typeof (Foo<>);
2845                         Type foo_int_type = typeof (Foo<int>);
2846                         Assert.IsFalse (foo_type.IsAssignableFrom (foo_int_type), "Foo<int> -!-> Foo<>");
2847                         Assert.IsFalse (foo_int_type.IsAssignableFrom (foo_type), "Foo<> -!-> Foo<int>");
2848
2849                         Type ibar_short_type = typeof (IBar<short>);
2850                         Type ibar_int_type = typeof (IBar<int>);
2851                         Type baz_short_type = typeof (Baz<short>);
2852                         Type baz_int_type = typeof (Baz<int>);
2853
2854                         Assert.IsTrue (ibar_int_type.IsAssignableFrom (baz_int_type), "Baz<int> -> IBar<int>");
2855                         Assert.IsTrue (ibar_short_type.IsAssignableFrom (baz_short_type), "Baz<short> -> IBar<short>");
2856
2857                         Assert.IsFalse (ibar_int_type.IsAssignableFrom (baz_short_type), "Baz<short> -!-> IBar<int>");
2858                         Assert.IsFalse (ibar_short_type.IsAssignableFrom (baz_int_type), "Baz<int> -!-> IBar<short>");
2859
2860                         // Nullable tests
2861                         Assert.IsTrue (typeof (Nullable<int>).IsAssignableFrom (typeof (int)));
2862                         Assert.IsFalse (typeof (int).IsAssignableFrom (typeof (Nullable<int>)));
2863                         Assert.IsTrue (typeof (Nullable<FooStruct>).IsAssignableFrom (typeof (FooStruct)));
2864                 }
2865
2866                 [Test]
2867                 public void IsInstanceOf ()
2868                 {
2869                         Assert.IsTrue (typeof (Nullable<int>).IsInstanceOfType (5));
2870                 }
2871
2872                 [Test]
2873                 public void IsInstanceOfArrayOfNullable ()
2874                 {
2875                         Assert.IsTrue (typeof (Nullable<int>[]).IsInstanceOfType (new Nullable<int> [0]));
2876                 }
2877
2878                 [Test]
2879                 public void ByrefType ()
2880                 {
2881                         Type foo_type = typeof (Foo<>);
2882                         Type type_param = foo_type.GetGenericArguments () [0];
2883                         Type byref_type_param = type_param.MakeByRefType ();
2884                         Assert.IsFalse (byref_type_param.IsGenericParameter);
2885                         Assert.IsNull (byref_type_param.DeclaringType);
2886                 }
2887
2888                 [ComVisible (true)]
2889                 public class ComFoo<T> {
2890                 }
2891
2892                 [Test]
2893                 public void GetCustomAttributesGenericInstance ()
2894                 {
2895                         Assert.AreEqual (1, typeof (ComFoo<int>).GetCustomAttributes (typeof (ComVisibleAttribute), true).Length);
2896                 }
2897
2898                 interface ByRef1<T> { void f (ref T t); }
2899                 interface ByRef2 { void f<T> (ref T t); }
2900
2901                 interface ByRef3<T> where T:struct { void f (ref T? t); }
2902                 interface ByRef4 { void f<T> (ref T? t) where T:struct; }
2903
2904                 void CheckGenericByRef (Type t)
2905                 {
2906                         string name = t.Name;
2907                         t = t.GetMethod ("f").GetParameters () [0].ParameterType;
2908
2909                         Assert.IsFalse (t.IsGenericType, name);
2910                         Assert.IsFalse (t.IsGenericTypeDefinition, name);
2911                         Assert.IsFalse (t.IsGenericParameter, name);
2912                 }
2913
2914                 [Test]
2915                 public void GenericByRef ()
2916                 {
2917                         CheckGenericByRef (typeof (ByRef1<>));
2918                         CheckGenericByRef (typeof (ByRef2));
2919                         CheckGenericByRef (typeof (ByRef3<>));
2920                         CheckGenericByRef (typeof (ByRef4));
2921                 }
2922
2923                 public class Bug80242<T> {
2924                         public interface IFoo { }
2925                         public class Bar : IFoo { }
2926                         public class Baz : Bar { }
2927                 }
2928
2929                 [Test]
2930                 public void TestNestedTypes ()
2931                 {
2932                         Type t = typeof (Bug80242<object>);
2933                         Assert.IsFalse (t.IsGenericTypeDefinition);
2934                         foreach (Type u in t.GetNestedTypes ()) {
2935                                 Assert.IsTrue (u.IsGenericTypeDefinition, "{0} isn't a generic definition", u);
2936                                 Assert.AreEqual (u, u.GetGenericArguments () [0].DeclaringType);
2937                         }
2938                 }
2939
2940                 [Test] // bug #82211
2941                 public void GetMembers_GenericArgument ()
2942                 {
2943                         Type argType = typeof (ComFoo<>).GetGenericArguments () [0];
2944                         MemberInfo [] members = argType.GetMembers ();
2945                         Assert.IsNotNull (members, "#1");
2946                         Assert.AreEqual (4, members.Length, "#2");
2947                 }
2948
2949                 [Test]
2950                 [ExpectedException (typeof (ArgumentNullException))]
2951                 public void ReflectionOnlyGetTypeNullTypeName ()
2952                 {
2953                         Type.ReflectionOnlyGetType (null, false, false);
2954                 }
2955
2956                 [Test]
2957                 public void ReflectionOnlyGetTypeDoNotThrow ()
2958                 {
2959                         Assert.IsNull (Type.ReflectionOnlyGetType ("a, nonexistent.dll", false, false));
2960                 }
2961
2962                 [Test]
2963                 [ExpectedException (typeof (FileNotFoundException))]
2964                 public void ReflectionOnlyGetTypeThrow ()
2965                 {
2966                         Type.ReflectionOnlyGetType ("a, nonexistent.dll", true, false);
2967                 }
2968
2969                 [Test]
2970                 public void ReflectionOnlyGetType ()
2971                 {
2972                         Type t = Type.ReflectionOnlyGetType (typeof (int).AssemblyQualifiedName.ToString (), true, true);
2973                         Assert.AreEqual ("System.Int32", t.FullName);
2974                 }
2975
2976                 [Test] //bug #331199
2977                 //FIXME: 2.0 SP 1 has a diferent behavior
2978                 public void MakeGenericType_UserDefinedType ()
2979                 {
2980                         Type ut = new UserType (typeof (int));
2981                         Type t = typeof (Foo<>).MakeGenericType (ut);
2982                         Assert.IsTrue (t.IsGenericType, "#A1");
2983                         Assert.AreEqual (1, t.GetGenericArguments ().Length, "#A2");
2984
2985                         Type arg = t.GetGenericArguments () [0];
2986                         Assert.IsNotNull (arg, "#B1");
2987                         Assert.IsFalse (arg.IsGenericType, "#B2");
2988                         Assert.AreEqual (typeof (int), arg, "#B3");
2989                 }
2990
2991                 [Category ("NotWorking")]
2992                 //We dont support instantiating a user type 
2993                 public void MakeGenericType_NestedUserDefinedType ()
2994                 {
2995                         Type ut = new UserType (new UserType (typeof (int)));
2996                         Type t = typeof (Foo<>).MakeGenericType (ut);
2997                         Assert.IsTrue (t.IsGenericType, "#A1");
2998                         Assert.AreEqual (1, t.GetGenericArguments ().Length, "#A2");
2999
3000                         Type arg = t.GetGenericArguments () [0];
3001                         Assert.IsNotNull (arg, "#B1");
3002                         Assert.IsFalse (arg.IsGenericType, "#B2");
3003                         Assert.AreEqual (ut, arg, "#B3");
3004                 }
3005                 
3006                 [Test]
3007                 [Category ("NotWorking")]
3008                 public void TestMakeGenericType_UserDefinedType_DotNet20SP1 () 
3009                 {
3010                         Type ut = new UserType(typeof(int));
3011                         Type t = typeof(Foo<>).MakeGenericType(ut);
3012                         Assert.IsTrue (t.IsGenericType, "#1");
3013
3014                         Assert.AreEqual (ut, t.GetGenericArguments()[0], "#2");
3015                 }
3016                 
3017                 [Test]
3018                 public void MakeGenericType_BadUserType ()
3019                 {
3020                         Type ut = new UserType (null);
3021                         try {
3022                                 Type t = typeof (Foo<>).MakeGenericType (ut);
3023                                 Assert.Fail ("#1");
3024                         } catch (ArgumentException) {
3025                         }
3026                 }
3027         
3028                 [Test]
3029                 public void MakeGenericType_WrongNumOfArguments ()
3030                 {
3031                         try {
3032                                 Type t = typeof (Foo<,>).MakeGenericType (new Type [] { typeof (int) });
3033                                 Assert.Fail ("#1");
3034                         } catch (ArgumentException) {
3035                         }
3036                 }
3037
3038                 [AttributeUsage (AttributeTargets.All)]
3039                 public class DocAttribute : Attribute {
3040                         public DocAttribute (string docs) {}
3041                 }
3042                 
3043                 class GenericClassWithAttributes<[Doc ("T")] T, [Doc ("B")] B> 
3044                         where T : class, new ()
3045                         where B : Attribute
3046                 {
3047                         public T Bar { get{return null;}}
3048
3049                         public void M<[Doc ("X")] X> (X x)
3050                         {
3051                         }
3052                 }
3053         
3054                 [Test] //bug #377596
3055                 public void GetGenericArguments_ArgumentsHaveAttributes ()
3056                 {
3057                         Type type = typeof(GenericClassWithAttributes<,>);
3058                         Type[] tArgs = type.GetGenericArguments ();
3059                         MethodInfo m = type.GetMethod ("M");
3060                         Type[] mArgs = m.GetGenericArguments ();
3061                         Assert.AreEqual(1, tArgs[0].GetCustomAttributes (typeof (DocAttribute), true).Length, "#1");
3062                         Assert.AreEqual(1, tArgs[1].GetCustomAttributes (typeof (DocAttribute), true).Length, "#1");
3063                         Assert.AreEqual(1, mArgs[0].GetCustomAttributes (typeof (DocAttribute), true).Length, "#1");
3064                 }
3065
3066         [Test]
3067         public void EqualsUserType () {
3068                 UserType2 t1 = new UserType2(null);
3069                 UserType2 t2 = new UserType2(t1);
3070                 Assert.IsTrue (t1.Equals(t2));
3071         }
3072
3073         [Test]
3074         public void GetHashCodeUserType () {
3075                 UserType2 t1 = new UserType2(null);
3076                 UserType2 t2 = new UserType2(t1);
3077                 Assert.AreEqual (42, t2.GetHashCode());
3078         }
3079 #endif
3080
3081                 [Test]
3082                 public void TypeGetMemberReturnTypeTest ()
3083                 {
3084                         object obj;
3085                         MemberTypes memtype;
3086                         Type testtype;
3087                         object [] flagsandtypes = new object [] {
3088                                 MemberTypes.All, typeof (MemberInfo []),
3089                                 MemberTypes.Constructor, typeof (ConstructorInfo []),
3090                                 MemberTypes.Custom, typeof (MemberInfo []),
3091                                 MemberTypes.Event, typeof (EventInfo []),
3092                                 MemberTypes.Field, typeof (FieldInfo []),
3093                                 MemberTypes.Method, typeof (MethodInfo []),
3094                                 MemberTypes.NestedType, typeof (Type []),
3095                                 MemberTypes.Property, typeof (PropertyInfo []),
3096                                 MemberTypes.TypeInfo, typeof (Type [])};
3097
3098                         for (int i=0; i < flagsandtypes.Length; i+=2) {
3099                                 memtype = (MemberTypes)flagsandtypes [i];
3100                                 testtype = (Type)flagsandtypes [i+1];
3101                                 obj = GetType ().GetMember ("DummyMember", memtype,
3102                                                 BindingFlags.Public | BindingFlags.Instance);
3103                                 Assert.AreEqual (testtype.GetHashCode (), obj.GetType ().GetHashCode (),
3104                                                 "Expected " + testtype.FullName);
3105                         }
3106
3107                 }
3108  
3109                 [Test]
3110                 public void TypeNameStartsWithSpace ()
3111                 {
3112                         Type t1 = Type.GetType ("System.Type, mscorlib");
3113                         Type t2 = Type.GetType (" System.Type, mscorlib");
3114                         Assert.AreEqual (t1, t2);
3115                 }
3116
3117                 static bool ContainsProperty (PropertyInfo [] props, string name)
3118                 {
3119                         foreach (PropertyInfo p in props)
3120                                 if (p.Name == name)
3121                                         return true;
3122                         return false;
3123                 }
3124
3125                 public class NemerleAttribute : Attribute
3126                 {
3127                 }
3128
3129                 public class VolatileModifier : NemerleAttribute
3130                 {
3131                 }
3132
3133                 [VolatileModifier]
3134                 [FooAttribute]
3135                 class A
3136                 {
3137                 }
3138
3139                 [AttributeUsage (AttributeTargets.Class, Inherited=false)]
3140                 public class FooAttribute : Attribute
3141                 {
3142                 }
3143
3144                 public class BarAttribute : FooAttribute
3145                 {
3146                 }
3147
3148                 [BarAttribute]
3149                 class BA : A
3150                 {
3151                 }
3152
3153                 class BBA : BA
3154                 {
3155                 }
3156
3157                 class CA : A
3158                 {
3159                 }
3160
3161                 [AttributeUsage (AttributeTargets.Class, Inherited=true)]
3162                 public class InheritAttribute : Attribute
3163                 {
3164                 }
3165
3166                 [AttributeUsage (AttributeTargets.Class, Inherited=false)]
3167                 public class NotInheritAttribute : InheritAttribute
3168                 {
3169                 }
3170
3171                 [NotInheritAttribute]
3172                 public class bug82431A1
3173                 {
3174                 }
3175
3176                 public class bug82431A2 : bug82431A1
3177                 {
3178                 }
3179
3180                 [NotInheritAttribute]
3181                 [InheritAttribute]
3182                 public class bug82431A3 : bug82431A1
3183                 {
3184                 }
3185
3186                 [InheritAttribute]
3187                 public class bug82431B1
3188                 {
3189                 }
3190
3191                 public class bug82431B2 : bug82431B1
3192                 {
3193                 }
3194
3195                 [NotInheritAttribute]
3196                 public class bug82431B3 : bug82431B2
3197                 {
3198                 }
3199
3200                 public class bug82431B4 : bug82431B3
3201                 {
3202                 }
3203
3204                 struct FooStruct
3205                 {
3206                 }
3207
3208                 public class Bug77367
3209                 {
3210                         public void Run (bool b)
3211                         {
3212                         }
3213                 }
3214
3215                 public class Blue
3216                 {
3217                         private string PrivInstBlue
3218                         {
3219                                 get { return null; }
3220                         }
3221
3222                         protected string ProtInstBlue
3223                         {
3224                                 get { return null; }
3225                         }
3226
3227                         protected internal string ProIntInstBlue
3228                         {
3229                                 get { return null; }
3230                         }
3231
3232                         public long PubInstBlue
3233                         {
3234                                 get
3235                                 {
3236                                         if (PrivInstBlue == null)
3237                                                 return 0;
3238                                         return long.MaxValue;
3239                                 }
3240                         }
3241
3242                         internal int IntInstBlue
3243                         {
3244                                 get { return 0; }
3245                         }
3246
3247                         private static string PrivStatBlue
3248                         {
3249                                 get { return null; }
3250                         }
3251
3252                         protected static string ProtStatBlue
3253                         {
3254                                 get { return null; }
3255                         }
3256
3257                         protected static internal string ProIntStatBlue
3258                         {
3259                                 get { return null; }
3260                         }
3261
3262                         public static long PubStatBlue
3263                         {
3264                                 get
3265                                 {
3266                                         if (PrivStatBlue == null)
3267                                                 return 0;
3268                                         return long.MaxValue;
3269                                 }
3270                         }
3271
3272                         internal static int IntStatBlue
3273                         {
3274                                 get { return 0; }
3275                         }
3276                 }
3277
3278                 public class Foo : Blue
3279                 {
3280                         private string PrivInstBase
3281                         {
3282                                 get { return null; }
3283                         }
3284
3285                         protected string ProtInstBase
3286                         {
3287                                 get { return null; }
3288                         }
3289
3290                         protected internal string ProIntInstBase
3291                         {
3292                                 get { return null; }
3293                         }
3294
3295                         public long PubInstBase
3296                         {
3297                                 get
3298                                 {
3299                                         if (PrivInstBase == null)
3300                                                 return 0;
3301                                         return long.MaxValue;
3302                                 }
3303                         }
3304
3305                         internal int IntInstBase
3306                         {
3307                                 get { return 0; }
3308                         }
3309
3310                         private static string PrivStatBase
3311                         {
3312                                 get { return null; }
3313                         }
3314
3315                         protected static string ProtStatBase
3316                         {
3317                                 get { return null; }
3318                         }
3319
3320                         protected static internal string ProIntStatBase
3321                         {
3322                                 get { return null; }
3323                         }
3324
3325                         public static long PubStatBase
3326                         {
3327                                 get
3328                                 {
3329                                         if (PrivStatBase == null)
3330                                                 return 0;
3331                                         return long.MaxValue;
3332                                 }
3333                         }
3334
3335                         internal static int IntStatBase
3336                         {
3337                                 get { return 0; }
3338                         }
3339                 }
3340
3341                 public class Bar : Foo
3342                 {
3343                         private string PrivInst
3344                         {
3345                                 get { return null; }
3346                         }
3347
3348                         protected string ProtInst
3349                         {
3350                                 get { return null; }
3351                         }
3352
3353                         protected internal string ProIntInst
3354                         {
3355                                 get { return null; }
3356                         }
3357
3358                         public long PubInst
3359                         {
3360                                 get
3361                                 {
3362                                         if (PrivInst == null)
3363                                                 return 0;
3364                                         return long.MaxValue;
3365                                 }
3366                         }
3367
3368                         internal int IntInst
3369                         {
3370                                 get { return 0; }
3371                         }
3372
3373                         private static string PrivStat
3374                         {
3375                                 get { return null; }
3376                         }
3377
3378                         protected static string ProtStat
3379                         {
3380                                 get { return null; }
3381                         }
3382
3383                         protected static internal string ProIntStat
3384                         {
3385                                 get { return null; }
3386                         }
3387
3388                         public static long PubStat
3389                         {
3390                                 get
3391                                 {
3392                                         if (PrivStat == null)
3393                                                 return 0;
3394                                         return long.MaxValue;
3395                                 }
3396                         }
3397
3398                         internal static int IntStat
3399                         {
3400                                 get { return 0; }
3401                         }
3402                 }
3403
3404                 class CtorsA
3405                 {
3406                         static CtorsA ()
3407                         {
3408                         }
3409                 }
3410
3411                 class CtorsB
3412                 {
3413                         public CtorsB ()
3414                         {
3415                         }
3416                 }
3417
3418                 class CtorsC
3419                 {
3420                         static CtorsC ()
3421                         {
3422                         }
3423
3424                         public CtorsC (int x)
3425                         {
3426                         }
3427                 }
3428         }
3429
3430 #if NET_2_0
3431         class UserType : Type
3432         {
3433                 protected Type type;
3434         
3435                 public UserType(Type type) {
3436                         this.type = type;
3437                 }
3438         
3439                 public override Type UnderlyingSystemType { get { return this.type; } }
3440         
3441                 public override Assembly Assembly { get { return this.type.Assembly; } }
3442         
3443                 public override string AssemblyQualifiedName { get { return null; } }
3444         
3445                 public override Type BaseType { get { return null; } }
3446         
3447                 public override Module Module { get { return this.type.Module; } }
3448         
3449                 public override string Namespace { get { return null; } }
3450         
3451                 public override bool IsGenericParameter { get { return true; } }
3452          
3453                 public override RuntimeTypeHandle TypeHandle { get { throw new NotSupportedException(); } }
3454         
3455                 public override bool ContainsGenericParameters { get { return true; } }
3456         
3457                 public override string FullName { get { return this.type.Name; } }
3458         
3459                 public override Guid GUID { get { throw new NotSupportedException(); } }
3460         
3461         
3462                 protected override bool IsArrayImpl() {
3463                         return false;
3464                 }
3465         
3466                 protected override bool IsByRefImpl()
3467                 {
3468                         return false;
3469                 }
3470         
3471                 protected override bool IsCOMObjectImpl()
3472                 {
3473                         return false;
3474                 }
3475         
3476                 protected override bool IsPointerImpl()
3477                 {
3478                         return false;
3479                 }
3480         
3481                 protected override bool IsPrimitiveImpl()
3482                 {
3483                         return false;
3484                 }
3485         
3486         
3487                 protected override TypeAttributes GetAttributeFlagsImpl()
3488                 {
3489                         return 0;
3490                 }
3491         
3492                 protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder,
3493                                                                            CallingConventions callConvention, Type[] types,
3494                                                                            ParameterModifier[] modifiers)
3495                 {
3496                         return null;
3497                 }
3498         
3499                 public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr)
3500                 {
3501                         return null;
3502                 }
3503         
3504                 public override Type GetElementType()
3505                 {
3506                         return null;
3507                 }
3508         
3509                 public override EventInfo GetEvent(string name, BindingFlags bindingAttr)
3510                 {
3511                         return null;
3512                 }
3513         
3514         
3515                 public override FieldInfo GetField(string name, BindingFlags bindingAttr)
3516                 {
3517                         return null;
3518                 }
3519         
3520         
3521                 public override Type GetInterface(string name, bool ignoreCase)
3522                 {
3523                         return null;
3524                 }
3525         
3526                 public override Type[] GetInterfaces()
3527                 {
3528                         return null;
3529                 }
3530         
3531                 public override MemberInfo[] GetMembers(BindingFlags bindingAttr)
3532                 {
3533                         return null;
3534                 }
3535         
3536                 public override object[] GetCustomAttributes(Type attributeType, bool inherit)
3537                 {
3538                         return null;
3539                 }
3540         
3541                 public override object[] GetCustomAttributes(bool inherit)
3542                 {
3543                         return null;
3544                 }
3545         
3546                 public override bool IsDefined(Type attributeType, bool inherit)
3547                 {
3548                         return false;
3549                 }
3550         
3551                 public override string Name { get { return this.type.Name; } }
3552         
3553                 public override EventInfo[] GetEvents(BindingFlags bindingAttr)
3554                 {
3555                         throw new NotImplementedException();
3556                 }
3557         
3558                 public override FieldInfo[] GetFields(BindingFlags bindingAttr)
3559                 {
3560                         throw new NotImplementedException();
3561                 }
3562         
3563                 protected override MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder,
3564                                                                  CallingConventions callConvention, Type[] types,
3565                                                                  ParameterModifier[] modifiers)
3566                 {
3567                         return null;
3568                 }
3569         
3570                 public override MethodInfo[] GetMethods(BindingFlags bindingAttr)
3571                 {
3572                         return null;
3573                 }
3574         
3575                 public override Type GetNestedType(string name, BindingFlags bindingAttr)
3576                 {
3577                         return null;
3578                 }
3579         
3580                 public override Type[] GetNestedTypes(BindingFlags bindingAttr)
3581                 {
3582                         return null;
3583                 }
3584         
3585                 public override PropertyInfo[] GetProperties(BindingFlags bindingAttr)
3586                 {
3587                         return null;
3588                 }
3589         
3590                 protected override PropertyInfo GetPropertyImpl(string name, BindingFlags bindingAttr, Binder binder,
3591                                                                  Type returnType, Type[] types, ParameterModifier[] modifiers)
3592                 {
3593                         return null;
3594                 }
3595         
3596                 protected override bool HasElementTypeImpl()
3597                 {
3598                         return false;
3599                 }
3600         
3601                 public override object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, object target,
3602                                                          object[] args, ParameterModifier[] modifiers, CultureInfo culture,
3603                                                          string[] namedParameters)
3604                 {
3605                         throw new NotSupportedException();
3606                 }
3607         }
3608
3609     class UserType2 : UserType {
3610                 public UserType2 (Type type) : base (type) {
3611                 }
3612
3613                 public override Type UnderlyingSystemType { get { return this.type ?? this; } }
3614
3615                 public override int GetHashCode()
3616                 {
3617                         if (type == null)
3618                                 return 42;
3619                         return type.GetHashCode();
3620                 }
3621         }
3622 #endif
3623 }