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