1 // TypeTest.cs - NUnit Test Cases for the System.Type class
4 // Zoltan Varga (vargaz@freemail.hu)
6 // Aleksey Kliger (aleksey@xamarin.com)
8 // (C) 2003 Ximian, Inc. http://www.ximian.com
9 // Copyright (C) 2015 Xamarin, Inc. (http://www.xamarin.com)
12 using NUnit.Framework;
14 using System.Threading;
15 using System.Collections;
16 using System.Collections.Generic;
18 using System.Reflection;
19 #if !MONOTOUCH && !MOBILE_STATIC
20 using System.Reflection.Emit;
22 using System.Runtime.InteropServices;
24 using System.Globalization;
26 class NoNamespaceClass {
29 namespace MonoTests.System
31 class Super : ICloneable
33 public virtual object Clone ()
48 interface IFace2 : IFace1
53 interface IFace3 : IFace2
68 public abstract int this [byte i] {
72 public abstract int this [int i] {
76 public abstract void TestVoid ();
77 public abstract void TestInt (int i);
80 class DeriveVTable : Base
82 public override int this [byte i] {
86 public override int this [int i] {
90 public override void TestVoid ()
95 public override void TestInt (int i)
101 class NewVTable : DeriveVTable
103 public new int this [byte i] {
107 public new int this [int i] {
111 public new void TestVoid ()
116 public new void TestInt (int i)
121 public void Overload ()
125 public void Overload (int i)
129 public NewVTable (out int i)
134 public void byref_method (out int i)
142 public virtual int Foo {
147 public event EventHandler E;
154 class Derived1 : Base1
156 public override int Foo {
161 class Derived2 : Base1
168 public new event Action E;
169 public new void Dummy ()
180 get { throw new NotImplementedException (); }
183 public T Execute (T a)
188 public class Nested<K> {}
195 public interface IBar<T>
199 public class Baz<T> : IBar<T>
205 public static void Bang<S> () {}
208 public class Bug348522
210 public void Test (int __argument)
215 public class GenericIndexers<T, U>
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; } }
225 public class FirstMethodBinder : Binder
227 public override MethodBase BindToMethod (BindingFlags bindingAttr, MethodBase [] match, ref object [] args,
228 ParameterModifier [] modifiers, CultureInfo culture, string [] names,
235 public override object ChangeType (object value, Type type1, CultureInfo culture)
240 // The rest is just to please the compiler
241 public override FieldInfo BindToField (BindingFlags a, FieldInfo[] b, object c, CultureInfo d)
246 public override void ReorderArgumentArray(ref object[] a, object b)
250 public override MethodBase SelectMethod(BindingFlags a, MethodBase[] b, Type[] c, ParameterModifier[] d)
255 public override PropertyInfo SelectProperty(BindingFlags a, PropertyInfo[] b, Type c, Type[] d, ParameterModifier[] e)
262 public class TypeTest
264 #if !MONOTOUCH && !MOBILE_STATIC
265 private ModuleBuilder module;
267 const string ASSEMBLY_NAME = "MonoTests.System.TypeTest";
268 static int typeIndexer = 0;
273 AssemblyName assemblyName = new AssemblyName ();
274 assemblyName.Name = ASSEMBLY_NAME;
275 #if !MONOTOUCH && !MOBILE_STATIC
276 var assembly = AppDomain.CurrentDomain.DefineDynamicAssembly (
277 assemblyName, AssemblyBuilderAccess.RunAndSave, Path.GetTempPath ());
278 module = assembly.DefineDynamicModule ("module1");
282 private string genTypeName ()
284 return "t" + (typeIndexer++);
287 private void ByrefMethod (ref int i, ref Derived1 j, ref Base1 k)
291 public interface IFace {
294 private void GenericMethod<Q, T1> (Q q, T1 t) where T1 : IFace
304 public void TestIsAssignableFrom ()
306 // Simple tests for inheritance
307 Assert.AreEqual (typeof (Super).IsAssignableFrom (typeof (Duper)) , true, "#01");
308 Assert.AreEqual (typeof (Duper).IsAssignableFrom (typeof (Duper)), true, "#02");
309 Assert.AreEqual (typeof (Object).IsAssignableFrom (typeof (Duper)), true, "#03");
310 Assert.AreEqual (typeof (ICloneable).IsAssignableFrom (typeof (Duper)), true, "#04");
313 Assert.AreEqual (typeof (Super[]).IsAssignableFrom (typeof (Duper[])), true, "#05");
314 Assert.AreEqual (typeof (Duper[]).IsAssignableFrom (typeof (Super[])), false, "#06");
315 Assert.AreEqual (typeof (Object[]).IsAssignableFrom (typeof (Duper[])), true, "#07");
316 Assert.AreEqual (typeof (ICloneable[]).IsAssignableFrom (typeof (Duper[])), true, "#08");
318 // Tests for multiple dimensional arrays
319 Assert.AreEqual (typeof (Super[][]).IsAssignableFrom (typeof (Duper[][])), true, "#09");
320 Assert.AreEqual (typeof (Duper[][]).IsAssignableFrom (typeof (Super[][])), false, "#10");
321 Assert.AreEqual (typeof (Object[][]).IsAssignableFrom (typeof (Duper[][])), true, "#11");
322 Assert.AreEqual (typeof (ICloneable[][]).IsAssignableFrom (typeof (Duper[][])), true, "#12");
324 // Tests for vectors<->one dimensional arrays */
325 Array arr1 = Array.CreateInstance (typeof (int), new int[] {1}, new int[] {0});
326 Array arr2 = Array.CreateInstance (typeof (int), new int[] {1}, new int[] {10});
328 Assert.AreEqual (typeof (int[]).IsAssignableFrom (arr1.GetType ()), true, "#13");
329 Assert.AreEqual (typeof (int[]).IsAssignableFrom (arr2.GetType ()), false, "#14");
331 // Test that arrays of enums can be cast to their base types
332 Assert.AreEqual (typeof (int[]).IsAssignableFrom (typeof (TypeCode[])), true, "#15");
334 // Test that arrays of valuetypes can't be cast to arrays of
336 Assert.AreEqual (typeof (object[]).IsAssignableFrom (typeof (TypeCode[])), false, "#16");
337 Assert.AreEqual (typeof (ValueType[]).IsAssignableFrom (typeof (TypeCode[])), false, "#17");
338 Assert.AreEqual (typeof (Enum[]).IsAssignableFrom (typeof (TypeCode[])), false, "#18");
340 // Test that arrays of enums can't be cast to arrays of references
341 Assert.AreEqual (typeof (object[]).IsAssignableFrom (typeof (TheEnum[])), false, "#19");
342 Assert.AreEqual (typeof (ValueType[]).IsAssignableFrom (typeof (TheEnum[])), false, "#20");
343 Assert.AreEqual (typeof (Enum[]).IsAssignableFrom (typeof (TheEnum[])), false, "#21");
345 // Check that ValueType and Enum are recognized as reference types
346 Assert.AreEqual (typeof (object).IsAssignableFrom (typeof (ValueType)), true, "#22");
347 Assert.AreEqual (typeof (object).IsAssignableFrom (typeof (Enum)), true, "#23");
348 Assert.AreEqual (typeof (ValueType).IsAssignableFrom (typeof (Enum)), true, "#24");
350 Assert.AreEqual (typeof (object[]).IsAssignableFrom (typeof (ValueType[])), true, "#25");
351 Assert.AreEqual (typeof (ValueType[]).IsAssignableFrom (typeof (ValueType[])), true, "#26");
352 Assert.AreEqual (typeof (Enum[]).IsAssignableFrom (typeof (ValueType[])), false, "#27");
354 Assert.AreEqual (typeof (object[]).IsAssignableFrom (typeof (Enum[])), true, "#28");
355 Assert.AreEqual (typeof (ValueType[]).IsAssignableFrom (typeof (Enum[])), true, "#29");
356 Assert.AreEqual (typeof (Enum[]).IsAssignableFrom (typeof (Enum[])), true, "#30");
358 // Tests for byref types
359 MethodInfo mi = typeof (TypeTest).GetMethod ("ByrefMethod", BindingFlags.Instance|BindingFlags.NonPublic);
360 Assert.IsTrue (mi.GetParameters ()[2].ParameterType.IsAssignableFrom (mi.GetParameters ()[1].ParameterType));
361 Assert.IsTrue (mi.GetParameters ()[1].ParameterType.IsAssignableFrom (mi.GetParameters ()[1].ParameterType));
363 // Tests for type parameters
364 mi = typeof (TypeTest).GetMethod ("GenericMethod", BindingFlags.Instance|BindingFlags.NonPublic);
365 Assert.IsTrue (mi.GetParameters ()[0].ParameterType.IsAssignableFrom (mi.GetParameters ()[0].ParameterType));
366 Assert.IsFalse (mi.GetParameters ()[0].ParameterType.IsAssignableFrom (typeof (int)));
368 // Tests for parameters with generic constraints
369 mi = typeof (TypeTest).GetMethod ("GenericMethod", BindingFlags.Instance|BindingFlags.NonPublic);
370 Assert.IsTrue (typeof (IFace).IsAssignableFrom (mi.GetParameters ()[1].ParameterType));
374 [ExpectedException (typeof (ArgumentException))]
375 public void GetInterfaceMapOnInterface ()
377 typeof (IList).GetInterfaceMap (typeof (ICollection));
381 public void TestIsSubclassOf ()
383 Assert.IsTrue (typeof (ICloneable).IsSubclassOf (typeof (object)), "#01");
385 // Tests for byref types
386 Type paramType = typeof (TypeTest).GetMethod ("ByrefMethod", BindingFlags.Instance|BindingFlags.NonPublic).GetParameters () [0].ParameterType;
387 Assert.IsFalse (paramType.IsSubclassOf (typeof(ValueType)), "#02");
388 Assert.IsNull (paramType.BaseType, "#02-b");
389 Assert.IsTrue (paramType.IsSubclassOf (typeof (Object)), "#03");
390 Assert.IsFalse (paramType.IsSubclassOf (paramType), "#04");
394 public void TestGetMethodImpl ()
396 // Test binding of new slot methods (using no types)
397 Assert.AreEqual (typeof (Base), typeof (Base).GetMethod("TestVoid").DeclaringType, "#01");
398 Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetMethod ("TestVoid").DeclaringType, "#02");
400 // Test binding of new slot methods (using types)
401 Assert.AreEqual (typeof (Base), typeof (Base).GetMethod ("TestInt", new Type[] { typeof (int) }).DeclaringType, "#03");
402 Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetMethod ("TestInt", new Type[] { typeof (int) }).DeclaringType, "#04");
404 // Test overload resolution
405 Assert.AreEqual (0, typeof (NewVTable).GetMethod ("Overload", new Type[0]).GetParameters ().Length, "#05");
407 // Test byref parameters
408 Assert.AreEqual (null, typeof (NewVTable).GetMethod ("byref_method", new Type[] { typeof (int) }), "#06");
409 Type byrefInt = typeof (NewVTable).GetMethod ("byref_method").GetParameters ()[0].ParameterType;
410 Assert.IsNotNull (typeof (NewVTable).GetMethod ("byref_method", new Type[] { byrefInt }), "#07");
414 public void TestGetPropertyImpl ()
416 // Test getting property that is exact
417 Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetProperty ("Item", new Type[1] { typeof (Int32) }).DeclaringType, "#01");
419 // Test getting property that is not exact
420 Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetProperty ("Item", new Type[1] { typeof (Int16) }).DeclaringType, "#02");
422 // Test overriding of properties when only the set accessor is overriden
423 Assert.AreEqual (1, typeof (Derived1).GetProperties ().Length, "#03");
427 public void GetEvents ()
430 Assert.AreEqual (1, typeof (Derived2).GetEvents ().Length);
431 Assert.AreEqual (typeof (Derived2), typeof (Derived2).GetEvents ()[0].DeclaringType);
435 public void GetProperties ()
437 // Test hide-by-name-and-signature
438 Assert.AreEqual (1, typeof (Derived2).GetProperties ().Length, "#1");
439 Assert.AreEqual (typeof (Derived2), typeof (Derived2).GetProperties ()[0].DeclaringType, "#2");
441 // For generics, hide-by-name-and-signature works on the unexpanded types. The
442 // GenericIndexers<T,U> class has two indexers that take different arguments.
443 // GetProperties on all instances of this generic type should still have 2 properties,
444 // even if T and U are instantiated with the same types.
446 var ps = typeof (GenericIndexers<int,int>).GetProperties ();
447 Assert.AreEqual (2, ps.Length, "#3");
448 for (int i = 0; i < ps.Length; i++) {
451 var getterResultType = p.GetGetMethod ().ReturnType;
453 var msg = String.Format ("#4-{0}", i);
454 Assert.AreEqual (typeof (int), getterResultType, msg);
459 class GetProperties_Overrides_Input
461 public class TestClass : BaseClass<object>
463 public override object TestProperty { get; set; }
466 public abstract class BaseClass<T>
468 public virtual T TestProperty { get; set; }
471 public class TestClass_Indexer : BaseClass_Indexer<object>
473 public override object this[int arg] { set { } }
476 public abstract class BaseClass_Indexer<T>
478 public virtual T this[int arg] { set { } }
481 public interface IB : IA<object>
483 new object TestProperty { get; set; }
486 public interface IA<T>
488 T TestProperty { get; set; }
493 public void GetProperties_Overrides ()
495 Assert.AreEqual (1, typeof (GetProperties_Overrides_Input.IB).GetProperties().Length);
497 var prop = typeof (GetProperties_Overrides_Input.TestClass).GetProperty ("TestProperty");
498 Assert.AreEqual (typeof (GetProperties_Overrides_Input.TestClass), prop.DeclaringType);
500 Assert.AreEqual (1, typeof (GetProperties_Overrides_Input.TestClass).GetProperties().Length);
501 Assert.AreEqual (1, typeof (GetProperties_Overrides_Input.TestClass_Indexer).GetProperties().Length);
504 [Test] // GetProperties (BindingFlags)
505 public void GetProperties_Flags ()
507 PropertyInfo [] props;
508 Type type = typeof (Bar);
511 flags = BindingFlags.Instance | BindingFlags.NonPublic;
512 props = type.GetProperties (flags);
514 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#A1");
515 Assert.IsTrue (ContainsProperty (props, "ProtInstBase"), "#A2");
516 Assert.IsTrue (ContainsProperty (props, "ProIntInstBase"), "#A3");
517 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#A4");
518 Assert.IsTrue (ContainsProperty (props, "IntInstBase"), "#A5");
519 Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#A6");
520 Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#A7");
521 Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#A8");
522 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#A9");
523 Assert.IsTrue (ContainsProperty (props, "IntInst"), "#A10");
524 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#A11");
525 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#A12");
526 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#A13");
527 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#A14");
528 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#A15");
529 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#A16");
530 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#A17");
531 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#A18");
532 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#A19");
533 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#A20");
534 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#A21");
535 Assert.IsTrue (ContainsProperty (props, "ProtInstBlue"), "#A22");
536 Assert.IsTrue (ContainsProperty (props, "ProIntInstBlue"), "#A23");
537 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#A24");
538 Assert.IsTrue (ContainsProperty (props, "IntInstBlue"), "#A25");
539 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#A26");
540 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#A27");
541 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#A28");
542 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#A29");
543 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#A30");
545 flags = BindingFlags.Instance | BindingFlags.Public;
546 props = type.GetProperties (flags);
548 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#B1");
549 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#B2");
550 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#B3");
551 Assert.IsTrue (ContainsProperty (props, "PubInstBase"), "#B4");
552 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#B5");
553 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#B6");
554 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#B7");
555 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#B8");
556 Assert.IsTrue (ContainsProperty (props, "PubInst"), "#B9");
557 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#B10");
558 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#B11");
559 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#B12");
560 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#B13");
561 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#B14");
562 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#B15");
563 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#B16");
564 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#B17");
565 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#B18");
566 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#B19");
567 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#B20");
568 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#B21");
569 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#B22");
570 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#B23");
571 Assert.IsTrue (ContainsProperty (props, "PubInstBlue"), "#B24");
572 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#B25");
573 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#B26");
574 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#B27");
575 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#B28");
576 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#B29");
577 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#B30");
579 flags = BindingFlags.Static | BindingFlags.Public;
580 props = type.GetProperties (flags);
582 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#C1");
583 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#C2");
584 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#C3");
585 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#C4");
586 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#C5");
587 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#C6");
588 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#C7");
589 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#C8");
590 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#C9");
591 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#C10");
592 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#C11");
593 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#C12");
594 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#C13");
595 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#C14");
596 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#C15");
597 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#C16");
598 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#C17");
599 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#C18");
600 Assert.IsTrue (ContainsProperty (props, "PubStat"), "#C19");
601 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#C20");
602 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#C21");
603 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#C22");
604 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#C23");
605 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#C24");
606 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#C25");
607 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#C26");
608 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#C27");
609 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#C28");
610 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#C29");
611 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#C30");
613 flags = BindingFlags.Static | BindingFlags.NonPublic;
614 props = type.GetProperties (flags);
616 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#D1");
617 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#D2");
618 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#D3");
619 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#D4");
620 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#D5");
621 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#D6");
622 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#D7");
623 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#D8");
624 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#D9");
625 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#D10");
626 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#D11");
627 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#D12");
628 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#D13");
629 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#D14");
630 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#D15");
631 Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#D16");
632 Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#D17");
633 Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#D18");
634 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#D19");
635 Assert.IsTrue (ContainsProperty (props, "IntStat"), "#D20");
636 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#D21");
637 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#D22");
638 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#D23");
639 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#D24");
640 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#D25");
641 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#D26");
642 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#D27");
643 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#D28");
644 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#D29");
645 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#D30");
647 flags = BindingFlags.Instance | BindingFlags.NonPublic |
648 BindingFlags.FlattenHierarchy;
649 props = type.GetProperties (flags);
651 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#E1");
652 Assert.IsTrue (ContainsProperty (props, "ProtInstBase"), "#E2");
653 Assert.IsTrue (ContainsProperty (props, "ProIntInstBase"), "#E3");
654 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#E4");
655 Assert.IsTrue (ContainsProperty (props, "IntInstBase"), "#E5");
656 Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#E6");
657 Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#E7");
658 Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#E8");
659 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#E9");
660 Assert.IsTrue (ContainsProperty (props, "IntInst"), "#E10");
661 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#E11");
662 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#E12");
663 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#E13");
664 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#E14");
665 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#E15");
666 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#E16");
667 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#E17");
668 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#E18");
669 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#E19");
670 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#E20");
671 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#E21");
672 Assert.IsTrue (ContainsProperty (props, "ProtInstBlue"), "#E22");
673 Assert.IsTrue (ContainsProperty (props, "ProIntInstBlue"), "#E23");
674 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#E24");
675 Assert.IsTrue (ContainsProperty (props, "IntInstBlue"), "#E25");
676 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#E26");
677 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#E27");
678 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#E28");
679 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#E29");
680 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#E30");
682 flags = BindingFlags.Instance | BindingFlags.Public |
683 BindingFlags.FlattenHierarchy;
684 props = type.GetProperties (flags);
686 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#F1");
687 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#F2");
688 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#F3");
689 Assert.IsTrue (ContainsProperty (props, "PubInstBase"), "#F4");
690 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#F5");
691 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#F6");
692 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#F7");
693 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#F8");
694 Assert.IsTrue (ContainsProperty (props, "PubInst"), "#F9");
695 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#F10");
696 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#F11");
697 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#F12");
698 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#F13");
699 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#F14");
700 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#F15");
701 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#F16");
702 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#F17");
703 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#F18");
704 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#F19");
705 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#F20");
706 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#F21");
707 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#F22");
708 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#F23");
709 Assert.IsTrue (ContainsProperty (props, "PubInstBlue"), "#F24");
710 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#F25");
711 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#F26");
712 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#F27");
713 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#F28");
714 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#F29");
715 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#F30");
717 flags = BindingFlags.Static | BindingFlags.Public |
718 BindingFlags.FlattenHierarchy;
719 props = type.GetProperties (flags);
721 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#G1");
722 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#G2");
723 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#G3");
724 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#G4");
725 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#G5");
726 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#G6");
727 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#G7");
728 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#G8");
729 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#G9");
730 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#G10");
731 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#G11");
732 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#G12");
733 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#G13");
734 Assert.IsTrue (ContainsProperty (props, "PubStatBase"), "#G14");
735 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#G15");
736 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#G16");
737 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#G17");
738 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#G18");
739 Assert.IsTrue (ContainsProperty (props, "PubStat"), "#G19");
740 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#G20");
741 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#G21");
742 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#G22");
743 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#G23");
744 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#G24");
745 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#G25");
746 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#G26");
747 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#G27");
748 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#G28");
749 Assert.IsTrue (ContainsProperty (props, "PubStatBlue"), "#G29");
750 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#G30");
752 flags = BindingFlags.Static | BindingFlags.NonPublic |
753 BindingFlags.FlattenHierarchy;
754 props = type.GetProperties (flags);
756 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#H1");
757 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#H2");
758 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#H3");
759 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#H4");
760 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#H5");
761 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#H6");
762 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#H7");
763 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#H8");
764 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#H9");
765 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#H10");
766 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#H11");
767 Assert.IsTrue (ContainsProperty (props, "ProtStatBase"), "#H12");
768 Assert.IsTrue (ContainsProperty (props, "ProIntStatBase"), "#H13");
769 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#H14");
770 Assert.IsTrue (ContainsProperty (props, "IntStatBase"), "#H15");
771 Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#H16");
772 Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#H17");
773 Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#H18");
774 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#H19");
775 Assert.IsTrue (ContainsProperty (props, "IntStat"), "#H20");
776 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#H21");
777 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#H22");
778 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#H23");
779 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#H24");
780 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#H25");
781 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#H26");
782 Assert.IsTrue (ContainsProperty (props, "ProtStatBlue"), "#H27");
783 Assert.IsTrue (ContainsProperty (props, "ProIntStatBlue"), "#H28");
784 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#H29");
785 Assert.IsTrue (ContainsProperty (props, "IntStatBlue"), "#H30");
787 flags = BindingFlags.Instance | BindingFlags.NonPublic |
788 BindingFlags.DeclaredOnly;
789 props = type.GetProperties (flags);
791 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#I1");
792 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#I2");
793 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#I3");
794 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#I4");
795 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#I5");
796 Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#I6");
797 Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#I7");
798 Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#I8");
799 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#I9");
800 Assert.IsTrue (ContainsProperty (props, "IntInst"), "#I10");
801 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#I11");
802 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#I12");
803 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#I13");
804 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#I14");
805 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#I15");
806 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#I16");
807 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#I17");
808 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#I18");
809 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#I19");
810 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#I20");
811 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#I21");
812 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#I22");
813 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#I23");
814 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#I24");
815 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#I25");
816 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#I26");
817 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#I27");
818 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#I28");
819 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#I29");
820 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#I30");
822 flags = BindingFlags.Instance | BindingFlags.Public |
823 BindingFlags.DeclaredOnly;
824 props = type.GetProperties (flags);
826 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#J1");
827 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#J2");
828 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#J3");
829 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#J4");
830 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#J5");
831 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#J6");
832 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#J7");
833 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#J8");
834 Assert.IsTrue (ContainsProperty (props, "PubInst"), "#J9");
835 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#J10");
836 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#J11");
837 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#J12");
838 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#J13");
839 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#J14");
840 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#J15");
841 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#J16");
842 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#J17");
843 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#J18");
844 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#J19");
845 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#J20");
846 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#J21");
847 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#J22");
848 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#J23");
849 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#J24");
850 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#J25");
851 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#J26");
852 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#J27");
853 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#J28");
854 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#J29");
855 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#J30");
857 flags = BindingFlags.Static | BindingFlags.Public |
858 BindingFlags.DeclaredOnly;
859 props = type.GetProperties (flags);
861 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#K1");
862 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#K2");
863 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#K3");
864 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#K4");
865 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#K5");
866 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#K6");
867 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#K7");
868 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#K8");
869 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#K9");
870 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#K10");
871 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#K11");
872 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#K12");
873 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#K13");
874 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#K14");
875 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#K15");
876 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#K16");
877 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#K17");
878 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#K18");
879 Assert.IsTrue (ContainsProperty (props, "PubStat"), "#K19");
880 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#K20");
881 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#K21");
882 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#K22");
883 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#K23");
884 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#K24");
885 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#K25");
886 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#K26");
887 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#K27");
888 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#K28");
889 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#K29");
890 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#K30");
892 flags = BindingFlags.Static | BindingFlags.NonPublic |
893 BindingFlags.DeclaredOnly;
894 props = type.GetProperties (flags);
896 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#L1");
897 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#L2");
898 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#L3");
899 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#L4");
900 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#L5");
901 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#L6");
902 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#L7");
903 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#L8");
904 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#L9");
905 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#L10");
906 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#L11");
907 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#L12");
908 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#L13");
909 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#L14");
910 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#L15");
911 Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#L16");
912 Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#L17");
913 Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#L18");
914 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#L19");
915 Assert.IsTrue (ContainsProperty (props, "IntStat"), "#L20");
916 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#L21");
917 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#L22");
918 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#L23");
919 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#L24");
920 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#L25");
921 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#L26");
922 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#L27");
923 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#L28");
924 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#L29");
925 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#L30");
927 flags = BindingFlags.Instance | BindingFlags.NonPublic |
929 props = type.GetProperties (flags);
931 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#M1");
932 Assert.IsTrue (ContainsProperty (props, "ProtInstBase"), "#M2");
933 Assert.IsTrue (ContainsProperty (props, "ProIntInstBase"), "#M3");
934 Assert.IsTrue (ContainsProperty (props, "PubInstBase"), "#M4");
935 Assert.IsTrue (ContainsProperty (props, "IntInstBase"), "#M5");
936 Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#M6");
937 Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#M7");
938 Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#M8");
939 Assert.IsTrue (ContainsProperty (props, "PubInst"), "#M9");
940 Assert.IsTrue (ContainsProperty (props, "IntInst"), "#M10");
941 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#M11");
942 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#M12");
943 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#M13");
944 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#M14");
945 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#M15");
946 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#M16");
947 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#M17");
948 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#M18");
949 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#M19");
950 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#M20");
951 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#M21");
952 Assert.IsTrue (ContainsProperty (props, "ProtInstBlue"), "#M22");
953 Assert.IsTrue (ContainsProperty (props, "ProIntInstBlue"), "#M23");
954 Assert.IsTrue (ContainsProperty (props, "PubInstBlue"), "#M24");
955 Assert.IsTrue (ContainsProperty (props, "IntInstBlue"), "#M25");
956 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#M26");
957 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#M27");
958 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#M28");
959 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#M29");
960 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#M30");
962 flags = BindingFlags.Static | BindingFlags.NonPublic |
964 props = type.GetProperties (flags);
966 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#N1");
967 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#N2");
968 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#N3");
969 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#N4");
970 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#N5");
971 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#N6");
972 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#N7");
973 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#N8");
974 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#N9");
975 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#N10");
976 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#N11");
977 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#N12");
978 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#N13");
979 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#N14");
980 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#N15");
981 Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#N16");
982 Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#N17");
983 Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#N18");
984 Assert.IsTrue (ContainsProperty (props, "PubStat"), "#N19");
985 Assert.IsTrue (ContainsProperty (props, "IntStat"), "#N20");
986 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#N21");
987 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#N22");
988 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#N23");
989 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#N24");
990 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#N25");
991 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#N26");
992 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#N27");
993 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#N28");
994 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#N29");
995 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#N30");
998 [Test] // GetProperty (String)
999 public void GetProperty1_Name_Null ()
1001 Type type = typeof (Bar);
1003 type.GetProperty ((string) null);
1005 } catch (ArgumentNullException ex) {
1006 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1007 Assert.IsNull (ex.InnerException, "#3");
1008 Assert.IsNotNull (ex.Message, "#4");
1009 Assert.IsNotNull (ex.ParamName, "#5");
1010 Assert.AreEqual ("name", ex.ParamName, "#6");
1014 [Test] // GetProperty (String, BindingFlags)
1015 public void GetProperty2 ()
1017 Type type = typeof (Bar);
1020 flags = BindingFlags.Instance | BindingFlags.NonPublic;
1022 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#A1");
1023 Assert.IsNotNull (type.GetProperty ("ProtInstBase", flags), "#A2");
1024 Assert.IsNotNull (type.GetProperty ("ProIntInstBase", flags), "#A3");
1025 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#A4");
1026 Assert.IsNotNull (type.GetProperty ("IntInstBase", flags), "#A5");
1027 Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#A6");
1028 Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#A7");
1029 Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#A8");
1030 Assert.IsNull (type.GetProperty ("PubInst", flags), "#A9");
1031 Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#A10");
1032 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#A11");
1033 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#A12");
1034 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#A13");
1035 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#A14");
1036 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#A15");
1037 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#A16");
1038 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#A17");
1039 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#A18");
1040 Assert.IsNull (type.GetProperty ("PubStat", flags), "#A19");
1041 Assert.IsNull (type.GetProperty ("IntStat", flags), "#A20");
1042 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#A21");
1043 Assert.IsNotNull (type.GetProperty ("ProtInstBlue", flags), "#A22");
1044 Assert.IsNotNull (type.GetProperty ("ProIntInstBlue", flags), "#A23");
1045 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#A24");
1046 Assert.IsNotNull (type.GetProperty ("IntInstBlue", flags), "#A25");
1047 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#A26");
1048 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#A27");
1049 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#A28");
1050 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#A29");
1051 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#A30");
1053 flags = BindingFlags.Instance | BindingFlags.Public;
1055 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#B1");
1056 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#B2");
1057 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#B3");
1058 Assert.IsNotNull (type.GetProperty ("PubInstBase", flags), "#B4");
1059 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#B5");
1060 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#B6");
1061 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#B7");
1062 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#B8");
1063 Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#B9");
1064 Assert.IsNull (type.GetProperty ("IntInst", flags), "#B10");
1065 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#B11");
1066 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#B12");
1067 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#B13");
1068 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#B14");
1069 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#B15");
1070 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#B16");
1071 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#B17");
1072 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#B18");
1073 Assert.IsNull (type.GetProperty ("PubStat", flags), "#B19");
1074 Assert.IsNull (type.GetProperty ("IntStat", flags), "#B20");
1075 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#B21");
1076 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#B22");
1077 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#B23");
1078 Assert.IsNotNull (type.GetProperty ("PubInstBlue", flags), "#B24");
1079 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#B25");
1080 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#B26");
1081 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#B27");
1082 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#B28");
1083 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#B29");
1084 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#B30");
1086 flags = BindingFlags.Static | BindingFlags.Public;
1088 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#C1");
1089 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#C2");
1090 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#C3");
1091 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#C4");
1092 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#C5");
1093 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#C6");
1094 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#C7");
1095 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#C8");
1096 Assert.IsNull (type.GetProperty ("PubInst", flags), "#C9");
1097 Assert.IsNull (type.GetProperty ("IntInst", flags), "#C10");
1098 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#C11");
1099 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#C12");
1100 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#C13");
1101 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#C14");
1102 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#C15");
1103 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#C16");
1104 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#C17");
1105 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#C18");
1106 Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#C19");
1107 Assert.IsNull (type.GetProperty ("IntStat", flags), "#C20");
1108 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#C21");
1109 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#C22");
1110 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#C23");
1111 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#C24");
1112 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#C25");
1113 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#C26");
1114 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#C27");
1115 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#C28");
1116 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#C29");
1117 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#C30");
1119 flags = BindingFlags.Static | BindingFlags.NonPublic;
1121 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#D1");
1122 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#D2");
1123 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#D3");
1124 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#D4");
1125 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#D5");
1126 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#D6");
1127 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#D7");
1128 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#D8");
1129 Assert.IsNull (type.GetProperty ("PubInst", flags), "#D9");
1130 Assert.IsNull (type.GetProperty ("IntInst", flags), "#D10");
1131 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#D11");
1132 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#D12");
1133 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#D13");
1134 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#D14");
1135 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#D15");
1136 Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#D16");
1137 Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#D17");
1138 Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#D18");
1139 Assert.IsNull (type.GetProperty ("PubStat", flags), "#D19");
1140 Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#D20");
1141 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#D21");
1142 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#D22");
1143 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#D23");
1144 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#D24");
1145 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#D25");
1146 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#D26");
1147 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#D27");
1148 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#D28");
1149 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#D29");
1150 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#D30");
1152 flags = BindingFlags.Instance | BindingFlags.NonPublic |
1153 BindingFlags.FlattenHierarchy;
1155 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#E1");
1156 Assert.IsNotNull (type.GetProperty ("ProtInstBase", flags), "#E2");
1157 Assert.IsNotNull (type.GetProperty ("ProIntInstBase", flags), "#E3");
1158 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#E4");
1159 Assert.IsNotNull (type.GetProperty ("IntInstBase", flags), "#E5");
1160 Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#E6");
1161 Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#E7");
1162 Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#E8");
1163 Assert.IsNull (type.GetProperty ("PubInst", flags), "#E9");
1164 Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#E10");
1165 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#E11");
1166 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#E12");
1167 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#E13");
1168 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#E14");
1169 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#E15");
1170 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#E16");
1171 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#E17");
1172 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#E18");
1173 Assert.IsNull (type.GetProperty ("PubStat", flags), "#E19");
1174 Assert.IsNull (type.GetProperty ("IntStat", flags), "#E20");
1175 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#E21");
1176 Assert.IsNotNull (type.GetProperty ("ProtInstBlue", flags), "#E22");
1177 Assert.IsNotNull (type.GetProperty ("ProIntInstBlue", flags), "#E23");
1178 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#E24");
1179 Assert.IsNotNull (type.GetProperty ("IntInstBlue", flags), "#E25");
1180 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#E26");
1181 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#E27");
1182 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#E28");
1183 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#E29");
1184 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#E30");
1186 flags = BindingFlags.Instance | BindingFlags.Public |
1187 BindingFlags.FlattenHierarchy;
1189 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#F1");
1190 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#F2");
1191 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#F3");
1192 Assert.IsNotNull (type.GetProperty ("PubInstBase", flags), "#F4");
1193 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#F5");
1194 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#F6");
1195 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#F7");
1196 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#F8");
1197 Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#F9");
1198 Assert.IsNull (type.GetProperty ("IntInst", flags), "#F10");
1199 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#F11");
1200 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#F12");
1201 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#F13");
1202 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#F14");
1203 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#F15");
1204 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#F16");
1205 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#F17");
1206 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#F18");
1207 Assert.IsNull (type.GetProperty ("PubStat", flags), "#F19");
1208 Assert.IsNull (type.GetProperty ("IntStat", flags), "#F20");
1209 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#F21");
1210 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#F22");
1211 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#F23");
1212 Assert.IsNotNull (type.GetProperty ("PubInstBlue", flags), "#F24");
1213 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#F25");
1214 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#F26");
1215 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#F27");
1216 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#F28");
1217 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#F29");
1218 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#F30");
1220 flags = BindingFlags.Static | BindingFlags.Public |
1221 BindingFlags.FlattenHierarchy;
1223 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#G1");
1224 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#G2");
1225 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#G3");
1226 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#G4");
1227 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#G5");
1228 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#G6");
1229 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#G7");
1230 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#G8");
1231 Assert.IsNull (type.GetProperty ("PubInst", flags), "#G9");
1232 Assert.IsNull (type.GetProperty ("IntInst", flags), "#G10");
1233 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#G11");
1234 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#G12");
1235 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#G13");
1236 Assert.IsNotNull (type.GetProperty ("PubStatBase", flags), "#G14");
1237 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#G15");
1238 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#G16");
1239 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#G17");
1240 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#G18");
1241 Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#G19");
1242 Assert.IsNull (type.GetProperty ("IntStat", flags), "#G20");
1243 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#G21");
1244 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#G22");
1245 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#G23");
1246 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#G24");
1247 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#G25");
1248 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#G26");
1249 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#G27");
1250 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#G28");
1251 Assert.IsNotNull (type.GetProperty ("PubStatBlue", flags), "#G29");
1252 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#G30");
1254 flags = BindingFlags.Static | BindingFlags.NonPublic |
1255 BindingFlags.FlattenHierarchy;
1257 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#H1");
1258 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#H2");
1259 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#H3");
1260 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#H4");
1261 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#H5");
1262 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#H6");
1263 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#H7");
1264 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#H8");
1265 Assert.IsNull (type.GetProperty ("PubInst", flags), "#H9");
1266 Assert.IsNull (type.GetProperty ("IntInst", flags), "#H10");
1267 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#H11");
1268 Assert.IsNotNull (type.GetProperty ("ProtStatBase", flags), "#H12");
1269 Assert.IsNotNull (type.GetProperty ("ProIntStatBase", flags), "#H13");
1270 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#H14");
1271 Assert.IsNotNull (type.GetProperty ("IntStatBase", flags), "#H15");
1272 Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#H16");
1273 Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#H17");
1274 Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#H18");
1275 Assert.IsNull (type.GetProperty ("PubStat", flags), "#H19");
1276 Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#H20");
1277 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#H21");
1278 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#H22");
1279 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#H23");
1280 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#H24");
1281 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#H25");
1282 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#H26");
1283 Assert.IsNotNull (type.GetProperty ("ProtStatBlue", flags), "#H27");
1284 Assert.IsNotNull (type.GetProperty ("ProIntStatBlue", flags), "#H28");
1285 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#H29");
1286 Assert.IsNotNull (type.GetProperty ("IntStatBlue", flags), "#H30");
1288 flags = BindingFlags.Instance | BindingFlags.NonPublic |
1289 BindingFlags.DeclaredOnly;
1291 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#I1");
1292 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#I2");
1293 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#I3");
1294 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#I4");
1295 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#I5");
1296 Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#I6");
1297 Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#I7");
1298 Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#I8");
1299 Assert.IsNull (type.GetProperty ("PubInst", flags), "#I9");
1300 Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#I10");
1301 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#I11");
1302 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#I12");
1303 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#I13");
1304 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#I14");
1305 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#I15");
1306 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#I16");
1307 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#I17");
1308 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#I18");
1309 Assert.IsNull (type.GetProperty ("PubStat", flags), "#I19");
1310 Assert.IsNull (type.GetProperty ("IntStat", flags), "#I20");
1311 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#I21");
1312 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#I22");
1313 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#I23");
1314 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#I24");
1315 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#I25");
1316 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#I26");
1317 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#I27");
1318 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#I28");
1319 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#I29");
1320 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#I30");
1322 flags = BindingFlags.Instance | BindingFlags.Public |
1323 BindingFlags.DeclaredOnly;
1325 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#J1");
1326 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#J2");
1327 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#J3");
1328 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#J4");
1329 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#J5");
1330 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#J6");
1331 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#J7");
1332 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#J8");
1333 Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#J9");
1334 Assert.IsNull (type.GetProperty ("IntInst", flags), "#J10");
1335 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#J11");
1336 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#J12");
1337 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#J13");
1338 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#J14");
1339 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#J15");
1340 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#J16");
1341 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#J17");
1342 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#J18");
1343 Assert.IsNull (type.GetProperty ("PubStat", flags), "#J19");
1344 Assert.IsNull (type.GetProperty ("IntStat", flags), "#J20");
1345 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#J21");
1346 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#J22");
1347 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#J23");
1348 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#J24");
1349 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#J25");
1350 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#J26");
1351 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#J27");
1352 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#J28");
1353 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#J29");
1354 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#J30");
1356 flags = BindingFlags.Static | BindingFlags.Public |
1357 BindingFlags.DeclaredOnly;
1359 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#K1");
1360 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#K2");
1361 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#K3");
1362 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#K4");
1363 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#K5");
1364 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#K6");
1365 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#K7");
1366 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#K8");
1367 Assert.IsNull (type.GetProperty ("PubInst", flags), "#K9");
1368 Assert.IsNull (type.GetProperty ("IntInst", flags), "#K10");
1369 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#K11");
1370 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#K12");
1371 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#K13");
1372 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#K14");
1373 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#K15");
1374 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#K16");
1375 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#K17");
1376 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#K18");
1377 Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#K19");
1378 Assert.IsNull (type.GetProperty ("IntStat", flags), "#K20");
1379 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#K21");
1380 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#K22");
1381 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#K23");
1382 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#K24");
1383 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#K25");
1384 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#K26");
1385 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#K27");
1386 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#K28");
1387 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#K29");
1388 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#K30");
1390 flags = BindingFlags.Static | BindingFlags.NonPublic |
1391 BindingFlags.DeclaredOnly;
1393 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#L1");
1394 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#L2");
1395 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#L3");
1396 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#L4");
1397 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#L5");
1398 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#L6");
1399 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#L7");
1400 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#L8");
1401 Assert.IsNull (type.GetProperty ("PubInst", flags), "#L9");
1402 Assert.IsNull (type.GetProperty ("IntInst", flags), "#L10");
1403 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#L11");
1404 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#L12");
1405 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#L13");
1406 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#L14");
1407 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#L15");
1408 Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#L16");
1409 Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#L17");
1410 Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#L18");
1411 Assert.IsNull (type.GetProperty ("PubStat", flags), "#L19");
1412 Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#L20");
1413 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#L21");
1414 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#L22");
1415 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#L23");
1416 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#L24");
1417 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#L25");
1418 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#L26");
1419 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#L27");
1420 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#L28");
1421 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#L29");
1422 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#L30");
1424 flags = BindingFlags.Instance | BindingFlags.NonPublic |
1425 BindingFlags.Public;
1427 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#M1");
1428 Assert.IsNotNull (type.GetProperty ("ProtInstBase", flags), "#M2");
1429 Assert.IsNotNull (type.GetProperty ("ProIntInstBase", flags), "#M3");
1430 Assert.IsNotNull (type.GetProperty ("PubInstBase", flags), "#M4");
1431 Assert.IsNotNull (type.GetProperty ("IntInstBase", flags), "#M5");
1432 Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#M6");
1433 Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#M7");
1434 Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#M8");
1435 Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#M9");
1436 Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#M10");
1437 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#M11");
1438 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#M12");
1439 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#M13");
1440 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#M14");
1441 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#M15");
1442 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#M16");
1443 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#M17");
1444 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#M18");
1445 Assert.IsNull (type.GetProperty ("PubStat", flags), "#M19");
1446 Assert.IsNull (type.GetProperty ("IntStat", flags), "#M20");
1447 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#M21");
1448 Assert.IsNotNull (type.GetProperty ("ProtInstBlue", flags), "#M22");
1449 Assert.IsNotNull (type.GetProperty ("ProIntInstBlue", flags), "#M23");
1450 Assert.IsNotNull (type.GetProperty ("PubInstBlue", flags), "#M24");
1451 Assert.IsNotNull (type.GetProperty ("IntInstBlue", flags), "#M25");
1452 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#M26");
1453 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#M27");
1454 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#M28");
1455 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#M29");
1456 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#M30");
1458 flags = BindingFlags.Static | BindingFlags.NonPublic |
1459 BindingFlags.Public;
1461 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#N1");
1462 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#N2");
1463 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#N3");
1464 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#N4");
1465 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#N5");
1466 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#N6");
1467 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#N7");
1468 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#N8");
1469 Assert.IsNull (type.GetProperty ("PubInst", flags), "#N9");
1470 Assert.IsNull (type.GetProperty ("IntInst", flags), "#N10");
1471 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#N11");
1472 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#N12");
1473 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#N13");
1474 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#N14");
1475 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#N15");
1476 Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#N16");
1477 Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#N17");
1478 Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#N18");
1479 Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#N19");
1480 Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#N20");
1481 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#N21");
1482 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#N22");
1483 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#N23");
1484 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#N24");
1485 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#N25");
1486 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#N26");
1487 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#N27");
1488 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#N28");
1489 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#N29");
1490 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#N30");
1493 [Test] // GetProperty (String, BindingFlags)
1494 public void GetProperty2_Name_Null ()
1496 Type type = typeof (Bar);
1498 type.GetProperty ((string) null);
1500 } catch (ArgumentNullException ex) {
1501 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1502 Assert.IsNull (ex.InnerException, "#3");
1503 Assert.IsNotNull (ex.Message, "#4");
1504 Assert.IsNotNull (ex.ParamName, "#5");
1505 Assert.AreEqual ("name", ex.ParamName, "#6");
1509 [Test] // GetProperty (String, Type)
1510 public void GetProperty3_Name_Null ()
1512 Type type = typeof (Bar);
1514 type.GetProperty ((string) null, typeof (int));
1516 } catch (ArgumentNullException ex) {
1517 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1518 Assert.IsNull (ex.InnerException, "#3");
1519 Assert.IsNotNull (ex.Message, "#4");
1520 Assert.IsNotNull (ex.ParamName, "#5");
1521 Assert.AreEqual ("name", ex.ParamName, "#6");
1525 [Test] // GetProperty (String, Type [])
1526 public void GetProperty4_Name_Null ()
1528 Type type = typeof (Bar);
1530 type.GetProperty ((string) null, Type.EmptyTypes);
1532 } catch (ArgumentNullException ex) {
1533 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1534 Assert.IsNull (ex.InnerException, "#3");
1535 Assert.IsNotNull (ex.Message, "#4");
1536 Assert.IsNotNull (ex.ParamName, "#5");
1537 Assert.AreEqual ("name", ex.ParamName, "#6");
1541 [Test] // GetProperty (String, Type, Type [])
1542 public void GetProperty5_Name_Null ()
1544 Type type = typeof (Bar);
1546 type.GetProperty ((string) null, typeof (int),
1549 } catch (ArgumentNullException ex) {
1550 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1551 Assert.IsNull (ex.InnerException, "#3");
1552 Assert.IsNotNull (ex.Message, "#4");
1553 Assert.IsNotNull (ex.ParamName, "#5");
1554 Assert.AreEqual ("name", ex.ParamName, "#6");
1558 [Test] // GetProperty (String, Type, Type [], ParameterModifier [])
1559 public void GetProperty6_Name_Null ()
1561 Type type = typeof (Bar);
1563 type.GetProperty ((string) null, typeof (int),
1564 Type.EmptyTypes, null);
1566 } catch (ArgumentNullException ex) {
1567 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1568 Assert.IsNull (ex.InnerException, "#3");
1569 Assert.IsNotNull (ex.Message, "#4");
1570 Assert.IsNotNull (ex.ParamName, "#5");
1571 Assert.AreEqual ("name", ex.ParamName, "#6");
1575 [Test] // GetProperty (String, BindingFlags, Binder, Type, Type [], ParameterModifier [])
1576 public void GetProperty7_Name_Null ()
1578 Type type = typeof (Bar);
1580 type.GetProperty ((string) null, BindingFlags.Public,
1581 null, typeof (int), Type.EmptyTypes, null);
1583 } catch (ArgumentNullException ex) {
1584 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1585 Assert.IsNull (ex.InnerException, "#3");
1586 Assert.IsNotNull (ex.Message, "#4");
1587 Assert.IsNotNull (ex.ParamName, "#5");
1588 Assert.AreEqual ("name", ex.ParamName, "#6");
1593 public void GetProperty8_PropertyType ()
1595 Type type = typeof (Bar);
1596 Assert.IsNull (type.GetProperty ("PubInst", BindingFlags.Public | BindingFlags.Instance,
1597 null, typeof (int), Type.EmptyTypes, null), "#1");
1598 Assert.IsNotNull (type.GetProperty ("PubInst", BindingFlags.Public | BindingFlags.Instance, null,
1599 typeof (long), new Type[0], null), "#2");
1603 public void GetProperty9_Indexers ()
1606 var bindingFlags = BindingFlags.Public | BindingFlags.Instance;
1608 Type type1 = typeof (List<byte>);
1609 var p1 = type1.GetProperty ("Item", bindingFlags, null, typeof (byte), new Type[] { typeof (int) }, null);
1610 Assert.IsNotNull (p1, "#1");
1612 Type type2 = typeof (List<string>);
1613 var p2 = type2.GetProperty ("Item", bindingFlags, null, typeof (string), new Type[] { typeof (int) }, null);
1614 Assert.IsNotNull (p2, "#2");
1616 Type type3 = typeof (List<Type>);
1617 // result type not convertible, make sure we fail.
1618 var p3 = type3.GetProperty ("Item", bindingFlags, null, typeof (string) /*!*/,
1619 new Type[] { typeof (int) }, null);
1620 Assert.IsNull (p3, "#3");
1623 [StructLayout(LayoutKind.Explicit, Pack = 4, Size = 64)]
1628 [StructLayout(LayoutKind.Explicit, CharSet=CharSet.Unicode)]
1634 public void StructLayoutAttribute ()
1636 StructLayoutAttribute attr1 = typeof (TypeTest).StructLayoutAttribute;
1637 Assert.AreEqual (LayoutKind.Auto, attr1.Value);
1639 StructLayoutAttribute attr2 = typeof (Class1).StructLayoutAttribute;
1640 Assert.AreEqual (LayoutKind.Explicit, attr2.Value);
1641 Assert.AreEqual (4, attr2.Pack);
1642 Assert.AreEqual (64, attr2.Size);
1644 StructLayoutAttribute attr3 = typeof (Class2).StructLayoutAttribute;
1645 Assert.AreEqual (LayoutKind.Explicit, attr3.Value);
1646 Assert.AreEqual (CharSet.Unicode, attr3.CharSet);
1650 public void Namespace ()
1652 Assert.AreEqual (null, typeof (NoNamespaceClass).Namespace);
1656 public void GenericParameterNamespace ()
1658 var t = typeof (Foo<>).GetGenericArguments () [0];
1660 Assert.AreEqual ("T", t.Name);
1661 Assert.AreEqual ("MonoTests.System", t.Namespace);
1663 var s = typeof (Gazonk).GetMethod ("Bang").GetGenericArguments () [0];
1665 Assert.AreEqual ("S", s.Name);
1666 Assert.AreEqual ("MonoTests.System", s.Namespace);
1669 public static void Reflected (ref int a)
1676 Assert.AreEqual ("Int32&", typeof (TypeTest).GetMethod ("Reflected").GetParameters () [0].ParameterType.Name);
1677 Assert.AreEqual ("String[*]", Array.CreateInstance (typeof(string), new int[] { 1 }, new int[] { 1 }).GetType ().Name);
1681 public void GetInterfaces ()
1683 Type[] t = typeof (Duper).GetInterfaces ();
1684 Assert.AreEqual (1, t.Length);
1685 Assert.AreEqual (typeof (ICloneable), t[0]);
1687 Type[] t2 = typeof (IFace3).GetInterfaces ();
1688 Assert.AreEqual (2, t2.Length);
1692 public void GetInterfacesGenericVarWithConstraints ()
1694 var a = typeof (TypeTest).GetMethod ("GenericMethod");
1696 var p = a.GetParameters ();
1697 var i = p[0].ParameterType.GetElementType ();
1701 public static void GenericMethod<T, T2> (T[] arr) where T: IComparable<T> {
1707 public void GetFieldIgnoreCase ()
1709 Assert.IsNotNull (typeof (TypeTest).GetField ("afield", BindingFlags.Instance|BindingFlags.Public|BindingFlags.IgnoreCase));
1722 public void GetPropertyAccessorModifiers ()
1724 Assert.IsNotNull (typeof (TypeTest).GetProperty ("Count", BindingFlags.Instance | BindingFlags.Public));
1725 Assert.IsNull (typeof (TypeTest).GetProperty ("Count", BindingFlags.Instance | BindingFlags.NonPublic));
1729 public void IsAbstract ()
1731 Assert.IsFalse (typeof (string).IsAbstract, "#1");
1732 Assert.IsTrue (typeof (ICloneable).IsAbstract, "#2");
1733 Assert.IsTrue (typeof (ValueType).IsAbstract, "#3");
1734 Assert.IsTrue (typeof (Enum).IsAbstract, "#4");
1735 Assert.IsFalse (typeof (TimeSpan).IsAbstract, "#5");
1736 Assert.IsTrue (typeof (TextReader).IsAbstract, "#6");
1739 // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=286308
1740 Type [] typeArgs = typeof (List<>).GetGenericArguments ();
1741 Assert.IsFalse (typeArgs [0].IsAbstract, "#7");
1745 public void IsCOMObject ()
1747 Type type = typeof (string);
1748 Assert.IsFalse (type.IsCOMObject, "#1");
1750 TypeBuilder tb = module.DefineType (genTypeName ());
1751 type = tb.CreateType ();
1752 Assert.IsFalse (type.IsCOMObject, "#2");
1756 public void IsImport ()
1758 Type type = typeof (string);
1759 Assert.IsFalse (type.IsImport, "#1");
1761 TypeBuilder tb = module.DefineType (genTypeName ());
1762 type = tb.CreateType ();
1763 Assert.IsFalse (type.IsImport, "#2");
1765 tb = module.DefineType (genTypeName (), TypeAttributes.Import |
1766 TypeAttributes.Interface | TypeAttributes.Abstract);
1767 type = tb.CreateType ();
1768 Assert.IsTrue (type.IsImport, "#3");
1772 public void IsInterface ()
1774 Assert.IsFalse (typeof (string).IsInterface, "#1");
1775 Assert.IsTrue (typeof (ICloneable).IsInterface, "#2");
1779 public void IsPrimitive () {
1780 Assert.IsTrue (typeof (IntPtr).IsPrimitive, "#1");
1781 Assert.IsTrue (typeof (int).IsPrimitive, "#2");
1782 Assert.IsFalse (typeof (string).IsPrimitive, "#2");
1786 public void IsValueType ()
1788 Assert.IsTrue (typeof (int).IsValueType, "#1");
1789 Assert.IsFalse (typeof (Enum).IsValueType, "#2");
1790 Assert.IsFalse (typeof (ValueType).IsValueType, "#3");
1791 Assert.IsTrue (typeof (AttributeTargets).IsValueType, "#4");
1792 Assert.IsFalse (typeof (string).IsValueType, "#5");
1793 Assert.IsTrue (typeof (TimeSpan).IsValueType, "#6");
1797 public void IsVisible ()
1799 Assert.IsTrue (typeof (int).IsVisible, "#1");
1800 Assert.IsTrue (typeof (Nested).IsVisible, "#2");
1804 public void GetTypeNonVectorArray ()
1806 Type t = Type.GetType ("System.String[*]");
1807 Assert.AreEqual ("System.String[*]", t.ToString ());
1812 public void TypeFromCLSID ()
1814 Guid CLSID_ShellDesktop = new Guid("00021400-0000-0000-c000-000000000046");
1815 Guid CLSID_Bogus = new Guid("1ea9d7a9-f7ab-443b-b486-30d285b21f1b");
1817 Type t1 = Type.GetTypeFromCLSID (CLSID_ShellDesktop);
1819 Type t2 = Type.GetTypeFromCLSID (CLSID_Bogus);
1821 Assert.AreEqual (t1.FullName, "System.__ComObject");
1823 if (Environment.OSVersion.Platform == PlatformID.Win32Windows ||
1824 Environment.OSVersion.Platform == PlatformID.Win32NT)
1825 Activator.CreateInstance(t1);
1827 Assert.AreEqual (t2.FullName, "System.__ComObject");
1829 Assert.AreNotEqual (t1, t2);
1833 [Category("NotWorking")] // Mono throws TargetInvokationException
1834 [ExpectedException("System.Runtime.InteropServices.COMException")]
1835 public void TypeFromCLSIDBogus ()
1837 Guid CLSID_Bogus = new Guid("1ea9d7a9-f7ab-443b-b486-30d285b21f1b");
1838 Type t = Type.GetTypeFromCLSID (CLSID_Bogus);
1839 if (Environment.OSVersion.Platform == PlatformID.Win32Windows ||
1840 Environment.OSVersion.Platform == PlatformID.Win32NT)
1841 Activator.CreateInstance(t);
1843 throw new COMException ();
1847 public void ExerciseFilterName ()
1849 MemberInfo[] mi = typeof(Base).FindMembers(
1851 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1852 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1853 Type.FilterName, "*");
1854 Assert.AreEqual (4, mi.Length);
1855 mi = typeof(Base).FindMembers(
1857 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1858 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1859 Type.FilterName, "Test*");
1860 Assert.AreEqual (2, mi.Length);
1861 mi = typeof(Base).FindMembers(
1863 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1864 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1865 Type.FilterName, "TestVoid");
1866 Assert.AreEqual (1, mi.Length);
1867 mi = typeof(Base).FindMembers(
1869 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1870 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1871 Type.FilterName, "NonExistingMethod");
1872 Assert.AreEqual (0, mi.Length);
1876 public void ExerciseFilterNameIgnoreCase ()
1878 MemberInfo[] mi = typeof(Base).FindMembers(
1880 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1881 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1882 Type.FilterNameIgnoreCase, "*");
1883 Assert.AreEqual (4, mi.Length);
1884 mi = typeof(Base).FindMembers(
1886 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1887 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1888 Type.FilterNameIgnoreCase, "test*");
1889 Assert.AreEqual (2, mi.Length);
1890 mi = typeof(Base).FindMembers(
1892 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1893 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1894 Type.FilterNameIgnoreCase, "TESTVOID");
1895 Assert.AreEqual (1, mi.Length);
1896 mi = typeof(Base).FindMembers(
1898 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1899 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1900 Type.FilterNameIgnoreCase, "NonExistingMethod");
1901 Assert.AreEqual (0, mi.Length);
1905 [ExpectedException (typeof (InvalidFilterCriteriaException))]
1906 public void FilterAttribute_Invalid ()
1908 Type.FilterAttribute (MethodBase.GetCurrentMethod (), (byte) 1);
1912 public void GenericParameterMemberType ()
1914 var t = typeof (Foo<>).GetGenericArguments () [0];
1915 Assert.IsNotNull (t);
1917 Assert.AreEqual (MemberTypes.TypeInfo, t.MemberType);
1923 public int property {
1926 public ByRef0 (int i) {}
1927 public void f (int i) {}
1931 public void ByrefTypes ()
1933 Type t = Type.GetType ("MonoTests.System.TypeTest+ByRef0&");
1934 Assert.IsNotNull (t);
1935 Assert.IsTrue (t.IsByRef);
1936 Assert.AreEqual (0, t.GetMethods (BindingFlags.Public | BindingFlags.Instance).Length);
1937 Assert.AreEqual (0, t.GetConstructors (BindingFlags.Public | BindingFlags.Instance).Length);
1938 Assert.AreEqual (0, t.GetEvents (BindingFlags.Public | BindingFlags.Instance).Length);
1939 Assert.AreEqual (0, t.GetProperties (BindingFlags.Public | BindingFlags.Instance).Length);
1941 Assert.IsNull (t.GetMethod ("f"));
1942 Assert.IsNull (t.GetField ("field"));
1943 Assert.IsNull (t.GetProperty ("property"));
1947 public void TestAssemblyQualifiedName ()
1949 Type t = Type.GetType ("System.Byte[]&");
1950 Assert.IsTrue (t.AssemblyQualifiedName.StartsWith ("System.Byte[]&"));
1952 t = Type.GetType ("System.Byte*&");
1953 Assert.IsTrue (t.AssemblyQualifiedName.StartsWith ("System.Byte*&"));
1955 t = Type.GetType ("System.Byte&");
1956 Assert.IsTrue (t.AssemblyQualifiedName.StartsWith ("System.Byte&"));
1961 #pragma warning disable 169
1963 #pragma warning restore 169
1967 public void CreateValueTypeNoCtor ()
1969 typeof(B).InvokeMember ("", BindingFlags.CreateInstance, null, null, null);
1973 [ExpectedException (typeof (MissingMethodException))]
1974 public void CreateValueTypeNoCtorArgs ()
1976 typeof(B).InvokeMember ("", BindingFlags.CreateInstance, null, null, new object [] { 1 });
1980 [ExpectedException (typeof (MissingMethodException))]
1981 public void InvokeGetPropertyMissing ()
1983 typeof(B).InvokeMember ("", BindingFlags.GetProperty, null, null, new object [] { 1 });
1987 [ExpectedException (typeof (MissingMethodException))]
1988 public void InvokeSetPropertyMissing ()
1990 typeof(B).InvokeMember ("", BindingFlags.SetProperty, null, null, new object [] { 1 });
1993 internal static string bug336841 (string param1, params string [] param2)
1995 StringBuilder sb = new StringBuilder ();
1999 for (int i = 0; i < param2.Length; i++) {
2002 sb.Append (param2 [i]);
2004 return sb.ToString ();
2007 internal static string bug336841 (string param1)
2009 return "#B:" + param1;
2012 internal static string bug336841 (params string [] param1)
2014 StringBuilder sb = new StringBuilder ();
2016 for (int i = 0; i < param1.Length; i++) {
2019 sb.Append (param1 [i]);
2021 return sb.ToString ();
2025 public void InvokeMember_GetSetField ()
2027 typeof (X).InvokeMember ("Value", BindingFlags.Public |
2028 BindingFlags.Static | BindingFlags.FlattenHierarchy |
2029 BindingFlags.SetField, null, null, new object [] { 5 });
2031 Assert.AreEqual (5, X.Value, "#A1");
2032 Assert.AreEqual (5, typeof (X).InvokeMember ("Value",
2033 BindingFlags.Public | BindingFlags.Static |
2034 BindingFlags.FlattenHierarchy | BindingFlags.GetField,
2035 null, null, new object [0]), "#A2");
2036 Assert.AreEqual (5, Y.Value, "#A3");
2037 Assert.AreEqual (5, typeof (Y).InvokeMember ("Value",
2038 BindingFlags.Public | BindingFlags.Static |
2039 BindingFlags.FlattenHierarchy | BindingFlags.GetField,
2040 null, null, new object [0]), "#A4");
2043 typeof (X).InvokeMember ("Value", BindingFlags.Public |
2044 BindingFlags.Static | BindingFlags.FlattenHierarchy |
2045 BindingFlags.GetField | BindingFlags.SetField,
2046 null, null, new object [] { 5 });
2047 Assert.Fail ("#B1");
2048 } catch (ArgumentException ex) {
2049 // Cannot specify both Get and Set on a field
2050 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
2051 Assert.IsNull (ex.InnerException, "#B3");
2052 Assert.IsNotNull (ex.Message, "#B4");
2053 Assert.IsNotNull (ex.ParamName, "#B5");
2054 Assert.AreEqual ("bindingFlags", ex.ParamName, "#B6");
2059 public void InvokeMember_GetSetProperty ()
2062 typeof (ArrayList).InvokeMember ("Item",
2063 BindingFlags.GetProperty | BindingFlags.SetProperty |
2064 BindingFlags.Instance | BindingFlags.Public,
2065 null, new ArrayList (), new object [] { 0, "bar" });
2067 } catch (ArgumentException ex) {
2068 // Cannot specify both Get and Set on a property
2069 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
2070 Assert.IsNull (ex.InnerException, "#3");
2071 Assert.IsNotNull (ex.Message, "#4");
2072 Assert.IsNotNull (ex.ParamName, "#5");
2073 Assert.AreEqual ("bindingFlags", ex.ParamName, "#6");
2079 public void InvokeMember_InvokeMethod_Set ()
2082 typeof (ArrayList).InvokeMember ("ToString",
2083 BindingFlags.InvokeMethod | BindingFlags.SetField |
2084 BindingFlags.Instance | BindingFlags.Public,
2085 null, new ArrayList (), new object [0]);
2086 Assert.Fail ("#A1");
2087 } catch (ArgumentException ex) {
2088 // Cannot specify Set on a field and Invoke on a method
2089 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
2090 Assert.IsNull (ex.InnerException, "#A3");
2091 Assert.IsNotNull (ex.Message, "#A4");
2092 Assert.IsNotNull (ex.ParamName, "#A5");
2093 Assert.AreEqual ("bindingFlags", ex.ParamName, "#A6");
2097 typeof (ArrayList).InvokeMember ("ToString",
2098 BindingFlags.InvokeMethod | BindingFlags.SetProperty |
2099 BindingFlags.Instance | BindingFlags.Public,
2100 null, new ArrayList (), new object [0]);
2101 Assert.Fail ("#B1");
2102 } catch (ArgumentException ex) {
2103 // Cannot specify Set on a property and Invoke on a method
2104 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
2105 Assert.IsNull (ex.InnerException, "#B3");
2106 Assert.IsNotNull (ex.Message, "#B4");
2107 Assert.IsNotNull (ex.ParamName, "#B5");
2108 Assert.AreEqual ("bindingFlags", ex.ParamName, "#B6");
2113 public void InvokeMember_MatchPrimitiveTypeWithInterface ()
2115 object [] invokeargs = { 1 };
2116 typeof (Z).InvokeMember ("", BindingFlags.DeclaredOnly |
2117 BindingFlags.Public | BindingFlags.NonPublic |
2118 BindingFlags.Instance | BindingFlags.CreateInstance,
2119 null, null, invokeargs);
2123 public void InvokeMember_Name_Null ()
2126 typeof (X).InvokeMember ((string) null,
2127 BindingFlags.Public | BindingFlags.Static |
2128 BindingFlags.FlattenHierarchy | BindingFlags.SetField,
2129 null, null, new object [] { 5 });
2131 } catch (ArgumentNullException ex) {
2132 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2133 Assert.IsNull (ex.InnerException, "#3");
2134 Assert.IsNotNull (ex.Message, "#4");
2135 Assert.IsNotNull (ex.ParamName, "#5");
2136 Assert.AreEqual ("name", ex.ParamName, "#6");
2141 public void InvokeMember_NoOperation ()
2144 typeof (TypeTest).InvokeMember ("Run", BindingFlags.Public |
2145 BindingFlags.Static, null, null, new object [0]);
2147 } catch (ArgumentException ex) {
2148 // Must specify binding flags describing the
2149 // invoke operation required
2150 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
2151 Assert.IsNull (ex.InnerException, "#3");
2152 Assert.IsNotNull (ex.Message, "#4");
2153 Assert.IsNotNull (ex.ParamName, "#5");
2154 Assert.AreEqual ("bindingFlags", ex.ParamName, "#6");
2158 [Test] // bug #321735
2159 public void InvokeMember_SetFieldProperty ()
2161 ArrayList list = new ArrayList ();
2163 list.GetType ().InvokeMember ("Item",
2164 BindingFlags.SetField | BindingFlags.SetProperty |
2165 BindingFlags.Instance | BindingFlags.Public,
2166 null, list, new object [] { 0, "bar" });
2167 Assert.AreEqual ("bar", list [0]);
2171 public void InvokeMember_SetField_ProvidedArgs ()
2174 typeof (X).InvokeMember ("Value", BindingFlags.Public |
2175 BindingFlags.Static | BindingFlags.SetField,
2176 null, null, new object [0]);
2177 Assert.Fail ("#A1");
2178 } catch (ArgumentException ex) {
2179 // Only the field value can be specified to set
2181 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
2182 Assert.IsNull (ex.InnerException, "#A3");
2183 Assert.IsNotNull (ex.Message, "#A4");
2184 Assert.IsNotNull (ex.ParamName, "#A5");
2185 Assert.AreEqual ("bindingFlags", ex.ParamName, "#6");
2189 typeof (X).InvokeMember ("Value", BindingFlags.Public |
2190 BindingFlags.Static | BindingFlags.SetField,
2192 Assert.Fail ("#B1");
2193 } catch (ArgumentNullException ex) {
2194 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
2195 Assert.IsNull (ex.InnerException, "#B3");
2196 Assert.IsNotNull (ex.Message, "#B4");
2197 Assert.IsNotNull (ex.ParamName, "#B5");
2198 Assert.AreEqual ("providedArgs", ex.ParamName, "#B6");
2202 [Test] // bug #336841
2203 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=306797
2204 public void InvokeMember_VarArgs ()
2206 BindingFlags flags = BindingFlags.InvokeMethod | BindingFlags.Public |
2207 BindingFlags.NonPublic | BindingFlags.OptionalParamBinding |
2208 BindingFlags.Static | BindingFlags.FlattenHierarchy |
2209 BindingFlags.Instance;
2211 Type type = typeof (TypeTest);
2212 string result = (string) type.InvokeMember ("bug336841",
2213 flags, null, null, new object [] { "1" });
2214 Assert.IsNotNull (result, "#A1");
2215 Assert.AreEqual ("#B:1", result, "#A2");
2217 result = (string) type.InvokeMember ("bug336841", flags,
2218 null, null, new object [] { "1", "2", "3", "4" });
2219 Assert.IsNotNull (result, "#B1");
2220 Assert.AreEqual ("#A:1|2,3,4", result, "#B2");
2224 [Test] // bug #348522
2225 public void InvokeMember_WithoutDefaultValue ()
2227 BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod;
2229 typeof (Bug348522).InvokeMember ("Test", flags, new FirstMethodBinder (), new Bug348522(),
2230 new object [] {Missing.Value}, null, null, null);
2232 } catch (ArgumentException ex) {
2233 // Missing parameter does not have a default value
2234 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
2235 Assert.IsNull (ex.InnerException, "#3");
2236 Assert.IsNotNull (ex.Message, "#4");
2237 Assert.IsNotNull (ex.ParamName, "#5");
2238 Assert.AreEqual ("parameters", ex.ParamName, "#6");
2243 public void TestMissing () {
2244 Assert.AreEqual (Type.Missing, Missing.Value);
2248 public void GetGenericMethodDefinitionOverInflatedMethodOnGTD () {
2249 var l = typeof (List<>);
2250 var m = l.GetMethod ("ConvertAll");
2251 var infl = m.MakeGenericMethod (typeof (int));
2252 var res = m.GetGenericMethodDefinition ();
2253 Assert.AreEqual (m, res, "#1");
2257 public void InvokeMember_OutParam ()
2259 object[] args = new object[] { new string [0] };
2260 typeof (TypeTest).InvokeMember ("OutTest", BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.Public, null, null, args);
2261 Assert.IsTrue (args [0] is string[]);
2262 Assert.AreEqual (10, ((string[])args[0]).Length);
2265 public static void OutTest (out string[] a1)
2267 a1 = new string [10];
2272 public static int Value;
2281 public Z (IComparable value)
2286 public static void Run ()
2294 public TakesInt (int x)
2299 public int Integer {
2306 public TakesObject (object x) {}
2309 [Test] // bug #75241
2310 public void GetConstructorNullInTypes ()
2312 // This ends up calling type.GetConstructor ()
2313 Activator.CreateInstance (typeof (TakesInt), new object [] { null });
2314 Activator.CreateInstance (typeof (TakesObject), new object [] { null });
2318 public void GetConstructor_TakeInt_Object ()
2320 Assert.IsNull (typeof (TakesInt).GetConstructor (new Type[1] { typeof (object) }));
2324 public void GetCustomAttributes_All ()
2326 object [] attrs = typeof (A).GetCustomAttributes (false);
2327 Assert.AreEqual (2, attrs.Length, "#A1");
2328 Assert.IsTrue (HasAttribute (attrs, typeof (FooAttribute)), "#A2");
2329 Assert.IsTrue (HasAttribute (attrs, typeof (VolatileModifier)), "#A3");
2331 attrs = typeof (BA).GetCustomAttributes (false);
2332 Assert.AreEqual (1, attrs.Length, "#B1");
2333 Assert.AreEqual (typeof (BarAttribute), attrs [0].GetType (), "#B2");
2335 attrs = typeof (BA).GetCustomAttributes (true);
2336 Assert.AreEqual (2, attrs.Length, "#C1");
2337 Assert.IsTrue (HasAttribute (attrs, typeof (BarAttribute)), "#C2");
2338 Assert.IsTrue (HasAttribute (attrs, typeof (VolatileModifier)), "#C3");
2340 attrs = typeof (CA).GetCustomAttributes (false);
2341 Assert.AreEqual (0, attrs.Length, "#D");
2343 attrs = typeof (CA).GetCustomAttributes (true);
2344 Assert.AreEqual (1, attrs.Length, "#E1");
2345 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#E2");
2348 static bool HasAttribute (object [] attrs, Type attributeType)
2350 foreach (object attr in attrs)
2351 if (attr.GetType () == attributeType)
2357 public void GetCustomAttributes_Type ()
2359 object [] attrs = null;
2361 attrs = typeof (A).GetCustomAttributes (
2362 typeof (VolatileModifier), false);
2363 Assert.AreEqual (1, attrs.Length, "#A1");
2364 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#A2");
2365 attrs = typeof (A).GetCustomAttributes (
2366 typeof (VolatileModifier), true);
2367 Assert.AreEqual (1, attrs.Length, "#A3");
2368 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#A4");
2370 attrs = typeof (A).GetCustomAttributes (
2371 typeof (NemerleAttribute), false);
2372 Assert.AreEqual (1, attrs.Length, "#B1");
2373 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#B2");
2374 attrs = typeof (A).GetCustomAttributes (
2375 typeof (NemerleAttribute), true);
2376 Assert.AreEqual (1, attrs.Length, "#B3");
2377 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#B4");
2379 attrs = typeof (A).GetCustomAttributes (
2380 typeof (FooAttribute), false);
2381 Assert.AreEqual (1, attrs.Length, "#C1");
2382 Assert.AreEqual (typeof (FooAttribute), attrs [0].GetType (), "#C2");
2383 attrs = typeof (A).GetCustomAttributes (
2384 typeof (FooAttribute), false);
2385 Assert.AreEqual (1, attrs.Length, "#C3");
2386 Assert.AreEqual (typeof (FooAttribute), attrs [0].GetType (), "#C4");
2388 attrs = typeof (BA).GetCustomAttributes (
2389 typeof (VolatileModifier), false);
2390 Assert.AreEqual (0, attrs.Length, "#D1");
2391 attrs = typeof (BA).GetCustomAttributes (
2392 typeof (VolatileModifier), true);
2393 Assert.AreEqual (1, attrs.Length, "#D2");
2394 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#D3");
2396 attrs = typeof (BA).GetCustomAttributes (
2397 typeof (NemerleAttribute), false);
2398 Assert.AreEqual (0, attrs.Length, "#E1");
2399 attrs = typeof (BA).GetCustomAttributes (
2400 typeof (NemerleAttribute), true);
2401 Assert.AreEqual (1, attrs.Length, "#E2");
2402 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#E3");
2404 attrs = typeof (BA).GetCustomAttributes (
2405 typeof (FooAttribute), false);
2406 Assert.AreEqual (1, attrs.Length, "#F1");
2407 Assert.AreEqual (typeof (BarAttribute), attrs [0].GetType (), "#F2");
2408 attrs = typeof (BA).GetCustomAttributes (
2409 typeof (FooAttribute), true);
2410 Assert.AreEqual (1, attrs.Length, "#F3");
2411 Assert.AreEqual (typeof (BarAttribute), attrs [0].GetType (), "#F4");
2413 attrs = typeof (bug82431A1).GetCustomAttributes (
2414 typeof (InheritAttribute), false);
2415 Assert.AreEqual (1, attrs.Length, "#G1");
2416 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#G2");
2417 attrs = typeof (bug82431A1).GetCustomAttributes (
2418 typeof (InheritAttribute), true);
2419 Assert.AreEqual (1, attrs.Length, "#G3");
2420 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#G4");
2422 attrs = typeof (bug82431A1).GetCustomAttributes (
2423 typeof (NotInheritAttribute), false);
2424 Assert.AreEqual (1, attrs.Length, "#H1");
2425 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#H2");
2426 attrs = typeof (bug82431A1).GetCustomAttributes (
2427 typeof (InheritAttribute), true);
2428 Assert.AreEqual (1, attrs.Length, "#H3");
2429 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#H4");
2431 attrs = typeof (bug82431A2).GetCustomAttributes (
2432 typeof (InheritAttribute), false);
2433 Assert.AreEqual (0, attrs.Length, "#I1");
2434 attrs = typeof (bug82431A2).GetCustomAttributes (
2435 typeof (InheritAttribute), true);
2436 Assert.AreEqual (0, attrs.Length, "#I2");
2438 attrs = typeof (bug82431A2).GetCustomAttributes (
2439 typeof (NotInheritAttribute), false);
2440 Assert.AreEqual (0, attrs.Length, "#J1");
2441 attrs = typeof (bug82431A2).GetCustomAttributes (
2442 typeof (NotInheritAttribute), true);
2443 Assert.AreEqual (0, attrs.Length, "#J2");
2445 attrs = typeof (bug82431A3).GetCustomAttributes (
2446 typeof (InheritAttribute), false);
2447 Assert.AreEqual (2, attrs.Length, "#K1");
2448 Assert.IsTrue (HasAttribute (attrs, typeof (InheritAttribute)), "#K2");
2449 Assert.IsTrue (HasAttribute (attrs, typeof (NotInheritAttribute)), "#K3");
2450 attrs = typeof (bug82431A3).GetCustomAttributes (
2451 typeof (InheritAttribute), true);
2452 Assert.AreEqual (2, attrs.Length, "#K4");
2453 Assert.IsTrue (HasAttribute (attrs, typeof (InheritAttribute)), "#K5");
2454 Assert.IsTrue (HasAttribute (attrs, typeof (NotInheritAttribute)), "#K6");
2456 attrs = typeof (bug82431A3).GetCustomAttributes (
2457 typeof (NotInheritAttribute), false);
2458 Assert.AreEqual (1, attrs.Length, "#L1");
2459 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#L2");
2460 attrs = typeof (bug82431A3).GetCustomAttributes (
2461 typeof (NotInheritAttribute), true);
2462 Assert.AreEqual (1, attrs.Length, "#L3");
2463 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#L4");
2465 attrs = typeof (bug82431B1).GetCustomAttributes (
2466 typeof (InheritAttribute), false);
2467 Assert.AreEqual (1, attrs.Length, "#M1");
2468 Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#M2");
2469 attrs = typeof (bug82431B1).GetCustomAttributes (
2470 typeof (InheritAttribute), true);
2471 Assert.AreEqual (1, attrs.Length, "#M3");
2472 Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#M4");
2474 attrs = typeof (bug82431B1).GetCustomAttributes (
2475 typeof (NotInheritAttribute), false);
2476 Assert.AreEqual (0, attrs.Length, "#N1");
2477 attrs = typeof (bug82431B1).GetCustomAttributes (
2478 typeof (NotInheritAttribute), true);
2479 Assert.AreEqual (0, attrs.Length, "#N2");
2481 attrs = typeof (bug82431B2).GetCustomAttributes (
2482 typeof (InheritAttribute), false);
2483 Assert.AreEqual (0, attrs.Length, "#O1");
2484 attrs = typeof (bug82431B2).GetCustomAttributes (
2485 typeof (InheritAttribute), true);
2486 Assert.AreEqual (1, attrs.Length, "#O2");
2487 Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#O3");
2489 attrs = typeof (bug82431B2).GetCustomAttributes (
2490 typeof (NotInheritAttribute), false);
2491 Assert.AreEqual (0, attrs.Length, "#P1");
2492 attrs = typeof (bug82431B2).GetCustomAttributes (
2493 typeof (NotInheritAttribute), true);
2494 Assert.AreEqual (0, attrs.Length, "#P2");
2496 attrs = typeof (bug82431B3).GetCustomAttributes (
2497 typeof (InheritAttribute), false);
2498 Assert.AreEqual (1, attrs.Length, "#Q1");
2499 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#Q2");
2500 attrs = typeof (bug82431B3).GetCustomAttributes (
2501 typeof (InheritAttribute), true);
2502 Assert.AreEqual (2, attrs.Length, "#Q3");
2503 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#Q4");
2504 Assert.AreEqual (typeof (InheritAttribute), attrs [1].GetType (), "#Q5");
2506 attrs = typeof (bug82431B3).GetCustomAttributes (
2507 typeof (NotInheritAttribute), false);
2508 Assert.AreEqual (1, attrs.Length, "#R1");
2509 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#R2");
2510 attrs = typeof (bug82431B3).GetCustomAttributes (
2511 typeof (NotInheritAttribute), true);
2512 Assert.AreEqual (1, attrs.Length, "#R3");
2513 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#R4");
2515 attrs = typeof (bug82431B4).GetCustomAttributes (
2516 typeof (InheritAttribute), false);
2517 Assert.AreEqual (0, attrs.Length, "#S1");
2518 attrs = typeof (bug82431B4).GetCustomAttributes (
2519 typeof (InheritAttribute), true);
2520 Assert.AreEqual (1, attrs.Length, "#S2");
2521 Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#S3");
2523 attrs = typeof (bug82431B4).GetCustomAttributes (
2524 typeof (NotInheritAttribute), false);
2525 Assert.AreEqual (0, attrs.Length, "#T1");
2526 attrs = typeof (bug82431B4).GetCustomAttributes (
2527 typeof (NotInheritAttribute), true);
2528 Assert.AreEqual (0, attrs.Length, "#T2");
2530 attrs = typeof (A).GetCustomAttributes (
2531 typeof (string), false);
2532 Assert.AreEqual (0, attrs.Length, "#U1");
2533 attrs = typeof (A).GetCustomAttributes (
2534 typeof (string), true);
2535 Assert.AreEqual (0, attrs.Length, "#U2");
2538 [Test] // bug #76150
2539 public void IsDefined ()
2541 Assert.IsTrue (typeof (A).IsDefined (typeof (NemerleAttribute), false), "#A1");
2542 Assert.IsTrue (typeof (A).IsDefined (typeof (VolatileModifier), false), "#A2");
2543 Assert.IsTrue (typeof (A).IsDefined (typeof (FooAttribute), false), "#A3");
2544 Assert.IsFalse (typeof (A).IsDefined (typeof (BarAttribute), false), "#A4");
2546 Assert.IsFalse (typeof (BA).IsDefined (typeof (NemerleAttribute), false), "#B1");
2547 Assert.IsFalse (typeof (BA).IsDefined (typeof (VolatileModifier), false), "#B2");
2548 Assert.IsTrue (typeof (BA).IsDefined (typeof (FooAttribute), false), "#B3");
2549 Assert.IsTrue (typeof (BA).IsDefined (typeof (BarAttribute), false), "#B4");
2550 Assert.IsFalse (typeof (BA).IsDefined (typeof (string), false), "#B5");
2551 Assert.IsFalse (typeof (BA).IsDefined (typeof (int), false), "#B6");
2552 Assert.IsTrue (typeof (BA).IsDefined (typeof (NemerleAttribute), true), "#B7");
2553 Assert.IsTrue (typeof (BA).IsDefined (typeof (VolatileModifier), true), "#B8");
2554 Assert.IsTrue (typeof (BA).IsDefined (typeof (FooAttribute), true), "#B9");
2555 Assert.IsTrue (typeof (BA).IsDefined (typeof (BarAttribute), true), "#B10");
2556 Assert.IsFalse (typeof (BA).IsDefined (typeof (string), true), "#B11");
2557 Assert.IsFalse (typeof (BA).IsDefined (typeof (int), true), "#B12");
2561 public void IsDefined_AttributeType_Null ()
2564 typeof (BA).IsDefined ((Type) null, false);
2566 } catch (ArgumentNullException ex) {
2567 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2568 Assert.IsNull (ex.InnerException, "#3");
2569 Assert.IsNotNull (ex.Message, "#4");
2570 Assert.IsNotNull (ex.ParamName, "#5");
2571 Assert.AreEqual ("attributeType", ex.ParamName, "#6");
2575 [Test] // bug #82431
2576 [Category ("NotWorking")]
2577 public void IsDefined_Inherited ()
2579 Assert.IsFalse (typeof (CA).IsDefined (typeof (NemerleAttribute), false), "#C1");
2580 Assert.IsFalse (typeof (CA).IsDefined (typeof (VolatileModifier), false), "#C2");
2581 Assert.IsFalse (typeof (CA).IsDefined (typeof (FooAttribute), false), "#C3");
2582 Assert.IsFalse (typeof (CA).IsDefined (typeof (BarAttribute), false), "#C4");
2583 Assert.IsTrue (typeof (CA).IsDefined (typeof (NemerleAttribute), true), "#C5");
2584 Assert.IsTrue (typeof (CA).IsDefined (typeof (VolatileModifier), true), "#C6");
2585 Assert.IsFalse (typeof (CA).IsDefined (typeof (FooAttribute), true), "#C7");
2586 Assert.IsFalse (typeof (CA).IsDefined (typeof (BarAttribute), true), "#C8");
2588 Assert.IsFalse (typeof (BBA).IsDefined (typeof (NemerleAttribute), false), "#D1");
2589 Assert.IsFalse (typeof (BBA).IsDefined (typeof (VolatileModifier), false), "#D2");
2590 Assert.IsFalse (typeof (BBA).IsDefined (typeof (FooAttribute), false), "#D3");
2591 Assert.IsFalse (typeof (BBA).IsDefined (typeof (BarAttribute), false), "#D4");
2592 Assert.IsTrue (typeof (BBA).IsDefined (typeof (NemerleAttribute), true), "#D5");
2593 Assert.IsTrue (typeof (BBA).IsDefined (typeof (VolatileModifier), true), "#D6");
2594 Assert.IsTrue (typeof (BBA).IsDefined (typeof (FooAttribute), true), "#D7");
2595 Assert.IsTrue (typeof (BBA).IsDefined (typeof (BarAttribute), true), "#D8");
2597 Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (InheritAttribute), false), "#E1");
2598 Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (NotInheritAttribute), false), "#E2");
2599 Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (InheritAttribute), true), "#E3");
2600 Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (NotInheritAttribute), true), "#E4");
2602 Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (InheritAttribute), false), "#F1");
2603 Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (NotInheritAttribute), false), "#F2");
2604 Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (InheritAttribute), true), "#F3");
2605 Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (NotInheritAttribute), true), "#F4");
2607 Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (InheritAttribute), false), "#G1");
2608 Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (NotInheritAttribute), false), "#G2");
2609 Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (InheritAttribute), true), "#G3");
2610 Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (NotInheritAttribute), true), "#G4");
2612 Assert.IsTrue (typeof (bug82431B1).IsDefined (typeof (InheritAttribute), false), "#H1");
2613 Assert.IsFalse (typeof (bug82431B1).IsDefined (typeof (NotInheritAttribute), false), "#H2");
2614 Assert.IsTrue (typeof (bug82431B1).IsDefined (typeof (InheritAttribute), true), "#H3");
2615 Assert.IsFalse (typeof (bug82431B1).IsDefined (typeof (NotInheritAttribute), true), "#H4");
2617 Assert.IsFalse (typeof (bug82431B2).IsDefined (typeof (InheritAttribute), false), "#I1");
2618 Assert.IsFalse (typeof (bug82431B2).IsDefined (typeof (NotInheritAttribute), false), "#I2");
2619 Assert.IsTrue (typeof (bug82431B2).IsDefined (typeof (InheritAttribute), true), "#I3");
2620 Assert.IsFalse (typeof (bug82431B2).IsDefined (typeof (NotInheritAttribute), true), "#I4");
2622 Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (InheritAttribute), false), "#J1");
2623 Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (NotInheritAttribute), false), "#J2");
2624 Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (InheritAttribute), true), "#J3");
2625 Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (NotInheritAttribute), true), "#J4");
2627 Assert.IsFalse (typeof (bug82431B4).IsDefined (typeof (InheritAttribute), false), "#K2");
2628 Assert.IsFalse (typeof (bug82431B4).IsDefined (typeof (NotInheritAttribute), false), "#K2");
2629 Assert.IsTrue (typeof (bug82431B4).IsDefined (typeof (InheritAttribute), true), "#K3");
2630 Assert.IsFalse (typeof (bug82431B4).IsDefined (typeof (NotInheritAttribute), true), "#K4");
2633 class Bug13767Attribute : Attribute
2635 public object[] field;
2637 public Bug13767Attribute (params object[] args)
2643 public enum Bug13767Enum
2649 [Bug13767("Demo", new[] { Bug13767Enum.Value1, Bug13767Enum.Value0 })]
2650 public void Bug13767Method(string attributeName, Bug13767Enum[]options)
2656 public void CustomAttributeWithNestedArrayOfEnum ()
2658 var m = GetType ().GetMethod ("Bug13767Method");
2660 var attr = m.GetCustomAttributes (false);
2661 Assert.AreEqual (1, attr.Length, "#1");
2663 var tc = (Bug13767Attribute)attr[0];
2664 Assert.AreEqual (2, tc.field.Length, "#2");
2665 Assert.AreEqual ("Demo", tc.field[0], "#3");
2666 Assert.IsNotNull (tc.field[1], "#4");
2668 var arr = (Bug13767Enum[])tc.field [1];
2669 Assert.AreEqual (2, arr.Length, "#5");
2670 Assert.AreEqual (Bug13767Enum.Value1, arr [0], "#6");
2671 Assert.AreEqual (Bug13767Enum.Value0, arr [1], "#7");
2674 [Test] // GetType (String)
2675 public void GetType1_TypeName_Null ()
2678 Type.GetType ((string) null);
2680 } catch (ArgumentNullException ex) {
2681 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2682 Assert.IsNull (ex.InnerException, "#3");
2683 Assert.IsNotNull (ex.Message, "#4");
2684 Assert.AreEqual ("TypeName", ex.ParamName, "#5");
2688 [Test] // GetType (String, Boolean)
2689 public void GetType2_TypeName_Null ()
2692 Type.GetType ((string) null, false);
2694 } catch (ArgumentNullException ex) {
2695 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2696 Assert.IsNull (ex.InnerException, "#3");
2697 Assert.IsNotNull (ex.Message, "#4");
2698 Assert.AreEqual ("TypeName", ex.ParamName, "#5");
2702 [Test] // GetType (String, Boolean, Boolean)
2703 public void GetType3_TypeName_Null ()
2706 Type.GetType ((string) null, false, false);
2708 } catch (ArgumentNullException ex) {
2709 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2710 Assert.IsNull (ex.InnerException, "#3");
2711 Assert.IsNotNull (ex.Message, "#4");
2712 Assert.AreEqual ("TypeName", ex.ParamName, "#5");
2717 public void GetTypeArray_Args_Null ()
2720 Type.GetTypeArray ((object []) null);
2722 } catch (ArgumentNullException ex) {
2723 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2724 Assert.IsNull (ex.InnerException, "#3");
2725 Assert.IsNotNull (ex.Message, "#4");
2726 Assert.AreEqual ("args", ex.ParamName, "#5");
2731 public void GetTypeCode ()
2733 Assert.AreEqual (TypeCode.Boolean, Type.GetTypeCode (typeof (bool)), "#1");
2734 Assert.AreEqual (TypeCode.Byte, Type.GetTypeCode (typeof (byte)), "#2");
2735 Assert.AreEqual (TypeCode.Char, Type.GetTypeCode (typeof (char)), "#3");
2736 Assert.AreEqual (TypeCode.DateTime, Type.GetTypeCode (typeof (DateTime)), "#4");
2737 Assert.AreEqual (TypeCode.DBNull, Type.GetTypeCode (typeof (DBNull)), "#5");
2738 Assert.AreEqual (TypeCode.Decimal, Type.GetTypeCode (typeof (decimal)), "#6");
2739 Assert.AreEqual (TypeCode.Double, Type.GetTypeCode (typeof (double)), "#7");
2740 Assert.AreEqual (TypeCode.Empty, Type.GetTypeCode (null), "#8");
2741 Assert.AreEqual (TypeCode.Int16, Type.GetTypeCode (typeof (short)), "#9");
2742 Assert.AreEqual (TypeCode.Int32, Type.GetTypeCode (typeof (int)), "#10");
2743 Assert.AreEqual (TypeCode.Int64, Type.GetTypeCode (typeof (long)), "#11");
2744 Assert.AreEqual (TypeCode.Object, Type.GetTypeCode (typeof (TakesInt)), "#12");
2745 Assert.AreEqual (TypeCode.SByte, Type.GetTypeCode (typeof (sbyte)), "#13");
2746 Assert.AreEqual (TypeCode.Single, Type.GetTypeCode (typeof (float)), "#14");
2747 Assert.AreEqual (TypeCode.String, Type.GetTypeCode (typeof (string)), "#15");
2748 Assert.AreEqual (TypeCode.UInt16, Type.GetTypeCode (typeof (ushort)), "#16");
2749 Assert.AreEqual (TypeCode.UInt32, Type.GetTypeCode (typeof (uint)), "#17");
2750 Assert.AreEqual (TypeCode.UInt64, Type.GetTypeCode (typeof (ulong)), "#18");
2754 public void GetTypeFromHandle_Handle_Zero ()
2756 RuntimeTypeHandle handle = new RuntimeTypeHandle ();
2758 Assert.IsNull (Type.GetTypeFromHandle (handle));
2762 public void GetTypeHandle_O_Null ()
2765 Type.GetTypeHandle (null);
2767 } catch (ArgumentNullException ex) {
2768 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2769 Assert.IsNull (ex.InnerException, "#3");
2770 Assert.IsNotNull (ex.Message, "#4");
2771 Assert.IsNull (ex.ParamName, "#5");
2775 [Test] // GetConstructor (Type [])
2776 public void GetConstructor1 ()
2779 ConstructorInfo ctor;
2781 type = typeof (CtorsA);
2782 ctor = type.GetConstructor (Type.EmptyTypes);
2783 Assert.IsNotNull (ctor, "#A1");
2784 Assert.AreEqual (0, ctor.GetParameters ().Length, "#A2");
2785 Assert.IsFalse (ctor.IsStatic, "#A3");
2786 Assert.IsTrue (ctor.IsPublic, "#A4");
2787 Assert.AreEqual (".ctor", ctor.Name, "#A5");
2789 type = typeof (CtorsB);
2790 ctor = type.GetConstructor (Type.EmptyTypes);
2791 Assert.IsNotNull (ctor, "#B1");
2792 Assert.AreEqual (0, ctor.GetParameters ().Length, "#B2");
2793 Assert.IsFalse (ctor.IsStatic, "#B3");
2794 Assert.IsTrue (ctor.IsPublic, "#B4");
2795 Assert.AreEqual (".ctor", ctor.Name, "#B5");
2797 type = typeof (CtorsC);
2798 ctor = type.GetConstructor (Type.EmptyTypes);
2799 Assert.IsNull (ctor, "#C");
2801 type = typeof (CtorsC);
2802 ctor = type.GetConstructor (new Type [] { typeof (int) });
2803 Assert.IsNotNull (ctor, "#D1");
2804 Assert.AreEqual (1, ctor.GetParameters ().Length, "#D2");
2805 Assert.IsFalse (ctor.IsStatic, "#D3");
2806 Assert.IsTrue (ctor.IsPublic, "#D4");
2807 Assert.AreEqual (".ctor", ctor.Name, "#D5");
2810 [Test] // GetConstructor (Type [])
2811 public void GetConstructor1_Types_Null ()
2814 typeof (BindingFlags).GetConstructor (null);
2816 } catch (ArgumentNullException ex) {
2817 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2818 Assert.IsNull (ex.InnerException, "#3");
2819 Assert.IsNotNull (ex.Message, "#4");
2820 Assert.IsNotNull (ex.ParamName, "#5");
2821 Assert.AreEqual ("types", ex.ParamName, "#6");
2825 [Test] // GetConstructor (Type [])
2826 public void GetConstructor1_Types_ItemNull ()
2828 Type type = typeof (BindingFlags);
2830 type.GetConstructor (new Type[1] { null });
2831 Assert.Fail ("#A1");
2832 } catch (ArgumentNullException ex) {
2833 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
2834 Assert.IsNull (ex.InnerException, "#A3");
2835 Assert.IsNotNull (ex.Message, "#A4");
2836 Assert.IsNotNull (ex.ParamName, "#A5");
2837 Assert.AreEqual ("types", ex.ParamName, "#A6");
2840 type = typeof (TakesInt);
2842 type.GetConstructor (new Type [1] { null });
2843 Assert.Fail ("#B1");
2844 } catch (ArgumentNullException ex) {
2845 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
2846 Assert.IsNull (ex.InnerException, "#B3");
2847 Assert.IsNotNull (ex.Message, "#B4");
2848 Assert.IsNotNull (ex.ParamName, "#B5");
2849 Assert.AreEqual ("types", ex.ParamName, "#B6");
2853 [Test] // GetConstructor (BindingFlags, Binder, Type [], ParameterModifier [])
2854 public void GetConstructor2_Types_ItemNull ()
2856 Type type = typeof (BindingFlags);
2858 type.GetConstructor (BindingFlags.Default, null,
2859 new Type[1] { null }, null);
2861 } catch (ArgumentNullException ex) {
2862 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2863 Assert.IsNull (ex.InnerException, "#3");
2864 Assert.IsNotNull (ex.Message, "#4");
2865 Assert.IsNotNull (ex.ParamName, "#5");
2866 Assert.AreEqual ("types", ex.ParamName, "#6");
2870 [Test] // GetConstructor (BindingFlags, Binder, CallingConventions, Type [], ParameterModifier [])
2871 public void GetConstructor3_Types_ItemNull ()
2873 Type type = typeof (BindingFlags);
2875 type.GetConstructor (BindingFlags.Default,
2876 null, CallingConventions.Any,
2877 new Type[1] { null }, null);
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");
2889 public void GetMethod_Bug77367 ()
2891 MethodInfo i = typeof (Bug77367).GetMethod ("Run", Type.EmptyTypes);
2897 public void EqualsUnderlyingType ()
2899 AssemblyBuilderAccess access = AssemblyBuilderAccess.RunAndSave;
2900 TypeAttributes attribs = TypeAttributes.Public;
2902 AssemblyName name = new AssemblyName ();
2903 name.Name = "enumtest";
2904 AssemblyBuilder assembly =
2905 AppDomain.CurrentDomain.DefineDynamicAssembly (
2908 ModuleBuilder module = assembly.DefineDynamicModule
2909 ("m", "enumtest.dll");
2910 EnumBuilder e = module.DefineEnum ("E", attribs, typeof (int));
2912 Assert.IsTrue (typeof (int).Equals (e));
2917 public void Equals_Type_Null ()
2919 Assert.IsFalse (typeof (int).Equals ((Type) null), "#1");
2920 Assert.IsFalse (typeof (int).Equals ((object) null), "#2");
2924 public void GetElementType_Bug63841 ()
2926 Assert.IsNull (typeof (TheEnum).GetElementType (), "#1");
2930 public void FullNameGenerics ()
2932 Type fooType = typeof (Foo<>);
2933 FieldInfo [] fields = fooType.GetFields ();
2935 Assert.AreEqual (1, fields.Length, "#0");
2937 Assert.IsNotNull (fooType.FullName, "#1");
2938 Assert.IsNotNull (fooType.AssemblyQualifiedName, "#1a");
2940 FieldInfo field = fooType.GetField ("Whatever");
2941 Assert.IsNotNull (field, "#2");
2942 Assert.AreEqual (field, fields [0], "#2a");
2943 Assert.IsNull (field.FieldType.FullName, "#3");
2944 Assert.IsNull (field.FieldType.AssemblyQualifiedName, "#3a");
2945 Assert.IsNotNull (field.FieldType.ToString (), "#4");
2947 PropertyInfo prop = fooType.GetProperty ("Test");
2948 Assert.IsNotNull (prop, "#5");
2949 Assert.IsNull (prop.PropertyType.FullName, "#6");
2950 Assert.IsNull (prop.PropertyType.AssemblyQualifiedName, "#6a");
2951 Assert.IsNotNull (prop.PropertyType.ToString (), "#7");
2953 MethodInfo method = fooType.GetMethod("Execute");
2954 Assert.IsNotNull (method, "#8");
2955 Assert.IsNull (method.ReturnType.FullName, "#9");
2956 Assert.IsNull (method.ReturnType.AssemblyQualifiedName, "#9a");
2957 Assert.IsNotNull (method.ReturnType.ToString (), "#10");
2959 ParameterInfo[] parameters = method.GetParameters();
2960 Assert.AreEqual (1, parameters.Length, "#11");
2961 Assert.IsNull (parameters[0].ParameterType.FullName, "#12");
2962 Assert.IsNull (parameters[0].ParameterType.AssemblyQualifiedName, "#12a");
2963 Assert.IsNotNull (parameters[0].ParameterType.ToString (), "#13");
2967 public void TypeParameterIsNotGeneric ()
2969 Type fooType = typeof (Foo<>);
2970 Type type_param = fooType.GetGenericArguments () [0];
2971 Assert.IsTrue (type_param.IsGenericParameter);
2972 Assert.IsFalse (type_param.IsGenericType);
2973 Assert.IsFalse (type_param.IsGenericTypeDefinition);
2975 // LAMESPEC: MSDN claims that this should be false, but .NET v2.0.50727 says it's true
2976 // http://msdn2.microsoft.com/en-us/library/system.type.isgenerictype.aspx
2977 Assert.IsTrue (type_param.ContainsGenericParameters);
2981 public void IsAssignable ()
2983 Type foo_type = typeof (Foo<>);
2984 Type foo_int_type = typeof (Foo<int>);
2985 Assert.IsFalse (foo_type.IsAssignableFrom (foo_int_type), "Foo<int> -!-> Foo<>");
2986 Assert.IsFalse (foo_int_type.IsAssignableFrom (foo_type), "Foo<> -!-> Foo<int>");
2988 Type ibar_short_type = typeof (IBar<short>);
2989 Type ibar_int_type = typeof (IBar<int>);
2990 Type baz_short_type = typeof (Baz<short>);
2991 Type baz_int_type = typeof (Baz<int>);
2993 Assert.IsTrue (ibar_int_type.IsAssignableFrom (baz_int_type), "Baz<int> -> IBar<int>");
2994 Assert.IsTrue (ibar_short_type.IsAssignableFrom (baz_short_type), "Baz<short> -> IBar<short>");
2996 Assert.IsFalse (ibar_int_type.IsAssignableFrom (baz_short_type), "Baz<short> -!-> IBar<int>");
2997 Assert.IsFalse (ibar_short_type.IsAssignableFrom (baz_int_type), "Baz<int> -!-> IBar<short>");
3000 Assert.IsTrue (typeof (Nullable<int>).IsAssignableFrom (typeof (int)));
3001 Assert.IsFalse (typeof (int).IsAssignableFrom (typeof (Nullable<int>)));
3002 Assert.IsTrue (typeof (Nullable<FooStruct>).IsAssignableFrom (typeof (FooStruct)));
3006 public void IsInstanceOf ()
3008 Assert.IsTrue (typeof (Nullable<int>).IsInstanceOfType (5));
3012 public void IsInstanceOfArrayOfNullable ()
3014 Assert.IsTrue (typeof (Nullable<int>[]).IsInstanceOfType (new Nullable<int> [0]));
3018 public void IsInstanceOfType_Null ()
3020 Assert.IsFalse (typeof (int).IsInstanceOfType (null), "int");
3021 Assert.IsFalse (typeof (object).IsInstanceOfType (null), "object");
3022 Assert.IsFalse (typeof (int?).IsInstanceOfType (null), "int?");
3026 public void ByrefType ()
3028 Type foo_type = typeof (Foo<>);
3029 Type type_param = foo_type.GetGenericArguments () [0];
3030 Type byref_type_param = type_param.MakeByRefType ();
3031 Assert.IsFalse (byref_type_param.IsGenericParameter);
3032 Assert.IsNull (byref_type_param.DeclaringType);
3036 [ExpectedException (typeof (TypeLoadException))]
3037 public void MakeByRefByRef ()
3039 typeof (int).MakeByRefType ().MakeByRefType ();
3043 public void MakeArrayTypeTest ()
3045 // This should not crash:
3046 typeof (void).MakeArrayType ();
3051 public class ComFoo<T> {
3055 public void GetCustomAttributesGenericInstance ()
3057 Assert.AreEqual (1, typeof (ComFoo<int>).GetCustomAttributes (typeof (ComVisibleAttribute), true).Length);
3060 interface ByRef1<T> { void f (ref T t); }
3061 interface ByRef2 { void f<T> (ref T t); }
3063 interface ByRef3<T> where T:struct { void f (ref T? t); }
3064 interface ByRef4 { void f<T> (ref T? t) where T:struct; }
3066 void CheckGenericByRef (Type t)
3068 string name = t.Name;
3069 t = t.GetMethod ("f").GetParameters () [0].ParameterType;
3071 Assert.IsFalse (t.IsGenericType, name);
3072 Assert.IsFalse (t.IsGenericTypeDefinition, name);
3073 Assert.IsFalse (t.IsGenericParameter, name);
3077 public void GenericByRef ()
3079 CheckGenericByRef (typeof (ByRef1<>));
3080 CheckGenericByRef (typeof (ByRef2));
3081 CheckGenericByRef (typeof (ByRef3<>));
3082 CheckGenericByRef (typeof (ByRef4));
3085 public class Bug80242<T> {
3086 public interface IFoo { }
3087 public class Bar : IFoo { }
3088 public class Baz : Bar { }
3092 public void TestNestedTypes ()
3094 Type t = typeof (Bug80242<object>);
3095 Assert.IsFalse (t.IsGenericTypeDefinition);
3096 foreach (Type u in t.GetNestedTypes ()) {
3097 Assert.IsTrue (u.IsGenericTypeDefinition, "{0} isn't a generic definition", u);
3098 Assert.AreEqual (u, u.GetGenericArguments () [0].DeclaringType);
3102 [Test] // bug #82211
3103 public void GetMembers_GenericArgument ()
3105 Type argType = typeof (ComFoo<>).GetGenericArguments () [0];
3106 MemberInfo [] members = argType.GetMembers ();
3107 Assert.IsNotNull (members, "#1");
3108 Assert.AreEqual (4, members.Length, "#2");
3112 [ExpectedException (typeof (ArgumentNullException))]
3113 public void ReflectionOnlyGetTypeNullTypeName ()
3115 Type.ReflectionOnlyGetType (null, false, false);
3119 public void ReflectionOnlyGetTypeDoNotThrow ()
3121 Assert.IsNull (Type.ReflectionOnlyGetType ("a, nonexistent.dll", false, false));
3125 [ExpectedException (typeof (FileNotFoundException))]
3126 public void ReflectionOnlyGetTypeThrow ()
3128 Type.ReflectionOnlyGetType ("a, nonexistent.dll", true, false);
3132 public void ReflectionOnlyGetType ()
3134 Type t = Type.ReflectionOnlyGetType (typeof (int).AssemblyQualifiedName.ToString (), true, true);
3135 Assert.AreEqual ("System.Int32", t.FullName);
3139 #if MONOTOUCH || MOBILE_STATIC
3140 [ExpectedException (typeof (NotSupportedException))]
3142 public void MakeGenericType_UserDefinedType ()
3144 Type ut = new UserType (typeof (int));
3145 Type t = typeof (Foo<>).MakeGenericType (ut);
3146 Assert.IsTrue (t.IsGenericType, "#A1");
3147 Assert.AreEqual (1, t.GetGenericArguments ().Length, "#A2");
3149 Type arg = t.GetGenericArguments () [0];
3150 Assert.IsNotNull (arg, "#B1");
3151 Assert.IsFalse (arg.IsGenericType, "#B2");
3152 Assert.AreEqual (ut, arg, "#B3");
3156 #if MONOTOUCH || MOBILE_STATIC
3157 [ExpectedException (typeof (NotSupportedException))]
3159 public void MakeGenericType_NestedUserDefinedType ()
3161 Type ut = new UserType (new UserType (typeof (int)));
3162 Type t = typeof (Foo<>).MakeGenericType (ut);
3163 Assert.IsTrue (t.IsGenericType, "#A1");
3164 Assert.AreEqual (1, t.GetGenericArguments ().Length, "#A2");
3166 Type arg = t.GetGenericArguments () [0];
3167 Assert.IsNotNull (arg, "#B1");
3168 Assert.IsFalse (arg.IsGenericType, "#B2");
3169 Assert.AreEqual (ut, arg, "#B3");
3173 #if MONOTOUCH || MOBILE_STATIC
3174 [ExpectedException (typeof (NotSupportedException))]
3176 public void TestMakeGenericType_UserDefinedType_DotNet20SP1 ()
3178 Type ut = new UserType(typeof(int));
3179 Type t = typeof(Foo<>).MakeGenericType(ut);
3180 Assert.IsTrue (t.IsGenericType, "#1");
3182 Assert.AreEqual (ut, t.GetGenericArguments()[0], "#2");
3186 #if MONOTOUCH || MOBILE_STATIC
3187 [ExpectedException (typeof (NotSupportedException))]
3189 public void MakeGenericType_BadUserType ()
3191 Type ut = new UserType (null);
3192 Type t = typeof (Foo<>).MakeGenericType (ut);
3193 var g0 = t.GetGenericArguments () [0];
3194 Assert.AreSame (g0, ut, "#1");
3198 public void MakeGenericType_WrongNumOfArguments ()
3201 Type t = typeof (Foo<,>).MakeGenericType (new Type [] { typeof (int) });
3203 } catch (ArgumentException) {
3207 [AttributeUsage (AttributeTargets.All)]
3208 public class DocAttribute : Attribute {
3209 public DocAttribute (string docs) {}
3212 class GenericClassWithAttributes<[Doc ("T")] T, [Doc ("B")] B>
3213 where T : class, new ()
3216 public T Bar { get{return null;}}
3218 public void M<[Doc ("X")] X> (X x)
3223 [Test] //bug #377596
3224 public void GetGenericArguments_ArgumentsHaveAttributes ()
3226 Type type = typeof(GenericClassWithAttributes<,>);
3227 Type[] tArgs = type.GetGenericArguments ();
3228 MethodInfo m = type.GetMethod ("M");
3229 Type[] mArgs = m.GetGenericArguments ();
3230 Assert.AreEqual(1, tArgs[0].GetCustomAttributes (typeof (DocAttribute), true).Length, "#1");
3231 Assert.AreEqual(1, tArgs[1].GetCustomAttributes (typeof (DocAttribute), true).Length, "#1");
3232 Assert.AreEqual(1, mArgs[0].GetCustomAttributes (typeof (DocAttribute), true).Length, "#1");
3235 [Test] //bug #471255
3236 public void GetTypeCalledUsingReflection ()
3238 Type expectedType = Type.GetType ("NoNamespaceClass");
3239 Assert.IsNotNull (expectedType, "#1");
3240 MethodInfo m = typeof (Type).GetMethod ("GetType", BindingFlags.Public | BindingFlags.Static, null, new Type [] { typeof (string) }, null);
3241 object r = m.Invoke (null, BindingFlags.Default, null, new object [] { "NoNamespaceClass" }, CultureInfo.InvariantCulture);
3242 Assert.AreSame (expectedType, r, "#2");
3246 public void EqualsUserType () {
3247 UserType2 t1 = new UserType2(null);
3248 UserType2 t2 = new UserType2(t1);
3249 Assert.IsTrue (t1.Equals(t2));
3253 public void GetHashCodeUserType () {
3254 UserType2 t1 = new UserType2(null);
3255 UserType2 t2 = new UserType2(t1);
3256 Assert.AreEqual (42, t2.GetHashCode());
3260 public void IsGenericTypeDefinitionUserType () {
3261 Assert.IsFalse (new UserType(null).IsGenericTypeDefinition);
3265 public void IsGenericTypeUserType () {
3266 Assert.IsFalse (new UserType(null).IsGenericType);
3270 [ExpectedException (typeof (NotSupportedException))]
3271 public void GetGenericTypeDefinitionUserType () {
3272 new UserType(null).GetGenericTypeDefinition ();
3275 [ExpectedException (typeof (NotSupportedException))]
3276 public void GetGenericArgumentsUserType () {
3277 new UserType(null).GetGenericArguments ();
3281 [ExpectedException (typeof (InvalidOperationException))]
3282 public void GenericParameterPositionUserType () {
3283 Assert.IsTrue (new UserType(null).GenericParameterPosition == 0);
3287 public void TypeGetMemberReturnTypeTest ()
3290 MemberTypes memtype;
3292 object [] flagsandtypes = new object [] {
3293 MemberTypes.All, typeof (MemberInfo []),
3294 MemberTypes.Constructor, typeof (ConstructorInfo []),
3295 MemberTypes.Custom, typeof (MemberInfo []),
3296 MemberTypes.Event, typeof (EventInfo []),
3297 MemberTypes.Field, typeof (FieldInfo []),
3298 MemberTypes.Method, typeof (MethodInfo []),
3299 MemberTypes.NestedType, typeof (Type []),
3300 MemberTypes.Property, typeof (PropertyInfo []),
3301 MemberTypes.TypeInfo, typeof (Type [])};
3303 for (int i=0; i < flagsandtypes.Length; i+=2) {
3304 memtype = (MemberTypes)flagsandtypes [i];
3305 testtype = (Type)flagsandtypes [i+1];
3306 obj = GetType ().GetMember ("DummyMember", memtype,
3307 BindingFlags.Public | BindingFlags.Instance);
3308 Assert.AreEqual (testtype.GetHashCode (), obj.GetType ().GetHashCode (),
3309 "Expected #" + i + " " + testtype.FullName);
3315 public void TypeNameStartsWithSpace ()
3317 Type t1 = Type.GetType ("System.Type, mscorlib");
3318 Type t2 = Type.GetType (" System.Type, mscorlib");
3319 Assert.AreEqual (t1, t2);
3322 #if !MONOTOUCH && !MOBILE_STATIC
3324 public void SpaceAfterComma () {
3325 string strType = "System.Collections.Generic.Dictionary`2[[System.Int32,mscorlib], [System.String,mscorlib]],mscorlib";
3326 Assert.IsTrue (Type.GetType (strType) != null);
3330 #if !MONOTOUCH && !MOBILE_STATIC
3332 public void Bug506757 ()
3334 AssemblyName assemblyName = new AssemblyName ();
3335 assemblyName.Name = "customMod";
3336 assemblyName.Version = new Version (1, 2, 3, 4);
3338 AssemblyBuilder assembly
3339 = Thread.GetDomain().DefineDynamicAssembly(
3340 assemblyName, AssemblyBuilderAccess.RunAndSave);
3342 ModuleBuilder module = assembly.DefineDynamicModule("res.exe", "res.exe");
3344 TypeBuilder type0 = module.DefineType ("Base", TypeAttributes.Public, typeof (object));
3345 TypeBuilder type1 = module.DefineType ("Middle", TypeAttributes.Public, type0);
3346 TypeBuilder type2 = module.DefineType ("End", TypeAttributes.Public, type1);
3348 MethodAttributes attrs0 = MethodAttributes.Virtual | MethodAttributes.HideBySig |
3349 MethodAttributes.NewSlot | MethodAttributes.FamORAssem;
3351 MethodAttributes attrs1 = MethodAttributes.Virtual | MethodAttributes.HideBySig |
3352 MethodAttributes.FamORAssem;
3354 MethodAttributes attrs2 = MethodAttributes.Virtual | MethodAttributes.HideBySig |
3355 MethodAttributes.Public;
3358 MethodBuilder m0 = type0.DefineMethod ("Tst", attrs0, typeof (void), null);
3359 m0.GetILGenerator ().Emit (OpCodes.Ret);
3361 MethodBuilder m1 = type1.DefineMethod ("Tst", attrs1, typeof (void), null);
3362 m1.GetILGenerator ().Emit (OpCodes.Ret);
3364 MethodBuilder m2 = type2.DefineMethod ("Tst", attrs2, typeof (void), null);
3365 m2.GetILGenerator ().Emit (OpCodes.Ret);
3368 type0.CreateType ();
3369 type1.CreateType ();
3370 Type t2 = type2.CreateType ();
3372 foreach (var m in t2.GetMethods (BindingFlags.Instance | BindingFlags.NonPublic))
3373 Assert.IsTrue (m.DeclaringType == typeof (object), String.Format ("{0}::{1}", m.DeclaringType, m.Name));
3377 public void MakeArrayTypeOfOneDimension ()
3379 Type vector = typeof (int).MakeArrayType ();
3380 Type szarray = typeof (int).MakeArrayType (1);
3382 Assert.AreNotEqual (vector, szarray, "#1");
3383 Assert.AreEqual ("Int32[]", vector.Name, "#2");
3384 Assert.AreEqual ("Int32[*]", szarray.Name, "#3");
3387 public class DeclaringMethodFoo {
3388 public void Test<T> (T t) {}
3389 public void Test2<T> (ref T t) {}
3392 public class DeclaringMethodBar<T> {
3393 public void Test2 (ref T t) {}
3397 public void DeclaringMethodOnlyWorksWithGenericArgs ()
3399 MethodInfo testMethod = typeof (DeclaringMethodFoo).GetMethod ("Test");
3400 MethodBase otherMethod = testMethod.GetParameters ()[0].ParameterType.DeclaringMethod;
3402 Assert.AreEqual (testMethod, otherMethod,"#1");
3404 Assert.IsNull (typeof (DeclaringMethodBar<>).GetGenericArguments ()[0].DeclaringMethod, "#2");
3407 var x = typeof (int).DeclaringMethod;
3409 } catch (InvalidOperationException) {}
3412 var x = typeof (DeclaringMethodFoo).GetMethod ("Test2").GetParameters () [0].ParameterType.DeclaringMethod;
3414 } catch (InvalidOperationException) {}
3417 var x = typeof (DeclaringMethodBar<>).GetMethod ("Test2").GetParameters () [0].ParameterType.DeclaringMethod;
3419 } catch (InvalidOperationException) {}
3424 public void GetArrayRankThrowsForNonArrayType ()
3426 Assert.AreEqual (1, typeof (int[]).GetArrayRank (), "#1");
3427 Assert.AreEqual (2, typeof (int[,]).GetArrayRank (), "#2");
3429 typeof (int).GetArrayRank ();
3431 } catch (ArgumentException) {}
3434 [Test] //Bug #564379
3435 public void GetMethodsReturnPublicMethodsInInterfaces ()
3437 Type t = typeof (NonClosingStream);
3438 MethodInfo[] methods = t.GetMethods (BindingFlags.Public | BindingFlags.Instance);
3440 Assert.AreEqual (5, methods.Length, "#1");
3443 foreach (var m in methods) {
3444 if (m.Name.Equals ("ToString"))
3445 Assert.IsTrue (m.DeclaringType == typeof (NonClosingStream), "#" + id);
3446 else if (m.Name.Equals ("Dispose") && m.GetParameters ().Length == 0)
3447 Assert.IsTrue (m.DeclaringType == typeof (Stream), "#" + id);
3448 else if (m.Name.Equals ("Equals") || m.Name.Equals ("GetHashCode") || m.Name.Equals ("GetType"))
3449 Assert.IsTrue (m.DeclaringType == typeof (object), "#" + id);
3451 Assert.Fail ("invalid method " + m);
3456 [Test] // Bug #574696
3457 public void GetMember_DoesntReturnPrivatePropOfParent ()
3459 BindingFlags flags = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance;
3460 Assert.AreEqual (1, typeof (Bar).GetMember ("PrivInst", flags).Length);
3461 Assert.AreEqual (0, typeof (Bar).GetMember ("PrivInstBase", flags).Length);
3462 Assert.AreEqual (1, typeof (Foo).GetMember ("PrivInstBase", flags).Length);
3465 [Test] // Bug #484246
3466 public void GetInterfaceCompareAgainstGTDNames ()
3468 var t = typeof (Dictionary<string,string>);
3469 var iface = typeof (IDictionary<string,string>);
3471 Assert.AreSame (iface, t.GetInterface ("System.Collections.Generic.IDictionary`2"), "#1");
3473 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]]";
3475 Assert.IsNull (t.GetInterface (name), "#2");
3479 public void RuntimeCorrectlyNormalizeGenericTypes ()
3481 Type lst = typeof (MList<>);
3482 Type arg = lst.GetGenericArguments ()[0];
3484 Type sup = lst.BaseType;
3485 Type sa0 = sup.GetGenericArguments ()[0];
3486 Type sa1 = sup.GetGenericArguments ()[1];
3488 Assert.IsTrue (sa1 == lst, "#1");
3489 Assert.IsTrue (sa0 == arg, "#2");
3491 Type inst = typeof (Cons<,>).MakeGenericType (arg, lst.MakeGenericType (arg));
3492 Assert.IsTrue (inst == sup, "#3");
3500 class MList<A> : Cons<A, MList<A>>
3505 [Test] // Bug #331126
3506 public void IsAssignableFromWorksCorrectlyWithByRefs ()
3508 Type int_byref = typeof (int).MakeByRefType ();
3509 Type obj_byref = typeof (object).MakeByRefType ();
3510 Type long_byref = typeof (long).MakeByRefType ();
3511 Type enum1_byref = typeof (AttributeTargets).MakeByRefType ();
3512 Type enum2_byref = typeof (PlatformID).MakeByRefType ();
3513 Type uint_byref = typeof (uint).MakeByRefType ();
3514 Type string_byref = typeof (object).MakeByRefType ();
3515 Type struct0_byref = typeof (Size4).MakeByRefType ();
3516 Type struct1_byref = typeof (Size4b).MakeByRefType ();
3517 Type mvar0_byref = typeof (TypeTest).GetMethod ("Bug331126").GetGenericArguments ()[0].MakeByRefType ();
3518 Type mvar1_byref = typeof (TypeTest).GetMethod ("Bug331126").GetGenericArguments ()[1].MakeByRefType ();
3520 Assert.IsFalse (typeof (int).IsAssignableFrom (int_byref), "#1");
3521 Assert.IsFalse (int_byref.IsAssignableFrom (typeof (int)), "#2");
3522 Assert.IsFalse (obj_byref.IsAssignableFrom (long_byref), "#3");
3523 Assert.IsFalse (long_byref.IsAssignableFrom (obj_byref), "#4");
3524 Assert.IsTrue (enum1_byref.IsAssignableFrom (enum2_byref), "#5");
3525 Assert.IsTrue (enum2_byref.IsAssignableFrom (enum1_byref), "#6");
3526 Assert.IsTrue (int_byref.IsAssignableFrom (enum2_byref), "#7");
3527 Assert.IsTrue (enum2_byref.IsAssignableFrom (int_byref), "#8");
3528 Assert.IsTrue (enum2_byref.IsAssignableFrom (uint_byref), "#9");
3529 Assert.IsTrue (uint_byref.IsAssignableFrom (enum2_byref), "#10");
3530 Assert.IsTrue (int_byref.IsAssignableFrom (uint_byref), "#11");
3531 Assert.IsTrue (uint_byref.IsAssignableFrom (int_byref), "#12");
3533 Assert.IsTrue (typeof (object).IsAssignableFrom (typeof (long)), "#13");
3535 Assert.IsTrue (obj_byref.IsAssignableFrom (string_byref), "#14");
3536 Assert.IsTrue (string_byref.IsAssignableFrom (obj_byref), "#15");
3538 Assert.IsFalse (uint_byref.IsAssignableFrom (struct0_byref), "#16");
3539 Assert.IsFalse (struct0_byref.IsAssignableFrom (int_byref), "#17");
3540 Assert.IsFalse (struct0_byref.IsAssignableFrom (struct1_byref), "#18");
3542 Assert.IsFalse (obj_byref.IsAssignableFrom (mvar0_byref), "#19");
3543 Assert.IsFalse (mvar0_byref.IsAssignableFrom (mvar1_byref), "#20");
3544 Assert.IsTrue (mvar0_byref.IsAssignableFrom (mvar0_byref), "#21");
3545 Assert.IsFalse (mvar0_byref.IsAssignableFrom (obj_byref), "#22");
3548 public void Bug331126<T,K> () {}
3550 public struct Size4 {
3554 public struct Size4b {
3558 [Test] // Bug #612780
3559 public void CannotMakeDerivedTypesFromTypedByRef ()
3562 typeof (global::System.TypedReference).MakeArrayType ();
3564 } catch (TypeLoadException) { }
3567 typeof (global::System.TypedReference).MakeByRefType ();
3569 } catch (TypeLoadException) { }
3572 typeof (global::System.TypedReference).MakePointerType ();
3574 } catch (TypeLoadException) { }
3579 public void DeclaringTypeOfGenericNestedTypeInstanceIsOpen ()
3581 var type = typeof (Foo<int>.Nested<string>);
3582 Assert.AreSame (typeof (Foo<>), type.DeclaringType, "#1");
3585 interface IGetInterfaceMap<in T>
3590 class GetInterfaceMap : IGetInterfaceMap<object>
3592 public string Bar (object t)
3594 return t.GetType ().FullName;
3599 public void GetInterfaceMapWorksWithVariantIfaces ()
3601 InterfaceMapping res = typeof (GetInterfaceMap).GetInterfaceMap (typeof (IGetInterfaceMap <object>));
3602 Assert.AreEqual (typeof (IGetInterfaceMap <object>), res.InterfaceType);
3603 Assert.AreEqual (typeof (object), res.InterfaceMethods [0].GetParameters () [0].ParameterType);
3605 res = typeof (GetInterfaceMap).GetInterfaceMap (typeof (IGetInterfaceMap <string>));
3606 Assert.AreEqual (typeof (IGetInterfaceMap <string>), res.InterfaceType);
3607 Assert.AreEqual (typeof (string), res.InterfaceMethods [0].GetParameters () [0].ParameterType);
3611 public class MyType : TypeDelegator {
3614 public override bool Equals (Type t) {
3616 return base.Equals (t);
3619 public override Type UnderlyingSystemType {
3622 return typeof (int);
3628 public void NewV4EqualsBehavior ()
3630 var ta = new MyType ();
3631 var tb = new MyType ();
3632 object a = ta, b = tb;
3635 Assert.AreEqual (1, ta.eq, "#1");
3636 Assert.AreEqual (2, ta.ust, "#2");
3638 Assert.AreEqual (2, ta.eq, "#3");
3639 Assert.AreEqual (3, ta.ust, "#4");
3640 Assert.AreEqual (0, tb.eq, "#5");
3641 Assert.AreEqual (1, tb.ust, "#6");
3644 public enum MyRealEnum : short {
3649 public enum MyRealEnum2 : byte {
3653 public enum MyRealEnum3 : short {
3657 public class MyEnum : TypeDelegator {
3658 public bool is_enum { get; set; }
3659 public int fields { get; set; }
3661 public override bool IsSubclassOf (Type c) {
3662 return c == typeof (Enum) && is_enum;
3665 public override FieldInfo[] GetFields (BindingFlags bindingAttr) {
3668 FieldInfo[] res = new FieldInfo [fields];
3669 for (int i = 0; i < fields; ++i) {
3670 if ((bindingAttr & BindingFlags.Instance) != 0)
3671 res [i] = typeof (MyRealEnum).GetField ("value__");
3673 res [i] = typeof (MyRealEnum).GetField ("A");
3680 public void GetEnumUnderlyingType () {
3683 new MyEnum () { is_enum = false }.GetEnumUnderlyingType ();
3685 } catch (ArgumentException) {}
3688 new MyEnum () { is_enum = true, fields = 0 }.GetEnumUnderlyingType ();
3690 } catch (ArgumentException) {}
3693 new MyEnum () { is_enum = true, fields = 2 }.GetEnumUnderlyingType ();
3695 } catch (ArgumentException) {}
3697 Assert.AreSame (typeof (short), new MyEnum () { is_enum = true, fields = 1 }.GetEnumUnderlyingType ());
3701 public void GetEnumNames () {
3703 new MyEnum () { is_enum = false }.GetEnumNames ();
3705 } catch (ArgumentException) {}
3707 var res = new MyEnum () { is_enum = true, fields = 1 }.GetEnumNames ();
3708 Assert.AreEqual (1, res.Length, "#2");
3709 Assert.AreEqual ("A", res [0], "#3");
3711 res = typeof (MyRealEnum).GetEnumNames ();
3712 Assert.AreEqual (3, res.Length, "#4");
3713 Assert.AreEqual ("A", res [0], "#5");
3714 Assert.AreEqual ("B", res [1], "#6");
3715 Assert.AreEqual ("C", res [2], "#7");
3718 public enum OutOfOrderEnum : sbyte
3720 D = -1, C = 2, B = 1, A = 0
3724 public void GetEnumNamesSortsByUnsignedValue ()
3726 string[] names = typeof (OutOfOrderEnum).GetEnumNames ();
3727 Assert.AreEqual (4, names.Length);
3728 Assert.AreEqual ("A", names [0]);
3729 Assert.AreEqual ("B", names [1]);
3730 Assert.AreEqual ("C", names [2]);
3731 Assert.AreEqual ("D", names [3]);
3735 public void GetEnumValues () {
3737 new MyEnum () { is_enum = false }.GetEnumValues ();
3739 } catch (ArgumentException) {}
3742 new MyEnum () { is_enum = true }.GetEnumValues ();
3744 } catch (NotImplementedException) {}
3746 var array = typeof (MyRealEnum).GetEnumValues ();
3747 Assert.AreEqual (typeof (MyRealEnum[]), array.GetType (), "#3");
3748 MyRealEnum[] res = (MyRealEnum[])array;
3750 Assert.AreEqual (3, res.Length, "#4");
3751 Assert.AreEqual (MyRealEnum.A, res [0], "#5");
3752 Assert.AreEqual (MyRealEnum.B, res [1], "#6");
3753 Assert.AreEqual (MyRealEnum.C, res [2], "#7");
3757 public void GetEnumValue () {
3759 typeof (MyRealEnum).GetEnumName (null);
3761 } catch (ArgumentException) { }
3764 new MyEnum () { is_enum = false }.GetEnumName (99);
3766 } catch (ArgumentException) { }
3769 Assert.IsNull (new MyEnum () { fields = 1, is_enum = true }.GetEnumName (77), "#3");
3770 Assert.AreEqual ("A", new MyEnum () { fields = 1, is_enum = true }.GetEnumName (0), "#4");
3771 Assert.AreEqual ("A", new MyEnum () { fields = 1, is_enum = true }.GetEnumName (MyRealEnum.A), "#5");
3772 Assert.AreEqual ("A", new MyEnum () { fields = 1, is_enum = true }.GetEnumName (MyRealEnum2.A), "#6");
3774 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName (MyRealEnum.A), "#7");
3775 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((short)0), "#8");
3776 Assert.AreEqual ("C", typeof (MyRealEnum).GetEnumName (2), "#9");
3777 Assert.IsNull (typeof (MyRealEnum).GetEnumName (9), "#10");
3779 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((byte)0), "#11");
3780 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((sbyte)0), "#12");
3781 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName (false), "#13");
3782 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((short)0), "#14");
3783 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((ushort)0), "#15");
3784 Assert.IsNull (typeof (MyRealEnum).GetEnumName ('c'), "#16");
3786 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((int)0), "#17");
3787 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((uint)0), "#18");
3789 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((long)0), "#19");
3790 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((ulong)0), "#20");
3793 typeof (MyRealEnum).GetEnumName ((float)0);
3794 Assert.Fail ("#21");
3795 } catch (ArgumentException) { }
3797 typeof (MyRealEnum).GetEnumName ((double)0);
3798 Assert.Fail ("#22");
3799 } catch (ArgumentException) { }
3802 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((byte)0), "#23");
3803 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((sbyte)0), "#24");
3804 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName (false), "#25");
3806 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((short)0), "#26");
3807 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((ushort)0), "#27");
3809 Assert.IsNull (typeof (MyRealEnum2).GetEnumName ('c'), "#28");
3811 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((int)0), "#29");
3812 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((uint)0), "#30");
3814 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((long)0), "#31");
3815 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((ulong)0), "#32");
3818 typeof (MyRealEnum2).GetEnumName ((float)0);
3819 Assert.Fail ("#33");
3820 } catch (ArgumentException) { }
3822 typeof (MyRealEnum2).GetEnumName ((double)0);
3823 Assert.Fail ("#34");
3824 } catch (ArgumentException) { }
3826 Assert.IsNull (typeof (MyRealEnum2).GetEnumName (12345), "#35");
3830 public void IsEnumDefined () {
3832 typeof (MyRealEnum).IsEnumDefined (null);
3834 } catch (ArgumentException) { }
3837 new MyEnum () { is_enum = false }.IsEnumDefined (99);
3839 } catch (ArgumentException) { }
3842 typeof (MyRealEnum).IsEnumDefined (0);
3844 } catch (ArgumentException) { }
3847 typeof (MyRealEnum).IsEnumDefined ((ushort)0);
3849 } catch (ArgumentException) { }
3852 typeof (MyRealEnum).IsEnumDefined (MyRealEnum3.A);
3854 } catch (ArgumentException) { }
3857 typeof (MyRealEnum).IsEnumDefined (true);
3859 } catch (ArgumentException) { }
3862 typeof (MyRealEnum).IsEnumDefined (MyRealEnum2.A);
3864 } catch (ArgumentException) { }
3867 typeof (MyRealEnum).IsEnumDefined (typeof (MyRealEnum));
3869 } catch (InvalidOperationException) { }
3871 Assert.IsTrue (typeof (MyRealEnum).IsEnumDefined ((short)0), "#9");
3872 Assert.IsFalse (typeof (MyRealEnum).IsEnumDefined ((short)88), "#10");
3873 Assert.IsTrue (typeof (MyRealEnum).IsEnumDefined (MyRealEnum.A), "#11");
3874 Assert.IsFalse (typeof (MyRealEnum).IsEnumDefined ("d"), "#12");
3875 Assert.IsTrue (typeof (MyRealEnum).IsEnumDefined ("A"), "#13");
3876 Assert.IsFalse (new MyEnum () { is_enum = true, fields = 1 }.IsEnumDefined ((short)99), "#14");
3881 public class Outer {
3882 public class Inner {}
3886 public class Outer<T> {
3887 public class Inner {}
3891 public void GetTypeWithDelegates () {
3892 var tname = typeof (MyRealEnum).AssemblyQualifiedName;
3893 var res = Type.GetType (tname, name => {
3894 return Assembly.Load (name);
3895 },(asm,name,ignore) => {
3896 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3898 Assert.AreEqual (typeof (MyRealEnum), res, "#1");
3901 tname = typeof (Dictionary<int, string>).AssemblyQualifiedName;
3902 res = Type.GetType (tname, name => {
3903 return Assembly.Load (name);
3904 },(asm,name,ignore) => {
3905 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3907 Assert.AreEqual (typeof (Dictionary<int, string>), res, "#2");
3910 tname = typeof (Foo<int>).AssemblyQualifiedName;
3911 res = Type.GetType (tname, name => {
3912 return Assembly.Load (name);
3913 },(asm,name,ignore) => {
3914 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3916 Assert.AreEqual (typeof (Foo<int>), res, "#3");
3919 tname = typeof (Outer.Inner).AssemblyQualifiedName;
3920 res = Type.GetType (tname, name => {
3921 return Assembly.Load (name);
3922 },(asm,name,ignore) => {
3923 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3925 Assert.AreEqual (typeof (Outer.Inner), res, "#4");
3928 tname = typeof (Outer<double>.Inner).AssemblyQualifiedName;
3929 res = Type.GetType (tname, name => {
3930 return Assembly.Load (name);
3931 },(asm,name,ignore) => {
3932 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3934 Assert.AreEqual (typeof (Outer<double>.Inner), res, "#5");
3937 tname = "System.Collections.Generic.List`1[System.Int32]";
3938 res = Type.GetType (tname, name => {
3939 return Assembly.Load (name);
3940 },(asm,name,ignore) => {
3941 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3943 Assert.AreEqual (typeof (List<int>), res, "#6");
3946 tname = typeof (Foo<>).FullName + "[,][]";
3947 res = Type.GetType (tname, name => {
3948 Console.WriteLine ("resolve-asm name {0}", name);
3949 return Assembly.Load (name);
3950 },(asm,name,ignore) => {
3951 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3953 Assert.AreEqual (typeof (Foo<>).MakeArrayType (2).MakeArrayType (), res, "#7");
3955 tname = string.Format("{0}[{1}][]*&", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName);
3956 res = Type.GetType (tname, name => {
3957 return Assembly.Load (name);
3958 },(asm,name,ignore) => {
3959 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3961 Assert.AreEqual (typeof (Foo<MyRealEnum>[]).MakePointerType ().MakeByRefType (), res, "#8");
3964 tname = typeof (MyRealEnum).FullName + "[][]";
3965 res = Type.GetType (tname, name => {
3966 return Assembly.Load (name);
3967 },(asm,name,ignore) => {
3968 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3970 Assert.AreEqual (typeof (MyRealEnum[][]), res, "#9");
3973 tname = typeof (MyRealEnum).FullName + "[*]";
3974 res = Type.GetType (tname, name => {
3975 return Assembly.Load (name);
3976 },(asm,name,ignore) => {
3977 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3979 Assert.AreEqual (typeof (MyRealEnum).MakeArrayType (1), res, "#10");
3982 tname = typeof (MyRealEnum).FullName + "&";
3983 res = Type.GetType (tname, name => {
3984 return Assembly.Load (name);
3985 },(asm,name,ignore) => {
3986 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3988 Assert.AreEqual (typeof (MyRealEnum).MakeByRefType (), res, "#11");
3991 tname = typeof (MyRealEnum).FullName + "*";
3992 res = Type.GetType (tname, name => {
3993 return Assembly.Load (name);
3994 },(asm,name,ignore) => {
3995 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3997 Assert.AreEqual (typeof (MyRealEnum).MakePointerType (), res, "#12");
3999 tname = typeof (MyRealEnum).FullName + "*&";
4000 res = Type.GetType (tname, name => {
4001 return Assembly.Load (name);
4002 },(asm,name,ignore) => {
4003 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4005 Assert.AreEqual (typeof (MyRealEnum).MakePointerType ().MakeByRefType(),
4008 tname = typeof (MyRealEnum).FullName + "[,]&";
4009 res = Type.GetType (tname, name => {
4010 return Assembly.Load (name);
4011 },(asm,name,ignore) => {
4012 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4014 Assert.AreEqual (typeof (MyRealEnum).MakeArrayType (2).MakeByRefType (),
4017 tname = typeof (MyRealEnum).FullName + "*[]";
4018 res = Type.GetType (tname, name => {
4019 return Assembly.Load (name);
4020 },(asm,name,ignore) => {
4021 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4023 Assert.AreEqual (typeof (MyRealEnum).MakePointerType().MakeArrayType(),
4026 // not a very useful type, but ought to be parsed correctly
4027 tname = typeof (MyRealEnum).FullName + "[]**[]*&";
4028 res = Type.GetType (tname, name => {
4029 return Assembly.Load (name);
4030 },(asm,name,ignore) => {
4031 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4033 Assert.AreEqual (typeof (MyRealEnum).MakeArrayType().MakePointerType().MakePointerType().MakeArrayType().MakePointerType().MakeByRefType(),
4036 // assembly resolve without type resolve
4037 res = Type.GetType ("System.String,mscorlib", delegate (AssemblyName aname) { return typeof (int).Assembly; }, null);
4038 Assert.AreEqual (typeof (string), res);
4042 public class CustomGetType : TypeDelegator {
4045 public CustomGetType (string name) { this.name = name; }
4047 public override Type MakeGenericType (Type[] args) {
4048 return new CustomGetType ("GINST");
4051 public override Type GetNestedType(String name, BindingFlags bidingAttr) {
4052 return new CustomGetType ("NESTED");
4055 public override string ToString () { return "UT_" + name; }
4057 public override string Name {
4058 get { return "UT_" + name; }
4063 public void GetTypeWithDelegatesAndUserTypes ()
4065 var tname = "Magic[System.Int32]";
4066 var res = Type.GetType (tname, name => {
4067 return Assembly.Load (name);
4068 },(asm,name,ignore) => {
4069 if (name == "Magic") return new CustomGetType ("MAGIC");
4070 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4072 Assert.AreEqual ("UT_GINST", res.Name, "#1");
4075 tname = "Magic+MyRealEnum";
4076 res = Type.GetType (tname, name => {
4077 return Assembly.Load (name);
4078 },(asm,name,ignore) => {
4079 if (name == "Magic") return new CustomGetType ("MAGIC");
4080 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4082 Assert.AreEqual ("UT_NESTED", res.Name, "#2");
4085 void MustTLE (string tname) {
4087 var res = Type.GetType (tname, name => {
4088 return Assembly.Load (name);
4089 },(asm,name,ignore) => {
4090 return (object)asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4092 Assert.Fail (tname);
4093 } catch (TypeLoadException) {}
4096 void MustANE (string tname) {
4098 var res = Type.GetType (tname, name => {
4099 return Assembly.Load (name);
4100 },(asm,name,ignore) => {
4101 return (object)asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4103 Assert.Fail (tname);
4104 } catch (ArgumentNullException) {}
4107 void MustAE_general (string tname, Func<string,Type> getType) {
4109 var res = getType (tname);
4110 Assert.Fail (tname);
4111 } catch (ArgumentException) {}
4114 void MustAE (string typename) {
4115 MustAE_general (typename, tname => {
4116 return Type.GetType (tname, name => {
4117 return Assembly.Load (name);
4118 },(asm,name,ignore) => {
4119 return (object)asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4124 void MustAEnn (string typename) {
4125 MustAE_general (typename, tname => Type.GetType (tname, null, null));
4128 void MustFNFE (string tname) {
4130 var res = Type.GetType (tname, name => {
4131 return Assembly.Load (name);
4132 },(asm,name,ignore) => {
4133 return (object)asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4135 Assert.Fail (tname);
4136 } catch (FileNotFoundException) {}
4140 public void NewGetTypeErrors () {
4142 MustAE ("!@#$%^&*");
4143 MustAE (string.Format ("{0}[{1}&]", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4144 MustAE (string.Format ("{0}[{1}*]", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4145 MustAE (string.Format ("{0}&&", typeof (MyRealEnum).FullName));
4146 MustAE (string.Format ("{0}&*", typeof (MyRealEnum).FullName));
4147 MustAE (string.Format ("{0}&[{1}]", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4148 MustAE (string.Format ("{0}[,", typeof (MyRealEnum).FullName));
4149 MustAE (string.Format ("{0}[*", typeof (MyRealEnum).FullName));
4151 MustAE (string.Format ("{0}[[{1},", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4152 MustAE (string.Format ("{0}[[{1}]", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4153 MustAE (string.Format ("{0}[[{1}],", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4154 MustAE (string.Format ("{0}[[{1}]_", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4156 MustAE (string.Format ("{0}[{1}", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4157 MustAE (string.Format ("{0}[{1},", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4158 MustAE (string.Format ("{0}[{1},,", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4159 MustAE (string.Format ("{0}[{1} (", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4160 MustAE (string.Format ("{0}[", typeof (Foo<>).FullName));
4162 MustAE (string.Format ("{0}[**]", typeof (MyRealEnum).FullName));
4163 MustAE (string.Format ("{0}[*,*]", typeof (MyRealEnum).FullName));
4164 MustAE (string.Format ("{0}[*,]", typeof (MyRealEnum).FullName));
4165 MustAE (string.Format ("{0}[,*]", typeof (MyRealEnum).FullName));
4166 MustAE (string.Format ("{0}[,-]", typeof (MyRealEnum).FullName));
4167 MustAE (string.Format ("{0}[,{0}]", typeof (MyRealEnum).FullName));
4169 MustAE (string.Format ("{0}[{1}]]", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4170 MustAE (string.Format ("{0}[,]]", typeof (MyRealEnum).FullName));
4173 string aqn = typeof (MyRealEnum).Assembly.FullName;
4174 MustFNFE (string.Format ("{0}, ZZZ{1}", typeof (MyRealEnum).FullName, aqn));
4175 MustTLE (string.Format ("{0}ZZZZ", typeof (MyRealEnum).FullName));
4176 MustTLE (string.Format ("{0}ZZZZ,{1}", typeof (MyRealEnum).FullName, aqn));
4179 delegate void MyAction<in T>(T ag);
4181 [Test] //bug #668506
4182 public void IsAssignableFromWithVariantDelegate () {
4183 Assert.IsFalse (typeof(MyAction<string>).IsAssignableFrom(typeof(MyAction<>)), "#1");
4187 public void IsAssignableFromWithNullable () {
4188 Console.WriteLine(typeof(IEnumerable<int?>).IsAssignableFrom(typeof(IEnumerable<int>)));
4192 public void GetTypeParseGenericCorrectly () { //Bug #15124
4193 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1"), typeof (Foo<>), "#1");
4194 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32]"), typeof (Foo<int>), "#2");
4195 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[[System.Int32]]"), typeof (Foo<int>), "#3");
4196 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32][]"), typeof (Foo<int>[]), "#4");
4197 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[][System.Int32]"), null, "#5");
4198 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32][,]"), typeof (Foo<int>[,]), "#6");
4199 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[]"), typeof (Foo<>).MakeArrayType(), "#7");
4200 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[,]"), typeof (Foo<>).MakeArrayType (2), "#8");
4201 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[][]"), typeof (Foo<>).MakeArrayType ().MakeArrayType (), "#9");
4202 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1["), null, "#10");
4203 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[["), null, "#11");
4204 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[[]"), null, "#12");
4205 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[,"), null, "#13");
4206 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[*"), null, "#14");
4207 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32"), null, "#15");
4211 public void GetTypeNullDelegatesParseGenericCorrectly () {
4212 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1", null, null), typeof (Foo<>), "#1");
4213 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32]", null, null), typeof (Foo<int>), "#2");
4214 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[[System.Int32]]", null, null), typeof (Foo<int>), "#3");
4215 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32][]", null, null), typeof (Foo<int>[]), "#4");
4216 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32][,]", null, null), typeof (Foo<int>[,]), "#5");
4217 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[]", null, null), typeof (Foo<>).MakeArrayType(), "#6");
4218 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[,]", null, null), typeof (Foo<>).MakeArrayType (2), "#7");
4219 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[][]", null, null), typeof (Foo<>).MakeArrayType ().MakeArrayType (), "#8");
4221 MustAEnn ("MonoTests.System.Foo`1[][System.Int32]");
4222 MustAEnn ("MonoTests.System.Foo`1[");
4223 MustAEnn ("MonoTests.System.Foo`1[[");
4224 MustAEnn ("MonoTests.System.Foo`1[[]");
4225 MustAEnn ("MonoTests.System.Foo`1[,");
4226 MustAEnn ("MonoTests.System.Foo`1[*");
4227 MustAEnn ("MonoTests.System.Foo`1[System.Int32");
4230 Dictionary<int, T> MakeDictHelper<T> (T[] arr) {
4231 return new Dictionary<int, T>();
4235 public void GetTypeAnonymousParseCorrectly () {
4236 var x = new { X = 1 };
4237 var a = new [] { x };
4238 var d = MakeDictHelper (a);
4240 var x_type = x.GetType ();
4241 var a_type = a.GetType ();
4242 var d_type = d.GetType ();
4244 Assert.AreEqual (Type.GetType (x_type.ToString ()), x_type, "#1");
4245 Assert.AreEqual (Type.GetType (x_type.ToString (), null, null), x_type, "#2");
4246 Assert.AreEqual (Type.GetType (a_type.ToString ()), a_type, "#3");
4247 Assert.AreEqual (Type.GetType (a_type.ToString (), null, null), a_type, "#4");
4248 Assert.AreEqual (Type.GetType (d_type.ToString ()), d_type, "#5");
4249 Assert.AreEqual (Type.GetType (d_type.ToString (), null, null), d_type, "#6");
4251 Assert.AreEqual (Type.GetType (x_type.FullName), x_type, "#7");
4252 Assert.AreEqual (Type.GetType (x_type.FullName, null, null), x_type, "#8");
4253 Assert.AreEqual (Type.GetType (a_type.FullName), a_type, "#9");
4254 Assert.AreEqual (Type.GetType (a_type.FullName, null, null), a_type, "#10");
4255 Assert.AreEqual (Type.GetType (d_type.FullName), d_type, "#11");
4256 Assert.AreEqual (Type.GetType (d_type.FullName, null, null), d_type, "#12");
4260 #if !MONOTOUCH && !MOBILE_STATIC
4262 [Category ("AndroidNotWorking")] // requires symbol writer
4263 public void FullNameGetTypeParseEscapeRoundtrip () // bug #26384
4265 var nm = new AssemblyName ("asm");
4266 var ab = AssemblyBuilder.DefineDynamicAssembly (nm,
4267 AssemblyBuilderAccess.Run);
4268 var mb = ab.DefineDynamicModule("m", true);
4269 var tb = mb.DefineType ("NameSpace,+*&[]\\.Type,+*&[]\\",
4270 TypeAttributes.Class | TypeAttributes.Public);
4272 var nestedTb = tb.DefineNestedType("Nested,+*&[]\\",
4273 TypeAttributes.Class | TypeAttributes.NestedPublic);
4275 var ty = tb.CreateType();
4277 var nestedTy = nestedTb.CreateType();
4279 var escapedNestedName =
4280 "NameSpace\\,\\+\\*\\&\\[\\]\\\\"
4282 + "Type\\,\\+\\*\\&\\[\\]\\\\"
4284 + "Nested\\,\\+\\*\\&\\[\\]\\\\";
4286 Assert.AreEqual(escapedNestedName, nestedTy.FullName);
4288 var lookupNestedTy =
4289 Type.GetType(escapedNestedName + "," + nm.FullName,
4291 if (asmName.FullName.Equals(nm.FullName)) return ab;
4292 else return Assembly.Load (asmName);
4294 (asm,name,ignore) => {
4296 return Type.GetType(name, true, ignore);
4297 else return asm.GetType(name, true, ignore);
4301 Assert.AreEqual(nestedTy, lookupNestedTy);
4306 public abstract class Stream : IDisposable
4308 public void Dispose ()
4310 Console.WriteLine ("stream::dispose");
4313 protected virtual void Dispose (bool disposing)
4318 public class NonClosingStream
4319 : Stream, IDisposable
4321 void IDisposable.Dispose()
4323 Console.WriteLine ("ncs::dispose");
4326 public override string ToString () { return ""; }
4329 static bool ContainsProperty (PropertyInfo [] props, string name)
4331 foreach (PropertyInfo p in props)
4337 public class NemerleAttribute : Attribute
4341 public class VolatileModifier : NemerleAttribute
4351 [AttributeUsage (AttributeTargets.Class, Inherited=false)]
4352 public class FooAttribute : Attribute
4356 public class BarAttribute : FooAttribute
4373 [AttributeUsage (AttributeTargets.Class, Inherited=true)]
4374 public class InheritAttribute : Attribute
4378 [AttributeUsage (AttributeTargets.Class, Inherited=false)]
4379 public class NotInheritAttribute : InheritAttribute
4383 [NotInheritAttribute]
4384 public class bug82431A1
4388 public class bug82431A2 : bug82431A1
4392 [NotInheritAttribute]
4394 public class bug82431A3 : bug82431A1
4399 public class bug82431B1
4403 public class bug82431B2 : bug82431B1
4407 [NotInheritAttribute]
4408 public class bug82431B3 : bug82431B2
4412 public class bug82431B4 : bug82431B3
4420 public class Bug77367
4422 public void Run (bool b)
4429 private string PrivInstBlue
4431 get { return null; }
4434 protected string ProtInstBlue
4436 get { return null; }
4439 protected internal string ProIntInstBlue
4441 get { return null; }
4444 public long PubInstBlue
4448 if (PrivInstBlue == null)
4450 return long.MaxValue;
4454 internal int IntInstBlue
4459 private static string PrivStatBlue
4461 get { return null; }
4464 protected static string ProtStatBlue
4466 get { return null; }
4469 protected static internal string ProIntStatBlue
4471 get { return null; }
4474 public static long PubStatBlue
4478 if (PrivStatBlue == null)
4480 return long.MaxValue;
4484 internal static int IntStatBlue
4490 public class Foo : Blue
4492 private string PrivInstBase
4494 get { return null; }
4497 protected string ProtInstBase
4499 get { return null; }
4502 protected internal string ProIntInstBase
4504 get { return null; }
4507 public long PubInstBase
4511 if (PrivInstBase == null)
4513 return long.MaxValue;
4517 internal int IntInstBase
4522 private static string PrivStatBase
4524 get { return null; }
4527 protected static string ProtStatBase
4529 get { return null; }
4532 protected static internal string ProIntStatBase
4534 get { return null; }
4537 public static long PubStatBase
4541 if (PrivStatBase == null)
4543 return long.MaxValue;
4547 internal static int IntStatBase
4553 public class Bar : Foo
4555 private string PrivInst
4557 get { return null; }
4560 protected string ProtInst
4562 get { return null; }
4565 protected internal string ProIntInst
4567 get { return null; }
4574 if (PrivInst == null)
4576 return long.MaxValue;
4580 internal int IntInst
4585 private static string PrivStat
4587 get { return null; }
4590 protected static string ProtStat
4592 get { return null; }
4595 protected static internal string ProIntStat
4597 get { return null; }
4600 public static long PubStat
4604 if (PrivStat == null)
4606 return long.MaxValue;
4610 internal static int IntStat
4636 public CtorsC (int x)
4642 class UserType : Type
4644 protected Type type;
4646 public UserType(Type type) {
4650 public override Type UnderlyingSystemType { get { return this.type; } }
4652 public override Assembly Assembly { get { return this.type == null ? null : this.type.Assembly; } }
4654 public override string AssemblyQualifiedName { get { return null; } }
4656 public override Type BaseType { get { return null; } }
4658 public override Module Module { get { return this.type.Module; } }
4660 public override string Namespace { get { return null; } }
4662 public override bool IsGenericParameter { get { return true; } }
4664 public override RuntimeTypeHandle TypeHandle { get { throw new NotSupportedException(); } }
4666 public override bool ContainsGenericParameters { get { return true; } }
4668 public override string FullName { get { return this.type.Name; } }
4670 public override Guid GUID { get { throw new NotSupportedException(); } }
4673 protected override bool IsArrayImpl() {
4677 protected override bool IsByRefImpl()
4682 protected override bool IsCOMObjectImpl()
4687 protected override bool IsPointerImpl()
4692 protected override bool IsPrimitiveImpl()
4698 protected override TypeAttributes GetAttributeFlagsImpl()
4703 protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder,
4704 CallingConventions callConvention, Type[] types,
4705 ParameterModifier[] modifiers)
4710 public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr)
4715 public override Type GetElementType()
4720 public override EventInfo GetEvent(string name, BindingFlags bindingAttr)
4726 public override FieldInfo GetField(string name, BindingFlags bindingAttr)
4732 public override Type GetInterface(string name, bool ignoreCase)
4737 public override Type[] GetInterfaces()
4742 public override MemberInfo[] GetMembers(BindingFlags bindingAttr)
4747 public override object[] GetCustomAttributes(Type attributeType, bool inherit)
4752 public override object[] GetCustomAttributes(bool inherit)
4757 public override bool IsDefined(Type attributeType, bool inherit)
4762 public override string Name { get { return this.type.Name; } }
4764 public override EventInfo[] GetEvents(BindingFlags bindingAttr)
4766 throw new NotImplementedException();
4769 public override FieldInfo[] GetFields(BindingFlags bindingAttr)
4771 throw new NotImplementedException();
4774 protected override MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder,
4775 CallingConventions callConvention, Type[] types,
4776 ParameterModifier[] modifiers)
4781 public override MethodInfo[] GetMethods(BindingFlags bindingAttr)
4786 public override Type GetNestedType(string name, BindingFlags bindingAttr)
4791 public override Type[] GetNestedTypes(BindingFlags bindingAttr)
4796 public override PropertyInfo[] GetProperties(BindingFlags bindingAttr)
4801 protected override PropertyInfo GetPropertyImpl(string name, BindingFlags bindingAttr, Binder binder,
4802 Type returnType, Type[] types, ParameterModifier[] modifiers)
4807 protected override bool HasElementTypeImpl()
4812 public override object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, object target,
4813 object[] args, ParameterModifier[] modifiers, CultureInfo culture,
4814 string[] namedParameters)
4816 throw new NotSupportedException();
4820 class UserType2 : UserType {
4821 public UserType2 (Type type) : base (type) {
4824 public override Type UnderlyingSystemType { get { return this.type ?? this; } }
4826 public override int GetHashCode()
4830 return type.GetHashCode();