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