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