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 && !FULL_AOT_RUNTIME
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 && !FULL_AOT_RUNTIME
265 private ModuleBuilder module;
267 const string ASSEMBLY_NAME = "MonoTests.System.TypeTest";
268 static int typeIndexer = 0;
269 static bool isMono = Type.GetType ("Mono.Runtime", false) != null;
274 AssemblyName assemblyName = new AssemblyName ();
275 assemblyName.Name = ASSEMBLY_NAME;
276 #if !MONOTOUCH && !FULL_AOT_RUNTIME
277 var assembly = AppDomain.CurrentDomain.DefineDynamicAssembly (
278 assemblyName, AssemblyBuilderAccess.RunAndSave, Path.GetTempPath ());
279 module = assembly.DefineDynamicModule ("module1");
283 private string genTypeName ()
285 return "t" + (typeIndexer++);
288 private void ByrefMethod (ref int i, ref Derived1 j, ref Base1 k)
292 public interface IFace {
295 private void GenericMethod<Q, T1> (Q q, T1 t) where T1 : IFace
305 public void TestIsAssignableFrom ()
307 // Simple tests for inheritance
308 Assert.AreEqual (typeof (Super).IsAssignableFrom (typeof (Duper)) , true, "#01");
309 Assert.AreEqual (typeof (Duper).IsAssignableFrom (typeof (Duper)), true, "#02");
310 Assert.AreEqual (typeof (Object).IsAssignableFrom (typeof (Duper)), true, "#03");
311 Assert.AreEqual (typeof (ICloneable).IsAssignableFrom (typeof (Duper)), true, "#04");
314 Assert.AreEqual (typeof (Super[]).IsAssignableFrom (typeof (Duper[])), true, "#05");
315 Assert.AreEqual (typeof (Duper[]).IsAssignableFrom (typeof (Super[])), false, "#06");
316 Assert.AreEqual (typeof (Object[]).IsAssignableFrom (typeof (Duper[])), true, "#07");
317 Assert.AreEqual (typeof (ICloneable[]).IsAssignableFrom (typeof (Duper[])), true, "#08");
319 // Tests for multiple dimensional arrays
320 Assert.AreEqual (typeof (Super[][]).IsAssignableFrom (typeof (Duper[][])), true, "#09");
321 Assert.AreEqual (typeof (Duper[][]).IsAssignableFrom (typeof (Super[][])), false, "#10");
322 Assert.AreEqual (typeof (Object[][]).IsAssignableFrom (typeof (Duper[][])), true, "#11");
323 Assert.AreEqual (typeof (ICloneable[][]).IsAssignableFrom (typeof (Duper[][])), true, "#12");
325 // Tests for vectors<->one dimensional arrays */
326 Array arr1 = Array.CreateInstance (typeof (int), new int[] {1}, new int[] {0});
327 Array arr2 = Array.CreateInstance (typeof (int), new int[] {1}, new int[] {10});
329 Assert.AreEqual (typeof (int[]).IsAssignableFrom (arr1.GetType ()), true, "#13");
330 Assert.AreEqual (typeof (int[]).IsAssignableFrom (arr2.GetType ()), false, "#14");
332 // Test that arrays of enums can be cast to their base types
333 Assert.AreEqual (typeof (int[]).IsAssignableFrom (typeof (TypeCode[])), true, "#15");
335 // Test that arrays of valuetypes can't be cast to arrays of
337 Assert.AreEqual (typeof (object[]).IsAssignableFrom (typeof (TypeCode[])), false, "#16");
338 Assert.AreEqual (typeof (ValueType[]).IsAssignableFrom (typeof (TypeCode[])), false, "#17");
339 Assert.AreEqual (typeof (Enum[]).IsAssignableFrom (typeof (TypeCode[])), false, "#18");
341 // Test that arrays of enums can't be cast to arrays of references
342 Assert.AreEqual (typeof (object[]).IsAssignableFrom (typeof (TheEnum[])), false, "#19");
343 Assert.AreEqual (typeof (ValueType[]).IsAssignableFrom (typeof (TheEnum[])), false, "#20");
344 Assert.AreEqual (typeof (Enum[]).IsAssignableFrom (typeof (TheEnum[])), false, "#21");
346 // Check that ValueType and Enum are recognized as reference types
347 Assert.AreEqual (typeof (object).IsAssignableFrom (typeof (ValueType)), true, "#22");
348 Assert.AreEqual (typeof (object).IsAssignableFrom (typeof (Enum)), true, "#23");
349 Assert.AreEqual (typeof (ValueType).IsAssignableFrom (typeof (Enum)), true, "#24");
351 Assert.AreEqual (typeof (object[]).IsAssignableFrom (typeof (ValueType[])), true, "#25");
352 Assert.AreEqual (typeof (ValueType[]).IsAssignableFrom (typeof (ValueType[])), true, "#26");
353 Assert.AreEqual (typeof (Enum[]).IsAssignableFrom (typeof (ValueType[])), false, "#27");
355 Assert.AreEqual (typeof (object[]).IsAssignableFrom (typeof (Enum[])), true, "#28");
356 Assert.AreEqual (typeof (ValueType[]).IsAssignableFrom (typeof (Enum[])), true, "#29");
357 Assert.AreEqual (typeof (Enum[]).IsAssignableFrom (typeof (Enum[])), true, "#30");
359 // Tests for byref types
360 MethodInfo mi = typeof (TypeTest).GetMethod ("ByrefMethod", BindingFlags.Instance|BindingFlags.NonPublic);
361 Assert.IsTrue (mi.GetParameters ()[2].ParameterType.IsAssignableFrom (mi.GetParameters ()[1].ParameterType));
362 Assert.IsTrue (mi.GetParameters ()[1].ParameterType.IsAssignableFrom (mi.GetParameters ()[1].ParameterType));
364 // Tests for type parameters
365 mi = typeof (TypeTest).GetMethod ("GenericMethod", BindingFlags.Instance|BindingFlags.NonPublic);
366 Assert.IsTrue (mi.GetParameters ()[0].ParameterType.IsAssignableFrom (mi.GetParameters ()[0].ParameterType));
367 Assert.IsFalse (mi.GetParameters ()[0].ParameterType.IsAssignableFrom (typeof (int)));
369 // Tests for parameters with generic constraints
370 mi = typeof (TypeTest).GetMethod ("GenericMethod", BindingFlags.Instance|BindingFlags.NonPublic);
371 Assert.IsTrue (typeof (IFace).IsAssignableFrom (mi.GetParameters ()[1].ParameterType));
375 [ExpectedException (typeof (ArgumentException))]
376 public void GetInterfaceMapOnInterface ()
378 typeof (IList).GetInterfaceMap (typeof (ICollection));
382 public void TestIsSubclassOf ()
384 Assert.IsTrue (typeof (ICloneable).IsSubclassOf (typeof (object)), "#01");
386 // Tests for byref types
387 Type paramType = typeof (TypeTest).GetMethod ("ByrefMethod", BindingFlags.Instance|BindingFlags.NonPublic).GetParameters () [0].ParameterType;
388 Assert.IsFalse (paramType.IsSubclassOf (typeof(ValueType)), "#02");
389 Assert.IsNull (paramType.BaseType, "#02-b");
390 Assert.IsTrue (paramType.IsSubclassOf (typeof (Object)), "#03");
391 Assert.IsFalse (paramType.IsSubclassOf (paramType), "#04");
395 public void TestGetMethodImpl ()
397 // Test binding of new slot methods (using no types)
398 Assert.AreEqual (typeof (Base), typeof (Base).GetMethod("TestVoid").DeclaringType, "#01");
399 Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetMethod ("TestVoid").DeclaringType, "#02");
401 // Test binding of new slot methods (using types)
402 Assert.AreEqual (typeof (Base), typeof (Base).GetMethod ("TestInt", new Type[] { typeof (int) }).DeclaringType, "#03");
403 Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetMethod ("TestInt", new Type[] { typeof (int) }).DeclaringType, "#04");
405 // Test overload resolution
406 Assert.AreEqual (0, typeof (NewVTable).GetMethod ("Overload", new Type[0]).GetParameters ().Length, "#05");
408 // Test byref parameters
409 Assert.AreEqual (null, typeof (NewVTable).GetMethod ("byref_method", new Type[] { typeof (int) }), "#06");
410 Type byrefInt = typeof (NewVTable).GetMethod ("byref_method").GetParameters ()[0].ParameterType;
411 Assert.IsNotNull (typeof (NewVTable).GetMethod ("byref_method", new Type[] { byrefInt }), "#07");
415 public void TestGetPropertyImpl ()
417 // Test getting property that is exact
418 Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetProperty ("Item", new Type[1] { typeof (Int32) }).DeclaringType, "#01");
420 // Test getting property that is not exact
421 Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetProperty ("Item", new Type[1] { typeof (Int16) }).DeclaringType, "#02");
423 // Test overriding of properties when only the set accessor is overriden
424 Assert.AreEqual (1, typeof (Derived1).GetProperties ().Length, "#03");
428 public void GetEvents ()
431 Assert.AreEqual (1, typeof (Derived2).GetEvents ().Length);
432 Assert.AreEqual (typeof (Derived2), typeof (Derived2).GetEvents ()[0].DeclaringType);
436 public void GetProperties ()
438 // Test hide-by-name-and-signature
439 Assert.AreEqual (1, typeof (Derived2).GetProperties ().Length, "#1");
440 Assert.AreEqual (typeof (Derived2), typeof (Derived2).GetProperties ()[0].DeclaringType, "#2");
442 // For generics, hide-by-name-and-signature works on the unexpanded types. The
443 // GenericIndexers<T,U> class has two indexers that take different arguments.
444 // GetProperties on all instances of this generic type should still have 2 properties,
445 // even if T and U are instantiated with the same types.
447 var ps = typeof (GenericIndexers<int,int>).GetProperties ();
448 Assert.AreEqual (2, ps.Length, "#3");
449 for (int i = 0; i < ps.Length; i++) {
452 var getterResultType = p.GetGetMethod ().ReturnType;
454 var msg = String.Format ("#4-{0}", i);
455 Assert.AreEqual (typeof (int), getterResultType, msg);
460 class GetProperties_Overrides_Input
462 public class TestClass : BaseClass<object>
464 public override object TestProperty { get; set; }
467 public abstract class BaseClass<T>
469 public virtual T TestProperty { get; set; }
472 public class TestClass_Indexer : BaseClass_Indexer<object>
474 public override object this[int arg] { set { } }
477 public abstract class BaseClass_Indexer<T>
479 public virtual T this[int arg] { set { } }
482 public interface IB : IA<object>
484 new object TestProperty { get; set; }
487 public interface IA<T>
489 T TestProperty { get; set; }
492 public class TestClass_HiddenProperty : BaseClass_HiddenProperty
494 public new virtual string Prop { set { } }
497 public class BaseClass_HiddenProperty
499 public virtual string Prop { set { } }
504 public void GetProperties_Overrides ()
506 Assert.AreEqual (1, typeof (GetProperties_Overrides_Input.IB).GetProperties().Length);
508 var prop = typeof (GetProperties_Overrides_Input.TestClass).GetProperty ("TestProperty");
509 Assert.AreEqual (typeof (GetProperties_Overrides_Input.TestClass), prop.DeclaringType);
511 var prop_2 = typeof (GetProperties_Overrides_Input.TestClass_HiddenProperty).GetProperty ("Prop");
512 Assert.AreEqual (typeof (GetProperties_Overrides_Input.TestClass_HiddenProperty), prop_2.DeclaringType);
514 Assert.AreEqual (1, typeof (GetProperties_Overrides_Input.TestClass).GetProperties().Length);
515 Assert.AreEqual (1, typeof (GetProperties_Overrides_Input.TestClass_Indexer).GetProperties().Length);
516 Assert.AreEqual (1, typeof (GetProperties_Overrides_Input.TestClass_HiddenProperty).GetProperties().Length);
519 [Test] // GetProperties (BindingFlags)
520 public void GetProperties_Flags ()
522 PropertyInfo [] props;
523 Type type = typeof (Bar);
526 flags = BindingFlags.Instance | BindingFlags.NonPublic;
527 props = type.GetProperties (flags);
529 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#A1");
530 Assert.IsTrue (ContainsProperty (props, "ProtInstBase"), "#A2");
531 Assert.IsTrue (ContainsProperty (props, "ProIntInstBase"), "#A3");
532 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#A4");
533 Assert.IsTrue (ContainsProperty (props, "IntInstBase"), "#A5");
534 Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#A6");
535 Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#A7");
536 Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#A8");
537 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#A9");
538 Assert.IsTrue (ContainsProperty (props, "IntInst"), "#A10");
539 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#A11");
540 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#A12");
541 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#A13");
542 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#A14");
543 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#A15");
544 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#A16");
545 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#A17");
546 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#A18");
547 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#A19");
548 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#A20");
549 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#A21");
550 Assert.IsTrue (ContainsProperty (props, "ProtInstBlue"), "#A22");
551 Assert.IsTrue (ContainsProperty (props, "ProIntInstBlue"), "#A23");
552 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#A24");
553 Assert.IsTrue (ContainsProperty (props, "IntInstBlue"), "#A25");
554 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#A26");
555 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#A27");
556 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#A28");
557 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#A29");
558 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#A30");
560 flags = BindingFlags.Instance | BindingFlags.Public;
561 props = type.GetProperties (flags);
563 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#B1");
564 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#B2");
565 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#B3");
566 Assert.IsTrue (ContainsProperty (props, "PubInstBase"), "#B4");
567 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#B5");
568 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#B6");
569 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#B7");
570 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#B8");
571 Assert.IsTrue (ContainsProperty (props, "PubInst"), "#B9");
572 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#B10");
573 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#B11");
574 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#B12");
575 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#B13");
576 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#B14");
577 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#B15");
578 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#B16");
579 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#B17");
580 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#B18");
581 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#B19");
582 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#B20");
583 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#B21");
584 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#B22");
585 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#B23");
586 Assert.IsTrue (ContainsProperty (props, "PubInstBlue"), "#B24");
587 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#B25");
588 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#B26");
589 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#B27");
590 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#B28");
591 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#B29");
592 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#B30");
594 flags = BindingFlags.Static | BindingFlags.Public;
595 props = type.GetProperties (flags);
597 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#C1");
598 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#C2");
599 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#C3");
600 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#C4");
601 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#C5");
602 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#C6");
603 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#C7");
604 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#C8");
605 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#C9");
606 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#C10");
607 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#C11");
608 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#C12");
609 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#C13");
610 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#C14");
611 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#C15");
612 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#C16");
613 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#C17");
614 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#C18");
615 Assert.IsTrue (ContainsProperty (props, "PubStat"), "#C19");
616 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#C20");
617 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#C21");
618 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#C22");
619 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#C23");
620 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#C24");
621 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#C25");
622 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#C26");
623 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#C27");
624 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#C28");
625 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#C29");
626 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#C30");
628 flags = BindingFlags.Static | BindingFlags.NonPublic;
629 props = type.GetProperties (flags);
631 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#D1");
632 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#D2");
633 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#D3");
634 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#D4");
635 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#D5");
636 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#D6");
637 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#D7");
638 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#D8");
639 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#D9");
640 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#D10");
641 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#D11");
642 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#D12");
643 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#D13");
644 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#D14");
645 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#D15");
646 Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#D16");
647 Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#D17");
648 Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#D18");
649 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#D19");
650 Assert.IsTrue (ContainsProperty (props, "IntStat"), "#D20");
651 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#D21");
652 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#D22");
653 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#D23");
654 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#D24");
655 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#D25");
656 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#D26");
657 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#D27");
658 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#D28");
659 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#D29");
660 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#D30");
662 flags = BindingFlags.Instance | BindingFlags.NonPublic |
663 BindingFlags.FlattenHierarchy;
664 props = type.GetProperties (flags);
666 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#E1");
667 Assert.IsTrue (ContainsProperty (props, "ProtInstBase"), "#E2");
668 Assert.IsTrue (ContainsProperty (props, "ProIntInstBase"), "#E3");
669 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#E4");
670 Assert.IsTrue (ContainsProperty (props, "IntInstBase"), "#E5");
671 Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#E6");
672 Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#E7");
673 Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#E8");
674 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#E9");
675 Assert.IsTrue (ContainsProperty (props, "IntInst"), "#E10");
676 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#E11");
677 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#E12");
678 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#E13");
679 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#E14");
680 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#E15");
681 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#E16");
682 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#E17");
683 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#E18");
684 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#E19");
685 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#E20");
686 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#E21");
687 Assert.IsTrue (ContainsProperty (props, "ProtInstBlue"), "#E22");
688 Assert.IsTrue (ContainsProperty (props, "ProIntInstBlue"), "#E23");
689 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#E24");
690 Assert.IsTrue (ContainsProperty (props, "IntInstBlue"), "#E25");
691 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#E26");
692 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#E27");
693 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#E28");
694 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#E29");
695 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#E30");
697 flags = BindingFlags.Instance | BindingFlags.Public |
698 BindingFlags.FlattenHierarchy;
699 props = type.GetProperties (flags);
701 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#F1");
702 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#F2");
703 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#F3");
704 Assert.IsTrue (ContainsProperty (props, "PubInstBase"), "#F4");
705 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#F5");
706 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#F6");
707 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#F7");
708 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#F8");
709 Assert.IsTrue (ContainsProperty (props, "PubInst"), "#F9");
710 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#F10");
711 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#F11");
712 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#F12");
713 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#F13");
714 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#F14");
715 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#F15");
716 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#F16");
717 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#F17");
718 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#F18");
719 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#F19");
720 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#F20");
721 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#F21");
722 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#F22");
723 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#F23");
724 Assert.IsTrue (ContainsProperty (props, "PubInstBlue"), "#F24");
725 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#F25");
726 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#F26");
727 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#F27");
728 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#F28");
729 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#F29");
730 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#F30");
732 flags = BindingFlags.Static | BindingFlags.Public |
733 BindingFlags.FlattenHierarchy;
734 props = type.GetProperties (flags);
736 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#G1");
737 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#G2");
738 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#G3");
739 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#G4");
740 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#G5");
741 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#G6");
742 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#G7");
743 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#G8");
744 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#G9");
745 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#G10");
746 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#G11");
747 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#G12");
748 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#G13");
749 Assert.IsTrue (ContainsProperty (props, "PubStatBase"), "#G14");
750 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#G15");
751 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#G16");
752 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#G17");
753 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#G18");
754 Assert.IsTrue (ContainsProperty (props, "PubStat"), "#G19");
755 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#G20");
756 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#G21");
757 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#G22");
758 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#G23");
759 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#G24");
760 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#G25");
761 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#G26");
762 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#G27");
763 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#G28");
764 Assert.IsTrue (ContainsProperty (props, "PubStatBlue"), "#G29");
765 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#G30");
767 flags = BindingFlags.Static | BindingFlags.NonPublic |
768 BindingFlags.FlattenHierarchy;
769 props = type.GetProperties (flags);
771 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#H1");
772 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#H2");
773 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#H3");
774 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#H4");
775 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#H5");
776 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#H6");
777 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#H7");
778 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#H8");
779 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#H9");
780 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#H10");
781 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#H11");
782 Assert.IsTrue (ContainsProperty (props, "ProtStatBase"), "#H12");
783 Assert.IsTrue (ContainsProperty (props, "ProIntStatBase"), "#H13");
784 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#H14");
785 Assert.IsTrue (ContainsProperty (props, "IntStatBase"), "#H15");
786 Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#H16");
787 Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#H17");
788 Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#H18");
789 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#H19");
790 Assert.IsTrue (ContainsProperty (props, "IntStat"), "#H20");
791 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#H21");
792 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#H22");
793 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#H23");
794 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#H24");
795 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#H25");
796 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#H26");
797 Assert.IsTrue (ContainsProperty (props, "ProtStatBlue"), "#H27");
798 Assert.IsTrue (ContainsProperty (props, "ProIntStatBlue"), "#H28");
799 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#H29");
800 Assert.IsTrue (ContainsProperty (props, "IntStatBlue"), "#H30");
802 flags = BindingFlags.Instance | BindingFlags.NonPublic |
803 BindingFlags.DeclaredOnly;
804 props = type.GetProperties (flags);
806 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#I1");
807 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#I2");
808 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#I3");
809 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#I4");
810 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#I5");
811 Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#I6");
812 Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#I7");
813 Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#I8");
814 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#I9");
815 Assert.IsTrue (ContainsProperty (props, "IntInst"), "#I10");
816 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#I11");
817 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#I12");
818 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#I13");
819 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#I14");
820 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#I15");
821 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#I16");
822 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#I17");
823 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#I18");
824 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#I19");
825 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#I20");
826 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#I21");
827 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#I22");
828 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#I23");
829 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#I24");
830 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#I25");
831 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#I26");
832 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#I27");
833 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#I28");
834 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#I29");
835 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#I30");
837 flags = BindingFlags.Instance | BindingFlags.Public |
838 BindingFlags.DeclaredOnly;
839 props = type.GetProperties (flags);
841 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#J1");
842 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#J2");
843 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#J3");
844 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#J4");
845 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#J5");
846 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#J6");
847 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#J7");
848 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#J8");
849 Assert.IsTrue (ContainsProperty (props, "PubInst"), "#J9");
850 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#J10");
851 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#J11");
852 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#J12");
853 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#J13");
854 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#J14");
855 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#J15");
856 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#J16");
857 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#J17");
858 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#J18");
859 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#J19");
860 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#J20");
861 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#J21");
862 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#J22");
863 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#J23");
864 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#J24");
865 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#J25");
866 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#J26");
867 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#J27");
868 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#J28");
869 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#J29");
870 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#J30");
872 flags = BindingFlags.Static | BindingFlags.Public |
873 BindingFlags.DeclaredOnly;
874 props = type.GetProperties (flags);
876 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#K1");
877 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#K2");
878 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#K3");
879 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#K4");
880 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#K5");
881 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#K6");
882 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#K7");
883 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#K8");
884 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#K9");
885 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#K10");
886 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#K11");
887 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#K12");
888 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#K13");
889 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#K14");
890 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#K15");
891 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#K16");
892 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#K17");
893 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#K18");
894 Assert.IsTrue (ContainsProperty (props, "PubStat"), "#K19");
895 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#K20");
896 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#K21");
897 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#K22");
898 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#K23");
899 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#K24");
900 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#K25");
901 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#K26");
902 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#K27");
903 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#K28");
904 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#K29");
905 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#K30");
907 flags = BindingFlags.Static | BindingFlags.NonPublic |
908 BindingFlags.DeclaredOnly;
909 props = type.GetProperties (flags);
911 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#L1");
912 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#L2");
913 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#L3");
914 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#L4");
915 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#L5");
916 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#L6");
917 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#L7");
918 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#L8");
919 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#L9");
920 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#L10");
921 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#L11");
922 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#L12");
923 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#L13");
924 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#L14");
925 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#L15");
926 Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#L16");
927 Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#L17");
928 Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#L18");
929 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#L19");
930 Assert.IsTrue (ContainsProperty (props, "IntStat"), "#L20");
931 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#L21");
932 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#L22");
933 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#L23");
934 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#L24");
935 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#L25");
936 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#L26");
937 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#L27");
938 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#L28");
939 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#L29");
940 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#L30");
942 flags = BindingFlags.Instance | BindingFlags.NonPublic |
944 props = type.GetProperties (flags);
946 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#M1");
947 Assert.IsTrue (ContainsProperty (props, "ProtInstBase"), "#M2");
948 Assert.IsTrue (ContainsProperty (props, "ProIntInstBase"), "#M3");
949 Assert.IsTrue (ContainsProperty (props, "PubInstBase"), "#M4");
950 Assert.IsTrue (ContainsProperty (props, "IntInstBase"), "#M5");
951 Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#M6");
952 Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#M7");
953 Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#M8");
954 Assert.IsTrue (ContainsProperty (props, "PubInst"), "#M9");
955 Assert.IsTrue (ContainsProperty (props, "IntInst"), "#M10");
956 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#M11");
957 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#M12");
958 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#M13");
959 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#M14");
960 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#M15");
961 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#M16");
962 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#M17");
963 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#M18");
964 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#M19");
965 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#M20");
966 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#M21");
967 Assert.IsTrue (ContainsProperty (props, "ProtInstBlue"), "#M22");
968 Assert.IsTrue (ContainsProperty (props, "ProIntInstBlue"), "#M23");
969 Assert.IsTrue (ContainsProperty (props, "PubInstBlue"), "#M24");
970 Assert.IsTrue (ContainsProperty (props, "IntInstBlue"), "#M25");
971 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#M26");
972 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#M27");
973 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#M28");
974 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#M29");
975 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#M30");
977 flags = BindingFlags.Static | BindingFlags.NonPublic |
979 props = type.GetProperties (flags);
981 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#N1");
982 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#N2");
983 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#N3");
984 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#N4");
985 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#N5");
986 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#N6");
987 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#N7");
988 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#N8");
989 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#N9");
990 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#N10");
991 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#N11");
992 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#N12");
993 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#N13");
994 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#N14");
995 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#N15");
996 Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#N16");
997 Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#N17");
998 Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#N18");
999 Assert.IsTrue (ContainsProperty (props, "PubStat"), "#N19");
1000 Assert.IsTrue (ContainsProperty (props, "IntStat"), "#N20");
1001 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#N21");
1002 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#N22");
1003 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#N23");
1004 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#N24");
1005 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#N25");
1006 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#N26");
1007 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#N27");
1008 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#N28");
1009 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#N29");
1010 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#N30");
1013 [Test] // GetProperty (String)
1014 public void GetProperty1_Name_Null ()
1016 Type type = typeof (Bar);
1018 type.GetProperty ((string) null);
1020 } catch (ArgumentNullException ex) {
1021 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1022 Assert.IsNull (ex.InnerException, "#3");
1023 Assert.IsNotNull (ex.Message, "#4");
1024 Assert.IsNotNull (ex.ParamName, "#5");
1025 Assert.AreEqual ("name", ex.ParamName, "#6");
1029 [Test] // GetProperty (String, BindingFlags)
1030 public void GetProperty2 ()
1032 Type type = typeof (Bar);
1035 flags = BindingFlags.Instance | BindingFlags.NonPublic;
1037 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#A1");
1038 Assert.IsNotNull (type.GetProperty ("ProtInstBase", flags), "#A2");
1039 Assert.IsNotNull (type.GetProperty ("ProIntInstBase", flags), "#A3");
1040 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#A4");
1041 Assert.IsNotNull (type.GetProperty ("IntInstBase", flags), "#A5");
1042 Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#A6");
1043 Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#A7");
1044 Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#A8");
1045 Assert.IsNull (type.GetProperty ("PubInst", flags), "#A9");
1046 Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#A10");
1047 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#A11");
1048 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#A12");
1049 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#A13");
1050 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#A14");
1051 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#A15");
1052 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#A16");
1053 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#A17");
1054 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#A18");
1055 Assert.IsNull (type.GetProperty ("PubStat", flags), "#A19");
1056 Assert.IsNull (type.GetProperty ("IntStat", flags), "#A20");
1057 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#A21");
1058 Assert.IsNotNull (type.GetProperty ("ProtInstBlue", flags), "#A22");
1059 Assert.IsNotNull (type.GetProperty ("ProIntInstBlue", flags), "#A23");
1060 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#A24");
1061 Assert.IsNotNull (type.GetProperty ("IntInstBlue", flags), "#A25");
1062 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#A26");
1063 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#A27");
1064 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#A28");
1065 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#A29");
1066 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#A30");
1068 flags = BindingFlags.Instance | BindingFlags.Public;
1070 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#B1");
1071 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#B2");
1072 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#B3");
1073 Assert.IsNotNull (type.GetProperty ("PubInstBase", flags), "#B4");
1074 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#B5");
1075 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#B6");
1076 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#B7");
1077 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#B8");
1078 Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#B9");
1079 Assert.IsNull (type.GetProperty ("IntInst", flags), "#B10");
1080 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#B11");
1081 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#B12");
1082 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#B13");
1083 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#B14");
1084 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#B15");
1085 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#B16");
1086 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#B17");
1087 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#B18");
1088 Assert.IsNull (type.GetProperty ("PubStat", flags), "#B19");
1089 Assert.IsNull (type.GetProperty ("IntStat", flags), "#B20");
1090 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#B21");
1091 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#B22");
1092 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#B23");
1093 Assert.IsNotNull (type.GetProperty ("PubInstBlue", flags), "#B24");
1094 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#B25");
1095 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#B26");
1096 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#B27");
1097 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#B28");
1098 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#B29");
1099 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#B30");
1101 flags = BindingFlags.Static | BindingFlags.Public;
1103 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#C1");
1104 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#C2");
1105 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#C3");
1106 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#C4");
1107 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#C5");
1108 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#C6");
1109 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#C7");
1110 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#C8");
1111 Assert.IsNull (type.GetProperty ("PubInst", flags), "#C9");
1112 Assert.IsNull (type.GetProperty ("IntInst", flags), "#C10");
1113 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#C11");
1114 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#C12");
1115 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#C13");
1116 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#C14");
1117 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#C15");
1118 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#C16");
1119 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#C17");
1120 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#C18");
1121 Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#C19");
1122 Assert.IsNull (type.GetProperty ("IntStat", flags), "#C20");
1123 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#C21");
1124 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#C22");
1125 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#C23");
1126 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#C24");
1127 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#C25");
1128 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#C26");
1129 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#C27");
1130 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#C28");
1131 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#C29");
1132 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#C30");
1134 flags = BindingFlags.Static | BindingFlags.NonPublic;
1136 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#D1");
1137 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#D2");
1138 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#D3");
1139 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#D4");
1140 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#D5");
1141 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#D6");
1142 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#D7");
1143 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#D8");
1144 Assert.IsNull (type.GetProperty ("PubInst", flags), "#D9");
1145 Assert.IsNull (type.GetProperty ("IntInst", flags), "#D10");
1146 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#D11");
1147 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#D12");
1148 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#D13");
1149 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#D14");
1150 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#D15");
1151 Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#D16");
1152 Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#D17");
1153 Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#D18");
1154 Assert.IsNull (type.GetProperty ("PubStat", flags), "#D19");
1155 Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#D20");
1156 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#D21");
1157 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#D22");
1158 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#D23");
1159 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#D24");
1160 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#D25");
1161 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#D26");
1162 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#D27");
1163 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#D28");
1164 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#D29");
1165 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#D30");
1167 flags = BindingFlags.Instance | BindingFlags.NonPublic |
1168 BindingFlags.FlattenHierarchy;
1170 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#E1");
1171 Assert.IsNotNull (type.GetProperty ("ProtInstBase", flags), "#E2");
1172 Assert.IsNotNull (type.GetProperty ("ProIntInstBase", flags), "#E3");
1173 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#E4");
1174 Assert.IsNotNull (type.GetProperty ("IntInstBase", flags), "#E5");
1175 Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#E6");
1176 Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#E7");
1177 Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#E8");
1178 Assert.IsNull (type.GetProperty ("PubInst", flags), "#E9");
1179 Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#E10");
1180 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#E11");
1181 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#E12");
1182 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#E13");
1183 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#E14");
1184 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#E15");
1185 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#E16");
1186 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#E17");
1187 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#E18");
1188 Assert.IsNull (type.GetProperty ("PubStat", flags), "#E19");
1189 Assert.IsNull (type.GetProperty ("IntStat", flags), "#E20");
1190 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#E21");
1191 Assert.IsNotNull (type.GetProperty ("ProtInstBlue", flags), "#E22");
1192 Assert.IsNotNull (type.GetProperty ("ProIntInstBlue", flags), "#E23");
1193 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#E24");
1194 Assert.IsNotNull (type.GetProperty ("IntInstBlue", flags), "#E25");
1195 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#E26");
1196 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#E27");
1197 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#E28");
1198 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#E29");
1199 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#E30");
1201 flags = BindingFlags.Instance | BindingFlags.Public |
1202 BindingFlags.FlattenHierarchy;
1204 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#F1");
1205 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#F2");
1206 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#F3");
1207 Assert.IsNotNull (type.GetProperty ("PubInstBase", flags), "#F4");
1208 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#F5");
1209 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#F6");
1210 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#F7");
1211 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#F8");
1212 Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#F9");
1213 Assert.IsNull (type.GetProperty ("IntInst", flags), "#F10");
1214 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#F11");
1215 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#F12");
1216 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#F13");
1217 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#F14");
1218 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#F15");
1219 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#F16");
1220 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#F17");
1221 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#F18");
1222 Assert.IsNull (type.GetProperty ("PubStat", flags), "#F19");
1223 Assert.IsNull (type.GetProperty ("IntStat", flags), "#F20");
1224 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#F21");
1225 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#F22");
1226 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#F23");
1227 Assert.IsNotNull (type.GetProperty ("PubInstBlue", flags), "#F24");
1228 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#F25");
1229 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#F26");
1230 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#F27");
1231 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#F28");
1232 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#F29");
1233 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#F30");
1235 flags = BindingFlags.Static | BindingFlags.Public |
1236 BindingFlags.FlattenHierarchy;
1238 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#G1");
1239 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#G2");
1240 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#G3");
1241 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#G4");
1242 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#G5");
1243 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#G6");
1244 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#G7");
1245 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#G8");
1246 Assert.IsNull (type.GetProperty ("PubInst", flags), "#G9");
1247 Assert.IsNull (type.GetProperty ("IntInst", flags), "#G10");
1248 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#G11");
1249 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#G12");
1250 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#G13");
1251 Assert.IsNotNull (type.GetProperty ("PubStatBase", flags), "#G14");
1252 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#G15");
1253 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#G16");
1254 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#G17");
1255 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#G18");
1256 Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#G19");
1257 Assert.IsNull (type.GetProperty ("IntStat", flags), "#G20");
1258 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#G21");
1259 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#G22");
1260 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#G23");
1261 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#G24");
1262 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#G25");
1263 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#G26");
1264 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#G27");
1265 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#G28");
1266 Assert.IsNotNull (type.GetProperty ("PubStatBlue", flags), "#G29");
1267 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#G30");
1269 flags = BindingFlags.Static | BindingFlags.NonPublic |
1270 BindingFlags.FlattenHierarchy;
1272 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#H1");
1273 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#H2");
1274 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#H3");
1275 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#H4");
1276 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#H5");
1277 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#H6");
1278 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#H7");
1279 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#H8");
1280 Assert.IsNull (type.GetProperty ("PubInst", flags), "#H9");
1281 Assert.IsNull (type.GetProperty ("IntInst", flags), "#H10");
1282 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#H11");
1283 Assert.IsNotNull (type.GetProperty ("ProtStatBase", flags), "#H12");
1284 Assert.IsNotNull (type.GetProperty ("ProIntStatBase", flags), "#H13");
1285 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#H14");
1286 Assert.IsNotNull (type.GetProperty ("IntStatBase", flags), "#H15");
1287 Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#H16");
1288 Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#H17");
1289 Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#H18");
1290 Assert.IsNull (type.GetProperty ("PubStat", flags), "#H19");
1291 Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#H20");
1292 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#H21");
1293 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#H22");
1294 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#H23");
1295 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#H24");
1296 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#H25");
1297 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#H26");
1298 Assert.IsNotNull (type.GetProperty ("ProtStatBlue", flags), "#H27");
1299 Assert.IsNotNull (type.GetProperty ("ProIntStatBlue", flags), "#H28");
1300 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#H29");
1301 Assert.IsNotNull (type.GetProperty ("IntStatBlue", flags), "#H30");
1303 flags = BindingFlags.Instance | BindingFlags.NonPublic |
1304 BindingFlags.DeclaredOnly;
1306 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#I1");
1307 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#I2");
1308 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#I3");
1309 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#I4");
1310 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#I5");
1311 Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#I6");
1312 Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#I7");
1313 Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#I8");
1314 Assert.IsNull (type.GetProperty ("PubInst", flags), "#I9");
1315 Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#I10");
1316 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#I11");
1317 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#I12");
1318 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#I13");
1319 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#I14");
1320 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#I15");
1321 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#I16");
1322 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#I17");
1323 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#I18");
1324 Assert.IsNull (type.GetProperty ("PubStat", flags), "#I19");
1325 Assert.IsNull (type.GetProperty ("IntStat", flags), "#I20");
1326 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#I21");
1327 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#I22");
1328 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#I23");
1329 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#I24");
1330 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#I25");
1331 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#I26");
1332 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#I27");
1333 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#I28");
1334 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#I29");
1335 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#I30");
1337 flags = BindingFlags.Instance | BindingFlags.Public |
1338 BindingFlags.DeclaredOnly;
1340 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#J1");
1341 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#J2");
1342 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#J3");
1343 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#J4");
1344 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#J5");
1345 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#J6");
1346 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#J7");
1347 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#J8");
1348 Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#J9");
1349 Assert.IsNull (type.GetProperty ("IntInst", flags), "#J10");
1350 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#J11");
1351 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#J12");
1352 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#J13");
1353 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#J14");
1354 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#J15");
1355 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#J16");
1356 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#J17");
1357 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#J18");
1358 Assert.IsNull (type.GetProperty ("PubStat", flags), "#J19");
1359 Assert.IsNull (type.GetProperty ("IntStat", flags), "#J20");
1360 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#J21");
1361 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#J22");
1362 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#J23");
1363 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#J24");
1364 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#J25");
1365 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#J26");
1366 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#J27");
1367 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#J28");
1368 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#J29");
1369 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#J30");
1371 flags = BindingFlags.Static | BindingFlags.Public |
1372 BindingFlags.DeclaredOnly;
1374 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#K1");
1375 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#K2");
1376 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#K3");
1377 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#K4");
1378 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#K5");
1379 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#K6");
1380 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#K7");
1381 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#K8");
1382 Assert.IsNull (type.GetProperty ("PubInst", flags), "#K9");
1383 Assert.IsNull (type.GetProperty ("IntInst", flags), "#K10");
1384 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#K11");
1385 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#K12");
1386 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#K13");
1387 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#K14");
1388 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#K15");
1389 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#K16");
1390 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#K17");
1391 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#K18");
1392 Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#K19");
1393 Assert.IsNull (type.GetProperty ("IntStat", flags), "#K20");
1394 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#K21");
1395 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#K22");
1396 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#K23");
1397 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#K24");
1398 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#K25");
1399 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#K26");
1400 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#K27");
1401 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#K28");
1402 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#K29");
1403 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#K30");
1405 flags = BindingFlags.Static | BindingFlags.NonPublic |
1406 BindingFlags.DeclaredOnly;
1408 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#L1");
1409 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#L2");
1410 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#L3");
1411 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#L4");
1412 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#L5");
1413 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#L6");
1414 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#L7");
1415 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#L8");
1416 Assert.IsNull (type.GetProperty ("PubInst", flags), "#L9");
1417 Assert.IsNull (type.GetProperty ("IntInst", flags), "#L10");
1418 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#L11");
1419 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#L12");
1420 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#L13");
1421 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#L14");
1422 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#L15");
1423 Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#L16");
1424 Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#L17");
1425 Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#L18");
1426 Assert.IsNull (type.GetProperty ("PubStat", flags), "#L19");
1427 Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#L20");
1428 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#L21");
1429 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#L22");
1430 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#L23");
1431 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#L24");
1432 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#L25");
1433 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#L26");
1434 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#L27");
1435 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#L28");
1436 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#L29");
1437 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#L30");
1439 flags = BindingFlags.Instance | BindingFlags.NonPublic |
1440 BindingFlags.Public;
1442 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#M1");
1443 Assert.IsNotNull (type.GetProperty ("ProtInstBase", flags), "#M2");
1444 Assert.IsNotNull (type.GetProperty ("ProIntInstBase", flags), "#M3");
1445 Assert.IsNotNull (type.GetProperty ("PubInstBase", flags), "#M4");
1446 Assert.IsNotNull (type.GetProperty ("IntInstBase", flags), "#M5");
1447 Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#M6");
1448 Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#M7");
1449 Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#M8");
1450 Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#M9");
1451 Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#M10");
1452 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#M11");
1453 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#M12");
1454 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#M13");
1455 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#M14");
1456 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#M15");
1457 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#M16");
1458 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#M17");
1459 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#M18");
1460 Assert.IsNull (type.GetProperty ("PubStat", flags), "#M19");
1461 Assert.IsNull (type.GetProperty ("IntStat", flags), "#M20");
1462 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#M21");
1463 Assert.IsNotNull (type.GetProperty ("ProtInstBlue", flags), "#M22");
1464 Assert.IsNotNull (type.GetProperty ("ProIntInstBlue", flags), "#M23");
1465 Assert.IsNotNull (type.GetProperty ("PubInstBlue", flags), "#M24");
1466 Assert.IsNotNull (type.GetProperty ("IntInstBlue", flags), "#M25");
1467 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#M26");
1468 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#M27");
1469 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#M28");
1470 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#M29");
1471 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#M30");
1473 flags = BindingFlags.Static | BindingFlags.NonPublic |
1474 BindingFlags.Public;
1476 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#N1");
1477 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#N2");
1478 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#N3");
1479 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#N4");
1480 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#N5");
1481 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#N6");
1482 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#N7");
1483 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#N8");
1484 Assert.IsNull (type.GetProperty ("PubInst", flags), "#N9");
1485 Assert.IsNull (type.GetProperty ("IntInst", flags), "#N10");
1486 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#N11");
1487 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#N12");
1488 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#N13");
1489 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#N14");
1490 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#N15");
1491 Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#N16");
1492 Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#N17");
1493 Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#N18");
1494 Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#N19");
1495 Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#N20");
1496 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#N21");
1497 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#N22");
1498 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#N23");
1499 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#N24");
1500 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#N25");
1501 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#N26");
1502 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#N27");
1503 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#N28");
1504 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#N29");
1505 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#N30");
1508 [Test] // GetProperty (String, BindingFlags)
1509 public void GetProperty2_Name_Null ()
1511 Type type = typeof (Bar);
1513 type.GetProperty ((string) null);
1515 } catch (ArgumentNullException ex) {
1516 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1517 Assert.IsNull (ex.InnerException, "#3");
1518 Assert.IsNotNull (ex.Message, "#4");
1519 Assert.IsNotNull (ex.ParamName, "#5");
1520 Assert.AreEqual ("name", ex.ParamName, "#6");
1524 [Test] // GetProperty (String, Type)
1525 public void GetProperty3_Name_Null ()
1527 Type type = typeof (Bar);
1529 type.GetProperty ((string) null, typeof (int));
1531 } catch (ArgumentNullException ex) {
1532 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1533 Assert.IsNull (ex.InnerException, "#3");
1534 Assert.IsNotNull (ex.Message, "#4");
1535 Assert.IsNotNull (ex.ParamName, "#5");
1536 Assert.AreEqual ("name", ex.ParamName, "#6");
1540 [Test] // GetProperty (String, Type [])
1541 public void GetProperty4_Name_Null ()
1543 Type type = typeof (Bar);
1545 type.GetProperty ((string) null, Type.EmptyTypes);
1547 } catch (ArgumentNullException ex) {
1548 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1549 Assert.IsNull (ex.InnerException, "#3");
1550 Assert.IsNotNull (ex.Message, "#4");
1551 Assert.IsNotNull (ex.ParamName, "#5");
1552 Assert.AreEqual ("name", ex.ParamName, "#6");
1556 [Test] // GetProperty (String, Type, Type [])
1557 public void GetProperty5_Name_Null ()
1559 Type type = typeof (Bar);
1561 type.GetProperty ((string) null, typeof (int),
1564 } catch (ArgumentNullException ex) {
1565 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1566 Assert.IsNull (ex.InnerException, "#3");
1567 Assert.IsNotNull (ex.Message, "#4");
1568 Assert.IsNotNull (ex.ParamName, "#5");
1569 Assert.AreEqual ("name", ex.ParamName, "#6");
1573 [Test] // GetProperty (String, Type, Type [], ParameterModifier [])
1574 public void GetProperty6_Name_Null ()
1576 Type type = typeof (Bar);
1578 type.GetProperty ((string) null, typeof (int),
1579 Type.EmptyTypes, null);
1581 } catch (ArgumentNullException ex) {
1582 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1583 Assert.IsNull (ex.InnerException, "#3");
1584 Assert.IsNotNull (ex.Message, "#4");
1585 Assert.IsNotNull (ex.ParamName, "#5");
1586 Assert.AreEqual ("name", ex.ParamName, "#6");
1590 [Test] // GetProperty (String, BindingFlags, Binder, Type, Type [], ParameterModifier [])
1591 public void GetProperty7_Name_Null ()
1593 Type type = typeof (Bar);
1595 type.GetProperty ((string) null, BindingFlags.Public,
1596 null, typeof (int), Type.EmptyTypes, null);
1598 } catch (ArgumentNullException ex) {
1599 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1600 Assert.IsNull (ex.InnerException, "#3");
1601 Assert.IsNotNull (ex.Message, "#4");
1602 Assert.IsNotNull (ex.ParamName, "#5");
1603 Assert.AreEqual ("name", ex.ParamName, "#6");
1608 public void GetProperty8_PropertyType ()
1610 Type type = typeof (Bar);
1611 Assert.IsNull (type.GetProperty ("PubInst", BindingFlags.Public | BindingFlags.Instance,
1612 null, typeof (int), Type.EmptyTypes, null), "#1");
1613 Assert.IsNotNull (type.GetProperty ("PubInst", BindingFlags.Public | BindingFlags.Instance, null,
1614 typeof (long), new Type[0], null), "#2");
1618 public void GetProperty9_Indexers ()
1621 var bindingFlags = BindingFlags.Public | BindingFlags.Instance;
1623 Type type1 = typeof (List<byte>);
1624 var p1 = type1.GetProperty ("Item", bindingFlags, null, typeof (byte), new Type[] { typeof (int) }, null);
1625 Assert.IsNotNull (p1, "#1");
1627 Type type2 = typeof (List<string>);
1628 var p2 = type2.GetProperty ("Item", bindingFlags, null, typeof (string), new Type[] { typeof (int) }, null);
1629 Assert.IsNotNull (p2, "#2");
1631 Type type3 = typeof (List<Type>);
1632 // result type not convertible, make sure we fail.
1633 var p3 = type3.GetProperty ("Item", bindingFlags, null, typeof (string) /*!*/,
1634 new Type[] { typeof (int) }, null);
1635 Assert.IsNull (p3, "#3");
1638 [StructLayout(LayoutKind.Explicit, Pack = 4, Size = 64)]
1643 [StructLayout(LayoutKind.Explicit, CharSet=CharSet.Unicode)]
1649 public void StructLayoutAttribute ()
1651 StructLayoutAttribute attr1 = typeof (TypeTest).StructLayoutAttribute;
1652 Assert.AreEqual (LayoutKind.Auto, attr1.Value);
1654 StructLayoutAttribute attr2 = typeof (Class1).StructLayoutAttribute;
1655 Assert.AreEqual (LayoutKind.Explicit, attr2.Value);
1656 Assert.AreEqual (4, attr2.Pack);
1657 Assert.AreEqual (64, attr2.Size);
1659 StructLayoutAttribute attr3 = typeof (Class2).StructLayoutAttribute;
1660 Assert.AreEqual (LayoutKind.Explicit, attr3.Value);
1661 Assert.AreEqual (CharSet.Unicode, attr3.CharSet);
1665 public void Namespace ()
1667 Assert.AreEqual (null, typeof (NoNamespaceClass).Namespace);
1671 public void GenericParameterNamespace ()
1673 var t = typeof (Foo<>).GetGenericArguments () [0];
1675 Assert.AreEqual ("T", t.Name);
1676 Assert.AreEqual ("MonoTests.System", t.Namespace);
1678 var s = typeof (Gazonk).GetMethod ("Bang").GetGenericArguments () [0];
1680 Assert.AreEqual ("S", s.Name);
1681 Assert.AreEqual ("MonoTests.System", s.Namespace);
1684 public static void Reflected (ref int a)
1691 Assert.AreEqual ("Int32&", typeof (TypeTest).GetMethod ("Reflected").GetParameters () [0].ParameterType.Name);
1692 Assert.AreEqual ("String[*]", Array.CreateInstance (typeof(string), new int[] { 1 }, new int[] { 1 }).GetType ().Name);
1696 public void GetInterfaces ()
1698 Type[] t = typeof (Duper).GetInterfaces ();
1699 Assert.AreEqual (1, t.Length);
1700 Assert.AreEqual (typeof (ICloneable), t[0]);
1702 Type[] t2 = typeof (IFace3).GetInterfaces ();
1703 Assert.AreEqual (2, t2.Length);
1707 public void GetInterfacesGenericVarWithConstraints ()
1709 var a = typeof (TypeTest).GetMethod ("GenericMethod");
1711 var p = a.GetParameters ();
1712 var i = p[0].ParameterType.GetElementType ();
1716 public static void GenericMethod<T, T2> (T[] arr) where T: IComparable<T> {
1722 public void GetFieldIgnoreCase ()
1724 Assert.IsNotNull (typeof (TypeTest).GetField ("afield", BindingFlags.Instance|BindingFlags.Public|BindingFlags.IgnoreCase));
1737 public void GetPropertyAccessorModifiers ()
1739 Assert.IsNotNull (typeof (TypeTest).GetProperty ("Count", BindingFlags.Instance | BindingFlags.Public));
1740 Assert.IsNull (typeof (TypeTest).GetProperty ("Count", BindingFlags.Instance | BindingFlags.NonPublic));
1744 public void IsAbstract ()
1746 Assert.IsFalse (typeof (string).IsAbstract, "#1");
1747 Assert.IsTrue (typeof (ICloneable).IsAbstract, "#2");
1748 Assert.IsTrue (typeof (ValueType).IsAbstract, "#3");
1749 Assert.IsTrue (typeof (Enum).IsAbstract, "#4");
1750 Assert.IsFalse (typeof (TimeSpan).IsAbstract, "#5");
1751 Assert.IsTrue (typeof (TextReader).IsAbstract, "#6");
1754 // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=286308
1755 Type [] typeArgs = typeof (List<>).GetGenericArguments ();
1756 Assert.IsFalse (typeArgs [0].IsAbstract, "#7");
1760 public void IsCOMObject ()
1762 Type type = typeof (string);
1763 Assert.IsFalse (type.IsCOMObject, "#1");
1765 TypeBuilder tb = module.DefineType (genTypeName ());
1766 type = tb.CreateType ();
1767 Assert.IsFalse (type.IsCOMObject, "#2");
1771 public void IsImport ()
1773 Type type = typeof (string);
1774 Assert.IsFalse (type.IsImport, "#1");
1776 TypeBuilder tb = module.DefineType (genTypeName ());
1777 type = tb.CreateType ();
1778 Assert.IsFalse (type.IsImport, "#2");
1780 tb = module.DefineType (genTypeName (), TypeAttributes.Import |
1781 TypeAttributes.Interface | TypeAttributes.Abstract);
1782 type = tb.CreateType ();
1783 Assert.IsTrue (type.IsImport, "#3");
1787 public void IsInterface ()
1789 Assert.IsFalse (typeof (string).IsInterface, "#1");
1790 Assert.IsTrue (typeof (ICloneable).IsInterface, "#2");
1794 public void IsPrimitive () {
1795 Assert.IsTrue (typeof (IntPtr).IsPrimitive, "#1");
1796 Assert.IsTrue (typeof (int).IsPrimitive, "#2");
1797 Assert.IsFalse (typeof (string).IsPrimitive, "#2");
1801 public void IsValueType ()
1803 Assert.IsTrue (typeof (int).IsValueType, "#1");
1804 Assert.IsFalse (typeof (Enum).IsValueType, "#2");
1805 Assert.IsFalse (typeof (ValueType).IsValueType, "#3");
1806 Assert.IsTrue (typeof (AttributeTargets).IsValueType, "#4");
1807 Assert.IsFalse (typeof (string).IsValueType, "#5");
1808 Assert.IsTrue (typeof (TimeSpan).IsValueType, "#6");
1812 public void IsVisible ()
1814 Assert.IsTrue (typeof (int).IsVisible, "#1");
1815 Assert.IsTrue (typeof (Nested).IsVisible, "#2");
1819 public void GetTypeNonVectorArray ()
1821 Type t = Type.GetType ("System.String[*]");
1822 Assert.AreEqual ("System.String[*]", t.ToString ());
1827 public void TypeFromCLSID ()
1829 Guid CLSID_ShellDesktop = new Guid("00021400-0000-0000-c000-000000000046");
1830 Guid CLSID_Bogus = new Guid("1ea9d7a9-f7ab-443b-b486-30d285b21f1b");
1832 Type t1 = Type.GetTypeFromCLSID (CLSID_ShellDesktop);
1834 Type t2 = Type.GetTypeFromCLSID (CLSID_Bogus);
1836 Assert.AreEqual (t1.FullName, "System.__ComObject");
1838 if (!isMono && (Environment.OSVersion.Platform == PlatformID.Win32Windows ||
1839 Environment.OSVersion.Platform == PlatformID.Win32NT))
1840 Activator.CreateInstance(t1);
1842 Assert.AreEqual (t2.FullName, "System.__ComObject");
1844 Assert.AreNotEqual (t1, t2);
1848 [Category("NotWorking")] // Mono throws TargetInvokationException
1849 [ExpectedException("System.Runtime.InteropServices.COMException")]
1850 public void TypeFromCLSIDBogus ()
1852 Guid CLSID_Bogus = new Guid("1ea9d7a9-f7ab-443b-b486-30d285b21f1b");
1853 Type t = Type.GetTypeFromCLSID (CLSID_Bogus);
1854 if (Environment.OSVersion.Platform == PlatformID.Win32Windows ||
1855 Environment.OSVersion.Platform == PlatformID.Win32NT)
1856 Activator.CreateInstance(t);
1858 throw new COMException ();
1862 public void ExerciseFilterName ()
1864 MemberInfo[] mi = typeof(Base).FindMembers(
1866 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1867 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1868 Type.FilterName, "*");
1869 Assert.AreEqual (4, mi.Length);
1870 mi = typeof(Base).FindMembers(
1872 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1873 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1874 Type.FilterName, "Test*");
1875 Assert.AreEqual (2, mi.Length);
1876 mi = typeof(Base).FindMembers(
1878 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1879 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1880 Type.FilterName, "TestVoid");
1881 Assert.AreEqual (1, mi.Length);
1882 mi = typeof(Base).FindMembers(
1884 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1885 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1886 Type.FilterName, "NonExistingMethod");
1887 Assert.AreEqual (0, mi.Length);
1891 public void ExerciseFilterNameIgnoreCase ()
1893 MemberInfo[] mi = typeof(Base).FindMembers(
1895 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1896 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1897 Type.FilterNameIgnoreCase, "*");
1898 Assert.AreEqual (4, mi.Length);
1899 mi = typeof(Base).FindMembers(
1901 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1902 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1903 Type.FilterNameIgnoreCase, "test*");
1904 Assert.AreEqual (2, mi.Length);
1905 mi = typeof(Base).FindMembers(
1907 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1908 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1909 Type.FilterNameIgnoreCase, "TESTVOID");
1910 Assert.AreEqual (1, mi.Length);
1911 mi = typeof(Base).FindMembers(
1913 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1914 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1915 Type.FilterNameIgnoreCase, "NonExistingMethod");
1916 Assert.AreEqual (0, mi.Length);
1920 [ExpectedException (typeof (InvalidFilterCriteriaException))]
1921 public void FilterAttribute_Invalid ()
1923 Type.FilterAttribute (MethodBase.GetCurrentMethod (), (byte) 1);
1927 public void GenericParameterMemberType ()
1929 var t = typeof (Foo<>).GetGenericArguments () [0];
1930 Assert.IsNotNull (t);
1932 Assert.AreEqual (MemberTypes.TypeInfo, t.MemberType);
1938 public int property {
1941 public ByRef0 (int i) {}
1942 public void f (int i) {}
1946 public void ByrefTypes ()
1948 Type t = Type.GetType ("MonoTests.System.TypeTest+ByRef0&");
1949 Assert.IsNotNull (t);
1950 Assert.IsTrue (t.IsByRef);
1951 Assert.AreEqual (0, t.GetMethods (BindingFlags.Public | BindingFlags.Instance).Length);
1952 Assert.AreEqual (0, t.GetConstructors (BindingFlags.Public | BindingFlags.Instance).Length);
1953 Assert.AreEqual (0, t.GetEvents (BindingFlags.Public | BindingFlags.Instance).Length);
1954 Assert.AreEqual (0, t.GetProperties (BindingFlags.Public | BindingFlags.Instance).Length);
1956 Assert.IsNull (t.GetMethod ("f"));
1957 Assert.IsNull (t.GetField ("field"));
1958 Assert.IsNull (t.GetProperty ("property"));
1962 public void TestAssemblyQualifiedName ()
1964 Type t = Type.GetType ("System.Byte[]&");
1965 Assert.IsTrue (t.AssemblyQualifiedName.StartsWith ("System.Byte[]&"));
1967 t = Type.GetType ("System.Byte*&");
1968 Assert.IsTrue (t.AssemblyQualifiedName.StartsWith ("System.Byte*&"));
1970 t = Type.GetType ("System.Byte&");
1971 Assert.IsTrue (t.AssemblyQualifiedName.StartsWith ("System.Byte&"));
1976 #pragma warning disable 169
1978 #pragma warning restore 169
1982 public void CreateValueTypeNoCtor ()
1984 typeof(B).InvokeMember ("", BindingFlags.CreateInstance, null, null, null);
1988 [ExpectedException (typeof (MissingMethodException))]
1989 public void CreateValueTypeNoCtorArgs ()
1991 typeof(B).InvokeMember ("", BindingFlags.CreateInstance, null, null, new object [] { 1 });
1995 [ExpectedException (typeof (MissingMethodException))]
1996 public void InvokeGetPropertyMissing ()
1998 typeof(B).InvokeMember ("", BindingFlags.GetProperty, null, null, new object [] { 1 });
2002 [ExpectedException (typeof (MissingMethodException))]
2003 public void InvokeSetPropertyMissing ()
2005 typeof(B).InvokeMember ("", BindingFlags.SetProperty, null, null, new object [] { 1 });
2008 internal static string bug336841 (string param1, params string [] param2)
2010 StringBuilder sb = new StringBuilder ();
2014 for (int i = 0; i < param2.Length; i++) {
2017 sb.Append (param2 [i]);
2019 return sb.ToString ();
2022 internal static string bug336841 (string param1)
2024 return "#B:" + param1;
2027 internal static string bug336841 (params string [] param1)
2029 StringBuilder sb = new StringBuilder ();
2031 for (int i = 0; i < param1.Length; i++) {
2034 sb.Append (param1 [i]);
2036 return sb.ToString ();
2040 public void InvokeMember_GetSetField ()
2042 typeof (X).InvokeMember ("Value", BindingFlags.Public |
2043 BindingFlags.Static | BindingFlags.FlattenHierarchy |
2044 BindingFlags.SetField, null, null, new object [] { 5 });
2046 Assert.AreEqual (5, X.Value, "#A1");
2047 Assert.AreEqual (5, typeof (X).InvokeMember ("Value",
2048 BindingFlags.Public | BindingFlags.Static |
2049 BindingFlags.FlattenHierarchy | BindingFlags.GetField,
2050 null, null, new object [0]), "#A2");
2051 Assert.AreEqual (5, Y.Value, "#A3");
2052 Assert.AreEqual (5, typeof (Y).InvokeMember ("Value",
2053 BindingFlags.Public | BindingFlags.Static |
2054 BindingFlags.FlattenHierarchy | BindingFlags.GetField,
2055 null, null, new object [0]), "#A4");
2058 typeof (X).InvokeMember ("Value", BindingFlags.Public |
2059 BindingFlags.Static | BindingFlags.FlattenHierarchy |
2060 BindingFlags.GetField | BindingFlags.SetField,
2061 null, null, new object [] { 5 });
2062 Assert.Fail ("#B1");
2063 } catch (ArgumentException ex) {
2064 // Cannot specify both Get and Set on a field
2065 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
2066 Assert.IsNull (ex.InnerException, "#B3");
2067 Assert.IsNotNull (ex.Message, "#B4");
2068 Assert.IsNotNull (ex.ParamName, "#B5");
2069 Assert.AreEqual ("bindingFlags", ex.ParamName, "#B6");
2074 public void InvokeMember_GetSetProperty ()
2077 typeof (ArrayList).InvokeMember ("Item",
2078 BindingFlags.GetProperty | BindingFlags.SetProperty |
2079 BindingFlags.Instance | BindingFlags.Public,
2080 null, new ArrayList (), new object [] { 0, "bar" });
2082 } catch (ArgumentException ex) {
2083 // Cannot specify both Get and Set on a property
2084 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
2085 Assert.IsNull (ex.InnerException, "#3");
2086 Assert.IsNotNull (ex.Message, "#4");
2087 Assert.IsNotNull (ex.ParamName, "#5");
2088 Assert.AreEqual ("bindingFlags", ex.ParamName, "#6");
2094 public void InvokeMember_InvokeMethod_Set ()
2097 typeof (ArrayList).InvokeMember ("ToString",
2098 BindingFlags.InvokeMethod | BindingFlags.SetField |
2099 BindingFlags.Instance | BindingFlags.Public,
2100 null, new ArrayList (), new object [0]);
2101 Assert.Fail ("#A1");
2102 } catch (ArgumentException ex) {
2103 // Cannot specify Set on a field and Invoke on a method
2104 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
2105 Assert.IsNull (ex.InnerException, "#A3");
2106 Assert.IsNotNull (ex.Message, "#A4");
2107 Assert.IsNotNull (ex.ParamName, "#A5");
2108 Assert.AreEqual ("bindingFlags", ex.ParamName, "#A6");
2112 typeof (ArrayList).InvokeMember ("ToString",
2113 BindingFlags.InvokeMethod | BindingFlags.SetProperty |
2114 BindingFlags.Instance | BindingFlags.Public,
2115 null, new ArrayList (), new object [0]);
2116 Assert.Fail ("#B1");
2117 } catch (ArgumentException ex) {
2118 // Cannot specify Set on a property and Invoke on a method
2119 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
2120 Assert.IsNull (ex.InnerException, "#B3");
2121 Assert.IsNotNull (ex.Message, "#B4");
2122 Assert.IsNotNull (ex.ParamName, "#B5");
2123 Assert.AreEqual ("bindingFlags", ex.ParamName, "#B6");
2128 public void InvokeMember_MatchPrimitiveTypeWithInterface ()
2130 object [] invokeargs = { 1 };
2131 typeof (Z).InvokeMember ("", BindingFlags.DeclaredOnly |
2132 BindingFlags.Public | BindingFlags.NonPublic |
2133 BindingFlags.Instance | BindingFlags.CreateInstance,
2134 null, null, invokeargs);
2138 public void InvokeMember_Name_Null ()
2141 typeof (X).InvokeMember ((string) null,
2142 BindingFlags.Public | BindingFlags.Static |
2143 BindingFlags.FlattenHierarchy | BindingFlags.SetField,
2144 null, null, new object [] { 5 });
2146 } catch (ArgumentNullException ex) {
2147 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2148 Assert.IsNull (ex.InnerException, "#3");
2149 Assert.IsNotNull (ex.Message, "#4");
2150 Assert.IsNotNull (ex.ParamName, "#5");
2151 Assert.AreEqual ("name", ex.ParamName, "#6");
2156 public void InvokeMember_NoOperation ()
2159 typeof (TypeTest).InvokeMember ("Run", BindingFlags.Public |
2160 BindingFlags.Static, null, null, new object [0]);
2162 } catch (ArgumentException ex) {
2163 // Must specify binding flags describing the
2164 // invoke operation required
2165 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
2166 Assert.IsNull (ex.InnerException, "#3");
2167 Assert.IsNotNull (ex.Message, "#4");
2168 Assert.IsNotNull (ex.ParamName, "#5");
2169 Assert.AreEqual ("bindingFlags", ex.ParamName, "#6");
2173 [Test] // bug #321735
2174 public void InvokeMember_SetFieldProperty ()
2176 ArrayList list = new ArrayList ();
2178 list.GetType ().InvokeMember ("Item",
2179 BindingFlags.SetField | BindingFlags.SetProperty |
2180 BindingFlags.Instance | BindingFlags.Public,
2181 null, list, new object [] { 0, "bar" });
2182 Assert.AreEqual ("bar", list [0]);
2186 public void InvokeMember_SetField_ProvidedArgs ()
2189 typeof (X).InvokeMember ("Value", BindingFlags.Public |
2190 BindingFlags.Static | BindingFlags.SetField,
2191 null, null, new object [0]);
2192 Assert.Fail ("#A1");
2193 } catch (ArgumentException ex) {
2194 // Only the field value can be specified to set
2196 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
2197 Assert.IsNull (ex.InnerException, "#A3");
2198 Assert.IsNotNull (ex.Message, "#A4");
2199 Assert.IsNotNull (ex.ParamName, "#A5");
2200 Assert.AreEqual ("bindingFlags", ex.ParamName, "#6");
2204 typeof (X).InvokeMember ("Value", BindingFlags.Public |
2205 BindingFlags.Static | BindingFlags.SetField,
2207 Assert.Fail ("#B1");
2208 } catch (ArgumentNullException ex) {
2209 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
2210 Assert.IsNull (ex.InnerException, "#B3");
2211 Assert.IsNotNull (ex.Message, "#B4");
2212 Assert.IsNotNull (ex.ParamName, "#B5");
2213 Assert.AreEqual ("providedArgs", ex.ParamName, "#B6");
2217 [Test] // bug #336841
2218 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=306797
2219 public void InvokeMember_VarArgs ()
2221 BindingFlags flags = BindingFlags.InvokeMethod | BindingFlags.Public |
2222 BindingFlags.NonPublic | BindingFlags.OptionalParamBinding |
2223 BindingFlags.Static | BindingFlags.FlattenHierarchy |
2224 BindingFlags.Instance;
2226 Type type = typeof (TypeTest);
2227 string result = (string) type.InvokeMember ("bug336841",
2228 flags, null, null, new object [] { "1" });
2229 Assert.IsNotNull (result, "#A1");
2230 Assert.AreEqual ("#B:1", result, "#A2");
2232 result = (string) type.InvokeMember ("bug336841", flags,
2233 null, null, new object [] { "1", "2", "3", "4" });
2234 Assert.IsNotNull (result, "#B1");
2235 Assert.AreEqual ("#A:1|2,3,4", result, "#B2");
2239 [Test] // bug #348522
2240 public void InvokeMember_WithoutDefaultValue ()
2242 BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod;
2244 typeof (Bug348522).InvokeMember ("Test", flags, new FirstMethodBinder (), new Bug348522(),
2245 new object [] {Missing.Value}, null, null, null);
2247 } catch (ArgumentException ex) {
2248 // Missing parameter does not have a default value
2249 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
2250 Assert.IsNull (ex.InnerException, "#3");
2251 Assert.IsNotNull (ex.Message, "#4");
2252 Assert.IsNotNull (ex.ParamName, "#5");
2253 Assert.AreEqual ("parameters", ex.ParamName, "#6");
2258 public void TestMissing () {
2259 Assert.AreEqual (Type.Missing, Missing.Value);
2263 public void GetGenericMethodDefinitionOverInflatedMethodOnGTD () {
2264 var l = typeof (List<>);
2265 var m = l.GetMethod ("ConvertAll");
2266 var infl = m.MakeGenericMethod (typeof (int));
2267 var res = m.GetGenericMethodDefinition ();
2268 Assert.AreEqual (m, res, "#1");
2272 public void InvokeMember_OutParam ()
2274 object[] args = new object[] { new string [0] };
2275 typeof (TypeTest).InvokeMember ("OutTest", BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.Public, null, null, args);
2276 Assert.IsTrue (args [0] is string[]);
2277 Assert.AreEqual (10, ((string[])args[0]).Length);
2280 public static void OutTest (out string[] a1)
2282 a1 = new string [10];
2287 public static int Value;
2296 public Z (IComparable value)
2301 public static void Run ()
2309 public TakesInt (int x)
2314 public int Integer {
2321 public TakesObject (object x) {}
2324 [Test] // bug #75241
2325 public void GetConstructorNullInTypes ()
2327 // This ends up calling type.GetConstructor ()
2328 Activator.CreateInstance (typeof (TakesInt), new object [] { null });
2329 Activator.CreateInstance (typeof (TakesObject), new object [] { null });
2333 public void GetConstructor_TakeInt_Object ()
2335 Assert.IsNull (typeof (TakesInt).GetConstructor (new Type[1] { typeof (object) }));
2339 public void GetCustomAttributes_All ()
2341 object [] attrs = typeof (A).GetCustomAttributes (false);
2342 Assert.AreEqual (2, attrs.Length, "#A1");
2343 Assert.IsTrue (HasAttribute (attrs, typeof (FooAttribute)), "#A2");
2344 Assert.IsTrue (HasAttribute (attrs, typeof (VolatileModifier)), "#A3");
2346 attrs = typeof (BA).GetCustomAttributes (false);
2347 Assert.AreEqual (1, attrs.Length, "#B1");
2348 Assert.AreEqual (typeof (BarAttribute), attrs [0].GetType (), "#B2");
2350 attrs = typeof (BA).GetCustomAttributes (true);
2351 Assert.AreEqual (2, attrs.Length, "#C1");
2352 Assert.IsTrue (HasAttribute (attrs, typeof (BarAttribute)), "#C2");
2353 Assert.IsTrue (HasAttribute (attrs, typeof (VolatileModifier)), "#C3");
2355 attrs = typeof (CA).GetCustomAttributes (false);
2356 Assert.AreEqual (0, attrs.Length, "#D");
2358 attrs = typeof (CA).GetCustomAttributes (true);
2359 Assert.AreEqual (1, attrs.Length, "#E1");
2360 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#E2");
2363 static bool HasAttribute (object [] attrs, Type attributeType)
2365 foreach (object attr in attrs)
2366 if (attr.GetType () == attributeType)
2372 public void GetCustomAttributes_Type ()
2374 object [] attrs = null;
2376 attrs = typeof (A).GetCustomAttributes (
2377 typeof (VolatileModifier), false);
2378 Assert.AreEqual (1, attrs.Length, "#A1");
2379 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#A2");
2380 attrs = typeof (A).GetCustomAttributes (
2381 typeof (VolatileModifier), true);
2382 Assert.AreEqual (1, attrs.Length, "#A3");
2383 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#A4");
2385 attrs = typeof (A).GetCustomAttributes (
2386 typeof (NemerleAttribute), false);
2387 Assert.AreEqual (1, attrs.Length, "#B1");
2388 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#B2");
2389 attrs = typeof (A).GetCustomAttributes (
2390 typeof (NemerleAttribute), true);
2391 Assert.AreEqual (1, attrs.Length, "#B3");
2392 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#B4");
2394 attrs = typeof (A).GetCustomAttributes (
2395 typeof (FooAttribute), false);
2396 Assert.AreEqual (1, attrs.Length, "#C1");
2397 Assert.AreEqual (typeof (FooAttribute), attrs [0].GetType (), "#C2");
2398 attrs = typeof (A).GetCustomAttributes (
2399 typeof (FooAttribute), false);
2400 Assert.AreEqual (1, attrs.Length, "#C3");
2401 Assert.AreEqual (typeof (FooAttribute), attrs [0].GetType (), "#C4");
2403 attrs = typeof (BA).GetCustomAttributes (
2404 typeof (VolatileModifier), false);
2405 Assert.AreEqual (0, attrs.Length, "#D1");
2406 attrs = typeof (BA).GetCustomAttributes (
2407 typeof (VolatileModifier), true);
2408 Assert.AreEqual (1, attrs.Length, "#D2");
2409 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#D3");
2411 attrs = typeof (BA).GetCustomAttributes (
2412 typeof (NemerleAttribute), false);
2413 Assert.AreEqual (0, attrs.Length, "#E1");
2414 attrs = typeof (BA).GetCustomAttributes (
2415 typeof (NemerleAttribute), true);
2416 Assert.AreEqual (1, attrs.Length, "#E2");
2417 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#E3");
2419 attrs = typeof (BA).GetCustomAttributes (
2420 typeof (FooAttribute), false);
2421 Assert.AreEqual (1, attrs.Length, "#F1");
2422 Assert.AreEqual (typeof (BarAttribute), attrs [0].GetType (), "#F2");
2423 attrs = typeof (BA).GetCustomAttributes (
2424 typeof (FooAttribute), true);
2425 Assert.AreEqual (1, attrs.Length, "#F3");
2426 Assert.AreEqual (typeof (BarAttribute), attrs [0].GetType (), "#F4");
2428 attrs = typeof (bug82431A1).GetCustomAttributes (
2429 typeof (InheritAttribute), false);
2430 Assert.AreEqual (1, attrs.Length, "#G1");
2431 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#G2");
2432 attrs = typeof (bug82431A1).GetCustomAttributes (
2433 typeof (InheritAttribute), true);
2434 Assert.AreEqual (1, attrs.Length, "#G3");
2435 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#G4");
2437 attrs = typeof (bug82431A1).GetCustomAttributes (
2438 typeof (NotInheritAttribute), false);
2439 Assert.AreEqual (1, attrs.Length, "#H1");
2440 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#H2");
2441 attrs = typeof (bug82431A1).GetCustomAttributes (
2442 typeof (InheritAttribute), true);
2443 Assert.AreEqual (1, attrs.Length, "#H3");
2444 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#H4");
2446 attrs = typeof (bug82431A2).GetCustomAttributes (
2447 typeof (InheritAttribute), false);
2448 Assert.AreEqual (0, attrs.Length, "#I1");
2449 attrs = typeof (bug82431A2).GetCustomAttributes (
2450 typeof (InheritAttribute), true);
2451 Assert.AreEqual (0, attrs.Length, "#I2");
2453 attrs = typeof (bug82431A2).GetCustomAttributes (
2454 typeof (NotInheritAttribute), false);
2455 Assert.AreEqual (0, attrs.Length, "#J1");
2456 attrs = typeof (bug82431A2).GetCustomAttributes (
2457 typeof (NotInheritAttribute), true);
2458 Assert.AreEqual (0, attrs.Length, "#J2");
2460 attrs = typeof (bug82431A3).GetCustomAttributes (
2461 typeof (InheritAttribute), false);
2462 Assert.AreEqual (2, attrs.Length, "#K1");
2463 Assert.IsTrue (HasAttribute (attrs, typeof (InheritAttribute)), "#K2");
2464 Assert.IsTrue (HasAttribute (attrs, typeof (NotInheritAttribute)), "#K3");
2465 attrs = typeof (bug82431A3).GetCustomAttributes (
2466 typeof (InheritAttribute), true);
2467 Assert.AreEqual (2, attrs.Length, "#K4");
2468 Assert.IsTrue (HasAttribute (attrs, typeof (InheritAttribute)), "#K5");
2469 Assert.IsTrue (HasAttribute (attrs, typeof (NotInheritAttribute)), "#K6");
2471 attrs = typeof (bug82431A3).GetCustomAttributes (
2472 typeof (NotInheritAttribute), false);
2473 Assert.AreEqual (1, attrs.Length, "#L1");
2474 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#L2");
2475 attrs = typeof (bug82431A3).GetCustomAttributes (
2476 typeof (NotInheritAttribute), true);
2477 Assert.AreEqual (1, attrs.Length, "#L3");
2478 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#L4");
2480 attrs = typeof (bug82431B1).GetCustomAttributes (
2481 typeof (InheritAttribute), false);
2482 Assert.AreEqual (1, attrs.Length, "#M1");
2483 Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#M2");
2484 attrs = typeof (bug82431B1).GetCustomAttributes (
2485 typeof (InheritAttribute), true);
2486 Assert.AreEqual (1, attrs.Length, "#M3");
2487 Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#M4");
2489 attrs = typeof (bug82431B1).GetCustomAttributes (
2490 typeof (NotInheritAttribute), false);
2491 Assert.AreEqual (0, attrs.Length, "#N1");
2492 attrs = typeof (bug82431B1).GetCustomAttributes (
2493 typeof (NotInheritAttribute), true);
2494 Assert.AreEqual (0, attrs.Length, "#N2");
2496 attrs = typeof (bug82431B2).GetCustomAttributes (
2497 typeof (InheritAttribute), false);
2498 Assert.AreEqual (0, attrs.Length, "#O1");
2499 attrs = typeof (bug82431B2).GetCustomAttributes (
2500 typeof (InheritAttribute), true);
2501 Assert.AreEqual (1, attrs.Length, "#O2");
2502 Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#O3");
2504 attrs = typeof (bug82431B2).GetCustomAttributes (
2505 typeof (NotInheritAttribute), false);
2506 Assert.AreEqual (0, attrs.Length, "#P1");
2507 attrs = typeof (bug82431B2).GetCustomAttributes (
2508 typeof (NotInheritAttribute), true);
2509 Assert.AreEqual (0, attrs.Length, "#P2");
2511 attrs = typeof (bug82431B3).GetCustomAttributes (
2512 typeof (InheritAttribute), false);
2513 Assert.AreEqual (1, attrs.Length, "#Q1");
2514 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#Q2");
2515 attrs = typeof (bug82431B3).GetCustomAttributes (
2516 typeof (InheritAttribute), true);
2517 Assert.AreEqual (2, attrs.Length, "#Q3");
2518 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#Q4");
2519 Assert.AreEqual (typeof (InheritAttribute), attrs [1].GetType (), "#Q5");
2521 attrs = typeof (bug82431B3).GetCustomAttributes (
2522 typeof (NotInheritAttribute), false);
2523 Assert.AreEqual (1, attrs.Length, "#R1");
2524 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#R2");
2525 attrs = typeof (bug82431B3).GetCustomAttributes (
2526 typeof (NotInheritAttribute), true);
2527 Assert.AreEqual (1, attrs.Length, "#R3");
2528 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#R4");
2530 attrs = typeof (bug82431B4).GetCustomAttributes (
2531 typeof (InheritAttribute), false);
2532 Assert.AreEqual (0, attrs.Length, "#S1");
2533 attrs = typeof (bug82431B4).GetCustomAttributes (
2534 typeof (InheritAttribute), true);
2535 Assert.AreEqual (1, attrs.Length, "#S2");
2536 Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#S3");
2538 attrs = typeof (bug82431B4).GetCustomAttributes (
2539 typeof (NotInheritAttribute), false);
2540 Assert.AreEqual (0, attrs.Length, "#T1");
2541 attrs = typeof (bug82431B4).GetCustomAttributes (
2542 typeof (NotInheritAttribute), true);
2543 Assert.AreEqual (0, attrs.Length, "#T2");
2545 attrs = typeof (A).GetCustomAttributes (
2546 typeof (string), false);
2547 Assert.AreEqual (0, attrs.Length, "#U1");
2548 attrs = typeof (A).GetCustomAttributes (
2549 typeof (string), true);
2550 Assert.AreEqual (0, attrs.Length, "#U2");
2553 [Test] // bug #76150
2554 public void IsDefined ()
2556 Assert.IsTrue (typeof (A).IsDefined (typeof (NemerleAttribute), false), "#A1");
2557 Assert.IsTrue (typeof (A).IsDefined (typeof (VolatileModifier), false), "#A2");
2558 Assert.IsTrue (typeof (A).IsDefined (typeof (FooAttribute), false), "#A3");
2559 Assert.IsFalse (typeof (A).IsDefined (typeof (BarAttribute), false), "#A4");
2561 Assert.IsFalse (typeof (BA).IsDefined (typeof (NemerleAttribute), false), "#B1");
2562 Assert.IsFalse (typeof (BA).IsDefined (typeof (VolatileModifier), false), "#B2");
2563 Assert.IsTrue (typeof (BA).IsDefined (typeof (FooAttribute), false), "#B3");
2564 Assert.IsTrue (typeof (BA).IsDefined (typeof (BarAttribute), false), "#B4");
2565 Assert.IsFalse (typeof (BA).IsDefined (typeof (string), false), "#B5");
2566 Assert.IsFalse (typeof (BA).IsDefined (typeof (int), false), "#B6");
2567 Assert.IsTrue (typeof (BA).IsDefined (typeof (NemerleAttribute), true), "#B7");
2568 Assert.IsTrue (typeof (BA).IsDefined (typeof (VolatileModifier), true), "#B8");
2569 Assert.IsTrue (typeof (BA).IsDefined (typeof (FooAttribute), true), "#B9");
2570 Assert.IsTrue (typeof (BA).IsDefined (typeof (BarAttribute), true), "#B10");
2571 Assert.IsFalse (typeof (BA).IsDefined (typeof (string), true), "#B11");
2572 Assert.IsFalse (typeof (BA).IsDefined (typeof (int), true), "#B12");
2576 public void IsDefined_AttributeType_Null ()
2579 typeof (BA).IsDefined ((Type) null, false);
2581 } catch (ArgumentNullException ex) {
2582 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2583 Assert.IsNull (ex.InnerException, "#3");
2584 Assert.IsNotNull (ex.Message, "#4");
2585 Assert.IsNotNull (ex.ParamName, "#5");
2586 Assert.AreEqual ("attributeType", ex.ParamName, "#6");
2590 [Test] // bug #82431
2591 [Category ("NotWorking")]
2592 public void IsDefined_Inherited ()
2594 Assert.IsFalse (typeof (CA).IsDefined (typeof (NemerleAttribute), false), "#C1");
2595 Assert.IsFalse (typeof (CA).IsDefined (typeof (VolatileModifier), false), "#C2");
2596 Assert.IsFalse (typeof (CA).IsDefined (typeof (FooAttribute), false), "#C3");
2597 Assert.IsFalse (typeof (CA).IsDefined (typeof (BarAttribute), false), "#C4");
2598 Assert.IsTrue (typeof (CA).IsDefined (typeof (NemerleAttribute), true), "#C5");
2599 Assert.IsTrue (typeof (CA).IsDefined (typeof (VolatileModifier), true), "#C6");
2600 Assert.IsFalse (typeof (CA).IsDefined (typeof (FooAttribute), true), "#C7");
2601 Assert.IsFalse (typeof (CA).IsDefined (typeof (BarAttribute), true), "#C8");
2603 Assert.IsFalse (typeof (BBA).IsDefined (typeof (NemerleAttribute), false), "#D1");
2604 Assert.IsFalse (typeof (BBA).IsDefined (typeof (VolatileModifier), false), "#D2");
2605 Assert.IsFalse (typeof (BBA).IsDefined (typeof (FooAttribute), false), "#D3");
2606 Assert.IsFalse (typeof (BBA).IsDefined (typeof (BarAttribute), false), "#D4");
2607 Assert.IsTrue (typeof (BBA).IsDefined (typeof (NemerleAttribute), true), "#D5");
2608 Assert.IsTrue (typeof (BBA).IsDefined (typeof (VolatileModifier), true), "#D6");
2609 Assert.IsTrue (typeof (BBA).IsDefined (typeof (FooAttribute), true), "#D7");
2610 Assert.IsTrue (typeof (BBA).IsDefined (typeof (BarAttribute), true), "#D8");
2612 Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (InheritAttribute), false), "#E1");
2613 Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (NotInheritAttribute), false), "#E2");
2614 Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (InheritAttribute), true), "#E3");
2615 Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (NotInheritAttribute), true), "#E4");
2617 Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (InheritAttribute), false), "#F1");
2618 Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (NotInheritAttribute), false), "#F2");
2619 Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (InheritAttribute), true), "#F3");
2620 Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (NotInheritAttribute), true), "#F4");
2622 Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (InheritAttribute), false), "#G1");
2623 Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (NotInheritAttribute), false), "#G2");
2624 Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (InheritAttribute), true), "#G3");
2625 Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (NotInheritAttribute), true), "#G4");
2627 Assert.IsTrue (typeof (bug82431B1).IsDefined (typeof (InheritAttribute), false), "#H1");
2628 Assert.IsFalse (typeof (bug82431B1).IsDefined (typeof (NotInheritAttribute), false), "#H2");
2629 Assert.IsTrue (typeof (bug82431B1).IsDefined (typeof (InheritAttribute), true), "#H3");
2630 Assert.IsFalse (typeof (bug82431B1).IsDefined (typeof (NotInheritAttribute), true), "#H4");
2632 Assert.IsFalse (typeof (bug82431B2).IsDefined (typeof (InheritAttribute), false), "#I1");
2633 Assert.IsFalse (typeof (bug82431B2).IsDefined (typeof (NotInheritAttribute), false), "#I2");
2634 Assert.IsTrue (typeof (bug82431B2).IsDefined (typeof (InheritAttribute), true), "#I3");
2635 Assert.IsFalse (typeof (bug82431B2).IsDefined (typeof (NotInheritAttribute), true), "#I4");
2637 Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (InheritAttribute), false), "#J1");
2638 Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (NotInheritAttribute), false), "#J2");
2639 Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (InheritAttribute), true), "#J3");
2640 Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (NotInheritAttribute), true), "#J4");
2642 Assert.IsFalse (typeof (bug82431B4).IsDefined (typeof (InheritAttribute), false), "#K2");
2643 Assert.IsFalse (typeof (bug82431B4).IsDefined (typeof (NotInheritAttribute), false), "#K2");
2644 Assert.IsTrue (typeof (bug82431B4).IsDefined (typeof (InheritAttribute), true), "#K3");
2645 Assert.IsFalse (typeof (bug82431B4).IsDefined (typeof (NotInheritAttribute), true), "#K4");
2648 class Bug13767Attribute : Attribute
2650 public object[] field;
2652 public Bug13767Attribute (params object[] args)
2658 public enum Bug13767Enum
2664 [Bug13767("Demo", new[] { Bug13767Enum.Value1, Bug13767Enum.Value0 })]
2665 public void Bug13767Method(string attributeName, Bug13767Enum[]options)
2671 public void CustomAttributeWithNestedArrayOfEnum ()
2673 var m = GetType ().GetMethod ("Bug13767Method");
2675 var attr = m.GetCustomAttributes (false);
2676 Assert.AreEqual (1, attr.Length, "#1");
2678 var tc = (Bug13767Attribute)attr[0];
2679 Assert.AreEqual (2, tc.field.Length, "#2");
2680 Assert.AreEqual ("Demo", tc.field[0], "#3");
2681 Assert.IsNotNull (tc.field[1], "#4");
2683 var arr = (Bug13767Enum[])tc.field [1];
2684 Assert.AreEqual (2, arr.Length, "#5");
2685 Assert.AreEqual (Bug13767Enum.Value1, arr [0], "#6");
2686 Assert.AreEqual (Bug13767Enum.Value0, arr [1], "#7");
2689 [Test] // GetType (String)
2690 public void GetType1_TypeName_Null ()
2693 Type.GetType ((string) null);
2695 } catch (ArgumentNullException ex) {
2696 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2697 Assert.IsNull (ex.InnerException, "#3");
2698 Assert.IsNotNull (ex.Message, "#4");
2699 Assert.AreEqual ("TypeName", ex.ParamName, "#5");
2703 [Test] // GetType (String, Boolean)
2704 public void GetType2_TypeName_Null ()
2707 Type.GetType ((string) null, false);
2709 } catch (ArgumentNullException ex) {
2710 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2711 Assert.IsNull (ex.InnerException, "#3");
2712 Assert.IsNotNull (ex.Message, "#4");
2713 Assert.AreEqual ("TypeName", ex.ParamName, "#5");
2717 [Test] // GetType (String, Boolean, Boolean)
2718 public void GetType3_TypeName_Null ()
2721 Type.GetType ((string) null, false, false);
2723 } catch (ArgumentNullException ex) {
2724 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2725 Assert.IsNull (ex.InnerException, "#3");
2726 Assert.IsNotNull (ex.Message, "#4");
2727 Assert.AreEqual ("TypeName", ex.ParamName, "#5");
2732 public void GetTypeArray_Args_Null ()
2735 Type.GetTypeArray ((object []) null);
2737 } catch (ArgumentNullException ex) {
2738 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2739 Assert.IsNull (ex.InnerException, "#3");
2740 Assert.IsNotNull (ex.Message, "#4");
2741 Assert.AreEqual ("args", ex.ParamName, "#5");
2746 public void GetTypeCode ()
2748 Assert.AreEqual (TypeCode.Boolean, Type.GetTypeCode (typeof (bool)), "#1");
2749 Assert.AreEqual (TypeCode.Byte, Type.GetTypeCode (typeof (byte)), "#2");
2750 Assert.AreEqual (TypeCode.Char, Type.GetTypeCode (typeof (char)), "#3");
2751 Assert.AreEqual (TypeCode.DateTime, Type.GetTypeCode (typeof (DateTime)), "#4");
2752 Assert.AreEqual (TypeCode.DBNull, Type.GetTypeCode (typeof (DBNull)), "#5");
2753 Assert.AreEqual (TypeCode.Decimal, Type.GetTypeCode (typeof (decimal)), "#6");
2754 Assert.AreEqual (TypeCode.Double, Type.GetTypeCode (typeof (double)), "#7");
2755 Assert.AreEqual (TypeCode.Empty, Type.GetTypeCode (null), "#8");
2756 Assert.AreEqual (TypeCode.Int16, Type.GetTypeCode (typeof (short)), "#9");
2757 Assert.AreEqual (TypeCode.Int32, Type.GetTypeCode (typeof (int)), "#10");
2758 Assert.AreEqual (TypeCode.Int64, Type.GetTypeCode (typeof (long)), "#11");
2759 Assert.AreEqual (TypeCode.Object, Type.GetTypeCode (typeof (TakesInt)), "#12");
2760 Assert.AreEqual (TypeCode.SByte, Type.GetTypeCode (typeof (sbyte)), "#13");
2761 Assert.AreEqual (TypeCode.Single, Type.GetTypeCode (typeof (float)), "#14");
2762 Assert.AreEqual (TypeCode.String, Type.GetTypeCode (typeof (string)), "#15");
2763 Assert.AreEqual (TypeCode.UInt16, Type.GetTypeCode (typeof (ushort)), "#16");
2764 Assert.AreEqual (TypeCode.UInt32, Type.GetTypeCode (typeof (uint)), "#17");
2765 Assert.AreEqual (TypeCode.UInt64, Type.GetTypeCode (typeof (ulong)), "#18");
2769 public void GetTypeFromHandle_Handle_Zero ()
2771 RuntimeTypeHandle handle = new RuntimeTypeHandle ();
2773 Assert.IsNull (Type.GetTypeFromHandle (handle));
2777 public void GetTypeHandle_O_Null ()
2780 Type.GetTypeHandle (null);
2782 } catch (ArgumentNullException ex) {
2783 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2784 Assert.IsNull (ex.InnerException, "#3");
2785 Assert.IsNotNull (ex.Message, "#4");
2786 Assert.IsNull (ex.ParamName, "#5");
2790 [Test] // GetConstructor (Type [])
2791 public void GetConstructor1 ()
2794 ConstructorInfo ctor;
2796 type = typeof (CtorsA);
2797 ctor = type.GetConstructor (Type.EmptyTypes);
2798 Assert.IsNotNull (ctor, "#A1");
2799 Assert.AreEqual (0, ctor.GetParameters ().Length, "#A2");
2800 Assert.IsFalse (ctor.IsStatic, "#A3");
2801 Assert.IsTrue (ctor.IsPublic, "#A4");
2802 Assert.AreEqual (".ctor", ctor.Name, "#A5");
2804 type = typeof (CtorsB);
2805 ctor = type.GetConstructor (Type.EmptyTypes);
2806 Assert.IsNotNull (ctor, "#B1");
2807 Assert.AreEqual (0, ctor.GetParameters ().Length, "#B2");
2808 Assert.IsFalse (ctor.IsStatic, "#B3");
2809 Assert.IsTrue (ctor.IsPublic, "#B4");
2810 Assert.AreEqual (".ctor", ctor.Name, "#B5");
2812 type = typeof (CtorsC);
2813 ctor = type.GetConstructor (Type.EmptyTypes);
2814 Assert.IsNull (ctor, "#C");
2816 type = typeof (CtorsC);
2817 ctor = type.GetConstructor (new Type [] { typeof (int) });
2818 Assert.IsNotNull (ctor, "#D1");
2819 Assert.AreEqual (1, ctor.GetParameters ().Length, "#D2");
2820 Assert.IsFalse (ctor.IsStatic, "#D3");
2821 Assert.IsTrue (ctor.IsPublic, "#D4");
2822 Assert.AreEqual (".ctor", ctor.Name, "#D5");
2825 [Test] // GetConstructor (Type [])
2826 public void GetConstructor1_Types_Null ()
2829 typeof (BindingFlags).GetConstructor (null);
2831 } catch (ArgumentNullException ex) {
2832 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2833 Assert.IsNull (ex.InnerException, "#3");
2834 Assert.IsNotNull (ex.Message, "#4");
2835 Assert.IsNotNull (ex.ParamName, "#5");
2836 Assert.AreEqual ("types", ex.ParamName, "#6");
2840 [Test] // GetConstructor (Type [])
2841 public void GetConstructor1_Types_ItemNull ()
2843 Type type = typeof (BindingFlags);
2845 type.GetConstructor (new Type[1] { null });
2846 Assert.Fail ("#A1");
2847 } catch (ArgumentNullException ex) {
2848 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
2849 Assert.IsNull (ex.InnerException, "#A3");
2850 Assert.IsNotNull (ex.Message, "#A4");
2851 Assert.IsNotNull (ex.ParamName, "#A5");
2852 Assert.AreEqual ("types", ex.ParamName, "#A6");
2855 type = typeof (TakesInt);
2857 type.GetConstructor (new Type [1] { null });
2858 Assert.Fail ("#B1");
2859 } catch (ArgumentNullException ex) {
2860 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
2861 Assert.IsNull (ex.InnerException, "#B3");
2862 Assert.IsNotNull (ex.Message, "#B4");
2863 Assert.IsNotNull (ex.ParamName, "#B5");
2864 Assert.AreEqual ("types", ex.ParamName, "#B6");
2868 [Test] // GetConstructor (BindingFlags, Binder, Type [], ParameterModifier [])
2869 public void GetConstructor2_Types_ItemNull ()
2871 Type type = typeof (BindingFlags);
2873 type.GetConstructor (BindingFlags.Default, null,
2874 new Type[1] { null }, null);
2876 } catch (ArgumentNullException ex) {
2877 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2878 Assert.IsNull (ex.InnerException, "#3");
2879 Assert.IsNotNull (ex.Message, "#4");
2880 Assert.IsNotNull (ex.ParamName, "#5");
2881 Assert.AreEqual ("types", ex.ParamName, "#6");
2885 [Test] // GetConstructor (BindingFlags, Binder, CallingConventions, Type [], ParameterModifier [])
2886 public void GetConstructor3_Types_ItemNull ()
2888 Type type = typeof (BindingFlags);
2890 type.GetConstructor (BindingFlags.Default,
2891 null, CallingConventions.Any,
2892 new Type[1] { null }, null);
2894 } catch (ArgumentNullException ex) {
2895 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2896 Assert.IsNull (ex.InnerException, "#3");
2897 Assert.IsNotNull (ex.Message, "#4");
2898 Assert.IsNotNull (ex.ParamName, "#5");
2899 Assert.AreEqual ("types", ex.ParamName, "#6");
2904 public void GetMethod_Bug77367 ()
2906 MethodInfo i = typeof (Bug77367).GetMethod ("Run", Type.EmptyTypes);
2912 public void EqualsUnderlyingType ()
2914 AssemblyBuilderAccess access = AssemblyBuilderAccess.RunAndSave;
2915 TypeAttributes attribs = TypeAttributes.Public;
2917 AssemblyName name = new AssemblyName ();
2918 name.Name = "enumtest";
2919 AssemblyBuilder assembly =
2920 AppDomain.CurrentDomain.DefineDynamicAssembly (
2923 ModuleBuilder module = assembly.DefineDynamicModule
2924 ("m", "enumtest.dll");
2925 EnumBuilder e = module.DefineEnum ("E", attribs, typeof (int));
2927 Assert.IsTrue (typeof (int).Equals (e));
2932 public void Equals_Type_Null ()
2934 Assert.IsFalse (typeof (int).Equals ((Type) null), "#1");
2935 Assert.IsFalse (typeof (int).Equals ((object) null), "#2");
2939 public void GetElementType_Bug63841 ()
2941 Assert.IsNull (typeof (TheEnum).GetElementType (), "#1");
2945 public void FullNameGenerics ()
2947 Type fooType = typeof (Foo<>);
2948 FieldInfo [] fields = fooType.GetFields ();
2950 Assert.AreEqual (1, fields.Length, "#0");
2952 Assert.IsNotNull (fooType.FullName, "#1");
2953 Assert.IsNotNull (fooType.AssemblyQualifiedName, "#1a");
2955 FieldInfo field = fooType.GetField ("Whatever");
2956 Assert.IsNotNull (field, "#2");
2957 Assert.AreEqual (field, fields [0], "#2a");
2958 Assert.IsNull (field.FieldType.FullName, "#3");
2959 Assert.IsNull (field.FieldType.AssemblyQualifiedName, "#3a");
2960 Assert.IsNotNull (field.FieldType.ToString (), "#4");
2962 PropertyInfo prop = fooType.GetProperty ("Test");
2963 Assert.IsNotNull (prop, "#5");
2964 Assert.IsNull (prop.PropertyType.FullName, "#6");
2965 Assert.IsNull (prop.PropertyType.AssemblyQualifiedName, "#6a");
2966 Assert.IsNotNull (prop.PropertyType.ToString (), "#7");
2968 MethodInfo method = fooType.GetMethod("Execute");
2969 Assert.IsNotNull (method, "#8");
2970 Assert.IsNull (method.ReturnType.FullName, "#9");
2971 Assert.IsNull (method.ReturnType.AssemblyQualifiedName, "#9a");
2972 Assert.IsNotNull (method.ReturnType.ToString (), "#10");
2974 ParameterInfo[] parameters = method.GetParameters();
2975 Assert.AreEqual (1, parameters.Length, "#11");
2976 Assert.IsNull (parameters[0].ParameterType.FullName, "#12");
2977 Assert.IsNull (parameters[0].ParameterType.AssemblyQualifiedName, "#12a");
2978 Assert.IsNotNull (parameters[0].ParameterType.ToString (), "#13");
2982 public void TypeParameterIsNotGeneric ()
2984 Type fooType = typeof (Foo<>);
2985 Type type_param = fooType.GetGenericArguments () [0];
2986 Assert.IsTrue (type_param.IsGenericParameter);
2987 Assert.IsFalse (type_param.IsGenericType);
2988 Assert.IsFalse (type_param.IsGenericTypeDefinition);
2990 // LAMESPEC: MSDN claims that this should be false, but .NET v2.0.50727 says it's true
2991 // http://msdn2.microsoft.com/en-us/library/system.type.isgenerictype.aspx
2992 Assert.IsTrue (type_param.ContainsGenericParameters);
2996 public void IsAssignable ()
2998 Type foo_type = typeof (Foo<>);
2999 Type foo_int_type = typeof (Foo<int>);
3000 Assert.IsFalse (foo_type.IsAssignableFrom (foo_int_type), "Foo<int> -!-> Foo<>");
3001 Assert.IsFalse (foo_int_type.IsAssignableFrom (foo_type), "Foo<> -!-> Foo<int>");
3003 Type ibar_short_type = typeof (IBar<short>);
3004 Type ibar_int_type = typeof (IBar<int>);
3005 Type baz_short_type = typeof (Baz<short>);
3006 Type baz_int_type = typeof (Baz<int>);
3008 Assert.IsTrue (ibar_int_type.IsAssignableFrom (baz_int_type), "Baz<int> -> IBar<int>");
3009 Assert.IsTrue (ibar_short_type.IsAssignableFrom (baz_short_type), "Baz<short> -> IBar<short>");
3011 Assert.IsFalse (ibar_int_type.IsAssignableFrom (baz_short_type), "Baz<short> -!-> IBar<int>");
3012 Assert.IsFalse (ibar_short_type.IsAssignableFrom (baz_int_type), "Baz<int> -!-> IBar<short>");
3015 Assert.IsTrue (typeof (Nullable<int>).IsAssignableFrom (typeof (int)));
3016 Assert.IsFalse (typeof (int).IsAssignableFrom (typeof (Nullable<int>)));
3017 Assert.IsTrue (typeof (Nullable<FooStruct>).IsAssignableFrom (typeof (FooStruct)));
3021 public void IsInstanceOf ()
3023 Assert.IsTrue (typeof (Nullable<int>).IsInstanceOfType (5));
3027 public void IsInstanceOfArrayOfNullable ()
3029 Assert.IsTrue (typeof (Nullable<int>[]).IsInstanceOfType (new Nullable<int> [0]));
3033 public void IsInstanceOfType_Null ()
3035 Assert.IsFalse (typeof (int).IsInstanceOfType (null), "int");
3036 Assert.IsFalse (typeof (object).IsInstanceOfType (null), "object");
3037 Assert.IsFalse (typeof (int?).IsInstanceOfType (null), "int?");
3041 public void ByrefType ()
3043 Type foo_type = typeof (Foo<>);
3044 Type type_param = foo_type.GetGenericArguments () [0];
3045 Type byref_type_param = type_param.MakeByRefType ();
3046 Assert.IsFalse (byref_type_param.IsGenericParameter);
3047 Assert.IsNull (byref_type_param.DeclaringType);
3051 [ExpectedException (typeof (TypeLoadException))]
3052 public void MakeByRefByRef ()
3054 typeof (int).MakeByRefType ().MakeByRefType ();
3058 public void MakeArrayTypeTest ()
3060 // This should not crash:
3061 Type t = typeof (void).MakeArrayType ();
3065 [ExpectedException (typeof (InvalidProgramException))]
3066 public void MakeArrayTypedReferenceInstanceTest ()
3068 object o = Array.CreateInstance (typeof (global::System.TypedReference), 1);
3072 public void MakeArrayTypeLargeRank ()
3074 Assert.Throws<TypeLoadException> (delegate () {
3075 typeof (int).MakeArrayType (33);
3080 public class ComFoo<T> {
3084 public void GetCustomAttributesGenericInstance ()
3086 Assert.AreEqual (1, typeof (ComFoo<int>).GetCustomAttributes (typeof (ComVisibleAttribute), true).Length);
3089 interface ByRef1<T> { void f (ref T t); }
3090 interface ByRef2 { void f<T> (ref T t); }
3092 interface ByRef3<T> where T:struct { void f (ref T? t); }
3093 interface ByRef4 { void f<T> (ref T? t) where T:struct; }
3095 void CheckGenericByRef (Type t)
3097 string name = t.Name;
3098 t = t.GetMethod ("f").GetParameters () [0].ParameterType;
3100 Assert.IsFalse (t.IsGenericType, name);
3101 Assert.IsFalse (t.IsGenericTypeDefinition, name);
3102 Assert.IsFalse (t.IsGenericParameter, name);
3106 public void GenericByRef ()
3108 CheckGenericByRef (typeof (ByRef1<>));
3109 CheckGenericByRef (typeof (ByRef2));
3110 CheckGenericByRef (typeof (ByRef3<>));
3111 CheckGenericByRef (typeof (ByRef4));
3114 public class Bug80242<T> {
3115 public interface IFoo { }
3116 public class Bar : IFoo { }
3117 public class Baz : Bar { }
3121 public void TestNestedTypes ()
3123 Type t = typeof (Bug80242<object>);
3124 Assert.IsFalse (t.IsGenericTypeDefinition);
3125 foreach (Type u in t.GetNestedTypes ()) {
3126 Assert.IsTrue (u.IsGenericTypeDefinition, "{0} isn't a generic definition", u);
3127 Assert.AreEqual (u, u.GetGenericArguments () [0].DeclaringType);
3131 [Test] // bug #82211
3132 public void GetMembers_GenericArgument ()
3134 Type argType = typeof (ComFoo<>).GetGenericArguments () [0];
3135 MemberInfo [] members = argType.GetMembers ();
3136 Assert.IsNotNull (members, "#1");
3137 Assert.AreEqual (4, members.Length, "#2");
3141 [ExpectedException (typeof (ArgumentNullException))]
3142 public void ReflectionOnlyGetTypeNullTypeName ()
3144 Type.ReflectionOnlyGetType (null, false, false);
3148 public void ReflectionOnlyGetTypeDoNotThrow ()
3150 Assert.IsNull (Type.ReflectionOnlyGetType ("a, nonexistent.dll", false, false));
3154 [ExpectedException (typeof (FileNotFoundException))]
3155 public void ReflectionOnlyGetTypeThrow ()
3157 Type.ReflectionOnlyGetType ("a, nonexistent.dll", true, false);
3161 public void ReflectionOnlyGetType ()
3163 Type t = Type.ReflectionOnlyGetType (typeof (int).AssemblyQualifiedName.ToString (), true, true);
3164 Assert.AreEqual ("System.Int32", t.FullName);
3168 #if MONOTOUCH || FULL_AOT_RUNTIME
3169 [ExpectedException (typeof (NotSupportedException))]
3171 public void MakeGenericType_UserDefinedType ()
3173 Type ut = new UserType (typeof (int));
3174 Type t = typeof (Foo<>).MakeGenericType (ut);
3175 Assert.IsTrue (t.IsGenericType, "#A1");
3176 Assert.AreEqual (1, t.GetGenericArguments ().Length, "#A2");
3178 Type arg = t.GetGenericArguments () [0];
3179 Assert.IsNotNull (arg, "#B1");
3180 Assert.IsFalse (arg.IsGenericType, "#B2");
3181 Assert.AreEqual (ut, arg, "#B3");
3185 #if MONOTOUCH || FULL_AOT_RUNTIME
3186 [ExpectedException (typeof (NotSupportedException))]
3188 public void MakeGenericType_NestedUserDefinedType ()
3190 Type ut = new UserType (new UserType (typeof (int)));
3191 Type t = typeof (Foo<>).MakeGenericType (ut);
3192 Assert.IsTrue (t.IsGenericType, "#A1");
3193 Assert.AreEqual (1, t.GetGenericArguments ().Length, "#A2");
3195 Type arg = t.GetGenericArguments () [0];
3196 Assert.IsNotNull (arg, "#B1");
3197 Assert.IsFalse (arg.IsGenericType, "#B2");
3198 Assert.AreEqual (ut, arg, "#B3");
3202 #if MONOTOUCH || FULL_AOT_RUNTIME
3203 [ExpectedException (typeof (NotSupportedException))]
3205 public void TestMakeGenericType_UserDefinedType_DotNet20SP1 ()
3207 Type ut = new UserType(typeof(int));
3208 Type t = typeof(Foo<>).MakeGenericType(ut);
3209 Assert.IsTrue (t.IsGenericType, "#1");
3211 Assert.AreEqual (ut, t.GetGenericArguments()[0], "#2");
3215 #if MONOTOUCH || FULL_AOT_RUNTIME
3216 [ExpectedException (typeof (NotSupportedException))]
3218 public void MakeGenericType_BadUserType ()
3220 Type ut = new UserType (null);
3221 Type t = typeof (Foo<>).MakeGenericType (ut);
3222 var g0 = t.GetGenericArguments () [0];
3223 Assert.AreSame (g0, ut, "#1");
3227 public void MakeGenericType_WrongNumOfArguments ()
3230 Type t = typeof (Foo<,>).MakeGenericType (new Type [] { typeof (int) });
3232 } catch (ArgumentException) {
3236 [AttributeUsage (AttributeTargets.All)]
3237 public class DocAttribute : Attribute {
3238 public DocAttribute (string docs) {}
3241 class GenericClassWithAttributes<[Doc ("T")] T, [Doc ("B")] B>
3242 where T : class, new ()
3245 public T Bar { get{return null;}}
3247 public void M<[Doc ("X")] X> (X x)
3252 [Test] //bug #377596
3253 public void GetGenericArguments_ArgumentsHaveAttributes ()
3255 Type type = typeof(GenericClassWithAttributes<,>);
3256 Type[] tArgs = type.GetGenericArguments ();
3257 MethodInfo m = type.GetMethod ("M");
3258 Type[] mArgs = m.GetGenericArguments ();
3259 Assert.AreEqual(1, tArgs[0].GetCustomAttributes (typeof (DocAttribute), true).Length, "#1");
3260 Assert.AreEqual(1, tArgs[1].GetCustomAttributes (typeof (DocAttribute), true).Length, "#1");
3261 Assert.AreEqual(1, mArgs[0].GetCustomAttributes (typeof (DocAttribute), true).Length, "#1");
3264 [Test] //bug #471255
3265 public void GetTypeCalledUsingReflection ()
3267 Type expectedType = Type.GetType ("NoNamespaceClass");
3268 Assert.IsNotNull (expectedType, "#1");
3269 MethodInfo m = typeof (Type).GetMethod ("GetType", BindingFlags.Public | BindingFlags.Static, null, new Type [] { typeof (string) }, null);
3270 object r = m.Invoke (null, BindingFlags.Default, null, new object [] { "NoNamespaceClass" }, CultureInfo.InvariantCulture);
3271 Assert.AreSame (expectedType, r, "#2");
3275 public void EqualsUserType () {
3276 UserType2 t1 = new UserType2(null);
3277 UserType2 t2 = new UserType2(t1);
3278 Assert.IsTrue (t1.Equals(t2));
3282 public void GetHashCodeUserType () {
3283 UserType2 t1 = new UserType2(null);
3284 UserType2 t2 = new UserType2(t1);
3285 Assert.AreEqual (42, t2.GetHashCode());
3289 public void IsGenericTypeDefinitionUserType () {
3290 Assert.IsFalse (new UserType(null).IsGenericTypeDefinition);
3294 public void IsGenericTypeUserType () {
3295 Assert.IsFalse (new UserType(null).IsGenericType);
3299 [ExpectedException (typeof (NotSupportedException))]
3300 public void GetGenericTypeDefinitionUserType () {
3301 new UserType(null).GetGenericTypeDefinition ();
3304 [ExpectedException (typeof (NotSupportedException))]
3305 public void GetGenericArgumentsUserType () {
3306 new UserType(null).GetGenericArguments ();
3310 [ExpectedException (typeof (InvalidOperationException))]
3311 public void GenericParameterPositionUserType () {
3312 Assert.IsTrue (new UserType(null).GenericParameterPosition == 0);
3316 public void TypeGetMemberReturnTypeTest ()
3319 MemberTypes memtype;
3321 object [] flagsandtypes = new object [] {
3322 MemberTypes.All, typeof (MemberInfo []),
3323 MemberTypes.Constructor, typeof (ConstructorInfo []),
3324 MemberTypes.Custom, typeof (MemberInfo []),
3325 MemberTypes.Event, typeof (EventInfo []),
3326 MemberTypes.Field, typeof (FieldInfo []),
3327 MemberTypes.Method, typeof (MethodInfo []),
3328 MemberTypes.NestedType, typeof (Type []),
3329 MemberTypes.Property, typeof (PropertyInfo []),
3330 MemberTypes.TypeInfo, typeof (Type [])};
3332 for (int i=0; i < flagsandtypes.Length; i+=2) {
3333 memtype = (MemberTypes)flagsandtypes [i];
3334 testtype = (Type)flagsandtypes [i+1];
3335 obj = GetType ().GetMember ("DummyMember", memtype,
3336 BindingFlags.Public | BindingFlags.Instance);
3337 Assert.AreEqual (testtype.GetHashCode (), obj.GetType ().GetHashCode (),
3338 "Expected #" + i + " " + testtype.FullName);
3344 public void TypeNameStartsWithSpace ()
3346 Type t1 = Type.GetType ("System.Type, mscorlib");
3347 Type t2 = Type.GetType (" System.Type, mscorlib");
3348 Assert.AreEqual (t1, t2);
3351 #if !MONOTOUCH && !FULL_AOT_RUNTIME
3353 public void SpaceAfterComma () {
3354 string strType = "System.Collections.Generic.Dictionary`2[[System.Int32,mscorlib], [System.String,mscorlib]],mscorlib";
3355 Assert.IsTrue (Type.GetType (strType) != null);
3359 #if !MONOTOUCH && !FULL_AOT_RUNTIME
3361 public void Bug506757 ()
3363 AssemblyName assemblyName = new AssemblyName ();
3364 assemblyName.Name = "customMod";
3365 assemblyName.Version = new Version (1, 2, 3, 4);
3367 AssemblyBuilder assembly
3368 = Thread.GetDomain().DefineDynamicAssembly(
3369 assemblyName, AssemblyBuilderAccess.RunAndSave);
3371 ModuleBuilder module = assembly.DefineDynamicModule("res.exe", "res.exe");
3373 TypeBuilder type0 = module.DefineType ("Base", TypeAttributes.Public, typeof (object));
3374 TypeBuilder type1 = module.DefineType ("Middle", TypeAttributes.Public, type0);
3375 TypeBuilder type2 = module.DefineType ("End", TypeAttributes.Public, type1);
3377 MethodAttributes attrs0 = MethodAttributes.Virtual | MethodAttributes.HideBySig |
3378 MethodAttributes.NewSlot | MethodAttributes.FamORAssem;
3380 MethodAttributes attrs1 = MethodAttributes.Virtual | MethodAttributes.HideBySig |
3381 MethodAttributes.FamORAssem;
3383 MethodAttributes attrs2 = MethodAttributes.Virtual | MethodAttributes.HideBySig |
3384 MethodAttributes.Public;
3387 MethodBuilder m0 = type0.DefineMethod ("Tst", attrs0, typeof (void), null);
3388 m0.GetILGenerator ().Emit (OpCodes.Ret);
3390 MethodBuilder m1 = type1.DefineMethod ("Tst", attrs1, typeof (void), null);
3391 m1.GetILGenerator ().Emit (OpCodes.Ret);
3393 MethodBuilder m2 = type2.DefineMethod ("Tst", attrs2, typeof (void), null);
3394 m2.GetILGenerator ().Emit (OpCodes.Ret);
3397 type0.CreateType ();
3398 type1.CreateType ();
3399 Type t2 = type2.CreateType ();
3401 foreach (var m in t2.GetMethods (BindingFlags.Instance | BindingFlags.NonPublic))
3402 Assert.IsTrue (m.DeclaringType == typeof (object), String.Format ("{0}::{1}", m.DeclaringType, m.Name));
3406 public void MakeArrayTypeOfOneDimension ()
3408 Type vector = typeof (int).MakeArrayType ();
3409 Type szarray = typeof (int).MakeArrayType (1);
3411 Assert.AreNotEqual (vector, szarray, "#1");
3412 Assert.AreEqual ("Int32[]", vector.Name, "#2");
3413 Assert.AreEqual ("Int32[*]", szarray.Name, "#3");
3416 public class DeclaringMethodFoo {
3417 public void Test<T> (T t) {}
3418 public void Test2<T> (ref T t) {}
3421 public class DeclaringMethodBar<T> {
3422 public void Test2 (ref T t) {}
3426 public void DeclaringMethodOnlyWorksWithGenericArgs ()
3428 MethodInfo testMethod = typeof (DeclaringMethodFoo).GetMethod ("Test");
3429 MethodBase otherMethod = testMethod.GetParameters ()[0].ParameterType.DeclaringMethod;
3431 Assert.AreEqual (testMethod, otherMethod,"#1");
3433 Assert.IsNull (typeof (DeclaringMethodBar<>).GetGenericArguments ()[0].DeclaringMethod, "#2");
3436 var x = typeof (int).DeclaringMethod;
3438 } catch (InvalidOperationException) {}
3441 var x = typeof (DeclaringMethodFoo).GetMethod ("Test2").GetParameters () [0].ParameterType.DeclaringMethod;
3443 } catch (InvalidOperationException) {}
3446 var x = typeof (DeclaringMethodBar<>).GetMethod ("Test2").GetParameters () [0].ParameterType.DeclaringMethod;
3448 } catch (InvalidOperationException) {}
3453 public void GetArrayRankThrowsForNonArrayType ()
3455 Assert.AreEqual (1, typeof (int[]).GetArrayRank (), "#1");
3456 Assert.AreEqual (2, typeof (int[,]).GetArrayRank (), "#2");
3458 typeof (int).GetArrayRank ();
3460 } catch (ArgumentException) {}
3463 [Test] //Bug #564379
3464 public void GetMethodsReturnPublicMethodsInInterfaces ()
3466 Type t = typeof (NonClosingStream);
3467 MethodInfo[] methods = t.GetMethods (BindingFlags.Public | BindingFlags.Instance);
3469 Assert.AreEqual (5, methods.Length, "#1");
3472 foreach (var m in methods) {
3473 if (m.Name.Equals ("ToString"))
3474 Assert.IsTrue (m.DeclaringType == typeof (NonClosingStream), "#" + id);
3475 else if (m.Name.Equals ("Dispose") && m.GetParameters ().Length == 0)
3476 Assert.IsTrue (m.DeclaringType == typeof (Stream), "#" + id);
3477 else if (m.Name.Equals ("Equals") || m.Name.Equals ("GetHashCode") || m.Name.Equals ("GetType"))
3478 Assert.IsTrue (m.DeclaringType == typeof (object), "#" + id);
3480 Assert.Fail ("invalid method " + m);
3485 [Test] // Bug #574696
3486 public void GetMember_DoesntReturnPrivatePropOfParent ()
3488 BindingFlags flags = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance;
3489 Assert.AreEqual (1, typeof (Bar).GetMember ("PrivInst", flags).Length);
3490 Assert.AreEqual (0, typeof (Bar).GetMember ("PrivInstBase", flags).Length);
3491 Assert.AreEqual (1, typeof (Foo).GetMember ("PrivInstBase", flags).Length);
3494 [Test] // Bug #484246
3495 public void GetInterfaceCompareAgainstGTDNames ()
3497 var t = typeof (Dictionary<string,string>);
3498 var iface = typeof (IDictionary<string,string>);
3500 Assert.AreSame (iface, t.GetInterface ("System.Collections.Generic.IDictionary`2"), "#1");
3502 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]]";
3504 Assert.IsNull (t.GetInterface (name), "#2");
3508 public void RuntimeCorrectlyNormalizeGenericTypes ()
3510 Type lst = typeof (MList<>);
3511 Type arg = lst.GetGenericArguments ()[0];
3513 Type sup = lst.BaseType;
3514 Type sa0 = sup.GetGenericArguments ()[0];
3515 Type sa1 = sup.GetGenericArguments ()[1];
3517 Assert.IsTrue (sa1 == lst, "#1");
3518 Assert.IsTrue (sa0 == arg, "#2");
3520 Type inst = typeof (Cons<,>).MakeGenericType (arg, lst.MakeGenericType (arg));
3521 Assert.IsTrue (inst == sup, "#3");
3529 class MList<A> : Cons<A, MList<A>>
3534 [Test] // Bug #331126
3535 public void IsAssignableFromWorksCorrectlyWithByRefs ()
3537 Type int_byref = typeof (int).MakeByRefType ();
3538 Type obj_byref = typeof (object).MakeByRefType ();
3539 Type long_byref = typeof (long).MakeByRefType ();
3540 Type enum1_byref = typeof (AttributeTargets).MakeByRefType ();
3541 Type enum2_byref = typeof (PlatformID).MakeByRefType ();
3542 Type uint_byref = typeof (uint).MakeByRefType ();
3543 Type string_byref = typeof (object).MakeByRefType ();
3544 Type struct0_byref = typeof (Size4).MakeByRefType ();
3545 Type struct1_byref = typeof (Size4b).MakeByRefType ();
3546 Type mvar0_byref = typeof (TypeTest).GetMethod ("Bug331126").GetGenericArguments ()[0].MakeByRefType ();
3547 Type mvar1_byref = typeof (TypeTest).GetMethod ("Bug331126").GetGenericArguments ()[1].MakeByRefType ();
3549 Assert.IsFalse (typeof (int).IsAssignableFrom (int_byref), "#1");
3550 Assert.IsFalse (int_byref.IsAssignableFrom (typeof (int)), "#2");
3551 Assert.IsFalse (obj_byref.IsAssignableFrom (long_byref), "#3");
3552 Assert.IsFalse (long_byref.IsAssignableFrom (obj_byref), "#4");
3553 Assert.IsTrue (enum1_byref.IsAssignableFrom (enum2_byref), "#5");
3554 Assert.IsTrue (enum2_byref.IsAssignableFrom (enum1_byref), "#6");
3555 Assert.IsTrue (int_byref.IsAssignableFrom (enum2_byref), "#7");
3556 Assert.IsTrue (enum2_byref.IsAssignableFrom (int_byref), "#8");
3557 Assert.IsTrue (enum2_byref.IsAssignableFrom (uint_byref), "#9");
3558 Assert.IsTrue (uint_byref.IsAssignableFrom (enum2_byref), "#10");
3559 Assert.IsTrue (int_byref.IsAssignableFrom (uint_byref), "#11");
3560 Assert.IsTrue (uint_byref.IsAssignableFrom (int_byref), "#12");
3562 Assert.IsTrue (typeof (object).IsAssignableFrom (typeof (long)), "#13");
3564 Assert.IsTrue (obj_byref.IsAssignableFrom (string_byref), "#14");
3565 Assert.IsTrue (string_byref.IsAssignableFrom (obj_byref), "#15");
3567 Assert.IsFalse (uint_byref.IsAssignableFrom (struct0_byref), "#16");
3568 Assert.IsFalse (struct0_byref.IsAssignableFrom (int_byref), "#17");
3569 Assert.IsFalse (struct0_byref.IsAssignableFrom (struct1_byref), "#18");
3571 Assert.IsFalse (obj_byref.IsAssignableFrom (mvar0_byref), "#19");
3572 Assert.IsFalse (mvar0_byref.IsAssignableFrom (mvar1_byref), "#20");
3573 Assert.IsTrue (mvar0_byref.IsAssignableFrom (mvar0_byref), "#21");
3574 Assert.IsFalse (mvar0_byref.IsAssignableFrom (obj_byref), "#22");
3577 public void Bug331126<T,K> () {}
3579 public struct Size4 {
3583 public struct Size4b {
3587 [Test] // Bug #612780
3588 public void CannotMakeDerivedTypesFromTypedByRef ()
3591 typeof (global::System.TypedReference).MakeArrayType ();
3593 } catch (TypeLoadException) { }
3596 typeof (global::System.TypedReference).MakeByRefType ();
3598 } catch (TypeLoadException) { }
3601 typeof (global::System.TypedReference).MakePointerType ();
3603 } catch (TypeLoadException) { }
3608 public void DeclaringTypeOfGenericNestedTypeInstanceIsOpen ()
3610 var type = typeof (Foo<int>.Nested<string>);
3611 Assert.AreSame (typeof (Foo<>), type.DeclaringType, "#1");
3614 interface IGetInterfaceMap<in T>
3619 class GetInterfaceMap : IGetInterfaceMap<object>
3621 public string Bar (object t)
3623 return t.GetType ().FullName;
3628 public void GetInterfaceMapWorksWithVariantIfaces ()
3630 InterfaceMapping res = typeof (GetInterfaceMap).GetInterfaceMap (typeof (IGetInterfaceMap <object>));
3631 Assert.AreEqual (typeof (IGetInterfaceMap <object>), res.InterfaceType);
3632 Assert.AreEqual (typeof (object), res.InterfaceMethods [0].GetParameters () [0].ParameterType);
3634 res = typeof (GetInterfaceMap).GetInterfaceMap (typeof (IGetInterfaceMap <string>));
3635 Assert.AreEqual (typeof (IGetInterfaceMap <string>), res.InterfaceType);
3636 Assert.AreEqual (typeof (string), res.InterfaceMethods [0].GetParameters () [0].ParameterType);
3640 public class MyType : TypeDelegator {
3643 public override bool Equals (Type t) {
3645 return base.Equals (t);
3648 public override Type UnderlyingSystemType {
3651 return typeof (int);
3657 public void NewV4EqualsBehavior ()
3659 var ta = new MyType ();
3660 var tb = new MyType ();
3661 object a = ta, b = tb;
3664 Assert.AreEqual (1, ta.eq, "#1");
3665 Assert.AreEqual (2, ta.ust, "#2");
3667 Assert.AreEqual (2, ta.eq, "#3");
3668 Assert.AreEqual (3, ta.ust, "#4");
3669 Assert.AreEqual (0, tb.eq, "#5");
3670 Assert.AreEqual (1, tb.ust, "#6");
3673 public enum MyRealEnum : short {
3678 public enum MyRealEnum2 : byte {
3682 public enum MyRealEnum3 : short {
3686 public class MyEnum : TypeDelegator {
3687 public bool is_enum { get; set; }
3688 public int fields { get; set; }
3690 public override bool IsSubclassOf (Type c) {
3691 return c == typeof (Enum) && is_enum;
3694 public override FieldInfo[] GetFields (BindingFlags bindingAttr) {
3697 FieldInfo[] res = new FieldInfo [fields];
3698 for (int i = 0; i < fields; ++i) {
3699 if ((bindingAttr & BindingFlags.Instance) != 0)
3700 res [i] = typeof (MyRealEnum).GetField ("value__");
3702 res [i] = typeof (MyRealEnum).GetField ("A");
3709 public void GetEnumUnderlyingType () {
3712 new MyEnum () { is_enum = false }.GetEnumUnderlyingType ();
3714 } catch (ArgumentException) {}
3717 new MyEnum () { is_enum = true, fields = 0 }.GetEnumUnderlyingType ();
3719 } catch (ArgumentException) {}
3722 new MyEnum () { is_enum = true, fields = 2 }.GetEnumUnderlyingType ();
3724 } catch (ArgumentException) {}
3726 Assert.AreSame (typeof (short), new MyEnum () { is_enum = true, fields = 1 }.GetEnumUnderlyingType ());
3730 public void GetEnumNames () {
3732 new MyEnum () { is_enum = false }.GetEnumNames ();
3734 } catch (ArgumentException) {}
3736 var res = new MyEnum () { is_enum = true, fields = 1 }.GetEnumNames ();
3737 Assert.AreEqual (1, res.Length, "#2");
3738 Assert.AreEqual ("A", res [0], "#3");
3740 res = typeof (MyRealEnum).GetEnumNames ();
3741 Assert.AreEqual (3, res.Length, "#4");
3742 Assert.AreEqual ("A", res [0], "#5");
3743 Assert.AreEqual ("B", res [1], "#6");
3744 Assert.AreEqual ("C", res [2], "#7");
3747 public enum OutOfOrderEnum : sbyte
3749 D = -1, C = 2, B = 1, A = 0
3753 public void GetEnumNamesSortsByUnsignedValue ()
3755 string[] names = typeof (OutOfOrderEnum).GetEnumNames ();
3756 Assert.AreEqual (4, names.Length);
3757 Assert.AreEqual ("A", names [0]);
3758 Assert.AreEqual ("B", names [1]);
3759 Assert.AreEqual ("C", names [2]);
3760 Assert.AreEqual ("D", names [3]);
3764 public void GetEnumValues () {
3766 new MyEnum () { is_enum = false }.GetEnumValues ();
3768 } catch (ArgumentException) {}
3771 new MyEnum () { is_enum = true }.GetEnumValues ();
3773 } catch (NotImplementedException) {}
3775 var array = typeof (MyRealEnum).GetEnumValues ();
3776 Assert.AreEqual (typeof (MyRealEnum[]), array.GetType (), "#3");
3777 MyRealEnum[] res = (MyRealEnum[])array;
3779 Assert.AreEqual (3, res.Length, "#4");
3780 Assert.AreEqual (MyRealEnum.A, res [0], "#5");
3781 Assert.AreEqual (MyRealEnum.B, res [1], "#6");
3782 Assert.AreEqual (MyRealEnum.C, res [2], "#7");
3786 public void GetEnumValue () {
3788 typeof (MyRealEnum).GetEnumName (null);
3790 } catch (ArgumentException) { }
3793 new MyEnum () { is_enum = false }.GetEnumName (99);
3795 } catch (ArgumentException) { }
3798 Assert.IsNull (new MyEnum () { fields = 1, is_enum = true }.GetEnumName (77), "#3");
3799 Assert.AreEqual ("A", new MyEnum () { fields = 1, is_enum = true }.GetEnumName (0), "#4");
3800 Assert.AreEqual ("A", new MyEnum () { fields = 1, is_enum = true }.GetEnumName (MyRealEnum.A), "#5");
3801 Assert.AreEqual ("A", new MyEnum () { fields = 1, is_enum = true }.GetEnumName (MyRealEnum2.A), "#6");
3803 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName (MyRealEnum.A), "#7");
3804 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((short)0), "#8");
3805 Assert.AreEqual ("C", typeof (MyRealEnum).GetEnumName (2), "#9");
3806 Assert.IsNull (typeof (MyRealEnum).GetEnumName (9), "#10");
3808 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((byte)0), "#11");
3809 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((sbyte)0), "#12");
3810 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName (false), "#13");
3811 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((short)0), "#14");
3812 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((ushort)0), "#15");
3813 Assert.IsNull (typeof (MyRealEnum).GetEnumName ('c'), "#16");
3815 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((int)0), "#17");
3816 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((uint)0), "#18");
3818 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((long)0), "#19");
3819 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((ulong)0), "#20");
3822 typeof (MyRealEnum).GetEnumName ((float)0);
3823 Assert.Fail ("#21");
3824 } catch (ArgumentException) { }
3826 typeof (MyRealEnum).GetEnumName ((double)0);
3827 Assert.Fail ("#22");
3828 } catch (ArgumentException) { }
3831 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((byte)0), "#23");
3832 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((sbyte)0), "#24");
3833 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName (false), "#25");
3835 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((short)0), "#26");
3836 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((ushort)0), "#27");
3838 Assert.IsNull (typeof (MyRealEnum2).GetEnumName ('c'), "#28");
3840 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((int)0), "#29");
3841 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((uint)0), "#30");
3843 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((long)0), "#31");
3844 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((ulong)0), "#32");
3847 typeof (MyRealEnum2).GetEnumName ((float)0);
3848 Assert.Fail ("#33");
3849 } catch (ArgumentException) { }
3851 typeof (MyRealEnum2).GetEnumName ((double)0);
3852 Assert.Fail ("#34");
3853 } catch (ArgumentException) { }
3855 Assert.IsNull (typeof (MyRealEnum2).GetEnumName (12345), "#35");
3859 public void IsEnumDefined () {
3861 typeof (MyRealEnum).IsEnumDefined (null);
3863 } catch (ArgumentException) { }
3866 new MyEnum () { is_enum = false }.IsEnumDefined (99);
3868 } catch (ArgumentException) { }
3871 typeof (MyRealEnum).IsEnumDefined (0);
3873 } catch (ArgumentException) { }
3876 typeof (MyRealEnum).IsEnumDefined ((ushort)0);
3878 } catch (ArgumentException) { }
3881 typeof (MyRealEnum).IsEnumDefined (MyRealEnum3.A);
3883 } catch (ArgumentException) { }
3886 typeof (MyRealEnum).IsEnumDefined (true);
3888 } catch (ArgumentException) { }
3891 typeof (MyRealEnum).IsEnumDefined (MyRealEnum2.A);
3893 } catch (ArgumentException) { }
3896 typeof (MyRealEnum).IsEnumDefined (typeof (MyRealEnum));
3898 } catch (InvalidOperationException) { }
3900 Assert.IsTrue (typeof (MyRealEnum).IsEnumDefined ((short)0), "#9");
3901 Assert.IsFalse (typeof (MyRealEnum).IsEnumDefined ((short)88), "#10");
3902 Assert.IsTrue (typeof (MyRealEnum).IsEnumDefined (MyRealEnum.A), "#11");
3903 Assert.IsFalse (typeof (MyRealEnum).IsEnumDefined ("d"), "#12");
3904 Assert.IsTrue (typeof (MyRealEnum).IsEnumDefined ("A"), "#13");
3905 Assert.IsFalse (new MyEnum () { is_enum = true, fields = 1 }.IsEnumDefined ((short)99), "#14");
3910 public class Outer {
3911 public class Inner {}
3915 public class Outer<T> {
3916 public class Inner {}
3920 public void GetTypeWithDelegates () {
3921 var tname = typeof (MyRealEnum).AssemblyQualifiedName;
3922 var res = Type.GetType (tname, name => {
3923 return Assembly.Load (name);
3924 },(asm,name,ignore) => {
3925 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3927 Assert.AreEqual (typeof (MyRealEnum), res, "#1");
3930 tname = typeof (Dictionary<int, string>).AssemblyQualifiedName;
3931 res = Type.GetType (tname, name => {
3932 return Assembly.Load (name);
3933 },(asm,name,ignore) => {
3934 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3936 Assert.AreEqual (typeof (Dictionary<int, string>), res, "#2");
3939 tname = typeof (Foo<int>).AssemblyQualifiedName;
3940 res = Type.GetType (tname, name => {
3941 return Assembly.Load (name);
3942 },(asm,name,ignore) => {
3943 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3945 Assert.AreEqual (typeof (Foo<int>), res, "#3");
3948 tname = typeof (Outer.Inner).AssemblyQualifiedName;
3949 res = Type.GetType (tname, name => {
3950 return Assembly.Load (name);
3951 },(asm,name,ignore) => {
3952 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3954 Assert.AreEqual (typeof (Outer.Inner), res, "#4");
3957 tname = typeof (Outer<double>.Inner).AssemblyQualifiedName;
3958 res = Type.GetType (tname, name => {
3959 return Assembly.Load (name);
3960 },(asm,name,ignore) => {
3961 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3963 Assert.AreEqual (typeof (Outer<double>.Inner), res, "#5");
3966 tname = "System.Collections.Generic.List`1[System.Int32]";
3967 res = Type.GetType (tname, name => {
3968 return Assembly.Load (name);
3969 },(asm,name,ignore) => {
3970 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3972 Assert.AreEqual (typeof (List<int>), res, "#6");
3975 tname = typeof (Foo<>).FullName + "[,][]";
3976 res = Type.GetType (tname, name => {
3977 Console.WriteLine ("resolve-asm name {0}", name);
3978 return Assembly.Load (name);
3979 },(asm,name,ignore) => {
3980 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3982 Assert.AreEqual (typeof (Foo<>).MakeArrayType (2).MakeArrayType (), res, "#7");
3984 tname = string.Format("{0}[{1}][]*&", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName);
3985 res = Type.GetType (tname, name => {
3986 return Assembly.Load (name);
3987 },(asm,name,ignore) => {
3988 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3990 Assert.AreEqual (typeof (Foo<MyRealEnum>[]).MakePointerType ().MakeByRefType (), res, "#8");
3993 tname = typeof (MyRealEnum).FullName + "[][]";
3994 res = Type.GetType (tname, name => {
3995 return Assembly.Load (name);
3996 },(asm,name,ignore) => {
3997 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3999 Assert.AreEqual (typeof (MyRealEnum[][]), res, "#9");
4002 tname = typeof (MyRealEnum).FullName + "[*]";
4003 res = Type.GetType (tname, name => {
4004 return Assembly.Load (name);
4005 },(asm,name,ignore) => {
4006 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4008 Assert.AreEqual (typeof (MyRealEnum).MakeArrayType (1), res, "#10");
4011 tname = typeof (MyRealEnum).FullName + "&";
4012 res = Type.GetType (tname, name => {
4013 return Assembly.Load (name);
4014 },(asm,name,ignore) => {
4015 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4017 Assert.AreEqual (typeof (MyRealEnum).MakeByRefType (), res, "#11");
4020 tname = typeof (MyRealEnum).FullName + "*";
4021 res = Type.GetType (tname, name => {
4022 return Assembly.Load (name);
4023 },(asm,name,ignore) => {
4024 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4026 Assert.AreEqual (typeof (MyRealEnum).MakePointerType (), res, "#12");
4028 tname = typeof (MyRealEnum).FullName + "*&";
4029 res = Type.GetType (tname, name => {
4030 return Assembly.Load (name);
4031 },(asm,name,ignore) => {
4032 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4034 Assert.AreEqual (typeof (MyRealEnum).MakePointerType ().MakeByRefType(),
4037 tname = typeof (MyRealEnum).FullName + "[,]&";
4038 res = Type.GetType (tname, name => {
4039 return Assembly.Load (name);
4040 },(asm,name,ignore) => {
4041 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4043 Assert.AreEqual (typeof (MyRealEnum).MakeArrayType (2).MakeByRefType (),
4046 tname = typeof (MyRealEnum).FullName + "*[]";
4047 res = Type.GetType (tname, name => {
4048 return Assembly.Load (name);
4049 },(asm,name,ignore) => {
4050 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4052 Assert.AreEqual (typeof (MyRealEnum).MakePointerType().MakeArrayType(),
4055 // not a very useful type, but ought to be parsed correctly
4056 tname = typeof (MyRealEnum).FullName + "[]**[]*&";
4057 res = Type.GetType (tname, name => {
4058 return Assembly.Load (name);
4059 },(asm,name,ignore) => {
4060 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4062 Assert.AreEqual (typeof (MyRealEnum).MakeArrayType().MakePointerType().MakePointerType().MakeArrayType().MakePointerType().MakeByRefType(),
4065 // assembly resolve without type resolve
4066 res = Type.GetType ("System.String,mscorlib", delegate (AssemblyName aname) { return typeof (int).Assembly; }, null);
4067 Assert.AreEqual (typeof (string), res);
4071 public class CustomGetType : TypeDelegator {
4074 public CustomGetType (string name) { this.name = name; }
4076 public override Type MakeGenericType (Type[] args) {
4077 return new CustomGetType ("GINST");
4080 public override Type GetNestedType(String name, BindingFlags bidingAttr) {
4081 return new CustomGetType ("NESTED");
4084 public override string ToString () { return "UT_" + name; }
4086 public override string Name {
4087 get { return "UT_" + name; }
4092 public void GetTypeWithDelegatesAndUserTypes ()
4094 var tname = "Magic[System.Int32]";
4095 var res = Type.GetType (tname, name => {
4096 return Assembly.Load (name);
4097 },(asm,name,ignore) => {
4098 if (name == "Magic") return new CustomGetType ("MAGIC");
4099 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4101 Assert.AreEqual ("UT_GINST", res.Name, "#1");
4104 tname = "Magic+MyRealEnum";
4105 res = Type.GetType (tname, name => {
4106 return Assembly.Load (name);
4107 },(asm,name,ignore) => {
4108 if (name == "Magic") return new CustomGetType ("MAGIC");
4109 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4111 Assert.AreEqual ("UT_NESTED", res.Name, "#2");
4114 void MustTLE (string tname) {
4116 var res = 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);
4121 Assert.Fail (tname);
4122 } catch (TypeLoadException) {}
4125 void MustANE (string tname) {
4127 var res = Type.GetType (tname, name => {
4128 return Assembly.Load (name);
4129 },(asm,name,ignore) => {
4130 return (object)asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4132 Assert.Fail (tname);
4133 } catch (ArgumentNullException) {}
4136 void MustAE_general (string tname, Func<string,Type> getType) {
4138 var res = getType (tname);
4139 Assert.Fail (tname);
4140 } catch (ArgumentException) {}
4143 void MustAE (string typename) {
4144 MustAE_general (typename, tname => {
4145 return Type.GetType (tname, name => {
4146 return Assembly.Load (name);
4147 },(asm,name,ignore) => {
4148 return (object)asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4153 void MustAEnn (string typename) {
4154 MustAE_general (typename, tname => Type.GetType (tname, null, null));
4157 void MustFNFE (string tname) {
4159 var res = Type.GetType (tname, name => {
4160 return Assembly.Load (name);
4161 },(asm,name,ignore) => {
4162 return (object)asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4164 Assert.Fail (tname);
4165 } catch (FileNotFoundException) {}
4169 public void NewGetTypeErrors () {
4171 MustAE ("!@#$%^&*");
4172 MustAE (string.Format ("{0}[{1}&]", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4173 MustAE (string.Format ("{0}[{1}*]", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4174 MustAE (string.Format ("{0}&&", typeof (MyRealEnum).FullName));
4175 MustAE (string.Format ("{0}&*", typeof (MyRealEnum).FullName));
4176 MustAE (string.Format ("{0}&[{1}]", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4177 MustAE (string.Format ("{0}[,", typeof (MyRealEnum).FullName));
4178 MustAE (string.Format ("{0}[*", typeof (MyRealEnum).FullName));
4180 MustAE (string.Format ("{0}[[{1},", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4181 MustAE (string.Format ("{0}[[{1}]", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4182 MustAE (string.Format ("{0}[[{1}],", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4183 MustAE (string.Format ("{0}[[{1}]_", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4185 MustAE (string.Format ("{0}[{1}", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4186 MustAE (string.Format ("{0}[{1},", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4187 MustAE (string.Format ("{0}[{1},,", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4188 MustAE (string.Format ("{0}[{1} (", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4189 MustAE (string.Format ("{0}[", typeof (Foo<>).FullName));
4191 MustAE (string.Format ("{0}[**]", typeof (MyRealEnum).FullName));
4192 MustAE (string.Format ("{0}[*,*]", typeof (MyRealEnum).FullName));
4193 MustAE (string.Format ("{0}[*,]", typeof (MyRealEnum).FullName));
4194 MustAE (string.Format ("{0}[,*]", typeof (MyRealEnum).FullName));
4195 MustAE (string.Format ("{0}[,-]", typeof (MyRealEnum).FullName));
4196 MustAE (string.Format ("{0}[,{0}]", typeof (MyRealEnum).FullName));
4198 MustAE (string.Format ("{0}[{1}]]", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4199 MustAE (string.Format ("{0}[,]]", typeof (MyRealEnum).FullName));
4202 string aqn = typeof (MyRealEnum).Assembly.FullName;
4203 MustFNFE (string.Format ("{0}, ZZZ{1}", typeof (MyRealEnum).FullName, aqn));
4204 MustTLE (string.Format ("{0}ZZZZ", typeof (MyRealEnum).FullName));
4205 MustTLE (string.Format ("{0}ZZZZ,{1}", typeof (MyRealEnum).FullName, aqn));
4209 public void GetTypeExceptionMsg () {
4210 string typeName = "system.int32, foo";
4212 Type.GetType(typeName, true, false);
4213 } catch (TypeLoadException ex) {
4214 Assert.IsTrue (ex.Message.Contains ("system.int32"));
4215 Assert.IsTrue (ex.Message.Contains ("foo"));
4219 delegate void MyAction<in T>(T ag);
4221 [Test] //bug #668506
4222 public void IsAssignableFromWithVariantDelegate () {
4223 Assert.IsFalse (typeof(MyAction<string>).IsAssignableFrom(typeof(MyAction<>)), "#1");
4227 public void IsAssignableFromWithNullable () {
4228 Console.WriteLine(typeof(IEnumerable<int?>).IsAssignableFrom(typeof(IEnumerable<int>)));
4232 public void GetTypeParseGenericCorrectly () { //Bug #15124
4233 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1"), typeof (Foo<>), "#1");
4234 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32]"), typeof (Foo<int>), "#2");
4235 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[[System.Int32]]"), typeof (Foo<int>), "#3");
4236 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32][]"), typeof (Foo<int>[]), "#4");
4237 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[][System.Int32]"), null, "#5");
4238 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32][,]"), typeof (Foo<int>[,]), "#6");
4239 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[]"), typeof (Foo<>).MakeArrayType(), "#7");
4240 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[,]"), typeof (Foo<>).MakeArrayType (2), "#8");
4241 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[][]"), typeof (Foo<>).MakeArrayType ().MakeArrayType (), "#9");
4242 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1["), null, "#10");
4243 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[["), null, "#11");
4244 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[[]"), null, "#12");
4245 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[,"), null, "#13");
4246 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[*"), null, "#14");
4247 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32"), null, "#15");
4251 public void GetTypeNullDelegatesParseGenericCorrectly () {
4252 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1", null, null), typeof (Foo<>), "#1");
4253 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32]", null, null), typeof (Foo<int>), "#2");
4254 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[[System.Int32]]", null, null), typeof (Foo<int>), "#3");
4255 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32][]", null, null), typeof (Foo<int>[]), "#4");
4256 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32][,]", null, null), typeof (Foo<int>[,]), "#5");
4257 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[]", null, null), typeof (Foo<>).MakeArrayType(), "#6");
4258 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[,]", null, null), typeof (Foo<>).MakeArrayType (2), "#7");
4259 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[][]", null, null), typeof (Foo<>).MakeArrayType ().MakeArrayType (), "#8");
4261 MustAEnn ("MonoTests.System.Foo`1[][System.Int32]");
4262 MustAEnn ("MonoTests.System.Foo`1[");
4263 MustAEnn ("MonoTests.System.Foo`1[[");
4264 MustAEnn ("MonoTests.System.Foo`1[[]");
4265 MustAEnn ("MonoTests.System.Foo`1[,");
4266 MustAEnn ("MonoTests.System.Foo`1[*");
4267 MustAEnn ("MonoTests.System.Foo`1[System.Int32");
4270 Dictionary<int, T> MakeDictHelper<T> (T[] arr) {
4271 return new Dictionary<int, T>();
4275 public void GetTypeAnonymousParseCorrectly () {
4276 var x = new { X = 1 };
4277 var a = new [] { x };
4278 var d = MakeDictHelper (a);
4280 var x_type = x.GetType ();
4281 var a_type = a.GetType ();
4282 var d_type = d.GetType ();
4284 Assert.AreEqual (Type.GetType (x_type.ToString ()), x_type, "#1");
4285 Assert.AreEqual (Type.GetType (x_type.ToString (), null, null), x_type, "#2");
4286 Assert.AreEqual (Type.GetType (a_type.ToString ()), a_type, "#3");
4287 Assert.AreEqual (Type.GetType (a_type.ToString (), null, null), a_type, "#4");
4288 Assert.AreEqual (Type.GetType (d_type.ToString ()), d_type, "#5");
4289 Assert.AreEqual (Type.GetType (d_type.ToString (), null, null), d_type, "#6");
4291 Assert.AreEqual (Type.GetType (x_type.FullName), x_type, "#7");
4292 Assert.AreEqual (Type.GetType (x_type.FullName, null, null), x_type, "#8");
4293 Assert.AreEqual (Type.GetType (a_type.FullName), a_type, "#9");
4294 Assert.AreEqual (Type.GetType (a_type.FullName, null, null), a_type, "#10");
4295 Assert.AreEqual (Type.GetType (d_type.FullName), d_type, "#11");
4296 Assert.AreEqual (Type.GetType (d_type.FullName, null, null), d_type, "#12");
4300 #if !MONOTOUCH && !FULL_AOT_RUNTIME && !MONOMAC
4302 [Category ("AndroidNotWorking")] // requires symbol writer
4303 public void FullNameGetTypeParseEscapeRoundtrip () // bug #26384
4305 var nm = new AssemblyName ("asm");
4306 var ab = AssemblyBuilder.DefineDynamicAssembly (nm,
4307 AssemblyBuilderAccess.Run);
4308 var mb = ab.DefineDynamicModule("m", false);
4309 var tb = mb.DefineType ("NameSpace,+*&[]\\.Type,+*&[]\\",
4310 TypeAttributes.Class | TypeAttributes.Public);
4312 var nestedTb = tb.DefineNestedType("Nested,+*&[]\\",
4313 TypeAttributes.Class | TypeAttributes.NestedPublic);
4315 var ty = tb.CreateType();
4317 var nestedTy = nestedTb.CreateType();
4319 var escapedNestedName =
4320 "NameSpace\\,\\+\\*\\&\\[\\]\\\\"
4322 + "Type\\,\\+\\*\\&\\[\\]\\\\"
4324 + "Nested\\,\\+\\*\\&\\[\\]\\\\";
4326 Assert.AreEqual(escapedNestedName, nestedTy.FullName);
4328 var lookupNestedTy =
4329 Type.GetType(escapedNestedName + "," + nm.FullName,
4331 if (asmName.FullName.Equals(nm.FullName)) return ab;
4332 else return Assembly.Load (asmName);
4334 (asm,name,ignore) => {
4336 return Type.GetType(name, true, ignore);
4337 else return asm.GetType(name, true, ignore);
4341 Assert.AreEqual(nestedTy, lookupNestedTy);
4348 public void GetTypeBadArity()
4350 // Regression test for #46250
4352 Type.GetType ("System.Collections.Generic.Dictionary`2[System.String]", true);
4353 Assert.Fail ("Did not throw an exception (#1)");
4354 } catch (ArgumentException) {
4358 Type.GetType ("System.Collections.Generic.Dictionary`2[System.String,System.Int32,System.Int64]", true);
4359 Assert.Fail ("Did not throw an exception (#2)");
4360 } catch (ArgumentException) {
4364 public abstract class Stream : IDisposable
4366 public void Dispose ()
4368 Console.WriteLine ("stream::dispose");
4371 protected virtual void Dispose (bool disposing)
4376 public class NonClosingStream
4377 : Stream, IDisposable
4379 void IDisposable.Dispose()
4381 Console.WriteLine ("ncs::dispose");
4384 public override string ToString () { return ""; }
4387 static bool ContainsProperty (PropertyInfo [] props, string name)
4389 foreach (PropertyInfo p in props)
4395 public class NemerleAttribute : Attribute
4399 public class VolatileModifier : NemerleAttribute
4409 [AttributeUsage (AttributeTargets.Class, Inherited=false)]
4410 public class FooAttribute : Attribute
4414 public class BarAttribute : FooAttribute
4431 [AttributeUsage (AttributeTargets.Class, Inherited=true)]
4432 public class InheritAttribute : Attribute
4436 [AttributeUsage (AttributeTargets.Class, Inherited=false)]
4437 public class NotInheritAttribute : InheritAttribute
4441 [NotInheritAttribute]
4442 public class bug82431A1
4446 public class bug82431A2 : bug82431A1
4450 [NotInheritAttribute]
4452 public class bug82431A3 : bug82431A1
4457 public class bug82431B1
4461 public class bug82431B2 : bug82431B1
4465 [NotInheritAttribute]
4466 public class bug82431B3 : bug82431B2
4470 public class bug82431B4 : bug82431B3
4478 public class Bug77367
4480 public void Run (bool b)
4487 private string PrivInstBlue
4489 get { return null; }
4492 protected string ProtInstBlue
4494 get { return null; }
4497 protected internal string ProIntInstBlue
4499 get { return null; }
4502 public long PubInstBlue
4506 if (PrivInstBlue == null)
4508 return long.MaxValue;
4512 internal int IntInstBlue
4517 private static string PrivStatBlue
4519 get { return null; }
4522 protected static string ProtStatBlue
4524 get { return null; }
4527 protected static internal string ProIntStatBlue
4529 get { return null; }
4532 public static long PubStatBlue
4536 if (PrivStatBlue == null)
4538 return long.MaxValue;
4542 internal static int IntStatBlue
4548 public class Foo : Blue
4550 private string PrivInstBase
4552 get { return null; }
4555 protected string ProtInstBase
4557 get { return null; }
4560 protected internal string ProIntInstBase
4562 get { return null; }
4565 public long PubInstBase
4569 if (PrivInstBase == null)
4571 return long.MaxValue;
4575 internal int IntInstBase
4580 private static string PrivStatBase
4582 get { return null; }
4585 protected static string ProtStatBase
4587 get { return null; }
4590 protected static internal string ProIntStatBase
4592 get { return null; }
4595 public static long PubStatBase
4599 if (PrivStatBase == null)
4601 return long.MaxValue;
4605 internal static int IntStatBase
4611 public class Bar : Foo
4613 private string PrivInst
4615 get { return null; }
4618 protected string ProtInst
4620 get { return null; }
4623 protected internal string ProIntInst
4625 get { return null; }
4632 if (PrivInst == null)
4634 return long.MaxValue;
4638 internal int IntInst
4643 private static string PrivStat
4645 get { return null; }
4648 protected static string ProtStat
4650 get { return null; }
4653 protected static internal string ProIntStat
4655 get { return null; }
4658 public static long PubStat
4662 if (PrivStat == null)
4664 return long.MaxValue;
4668 internal static int IntStat
4694 public CtorsC (int x)
4700 class UserType : Type
4702 protected Type type;
4704 public UserType(Type type) {
4708 public override Type UnderlyingSystemType { get { return this.type; } }
4710 public override Assembly Assembly { get { return this.type == null ? null : this.type.Assembly; } }
4712 public override string AssemblyQualifiedName { get { return null; } }
4714 public override Type BaseType { get { return null; } }
4716 public override Module Module { get { return this.type.Module; } }
4718 public override string Namespace { get { return null; } }
4720 public override bool IsGenericParameter { get { return true; } }
4722 public override RuntimeTypeHandle TypeHandle { get { throw new NotSupportedException(); } }
4724 public override bool ContainsGenericParameters { get { return true; } }
4726 public override string FullName { get { return this.type.Name; } }
4728 public override Guid GUID { get { throw new NotSupportedException(); } }
4731 protected override bool IsArrayImpl() {
4735 protected override bool IsByRefImpl()
4740 protected override bool IsCOMObjectImpl()
4745 protected override bool IsPointerImpl()
4750 protected override bool IsPrimitiveImpl()
4756 protected override TypeAttributes GetAttributeFlagsImpl()
4761 protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder,
4762 CallingConventions callConvention, Type[] types,
4763 ParameterModifier[] modifiers)
4768 public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr)
4773 public override Type GetElementType()
4778 public override EventInfo GetEvent(string name, BindingFlags bindingAttr)
4784 public override FieldInfo GetField(string name, BindingFlags bindingAttr)
4790 public override Type GetInterface(string name, bool ignoreCase)
4795 public override Type[] GetInterfaces()
4800 public override MemberInfo[] GetMembers(BindingFlags bindingAttr)
4805 public override object[] GetCustomAttributes(Type attributeType, bool inherit)
4810 public override object[] GetCustomAttributes(bool inherit)
4815 public override bool IsDefined(Type attributeType, bool inherit)
4820 public override string Name { get { return this.type.Name; } }
4822 public override EventInfo[] GetEvents(BindingFlags bindingAttr)
4824 throw new NotImplementedException();
4827 public override FieldInfo[] GetFields(BindingFlags bindingAttr)
4829 throw new NotImplementedException();
4832 protected override MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder,
4833 CallingConventions callConvention, Type[] types,
4834 ParameterModifier[] modifiers)
4839 public override MethodInfo[] GetMethods(BindingFlags bindingAttr)
4844 public override Type GetNestedType(string name, BindingFlags bindingAttr)
4849 public override Type[] GetNestedTypes(BindingFlags bindingAttr)
4854 public override PropertyInfo[] GetProperties(BindingFlags bindingAttr)
4859 protected override PropertyInfo GetPropertyImpl(string name, BindingFlags bindingAttr, Binder binder,
4860 Type returnType, Type[] types, ParameterModifier[] modifiers)
4865 protected override bool HasElementTypeImpl()
4870 public override object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, object target,
4871 object[] args, ParameterModifier[] modifiers, CultureInfo culture,
4872 string[] namedParameters)
4874 throw new NotSupportedException();
4878 class UserType2 : UserType {
4879 public UserType2 (Type type) : base (type) {
4882 public override Type UnderlyingSystemType { get { return this.type ?? this; } }
4884 public override int GetHashCode()
4888 return type.GetHashCode();