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