1 // TypeTest.cs - NUnit Test Cases for the System.Type class
4 // Zoltan Varga (vargaz@freemail.hu)
6 // Aleksey Kliger (aleksey@xamarin.com)
8 // (C) 2003 Ximian, Inc. http://www.ximian.com
9 // Copyright (C) 2015 Xamarin, Inc. (http://www.xamarin.com)
12 using NUnit.Framework;
14 using System.Threading;
15 using System.Collections;
16 using System.Collections.Generic;
18 using System.Reflection;
19 #if !MONOTOUCH && !MOBILE_STATIC
20 using System.Reflection.Emit;
22 using System.Runtime.InteropServices;
24 using System.Globalization;
26 class NoNamespaceClass {
29 namespace MonoTests.System
31 class Super : ICloneable
33 public virtual object Clone ()
48 interface IFace2 : IFace1
53 interface IFace3 : IFace2
68 public abstract int this [byte i] {
72 public abstract int this [int i] {
76 public abstract void TestVoid ();
77 public abstract void TestInt (int i);
80 class DeriveVTable : Base
82 public override int this [byte i] {
86 public override int this [int i] {
90 public override void TestVoid ()
95 public override void TestInt (int i)
101 class NewVTable : DeriveVTable
103 public new int this [byte i] {
107 public new int this [int i] {
111 public new void TestVoid ()
116 public new void TestInt (int i)
121 public void Overload ()
125 public void Overload (int i)
129 public NewVTable (out int i)
134 public void byref_method (out int i)
142 public virtual int Foo {
147 public event EventHandler E;
154 class Derived1 : Base1
156 public override int Foo {
161 class Derived2 : Base1
168 public new event Action E;
169 public new void Dummy ()
180 get { throw new NotImplementedException (); }
183 public T Execute (T a)
188 public class Nested<K> {}
195 public interface IBar<T>
199 public class Baz<T> : IBar<T>
205 public static void Bang<S> () {}
208 public class Bug348522
210 public void Test (int __argument)
215 public class GenericIndexers<T, U>
217 // This class has two indexers that take different
218 // arguments. GetProperties on all instances of this
219 // generic type should still have 2 properties, even
220 // if T and U are instantiated with the same types.
221 public T this[T t] { get { return t; } }
222 public U this[U u] { get { return u; } }
225 public class FirstMethodBinder : Binder
227 public override MethodBase BindToMethod (BindingFlags bindingAttr, MethodBase [] match, ref object [] args,
228 ParameterModifier [] modifiers, CultureInfo culture, string [] names,
235 public override object ChangeType (object value, Type type1, CultureInfo culture)
240 // The rest is just to please the compiler
241 public override FieldInfo BindToField (BindingFlags a, FieldInfo[] b, object c, CultureInfo d)
246 public override void ReorderArgumentArray(ref object[] a, object b)
250 public override MethodBase SelectMethod(BindingFlags a, MethodBase[] b, Type[] c, ParameterModifier[] d)
255 public override PropertyInfo SelectProperty(BindingFlags a, PropertyInfo[] b, Type c, Type[] d, ParameterModifier[] e)
262 public class TypeTest
264 #if !MONOTOUCH && !MOBILE_STATIC
265 private ModuleBuilder module;
267 const string ASSEMBLY_NAME = "MonoTests.System.TypeTest";
268 static int typeIndexer = 0;
273 AssemblyName assemblyName = new AssemblyName ();
274 assemblyName.Name = ASSEMBLY_NAME;
275 #if !MONOTOUCH && !MOBILE_STATIC
276 var assembly = AppDomain.CurrentDomain.DefineDynamicAssembly (
277 assemblyName, AssemblyBuilderAccess.RunAndSave, Path.GetTempPath ());
278 module = assembly.DefineDynamicModule ("module1");
282 private string genTypeName ()
284 return "t" + (typeIndexer++);
287 private void ByrefMethod (ref int i, ref Derived1 j, ref Base1 k)
291 public interface IFace {
294 private void GenericMethod<Q, T1> (Q q, T1 t) where T1 : IFace
304 public void TestIsAssignableFrom ()
306 // Simple tests for inheritance
307 Assert.AreEqual (typeof (Super).IsAssignableFrom (typeof (Duper)) , true, "#01");
308 Assert.AreEqual (typeof (Duper).IsAssignableFrom (typeof (Duper)), true, "#02");
309 Assert.AreEqual (typeof (Object).IsAssignableFrom (typeof (Duper)), true, "#03");
310 Assert.AreEqual (typeof (ICloneable).IsAssignableFrom (typeof (Duper)), true, "#04");
313 Assert.AreEqual (typeof (Super[]).IsAssignableFrom (typeof (Duper[])), true, "#05");
314 Assert.AreEqual (typeof (Duper[]).IsAssignableFrom (typeof (Super[])), false, "#06");
315 Assert.AreEqual (typeof (Object[]).IsAssignableFrom (typeof (Duper[])), true, "#07");
316 Assert.AreEqual (typeof (ICloneable[]).IsAssignableFrom (typeof (Duper[])), true, "#08");
318 // Tests for multiple dimensional arrays
319 Assert.AreEqual (typeof (Super[][]).IsAssignableFrom (typeof (Duper[][])), true, "#09");
320 Assert.AreEqual (typeof (Duper[][]).IsAssignableFrom (typeof (Super[][])), false, "#10");
321 Assert.AreEqual (typeof (Object[][]).IsAssignableFrom (typeof (Duper[][])), true, "#11");
322 Assert.AreEqual (typeof (ICloneable[][]).IsAssignableFrom (typeof (Duper[][])), true, "#12");
324 // Tests for vectors<->one dimensional arrays */
325 Array arr1 = Array.CreateInstance (typeof (int), new int[] {1}, new int[] {0});
326 Array arr2 = Array.CreateInstance (typeof (int), new int[] {1}, new int[] {10});
328 Assert.AreEqual (typeof (int[]).IsAssignableFrom (arr1.GetType ()), true, "#13");
329 Assert.AreEqual (typeof (int[]).IsAssignableFrom (arr2.GetType ()), false, "#14");
331 // Test that arrays of enums can be cast to their base types
332 Assert.AreEqual (typeof (int[]).IsAssignableFrom (typeof (TypeCode[])), true, "#15");
334 // Test that arrays of valuetypes can't be cast to arrays of
336 Assert.AreEqual (typeof (object[]).IsAssignableFrom (typeof (TypeCode[])), false, "#16");
337 Assert.AreEqual (typeof (ValueType[]).IsAssignableFrom (typeof (TypeCode[])), false, "#17");
338 Assert.AreEqual (typeof (Enum[]).IsAssignableFrom (typeof (TypeCode[])), false, "#18");
340 // Test that arrays of enums can't be cast to arrays of references
341 Assert.AreEqual (typeof (object[]).IsAssignableFrom (typeof (TheEnum[])), false, "#19");
342 Assert.AreEqual (typeof (ValueType[]).IsAssignableFrom (typeof (TheEnum[])), false, "#20");
343 Assert.AreEqual (typeof (Enum[]).IsAssignableFrom (typeof (TheEnum[])), false, "#21");
345 // Check that ValueType and Enum are recognized as reference types
346 Assert.AreEqual (typeof (object).IsAssignableFrom (typeof (ValueType)), true, "#22");
347 Assert.AreEqual (typeof (object).IsAssignableFrom (typeof (Enum)), true, "#23");
348 Assert.AreEqual (typeof (ValueType).IsAssignableFrom (typeof (Enum)), true, "#24");
350 Assert.AreEqual (typeof (object[]).IsAssignableFrom (typeof (ValueType[])), true, "#25");
351 Assert.AreEqual (typeof (ValueType[]).IsAssignableFrom (typeof (ValueType[])), true, "#26");
352 Assert.AreEqual (typeof (Enum[]).IsAssignableFrom (typeof (ValueType[])), false, "#27");
354 Assert.AreEqual (typeof (object[]).IsAssignableFrom (typeof (Enum[])), true, "#28");
355 Assert.AreEqual (typeof (ValueType[]).IsAssignableFrom (typeof (Enum[])), true, "#29");
356 Assert.AreEqual (typeof (Enum[]).IsAssignableFrom (typeof (Enum[])), true, "#30");
358 // Tests for byref types
359 MethodInfo mi = typeof (TypeTest).GetMethod ("ByrefMethod", BindingFlags.Instance|BindingFlags.NonPublic);
360 Assert.IsTrue (mi.GetParameters ()[2].ParameterType.IsAssignableFrom (mi.GetParameters ()[1].ParameterType));
361 Assert.IsTrue (mi.GetParameters ()[1].ParameterType.IsAssignableFrom (mi.GetParameters ()[1].ParameterType));
363 // Tests for type parameters
364 mi = typeof (TypeTest).GetMethod ("GenericMethod", BindingFlags.Instance|BindingFlags.NonPublic);
365 Assert.IsTrue (mi.GetParameters ()[0].ParameterType.IsAssignableFrom (mi.GetParameters ()[0].ParameterType));
366 Assert.IsFalse (mi.GetParameters ()[0].ParameterType.IsAssignableFrom (typeof (int)));
368 // Tests for parameters with generic constraints
369 mi = typeof (TypeTest).GetMethod ("GenericMethod", BindingFlags.Instance|BindingFlags.NonPublic);
370 Assert.IsTrue (typeof (IFace).IsAssignableFrom (mi.GetParameters ()[1].ParameterType));
374 [ExpectedException (typeof (ArgumentException))]
375 public void GetInterfaceMapOnInterface ()
377 typeof (IList).GetInterfaceMap (typeof (ICollection));
381 public void TestIsSubclassOf ()
383 Assert.IsTrue (typeof (ICloneable).IsSubclassOf (typeof (object)), "#01");
385 // Tests for byref types
386 Type paramType = typeof (TypeTest).GetMethod ("ByrefMethod", BindingFlags.Instance|BindingFlags.NonPublic).GetParameters () [0].ParameterType;
387 Assert.IsFalse (paramType.IsSubclassOf (typeof(ValueType)), "#02");
388 Assert.IsNull (paramType.BaseType, "#02-b");
389 Assert.IsTrue (paramType.IsSubclassOf (typeof (Object)), "#03");
390 Assert.IsFalse (paramType.IsSubclassOf (paramType), "#04");
394 public void TestGetMethodImpl ()
396 // Test binding of new slot methods (using no types)
397 Assert.AreEqual (typeof (Base), typeof (Base).GetMethod("TestVoid").DeclaringType, "#01");
398 Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetMethod ("TestVoid").DeclaringType, "#02");
400 // Test binding of new slot methods (using types)
401 Assert.AreEqual (typeof (Base), typeof (Base).GetMethod ("TestInt", new Type[] { typeof (int) }).DeclaringType, "#03");
402 Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetMethod ("TestInt", new Type[] { typeof (int) }).DeclaringType, "#04");
404 // Test overload resolution
405 Assert.AreEqual (0, typeof (NewVTable).GetMethod ("Overload", new Type[0]).GetParameters ().Length, "#05");
407 // Test byref parameters
408 Assert.AreEqual (null, typeof (NewVTable).GetMethod ("byref_method", new Type[] { typeof (int) }), "#06");
409 Type byrefInt = typeof (NewVTable).GetMethod ("byref_method").GetParameters ()[0].ParameterType;
410 Assert.IsNotNull (typeof (NewVTable).GetMethod ("byref_method", new Type[] { byrefInt }), "#07");
414 public void TestGetPropertyImpl ()
416 // Test getting property that is exact
417 Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetProperty ("Item", new Type[1] { typeof (Int32) }).DeclaringType, "#01");
419 // Test getting property that is not exact
420 Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetProperty ("Item", new Type[1] { typeof (Int16) }).DeclaringType, "#02");
422 // Test overriding of properties when only the set accessor is overriden
423 Assert.AreEqual (1, typeof (Derived1).GetProperties ().Length, "#03");
427 public void GetEvents ()
430 Assert.AreEqual (1, typeof (Derived2).GetEvents ().Length);
431 Assert.AreEqual (typeof (Derived2), typeof (Derived2).GetEvents ()[0].DeclaringType);
435 public void GetProperties ()
437 // Test hide-by-name-and-signature
438 Assert.AreEqual (1, typeof (Derived2).GetProperties ().Length, "#1");
439 Assert.AreEqual (typeof (Derived2), typeof (Derived2).GetProperties ()[0].DeclaringType, "#2");
441 // For generics, hide-by-name-and-signature works on the unexpanded types. The
442 // GenericIndexers<T,U> class has two indexers that take different arguments.
443 // GetProperties on all instances of this generic type should still have 2 properties,
444 // even if T and U are instantiated with the same types.
446 var ps = typeof (GenericIndexers<int,int>).GetProperties ();
447 Assert.AreEqual (2, ps.Length, "#3");
448 for (int i = 0; i < ps.Length; i++) {
451 var getterResultType = p.GetGetMethod ().ReturnType;
453 var msg = String.Format ("#4-{0}", i);
454 Assert.AreEqual (typeof (int), getterResultType, msg);
459 class GetProperties_Overrides_Input
461 public class TestClass : BaseClass<object>
463 public override object TestProperty { get; set; }
466 public abstract class BaseClass<T>
468 public virtual T TestProperty { get; set; }
471 public class TestClass_Indexer : BaseClass_Indexer<object>
473 public override object this[int arg] { set { } }
476 public abstract class BaseClass_Indexer<T>
478 public virtual T this[int arg] { set { } }
481 public interface IB : IA<object>
483 new object TestProperty { get; set; }
486 public interface IA<T>
488 T TestProperty { get; set; }
491 public class TestClass_HiddenProperty : BaseClass_HiddenProperty
493 public new virtual string Prop { set { } }
496 public class BaseClass_HiddenProperty
498 public virtual string Prop { set { } }
503 public void GetProperties_Overrides ()
505 Assert.AreEqual (1, typeof (GetProperties_Overrides_Input.IB).GetProperties().Length);
507 var prop = typeof (GetProperties_Overrides_Input.TestClass).GetProperty ("TestProperty");
508 Assert.AreEqual (typeof (GetProperties_Overrides_Input.TestClass), prop.DeclaringType);
510 var prop_2 = typeof (GetProperties_Overrides_Input.TestClass_HiddenProperty).GetProperty ("Prop");
511 Assert.AreEqual (typeof (GetProperties_Overrides_Input.TestClass_HiddenProperty), prop_2.DeclaringType);
513 Assert.AreEqual (1, typeof (GetProperties_Overrides_Input.TestClass).GetProperties().Length);
514 Assert.AreEqual (1, typeof (GetProperties_Overrides_Input.TestClass_Indexer).GetProperties().Length);
515 Assert.AreEqual (1, typeof (GetProperties_Overrides_Input.TestClass_HiddenProperty).GetProperties().Length);
518 [Test] // GetProperties (BindingFlags)
519 public void GetProperties_Flags ()
521 PropertyInfo [] props;
522 Type type = typeof (Bar);
525 flags = BindingFlags.Instance | BindingFlags.NonPublic;
526 props = type.GetProperties (flags);
528 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#A1");
529 Assert.IsTrue (ContainsProperty (props, "ProtInstBase"), "#A2");
530 Assert.IsTrue (ContainsProperty (props, "ProIntInstBase"), "#A3");
531 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#A4");
532 Assert.IsTrue (ContainsProperty (props, "IntInstBase"), "#A5");
533 Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#A6");
534 Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#A7");
535 Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#A8");
536 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#A9");
537 Assert.IsTrue (ContainsProperty (props, "IntInst"), "#A10");
538 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#A11");
539 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#A12");
540 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#A13");
541 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#A14");
542 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#A15");
543 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#A16");
544 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#A17");
545 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#A18");
546 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#A19");
547 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#A20");
548 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#A21");
549 Assert.IsTrue (ContainsProperty (props, "ProtInstBlue"), "#A22");
550 Assert.IsTrue (ContainsProperty (props, "ProIntInstBlue"), "#A23");
551 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#A24");
552 Assert.IsTrue (ContainsProperty (props, "IntInstBlue"), "#A25");
553 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#A26");
554 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#A27");
555 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#A28");
556 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#A29");
557 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#A30");
559 flags = BindingFlags.Instance | BindingFlags.Public;
560 props = type.GetProperties (flags);
562 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#B1");
563 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#B2");
564 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#B3");
565 Assert.IsTrue (ContainsProperty (props, "PubInstBase"), "#B4");
566 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#B5");
567 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#B6");
568 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#B7");
569 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#B8");
570 Assert.IsTrue (ContainsProperty (props, "PubInst"), "#B9");
571 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#B10");
572 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#B11");
573 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#B12");
574 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#B13");
575 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#B14");
576 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#B15");
577 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#B16");
578 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#B17");
579 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#B18");
580 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#B19");
581 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#B20");
582 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#B21");
583 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#B22");
584 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#B23");
585 Assert.IsTrue (ContainsProperty (props, "PubInstBlue"), "#B24");
586 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#B25");
587 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#B26");
588 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#B27");
589 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#B28");
590 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#B29");
591 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#B30");
593 flags = BindingFlags.Static | BindingFlags.Public;
594 props = type.GetProperties (flags);
596 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#C1");
597 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#C2");
598 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#C3");
599 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#C4");
600 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#C5");
601 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#C6");
602 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#C7");
603 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#C8");
604 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#C9");
605 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#C10");
606 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#C11");
607 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#C12");
608 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#C13");
609 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#C14");
610 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#C15");
611 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#C16");
612 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#C17");
613 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#C18");
614 Assert.IsTrue (ContainsProperty (props, "PubStat"), "#C19");
615 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#C20");
616 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#C21");
617 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#C22");
618 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#C23");
619 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#C24");
620 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#C25");
621 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#C26");
622 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#C27");
623 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#C28");
624 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#C29");
625 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#C30");
627 flags = BindingFlags.Static | BindingFlags.NonPublic;
628 props = type.GetProperties (flags);
630 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#D1");
631 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#D2");
632 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#D3");
633 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#D4");
634 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#D5");
635 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#D6");
636 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#D7");
637 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#D8");
638 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#D9");
639 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#D10");
640 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#D11");
641 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#D12");
642 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#D13");
643 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#D14");
644 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#D15");
645 Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#D16");
646 Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#D17");
647 Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#D18");
648 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#D19");
649 Assert.IsTrue (ContainsProperty (props, "IntStat"), "#D20");
650 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#D21");
651 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#D22");
652 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#D23");
653 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#D24");
654 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#D25");
655 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#D26");
656 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#D27");
657 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#D28");
658 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#D29");
659 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#D30");
661 flags = BindingFlags.Instance | BindingFlags.NonPublic |
662 BindingFlags.FlattenHierarchy;
663 props = type.GetProperties (flags);
665 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#E1");
666 Assert.IsTrue (ContainsProperty (props, "ProtInstBase"), "#E2");
667 Assert.IsTrue (ContainsProperty (props, "ProIntInstBase"), "#E3");
668 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#E4");
669 Assert.IsTrue (ContainsProperty (props, "IntInstBase"), "#E5");
670 Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#E6");
671 Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#E7");
672 Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#E8");
673 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#E9");
674 Assert.IsTrue (ContainsProperty (props, "IntInst"), "#E10");
675 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#E11");
676 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#E12");
677 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#E13");
678 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#E14");
679 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#E15");
680 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#E16");
681 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#E17");
682 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#E18");
683 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#E19");
684 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#E20");
685 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#E21");
686 Assert.IsTrue (ContainsProperty (props, "ProtInstBlue"), "#E22");
687 Assert.IsTrue (ContainsProperty (props, "ProIntInstBlue"), "#E23");
688 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#E24");
689 Assert.IsTrue (ContainsProperty (props, "IntInstBlue"), "#E25");
690 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#E26");
691 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#E27");
692 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#E28");
693 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#E29");
694 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#E30");
696 flags = BindingFlags.Instance | BindingFlags.Public |
697 BindingFlags.FlattenHierarchy;
698 props = type.GetProperties (flags);
700 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#F1");
701 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#F2");
702 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#F3");
703 Assert.IsTrue (ContainsProperty (props, "PubInstBase"), "#F4");
704 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#F5");
705 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#F6");
706 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#F7");
707 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#F8");
708 Assert.IsTrue (ContainsProperty (props, "PubInst"), "#F9");
709 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#F10");
710 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#F11");
711 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#F12");
712 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#F13");
713 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#F14");
714 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#F15");
715 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#F16");
716 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#F17");
717 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#F18");
718 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#F19");
719 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#F20");
720 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#F21");
721 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#F22");
722 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#F23");
723 Assert.IsTrue (ContainsProperty (props, "PubInstBlue"), "#F24");
724 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#F25");
725 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#F26");
726 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#F27");
727 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#F28");
728 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#F29");
729 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#F30");
731 flags = BindingFlags.Static | BindingFlags.Public |
732 BindingFlags.FlattenHierarchy;
733 props = type.GetProperties (flags);
735 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#G1");
736 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#G2");
737 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#G3");
738 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#G4");
739 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#G5");
740 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#G6");
741 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#G7");
742 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#G8");
743 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#G9");
744 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#G10");
745 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#G11");
746 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#G12");
747 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#G13");
748 Assert.IsTrue (ContainsProperty (props, "PubStatBase"), "#G14");
749 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#G15");
750 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#G16");
751 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#G17");
752 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#G18");
753 Assert.IsTrue (ContainsProperty (props, "PubStat"), "#G19");
754 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#G20");
755 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#G21");
756 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#G22");
757 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#G23");
758 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#G24");
759 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#G25");
760 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#G26");
761 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#G27");
762 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#G28");
763 Assert.IsTrue (ContainsProperty (props, "PubStatBlue"), "#G29");
764 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#G30");
766 flags = BindingFlags.Static | BindingFlags.NonPublic |
767 BindingFlags.FlattenHierarchy;
768 props = type.GetProperties (flags);
770 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#H1");
771 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#H2");
772 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#H3");
773 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#H4");
774 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#H5");
775 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#H6");
776 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#H7");
777 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#H8");
778 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#H9");
779 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#H10");
780 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#H11");
781 Assert.IsTrue (ContainsProperty (props, "ProtStatBase"), "#H12");
782 Assert.IsTrue (ContainsProperty (props, "ProIntStatBase"), "#H13");
783 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#H14");
784 Assert.IsTrue (ContainsProperty (props, "IntStatBase"), "#H15");
785 Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#H16");
786 Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#H17");
787 Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#H18");
788 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#H19");
789 Assert.IsTrue (ContainsProperty (props, "IntStat"), "#H20");
790 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#H21");
791 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#H22");
792 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#H23");
793 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#H24");
794 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#H25");
795 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#H26");
796 Assert.IsTrue (ContainsProperty (props, "ProtStatBlue"), "#H27");
797 Assert.IsTrue (ContainsProperty (props, "ProIntStatBlue"), "#H28");
798 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#H29");
799 Assert.IsTrue (ContainsProperty (props, "IntStatBlue"), "#H30");
801 flags = BindingFlags.Instance | BindingFlags.NonPublic |
802 BindingFlags.DeclaredOnly;
803 props = type.GetProperties (flags);
805 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#I1");
806 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#I2");
807 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#I3");
808 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#I4");
809 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#I5");
810 Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#I6");
811 Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#I7");
812 Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#I8");
813 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#I9");
814 Assert.IsTrue (ContainsProperty (props, "IntInst"), "#I10");
815 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#I11");
816 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#I12");
817 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#I13");
818 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#I14");
819 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#I15");
820 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#I16");
821 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#I17");
822 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#I18");
823 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#I19");
824 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#I20");
825 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#I21");
826 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#I22");
827 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#I23");
828 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#I24");
829 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#I25");
830 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#I26");
831 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#I27");
832 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#I28");
833 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#I29");
834 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#I30");
836 flags = BindingFlags.Instance | BindingFlags.Public |
837 BindingFlags.DeclaredOnly;
838 props = type.GetProperties (flags);
840 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#J1");
841 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#J2");
842 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#J3");
843 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#J4");
844 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#J5");
845 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#J6");
846 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#J7");
847 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#J8");
848 Assert.IsTrue (ContainsProperty (props, "PubInst"), "#J9");
849 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#J10");
850 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#J11");
851 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#J12");
852 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#J13");
853 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#J14");
854 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#J15");
855 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#J16");
856 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#J17");
857 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#J18");
858 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#J19");
859 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#J20");
860 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#J21");
861 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#J22");
862 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#J23");
863 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#J24");
864 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#J25");
865 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#J26");
866 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#J27");
867 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#J28");
868 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#J29");
869 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#J30");
871 flags = BindingFlags.Static | BindingFlags.Public |
872 BindingFlags.DeclaredOnly;
873 props = type.GetProperties (flags);
875 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#K1");
876 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#K2");
877 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#K3");
878 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#K4");
879 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#K5");
880 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#K6");
881 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#K7");
882 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#K8");
883 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#K9");
884 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#K10");
885 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#K11");
886 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#K12");
887 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#K13");
888 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#K14");
889 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#K15");
890 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#K16");
891 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#K17");
892 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#K18");
893 Assert.IsTrue (ContainsProperty (props, "PubStat"), "#K19");
894 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#K20");
895 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#K21");
896 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#K22");
897 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#K23");
898 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#K24");
899 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#K25");
900 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#K26");
901 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#K27");
902 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#K28");
903 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#K29");
904 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#K30");
906 flags = BindingFlags.Static | BindingFlags.NonPublic |
907 BindingFlags.DeclaredOnly;
908 props = type.GetProperties (flags);
910 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#L1");
911 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#L2");
912 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#L3");
913 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#L4");
914 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#L5");
915 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#L6");
916 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#L7");
917 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#L8");
918 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#L9");
919 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#L10");
920 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#L11");
921 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#L12");
922 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#L13");
923 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#L14");
924 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#L15");
925 Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#L16");
926 Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#L17");
927 Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#L18");
928 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#L19");
929 Assert.IsTrue (ContainsProperty (props, "IntStat"), "#L20");
930 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#L21");
931 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#L22");
932 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#L23");
933 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#L24");
934 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#L25");
935 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#L26");
936 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#L27");
937 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#L28");
938 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#L29");
939 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#L30");
941 flags = BindingFlags.Instance | BindingFlags.NonPublic |
943 props = type.GetProperties (flags);
945 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#M1");
946 Assert.IsTrue (ContainsProperty (props, "ProtInstBase"), "#M2");
947 Assert.IsTrue (ContainsProperty (props, "ProIntInstBase"), "#M3");
948 Assert.IsTrue (ContainsProperty (props, "PubInstBase"), "#M4");
949 Assert.IsTrue (ContainsProperty (props, "IntInstBase"), "#M5");
950 Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#M6");
951 Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#M7");
952 Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#M8");
953 Assert.IsTrue (ContainsProperty (props, "PubInst"), "#M9");
954 Assert.IsTrue (ContainsProperty (props, "IntInst"), "#M10");
955 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#M11");
956 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#M12");
957 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#M13");
958 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#M14");
959 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#M15");
960 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#M16");
961 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#M17");
962 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#M18");
963 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#M19");
964 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#M20");
965 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#M21");
966 Assert.IsTrue (ContainsProperty (props, "ProtInstBlue"), "#M22");
967 Assert.IsTrue (ContainsProperty (props, "ProIntInstBlue"), "#M23");
968 Assert.IsTrue (ContainsProperty (props, "PubInstBlue"), "#M24");
969 Assert.IsTrue (ContainsProperty (props, "IntInstBlue"), "#M25");
970 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#M26");
971 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#M27");
972 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#M28");
973 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#M29");
974 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#M30");
976 flags = BindingFlags.Static | BindingFlags.NonPublic |
978 props = type.GetProperties (flags);
980 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#N1");
981 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#N2");
982 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#N3");
983 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#N4");
984 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#N5");
985 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#N6");
986 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#N7");
987 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#N8");
988 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#N9");
989 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#N10");
990 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#N11");
991 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#N12");
992 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#N13");
993 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#N14");
994 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#N15");
995 Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#N16");
996 Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#N17");
997 Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#N18");
998 Assert.IsTrue (ContainsProperty (props, "PubStat"), "#N19");
999 Assert.IsTrue (ContainsProperty (props, "IntStat"), "#N20");
1000 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#N21");
1001 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#N22");
1002 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#N23");
1003 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#N24");
1004 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#N25");
1005 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#N26");
1006 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#N27");
1007 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#N28");
1008 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#N29");
1009 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#N30");
1012 [Test] // GetProperty (String)
1013 public void GetProperty1_Name_Null ()
1015 Type type = typeof (Bar);
1017 type.GetProperty ((string) null);
1019 } catch (ArgumentNullException ex) {
1020 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1021 Assert.IsNull (ex.InnerException, "#3");
1022 Assert.IsNotNull (ex.Message, "#4");
1023 Assert.IsNotNull (ex.ParamName, "#5");
1024 Assert.AreEqual ("name", ex.ParamName, "#6");
1028 [Test] // GetProperty (String, BindingFlags)
1029 public void GetProperty2 ()
1031 Type type = typeof (Bar);
1034 flags = BindingFlags.Instance | BindingFlags.NonPublic;
1036 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#A1");
1037 Assert.IsNotNull (type.GetProperty ("ProtInstBase", flags), "#A2");
1038 Assert.IsNotNull (type.GetProperty ("ProIntInstBase", flags), "#A3");
1039 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#A4");
1040 Assert.IsNotNull (type.GetProperty ("IntInstBase", flags), "#A5");
1041 Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#A6");
1042 Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#A7");
1043 Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#A8");
1044 Assert.IsNull (type.GetProperty ("PubInst", flags), "#A9");
1045 Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#A10");
1046 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#A11");
1047 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#A12");
1048 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#A13");
1049 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#A14");
1050 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#A15");
1051 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#A16");
1052 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#A17");
1053 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#A18");
1054 Assert.IsNull (type.GetProperty ("PubStat", flags), "#A19");
1055 Assert.IsNull (type.GetProperty ("IntStat", flags), "#A20");
1056 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#A21");
1057 Assert.IsNotNull (type.GetProperty ("ProtInstBlue", flags), "#A22");
1058 Assert.IsNotNull (type.GetProperty ("ProIntInstBlue", flags), "#A23");
1059 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#A24");
1060 Assert.IsNotNull (type.GetProperty ("IntInstBlue", flags), "#A25");
1061 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#A26");
1062 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#A27");
1063 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#A28");
1064 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#A29");
1065 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#A30");
1067 flags = BindingFlags.Instance | BindingFlags.Public;
1069 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#B1");
1070 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#B2");
1071 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#B3");
1072 Assert.IsNotNull (type.GetProperty ("PubInstBase", flags), "#B4");
1073 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#B5");
1074 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#B6");
1075 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#B7");
1076 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#B8");
1077 Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#B9");
1078 Assert.IsNull (type.GetProperty ("IntInst", flags), "#B10");
1079 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#B11");
1080 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#B12");
1081 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#B13");
1082 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#B14");
1083 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#B15");
1084 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#B16");
1085 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#B17");
1086 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#B18");
1087 Assert.IsNull (type.GetProperty ("PubStat", flags), "#B19");
1088 Assert.IsNull (type.GetProperty ("IntStat", flags), "#B20");
1089 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#B21");
1090 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#B22");
1091 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#B23");
1092 Assert.IsNotNull (type.GetProperty ("PubInstBlue", flags), "#B24");
1093 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#B25");
1094 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#B26");
1095 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#B27");
1096 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#B28");
1097 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#B29");
1098 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#B30");
1100 flags = BindingFlags.Static | BindingFlags.Public;
1102 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#C1");
1103 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#C2");
1104 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#C3");
1105 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#C4");
1106 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#C5");
1107 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#C6");
1108 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#C7");
1109 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#C8");
1110 Assert.IsNull (type.GetProperty ("PubInst", flags), "#C9");
1111 Assert.IsNull (type.GetProperty ("IntInst", flags), "#C10");
1112 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#C11");
1113 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#C12");
1114 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#C13");
1115 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#C14");
1116 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#C15");
1117 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#C16");
1118 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#C17");
1119 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#C18");
1120 Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#C19");
1121 Assert.IsNull (type.GetProperty ("IntStat", flags), "#C20");
1122 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#C21");
1123 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#C22");
1124 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#C23");
1125 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#C24");
1126 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#C25");
1127 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#C26");
1128 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#C27");
1129 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#C28");
1130 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#C29");
1131 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#C30");
1133 flags = BindingFlags.Static | BindingFlags.NonPublic;
1135 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#D1");
1136 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#D2");
1137 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#D3");
1138 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#D4");
1139 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#D5");
1140 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#D6");
1141 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#D7");
1142 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#D8");
1143 Assert.IsNull (type.GetProperty ("PubInst", flags), "#D9");
1144 Assert.IsNull (type.GetProperty ("IntInst", flags), "#D10");
1145 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#D11");
1146 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#D12");
1147 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#D13");
1148 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#D14");
1149 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#D15");
1150 Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#D16");
1151 Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#D17");
1152 Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#D18");
1153 Assert.IsNull (type.GetProperty ("PubStat", flags), "#D19");
1154 Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#D20");
1155 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#D21");
1156 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#D22");
1157 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#D23");
1158 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#D24");
1159 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#D25");
1160 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#D26");
1161 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#D27");
1162 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#D28");
1163 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#D29");
1164 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#D30");
1166 flags = BindingFlags.Instance | BindingFlags.NonPublic |
1167 BindingFlags.FlattenHierarchy;
1169 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#E1");
1170 Assert.IsNotNull (type.GetProperty ("ProtInstBase", flags), "#E2");
1171 Assert.IsNotNull (type.GetProperty ("ProIntInstBase", flags), "#E3");
1172 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#E4");
1173 Assert.IsNotNull (type.GetProperty ("IntInstBase", flags), "#E5");
1174 Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#E6");
1175 Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#E7");
1176 Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#E8");
1177 Assert.IsNull (type.GetProperty ("PubInst", flags), "#E9");
1178 Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#E10");
1179 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#E11");
1180 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#E12");
1181 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#E13");
1182 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#E14");
1183 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#E15");
1184 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#E16");
1185 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#E17");
1186 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#E18");
1187 Assert.IsNull (type.GetProperty ("PubStat", flags), "#E19");
1188 Assert.IsNull (type.GetProperty ("IntStat", flags), "#E20");
1189 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#E21");
1190 Assert.IsNotNull (type.GetProperty ("ProtInstBlue", flags), "#E22");
1191 Assert.IsNotNull (type.GetProperty ("ProIntInstBlue", flags), "#E23");
1192 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#E24");
1193 Assert.IsNotNull (type.GetProperty ("IntInstBlue", flags), "#E25");
1194 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#E26");
1195 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#E27");
1196 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#E28");
1197 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#E29");
1198 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#E30");
1200 flags = BindingFlags.Instance | BindingFlags.Public |
1201 BindingFlags.FlattenHierarchy;
1203 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#F1");
1204 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#F2");
1205 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#F3");
1206 Assert.IsNotNull (type.GetProperty ("PubInstBase", flags), "#F4");
1207 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#F5");
1208 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#F6");
1209 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#F7");
1210 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#F8");
1211 Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#F9");
1212 Assert.IsNull (type.GetProperty ("IntInst", flags), "#F10");
1213 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#F11");
1214 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#F12");
1215 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#F13");
1216 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#F14");
1217 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#F15");
1218 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#F16");
1219 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#F17");
1220 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#F18");
1221 Assert.IsNull (type.GetProperty ("PubStat", flags), "#F19");
1222 Assert.IsNull (type.GetProperty ("IntStat", flags), "#F20");
1223 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#F21");
1224 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#F22");
1225 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#F23");
1226 Assert.IsNotNull (type.GetProperty ("PubInstBlue", flags), "#F24");
1227 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#F25");
1228 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#F26");
1229 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#F27");
1230 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#F28");
1231 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#F29");
1232 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#F30");
1234 flags = BindingFlags.Static | BindingFlags.Public |
1235 BindingFlags.FlattenHierarchy;
1237 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#G1");
1238 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#G2");
1239 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#G3");
1240 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#G4");
1241 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#G5");
1242 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#G6");
1243 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#G7");
1244 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#G8");
1245 Assert.IsNull (type.GetProperty ("PubInst", flags), "#G9");
1246 Assert.IsNull (type.GetProperty ("IntInst", flags), "#G10");
1247 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#G11");
1248 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#G12");
1249 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#G13");
1250 Assert.IsNotNull (type.GetProperty ("PubStatBase", flags), "#G14");
1251 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#G15");
1252 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#G16");
1253 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#G17");
1254 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#G18");
1255 Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#G19");
1256 Assert.IsNull (type.GetProperty ("IntStat", flags), "#G20");
1257 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#G21");
1258 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#G22");
1259 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#G23");
1260 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#G24");
1261 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#G25");
1262 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#G26");
1263 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#G27");
1264 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#G28");
1265 Assert.IsNotNull (type.GetProperty ("PubStatBlue", flags), "#G29");
1266 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#G30");
1268 flags = BindingFlags.Static | BindingFlags.NonPublic |
1269 BindingFlags.FlattenHierarchy;
1271 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#H1");
1272 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#H2");
1273 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#H3");
1274 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#H4");
1275 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#H5");
1276 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#H6");
1277 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#H7");
1278 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#H8");
1279 Assert.IsNull (type.GetProperty ("PubInst", flags), "#H9");
1280 Assert.IsNull (type.GetProperty ("IntInst", flags), "#H10");
1281 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#H11");
1282 Assert.IsNotNull (type.GetProperty ("ProtStatBase", flags), "#H12");
1283 Assert.IsNotNull (type.GetProperty ("ProIntStatBase", flags), "#H13");
1284 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#H14");
1285 Assert.IsNotNull (type.GetProperty ("IntStatBase", flags), "#H15");
1286 Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#H16");
1287 Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#H17");
1288 Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#H18");
1289 Assert.IsNull (type.GetProperty ("PubStat", flags), "#H19");
1290 Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#H20");
1291 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#H21");
1292 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#H22");
1293 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#H23");
1294 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#H24");
1295 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#H25");
1296 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#H26");
1297 Assert.IsNotNull (type.GetProperty ("ProtStatBlue", flags), "#H27");
1298 Assert.IsNotNull (type.GetProperty ("ProIntStatBlue", flags), "#H28");
1299 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#H29");
1300 Assert.IsNotNull (type.GetProperty ("IntStatBlue", flags), "#H30");
1302 flags = BindingFlags.Instance | BindingFlags.NonPublic |
1303 BindingFlags.DeclaredOnly;
1305 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#I1");
1306 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#I2");
1307 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#I3");
1308 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#I4");
1309 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#I5");
1310 Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#I6");
1311 Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#I7");
1312 Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#I8");
1313 Assert.IsNull (type.GetProperty ("PubInst", flags), "#I9");
1314 Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#I10");
1315 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#I11");
1316 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#I12");
1317 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#I13");
1318 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#I14");
1319 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#I15");
1320 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#I16");
1321 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#I17");
1322 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#I18");
1323 Assert.IsNull (type.GetProperty ("PubStat", flags), "#I19");
1324 Assert.IsNull (type.GetProperty ("IntStat", flags), "#I20");
1325 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#I21");
1326 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#I22");
1327 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#I23");
1328 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#I24");
1329 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#I25");
1330 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#I26");
1331 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#I27");
1332 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#I28");
1333 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#I29");
1334 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#I30");
1336 flags = BindingFlags.Instance | BindingFlags.Public |
1337 BindingFlags.DeclaredOnly;
1339 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#J1");
1340 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#J2");
1341 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#J3");
1342 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#J4");
1343 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#J5");
1344 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#J6");
1345 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#J7");
1346 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#J8");
1347 Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#J9");
1348 Assert.IsNull (type.GetProperty ("IntInst", flags), "#J10");
1349 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#J11");
1350 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#J12");
1351 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#J13");
1352 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#J14");
1353 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#J15");
1354 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#J16");
1355 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#J17");
1356 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#J18");
1357 Assert.IsNull (type.GetProperty ("PubStat", flags), "#J19");
1358 Assert.IsNull (type.GetProperty ("IntStat", flags), "#J20");
1359 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#J21");
1360 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#J22");
1361 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#J23");
1362 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#J24");
1363 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#J25");
1364 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#J26");
1365 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#J27");
1366 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#J28");
1367 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#J29");
1368 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#J30");
1370 flags = BindingFlags.Static | BindingFlags.Public |
1371 BindingFlags.DeclaredOnly;
1373 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#K1");
1374 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#K2");
1375 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#K3");
1376 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#K4");
1377 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#K5");
1378 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#K6");
1379 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#K7");
1380 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#K8");
1381 Assert.IsNull (type.GetProperty ("PubInst", flags), "#K9");
1382 Assert.IsNull (type.GetProperty ("IntInst", flags), "#K10");
1383 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#K11");
1384 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#K12");
1385 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#K13");
1386 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#K14");
1387 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#K15");
1388 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#K16");
1389 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#K17");
1390 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#K18");
1391 Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#K19");
1392 Assert.IsNull (type.GetProperty ("IntStat", flags), "#K20");
1393 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#K21");
1394 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#K22");
1395 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#K23");
1396 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#K24");
1397 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#K25");
1398 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#K26");
1399 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#K27");
1400 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#K28");
1401 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#K29");
1402 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#K30");
1404 flags = BindingFlags.Static | BindingFlags.NonPublic |
1405 BindingFlags.DeclaredOnly;
1407 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#L1");
1408 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#L2");
1409 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#L3");
1410 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#L4");
1411 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#L5");
1412 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#L6");
1413 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#L7");
1414 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#L8");
1415 Assert.IsNull (type.GetProperty ("PubInst", flags), "#L9");
1416 Assert.IsNull (type.GetProperty ("IntInst", flags), "#L10");
1417 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#L11");
1418 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#L12");
1419 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#L13");
1420 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#L14");
1421 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#L15");
1422 Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#L16");
1423 Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#L17");
1424 Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#L18");
1425 Assert.IsNull (type.GetProperty ("PubStat", flags), "#L19");
1426 Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#L20");
1427 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#L21");
1428 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#L22");
1429 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#L23");
1430 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#L24");
1431 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#L25");
1432 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#L26");
1433 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#L27");
1434 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#L28");
1435 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#L29");
1436 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#L30");
1438 flags = BindingFlags.Instance | BindingFlags.NonPublic |
1439 BindingFlags.Public;
1441 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#M1");
1442 Assert.IsNotNull (type.GetProperty ("ProtInstBase", flags), "#M2");
1443 Assert.IsNotNull (type.GetProperty ("ProIntInstBase", flags), "#M3");
1444 Assert.IsNotNull (type.GetProperty ("PubInstBase", flags), "#M4");
1445 Assert.IsNotNull (type.GetProperty ("IntInstBase", flags), "#M5");
1446 Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#M6");
1447 Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#M7");
1448 Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#M8");
1449 Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#M9");
1450 Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#M10");
1451 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#M11");
1452 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#M12");
1453 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#M13");
1454 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#M14");
1455 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#M15");
1456 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#M16");
1457 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#M17");
1458 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#M18");
1459 Assert.IsNull (type.GetProperty ("PubStat", flags), "#M19");
1460 Assert.IsNull (type.GetProperty ("IntStat", flags), "#M20");
1461 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#M21");
1462 Assert.IsNotNull (type.GetProperty ("ProtInstBlue", flags), "#M22");
1463 Assert.IsNotNull (type.GetProperty ("ProIntInstBlue", flags), "#M23");
1464 Assert.IsNotNull (type.GetProperty ("PubInstBlue", flags), "#M24");
1465 Assert.IsNotNull (type.GetProperty ("IntInstBlue", flags), "#M25");
1466 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#M26");
1467 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#M27");
1468 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#M28");
1469 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#M29");
1470 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#M30");
1472 flags = BindingFlags.Static | BindingFlags.NonPublic |
1473 BindingFlags.Public;
1475 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#N1");
1476 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#N2");
1477 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#N3");
1478 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#N4");
1479 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#N5");
1480 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#N6");
1481 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#N7");
1482 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#N8");
1483 Assert.IsNull (type.GetProperty ("PubInst", flags), "#N9");
1484 Assert.IsNull (type.GetProperty ("IntInst", flags), "#N10");
1485 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#N11");
1486 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#N12");
1487 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#N13");
1488 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#N14");
1489 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#N15");
1490 Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#N16");
1491 Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#N17");
1492 Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#N18");
1493 Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#N19");
1494 Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#N20");
1495 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#N21");
1496 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#N22");
1497 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#N23");
1498 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#N24");
1499 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#N25");
1500 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#N26");
1501 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#N27");
1502 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#N28");
1503 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#N29");
1504 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#N30");
1507 [Test] // GetProperty (String, BindingFlags)
1508 public void GetProperty2_Name_Null ()
1510 Type type = typeof (Bar);
1512 type.GetProperty ((string) null);
1514 } catch (ArgumentNullException ex) {
1515 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1516 Assert.IsNull (ex.InnerException, "#3");
1517 Assert.IsNotNull (ex.Message, "#4");
1518 Assert.IsNotNull (ex.ParamName, "#5");
1519 Assert.AreEqual ("name", ex.ParamName, "#6");
1523 [Test] // GetProperty (String, Type)
1524 public void GetProperty3_Name_Null ()
1526 Type type = typeof (Bar);
1528 type.GetProperty ((string) null, typeof (int));
1530 } catch (ArgumentNullException ex) {
1531 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1532 Assert.IsNull (ex.InnerException, "#3");
1533 Assert.IsNotNull (ex.Message, "#4");
1534 Assert.IsNotNull (ex.ParamName, "#5");
1535 Assert.AreEqual ("name", ex.ParamName, "#6");
1539 [Test] // GetProperty (String, Type [])
1540 public void GetProperty4_Name_Null ()
1542 Type type = typeof (Bar);
1544 type.GetProperty ((string) null, Type.EmptyTypes);
1546 } catch (ArgumentNullException ex) {
1547 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1548 Assert.IsNull (ex.InnerException, "#3");
1549 Assert.IsNotNull (ex.Message, "#4");
1550 Assert.IsNotNull (ex.ParamName, "#5");
1551 Assert.AreEqual ("name", ex.ParamName, "#6");
1555 [Test] // GetProperty (String, Type, Type [])
1556 public void GetProperty5_Name_Null ()
1558 Type type = typeof (Bar);
1560 type.GetProperty ((string) null, typeof (int),
1563 } catch (ArgumentNullException ex) {
1564 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1565 Assert.IsNull (ex.InnerException, "#3");
1566 Assert.IsNotNull (ex.Message, "#4");
1567 Assert.IsNotNull (ex.ParamName, "#5");
1568 Assert.AreEqual ("name", ex.ParamName, "#6");
1572 [Test] // GetProperty (String, Type, Type [], ParameterModifier [])
1573 public void GetProperty6_Name_Null ()
1575 Type type = typeof (Bar);
1577 type.GetProperty ((string) null, typeof (int),
1578 Type.EmptyTypes, null);
1580 } catch (ArgumentNullException ex) {
1581 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1582 Assert.IsNull (ex.InnerException, "#3");
1583 Assert.IsNotNull (ex.Message, "#4");
1584 Assert.IsNotNull (ex.ParamName, "#5");
1585 Assert.AreEqual ("name", ex.ParamName, "#6");
1589 [Test] // GetProperty (String, BindingFlags, Binder, Type, Type [], ParameterModifier [])
1590 public void GetProperty7_Name_Null ()
1592 Type type = typeof (Bar);
1594 type.GetProperty ((string) null, BindingFlags.Public,
1595 null, typeof (int), Type.EmptyTypes, null);
1597 } catch (ArgumentNullException ex) {
1598 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1599 Assert.IsNull (ex.InnerException, "#3");
1600 Assert.IsNotNull (ex.Message, "#4");
1601 Assert.IsNotNull (ex.ParamName, "#5");
1602 Assert.AreEqual ("name", ex.ParamName, "#6");
1607 public void GetProperty8_PropertyType ()
1609 Type type = typeof (Bar);
1610 Assert.IsNull (type.GetProperty ("PubInst", BindingFlags.Public | BindingFlags.Instance,
1611 null, typeof (int), Type.EmptyTypes, null), "#1");
1612 Assert.IsNotNull (type.GetProperty ("PubInst", BindingFlags.Public | BindingFlags.Instance, null,
1613 typeof (long), new Type[0], null), "#2");
1617 public void GetProperty9_Indexers ()
1620 var bindingFlags = BindingFlags.Public | BindingFlags.Instance;
1622 Type type1 = typeof (List<byte>);
1623 var p1 = type1.GetProperty ("Item", bindingFlags, null, typeof (byte), new Type[] { typeof (int) }, null);
1624 Assert.IsNotNull (p1, "#1");
1626 Type type2 = typeof (List<string>);
1627 var p2 = type2.GetProperty ("Item", bindingFlags, null, typeof (string), new Type[] { typeof (int) }, null);
1628 Assert.IsNotNull (p2, "#2");
1630 Type type3 = typeof (List<Type>);
1631 // result type not convertible, make sure we fail.
1632 var p3 = type3.GetProperty ("Item", bindingFlags, null, typeof (string) /*!*/,
1633 new Type[] { typeof (int) }, null);
1634 Assert.IsNull (p3, "#3");
1637 [StructLayout(LayoutKind.Explicit, Pack = 4, Size = 64)]
1642 [StructLayout(LayoutKind.Explicit, CharSet=CharSet.Unicode)]
1648 public void StructLayoutAttribute ()
1650 StructLayoutAttribute attr1 = typeof (TypeTest).StructLayoutAttribute;
1651 Assert.AreEqual (LayoutKind.Auto, attr1.Value);
1653 StructLayoutAttribute attr2 = typeof (Class1).StructLayoutAttribute;
1654 Assert.AreEqual (LayoutKind.Explicit, attr2.Value);
1655 Assert.AreEqual (4, attr2.Pack);
1656 Assert.AreEqual (64, attr2.Size);
1658 StructLayoutAttribute attr3 = typeof (Class2).StructLayoutAttribute;
1659 Assert.AreEqual (LayoutKind.Explicit, attr3.Value);
1660 Assert.AreEqual (CharSet.Unicode, attr3.CharSet);
1664 public void Namespace ()
1666 Assert.AreEqual (null, typeof (NoNamespaceClass).Namespace);
1670 public void GenericParameterNamespace ()
1672 var t = typeof (Foo<>).GetGenericArguments () [0];
1674 Assert.AreEqual ("T", t.Name);
1675 Assert.AreEqual ("MonoTests.System", t.Namespace);
1677 var s = typeof (Gazonk).GetMethod ("Bang").GetGenericArguments () [0];
1679 Assert.AreEqual ("S", s.Name);
1680 Assert.AreEqual ("MonoTests.System", s.Namespace);
1683 public static void Reflected (ref int a)
1690 Assert.AreEqual ("Int32&", typeof (TypeTest).GetMethod ("Reflected").GetParameters () [0].ParameterType.Name);
1691 Assert.AreEqual ("String[*]", Array.CreateInstance (typeof(string), new int[] { 1 }, new int[] { 1 }).GetType ().Name);
1695 public void GetInterfaces ()
1697 Type[] t = typeof (Duper).GetInterfaces ();
1698 Assert.AreEqual (1, t.Length);
1699 Assert.AreEqual (typeof (ICloneable), t[0]);
1701 Type[] t2 = typeof (IFace3).GetInterfaces ();
1702 Assert.AreEqual (2, t2.Length);
1706 public void GetInterfacesGenericVarWithConstraints ()
1708 var a = typeof (TypeTest).GetMethod ("GenericMethod");
1710 var p = a.GetParameters ();
1711 var i = p[0].ParameterType.GetElementType ();
1715 public static void GenericMethod<T, T2> (T[] arr) where T: IComparable<T> {
1721 public void GetFieldIgnoreCase ()
1723 Assert.IsNotNull (typeof (TypeTest).GetField ("afield", BindingFlags.Instance|BindingFlags.Public|BindingFlags.IgnoreCase));
1736 public void GetPropertyAccessorModifiers ()
1738 Assert.IsNotNull (typeof (TypeTest).GetProperty ("Count", BindingFlags.Instance | BindingFlags.Public));
1739 Assert.IsNull (typeof (TypeTest).GetProperty ("Count", BindingFlags.Instance | BindingFlags.NonPublic));
1743 public void IsAbstract ()
1745 Assert.IsFalse (typeof (string).IsAbstract, "#1");
1746 Assert.IsTrue (typeof (ICloneable).IsAbstract, "#2");
1747 Assert.IsTrue (typeof (ValueType).IsAbstract, "#3");
1748 Assert.IsTrue (typeof (Enum).IsAbstract, "#4");
1749 Assert.IsFalse (typeof (TimeSpan).IsAbstract, "#5");
1750 Assert.IsTrue (typeof (TextReader).IsAbstract, "#6");
1753 // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=286308
1754 Type [] typeArgs = typeof (List<>).GetGenericArguments ();
1755 Assert.IsFalse (typeArgs [0].IsAbstract, "#7");
1759 public void IsCOMObject ()
1761 Type type = typeof (string);
1762 Assert.IsFalse (type.IsCOMObject, "#1");
1764 TypeBuilder tb = module.DefineType (genTypeName ());
1765 type = tb.CreateType ();
1766 Assert.IsFalse (type.IsCOMObject, "#2");
1770 public void IsImport ()
1772 Type type = typeof (string);
1773 Assert.IsFalse (type.IsImport, "#1");
1775 TypeBuilder tb = module.DefineType (genTypeName ());
1776 type = tb.CreateType ();
1777 Assert.IsFalse (type.IsImport, "#2");
1779 tb = module.DefineType (genTypeName (), TypeAttributes.Import |
1780 TypeAttributes.Interface | TypeAttributes.Abstract);
1781 type = tb.CreateType ();
1782 Assert.IsTrue (type.IsImport, "#3");
1786 public void IsInterface ()
1788 Assert.IsFalse (typeof (string).IsInterface, "#1");
1789 Assert.IsTrue (typeof (ICloneable).IsInterface, "#2");
1793 public void IsPrimitive () {
1794 Assert.IsTrue (typeof (IntPtr).IsPrimitive, "#1");
1795 Assert.IsTrue (typeof (int).IsPrimitive, "#2");
1796 Assert.IsFalse (typeof (string).IsPrimitive, "#2");
1800 public void IsValueType ()
1802 Assert.IsTrue (typeof (int).IsValueType, "#1");
1803 Assert.IsFalse (typeof (Enum).IsValueType, "#2");
1804 Assert.IsFalse (typeof (ValueType).IsValueType, "#3");
1805 Assert.IsTrue (typeof (AttributeTargets).IsValueType, "#4");
1806 Assert.IsFalse (typeof (string).IsValueType, "#5");
1807 Assert.IsTrue (typeof (TimeSpan).IsValueType, "#6");
1811 public void IsVisible ()
1813 Assert.IsTrue (typeof (int).IsVisible, "#1");
1814 Assert.IsTrue (typeof (Nested).IsVisible, "#2");
1818 public void GetTypeNonVectorArray ()
1820 Type t = Type.GetType ("System.String[*]");
1821 Assert.AreEqual ("System.String[*]", t.ToString ());
1826 public void TypeFromCLSID ()
1828 Guid CLSID_ShellDesktop = new Guid("00021400-0000-0000-c000-000000000046");
1829 Guid CLSID_Bogus = new Guid("1ea9d7a9-f7ab-443b-b486-30d285b21f1b");
1831 Type t1 = Type.GetTypeFromCLSID (CLSID_ShellDesktop);
1833 Type t2 = Type.GetTypeFromCLSID (CLSID_Bogus);
1835 Assert.AreEqual (t1.FullName, "System.__ComObject");
1837 if (Environment.OSVersion.Platform == PlatformID.Win32Windows ||
1838 Environment.OSVersion.Platform == PlatformID.Win32NT)
1839 Activator.CreateInstance(t1);
1841 Assert.AreEqual (t2.FullName, "System.__ComObject");
1843 Assert.AreNotEqual (t1, t2);
1847 [Category("NotWorking")] // Mono throws TargetInvokationException
1848 [ExpectedException("System.Runtime.InteropServices.COMException")]
1849 public void TypeFromCLSIDBogus ()
1851 Guid CLSID_Bogus = new Guid("1ea9d7a9-f7ab-443b-b486-30d285b21f1b");
1852 Type t = Type.GetTypeFromCLSID (CLSID_Bogus);
1853 if (Environment.OSVersion.Platform == PlatformID.Win32Windows ||
1854 Environment.OSVersion.Platform == PlatformID.Win32NT)
1855 Activator.CreateInstance(t);
1857 throw new COMException ();
1861 public void ExerciseFilterName ()
1863 MemberInfo[] mi = typeof(Base).FindMembers(
1865 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1866 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1867 Type.FilterName, "*");
1868 Assert.AreEqual (4, mi.Length);
1869 mi = typeof(Base).FindMembers(
1871 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1872 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1873 Type.FilterName, "Test*");
1874 Assert.AreEqual (2, mi.Length);
1875 mi = typeof(Base).FindMembers(
1877 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1878 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1879 Type.FilterName, "TestVoid");
1880 Assert.AreEqual (1, mi.Length);
1881 mi = typeof(Base).FindMembers(
1883 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1884 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1885 Type.FilterName, "NonExistingMethod");
1886 Assert.AreEqual (0, mi.Length);
1890 public void ExerciseFilterNameIgnoreCase ()
1892 MemberInfo[] mi = typeof(Base).FindMembers(
1894 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1895 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1896 Type.FilterNameIgnoreCase, "*");
1897 Assert.AreEqual (4, mi.Length);
1898 mi = typeof(Base).FindMembers(
1900 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1901 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1902 Type.FilterNameIgnoreCase, "test*");
1903 Assert.AreEqual (2, mi.Length);
1904 mi = typeof(Base).FindMembers(
1906 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1907 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1908 Type.FilterNameIgnoreCase, "TESTVOID");
1909 Assert.AreEqual (1, mi.Length);
1910 mi = typeof(Base).FindMembers(
1912 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1913 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1914 Type.FilterNameIgnoreCase, "NonExistingMethod");
1915 Assert.AreEqual (0, mi.Length);
1919 [ExpectedException (typeof (InvalidFilterCriteriaException))]
1920 public void FilterAttribute_Invalid ()
1922 Type.FilterAttribute (MethodBase.GetCurrentMethod (), (byte) 1);
1926 public void GenericParameterMemberType ()
1928 var t = typeof (Foo<>).GetGenericArguments () [0];
1929 Assert.IsNotNull (t);
1931 Assert.AreEqual (MemberTypes.TypeInfo, t.MemberType);
1937 public int property {
1940 public ByRef0 (int i) {}
1941 public void f (int i) {}
1945 public void ByrefTypes ()
1947 Type t = Type.GetType ("MonoTests.System.TypeTest+ByRef0&");
1948 Assert.IsNotNull (t);
1949 Assert.IsTrue (t.IsByRef);
1950 Assert.AreEqual (0, t.GetMethods (BindingFlags.Public | BindingFlags.Instance).Length);
1951 Assert.AreEqual (0, t.GetConstructors (BindingFlags.Public | BindingFlags.Instance).Length);
1952 Assert.AreEqual (0, t.GetEvents (BindingFlags.Public | BindingFlags.Instance).Length);
1953 Assert.AreEqual (0, t.GetProperties (BindingFlags.Public | BindingFlags.Instance).Length);
1955 Assert.IsNull (t.GetMethod ("f"));
1956 Assert.IsNull (t.GetField ("field"));
1957 Assert.IsNull (t.GetProperty ("property"));
1961 public void TestAssemblyQualifiedName ()
1963 Type t = Type.GetType ("System.Byte[]&");
1964 Assert.IsTrue (t.AssemblyQualifiedName.StartsWith ("System.Byte[]&"));
1966 t = Type.GetType ("System.Byte*&");
1967 Assert.IsTrue (t.AssemblyQualifiedName.StartsWith ("System.Byte*&"));
1969 t = Type.GetType ("System.Byte&");
1970 Assert.IsTrue (t.AssemblyQualifiedName.StartsWith ("System.Byte&"));
1975 #pragma warning disable 169
1977 #pragma warning restore 169
1981 public void CreateValueTypeNoCtor ()
1983 typeof(B).InvokeMember ("", BindingFlags.CreateInstance, null, null, null);
1987 [ExpectedException (typeof (MissingMethodException))]
1988 public void CreateValueTypeNoCtorArgs ()
1990 typeof(B).InvokeMember ("", BindingFlags.CreateInstance, null, null, new object [] { 1 });
1994 [ExpectedException (typeof (MissingMethodException))]
1995 public void InvokeGetPropertyMissing ()
1997 typeof(B).InvokeMember ("", BindingFlags.GetProperty, null, null, new object [] { 1 });
2001 [ExpectedException (typeof (MissingMethodException))]
2002 public void InvokeSetPropertyMissing ()
2004 typeof(B).InvokeMember ("", BindingFlags.SetProperty, null, null, new object [] { 1 });
2007 internal static string bug336841 (string param1, params string [] param2)
2009 StringBuilder sb = new StringBuilder ();
2013 for (int i = 0; i < param2.Length; i++) {
2016 sb.Append (param2 [i]);
2018 return sb.ToString ();
2021 internal static string bug336841 (string param1)
2023 return "#B:" + param1;
2026 internal static string bug336841 (params string [] param1)
2028 StringBuilder sb = new StringBuilder ();
2030 for (int i = 0; i < param1.Length; i++) {
2033 sb.Append (param1 [i]);
2035 return sb.ToString ();
2039 public void InvokeMember_GetSetField ()
2041 typeof (X).InvokeMember ("Value", BindingFlags.Public |
2042 BindingFlags.Static | BindingFlags.FlattenHierarchy |
2043 BindingFlags.SetField, null, null, new object [] { 5 });
2045 Assert.AreEqual (5, X.Value, "#A1");
2046 Assert.AreEqual (5, typeof (X).InvokeMember ("Value",
2047 BindingFlags.Public | BindingFlags.Static |
2048 BindingFlags.FlattenHierarchy | BindingFlags.GetField,
2049 null, null, new object [0]), "#A2");
2050 Assert.AreEqual (5, Y.Value, "#A3");
2051 Assert.AreEqual (5, typeof (Y).InvokeMember ("Value",
2052 BindingFlags.Public | BindingFlags.Static |
2053 BindingFlags.FlattenHierarchy | BindingFlags.GetField,
2054 null, null, new object [0]), "#A4");
2057 typeof (X).InvokeMember ("Value", BindingFlags.Public |
2058 BindingFlags.Static | BindingFlags.FlattenHierarchy |
2059 BindingFlags.GetField | BindingFlags.SetField,
2060 null, null, new object [] { 5 });
2061 Assert.Fail ("#B1");
2062 } catch (ArgumentException ex) {
2063 // Cannot specify both Get and Set on a field
2064 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
2065 Assert.IsNull (ex.InnerException, "#B3");
2066 Assert.IsNotNull (ex.Message, "#B4");
2067 Assert.IsNotNull (ex.ParamName, "#B5");
2068 Assert.AreEqual ("bindingFlags", ex.ParamName, "#B6");
2073 public void InvokeMember_GetSetProperty ()
2076 typeof (ArrayList).InvokeMember ("Item",
2077 BindingFlags.GetProperty | BindingFlags.SetProperty |
2078 BindingFlags.Instance | BindingFlags.Public,
2079 null, new ArrayList (), new object [] { 0, "bar" });
2081 } catch (ArgumentException ex) {
2082 // Cannot specify both Get and Set on a property
2083 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
2084 Assert.IsNull (ex.InnerException, "#3");
2085 Assert.IsNotNull (ex.Message, "#4");
2086 Assert.IsNotNull (ex.ParamName, "#5");
2087 Assert.AreEqual ("bindingFlags", ex.ParamName, "#6");
2093 public void InvokeMember_InvokeMethod_Set ()
2096 typeof (ArrayList).InvokeMember ("ToString",
2097 BindingFlags.InvokeMethod | BindingFlags.SetField |
2098 BindingFlags.Instance | BindingFlags.Public,
2099 null, new ArrayList (), new object [0]);
2100 Assert.Fail ("#A1");
2101 } catch (ArgumentException ex) {
2102 // Cannot specify Set on a field and Invoke on a method
2103 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
2104 Assert.IsNull (ex.InnerException, "#A3");
2105 Assert.IsNotNull (ex.Message, "#A4");
2106 Assert.IsNotNull (ex.ParamName, "#A5");
2107 Assert.AreEqual ("bindingFlags", ex.ParamName, "#A6");
2111 typeof (ArrayList).InvokeMember ("ToString",
2112 BindingFlags.InvokeMethod | BindingFlags.SetProperty |
2113 BindingFlags.Instance | BindingFlags.Public,
2114 null, new ArrayList (), new object [0]);
2115 Assert.Fail ("#B1");
2116 } catch (ArgumentException ex) {
2117 // Cannot specify Set on a property and Invoke on a method
2118 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
2119 Assert.IsNull (ex.InnerException, "#B3");
2120 Assert.IsNotNull (ex.Message, "#B4");
2121 Assert.IsNotNull (ex.ParamName, "#B5");
2122 Assert.AreEqual ("bindingFlags", ex.ParamName, "#B6");
2127 public void InvokeMember_MatchPrimitiveTypeWithInterface ()
2129 object [] invokeargs = { 1 };
2130 typeof (Z).InvokeMember ("", BindingFlags.DeclaredOnly |
2131 BindingFlags.Public | BindingFlags.NonPublic |
2132 BindingFlags.Instance | BindingFlags.CreateInstance,
2133 null, null, invokeargs);
2137 public void InvokeMember_Name_Null ()
2140 typeof (X).InvokeMember ((string) null,
2141 BindingFlags.Public | BindingFlags.Static |
2142 BindingFlags.FlattenHierarchy | BindingFlags.SetField,
2143 null, null, new object [] { 5 });
2145 } catch (ArgumentNullException ex) {
2146 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2147 Assert.IsNull (ex.InnerException, "#3");
2148 Assert.IsNotNull (ex.Message, "#4");
2149 Assert.IsNotNull (ex.ParamName, "#5");
2150 Assert.AreEqual ("name", ex.ParamName, "#6");
2155 public void InvokeMember_NoOperation ()
2158 typeof (TypeTest).InvokeMember ("Run", BindingFlags.Public |
2159 BindingFlags.Static, null, null, new object [0]);
2161 } catch (ArgumentException ex) {
2162 // Must specify binding flags describing the
2163 // invoke operation required
2164 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
2165 Assert.IsNull (ex.InnerException, "#3");
2166 Assert.IsNotNull (ex.Message, "#4");
2167 Assert.IsNotNull (ex.ParamName, "#5");
2168 Assert.AreEqual ("bindingFlags", ex.ParamName, "#6");
2172 [Test] // bug #321735
2173 public void InvokeMember_SetFieldProperty ()
2175 ArrayList list = new ArrayList ();
2177 list.GetType ().InvokeMember ("Item",
2178 BindingFlags.SetField | BindingFlags.SetProperty |
2179 BindingFlags.Instance | BindingFlags.Public,
2180 null, list, new object [] { 0, "bar" });
2181 Assert.AreEqual ("bar", list [0]);
2185 public void InvokeMember_SetField_ProvidedArgs ()
2188 typeof (X).InvokeMember ("Value", BindingFlags.Public |
2189 BindingFlags.Static | BindingFlags.SetField,
2190 null, null, new object [0]);
2191 Assert.Fail ("#A1");
2192 } catch (ArgumentException ex) {
2193 // Only the field value can be specified to set
2195 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
2196 Assert.IsNull (ex.InnerException, "#A3");
2197 Assert.IsNotNull (ex.Message, "#A4");
2198 Assert.IsNotNull (ex.ParamName, "#A5");
2199 Assert.AreEqual ("bindingFlags", ex.ParamName, "#6");
2203 typeof (X).InvokeMember ("Value", BindingFlags.Public |
2204 BindingFlags.Static | BindingFlags.SetField,
2206 Assert.Fail ("#B1");
2207 } catch (ArgumentNullException ex) {
2208 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
2209 Assert.IsNull (ex.InnerException, "#B3");
2210 Assert.IsNotNull (ex.Message, "#B4");
2211 Assert.IsNotNull (ex.ParamName, "#B5");
2212 Assert.AreEqual ("providedArgs", ex.ParamName, "#B6");
2216 [Test] // bug #336841
2217 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=306797
2218 public void InvokeMember_VarArgs ()
2220 BindingFlags flags = BindingFlags.InvokeMethod | BindingFlags.Public |
2221 BindingFlags.NonPublic | BindingFlags.OptionalParamBinding |
2222 BindingFlags.Static | BindingFlags.FlattenHierarchy |
2223 BindingFlags.Instance;
2225 Type type = typeof (TypeTest);
2226 string result = (string) type.InvokeMember ("bug336841",
2227 flags, null, null, new object [] { "1" });
2228 Assert.IsNotNull (result, "#A1");
2229 Assert.AreEqual ("#B:1", result, "#A2");
2231 result = (string) type.InvokeMember ("bug336841", flags,
2232 null, null, new object [] { "1", "2", "3", "4" });
2233 Assert.IsNotNull (result, "#B1");
2234 Assert.AreEqual ("#A:1|2,3,4", result, "#B2");
2238 [Test] // bug #348522
2239 public void InvokeMember_WithoutDefaultValue ()
2241 BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod;
2243 typeof (Bug348522).InvokeMember ("Test", flags, new FirstMethodBinder (), new Bug348522(),
2244 new object [] {Missing.Value}, null, null, null);
2246 } catch (ArgumentException ex) {
2247 // Missing parameter does not have a default value
2248 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
2249 Assert.IsNull (ex.InnerException, "#3");
2250 Assert.IsNotNull (ex.Message, "#4");
2251 Assert.IsNotNull (ex.ParamName, "#5");
2252 Assert.AreEqual ("parameters", ex.ParamName, "#6");
2257 public void TestMissing () {
2258 Assert.AreEqual (Type.Missing, Missing.Value);
2262 public void GetGenericMethodDefinitionOverInflatedMethodOnGTD () {
2263 var l = typeof (List<>);
2264 var m = l.GetMethod ("ConvertAll");
2265 var infl = m.MakeGenericMethod (typeof (int));
2266 var res = m.GetGenericMethodDefinition ();
2267 Assert.AreEqual (m, res, "#1");
2271 public void InvokeMember_OutParam ()
2273 object[] args = new object[] { new string [0] };
2274 typeof (TypeTest).InvokeMember ("OutTest", BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.Public, null, null, args);
2275 Assert.IsTrue (args [0] is string[]);
2276 Assert.AreEqual (10, ((string[])args[0]).Length);
2279 public static void OutTest (out string[] a1)
2281 a1 = new string [10];
2286 public static int Value;
2295 public Z (IComparable value)
2300 public static void Run ()
2308 public TakesInt (int x)
2313 public int Integer {
2320 public TakesObject (object x) {}
2323 [Test] // bug #75241
2324 public void GetConstructorNullInTypes ()
2326 // This ends up calling type.GetConstructor ()
2327 Activator.CreateInstance (typeof (TakesInt), new object [] { null });
2328 Activator.CreateInstance (typeof (TakesObject), new object [] { null });
2332 public void GetConstructor_TakeInt_Object ()
2334 Assert.IsNull (typeof (TakesInt).GetConstructor (new Type[1] { typeof (object) }));
2338 public void GetCustomAttributes_All ()
2340 object [] attrs = typeof (A).GetCustomAttributes (false);
2341 Assert.AreEqual (2, attrs.Length, "#A1");
2342 Assert.IsTrue (HasAttribute (attrs, typeof (FooAttribute)), "#A2");
2343 Assert.IsTrue (HasAttribute (attrs, typeof (VolatileModifier)), "#A3");
2345 attrs = typeof (BA).GetCustomAttributes (false);
2346 Assert.AreEqual (1, attrs.Length, "#B1");
2347 Assert.AreEqual (typeof (BarAttribute), attrs [0].GetType (), "#B2");
2349 attrs = typeof (BA).GetCustomAttributes (true);
2350 Assert.AreEqual (2, attrs.Length, "#C1");
2351 Assert.IsTrue (HasAttribute (attrs, typeof (BarAttribute)), "#C2");
2352 Assert.IsTrue (HasAttribute (attrs, typeof (VolatileModifier)), "#C3");
2354 attrs = typeof (CA).GetCustomAttributes (false);
2355 Assert.AreEqual (0, attrs.Length, "#D");
2357 attrs = typeof (CA).GetCustomAttributes (true);
2358 Assert.AreEqual (1, attrs.Length, "#E1");
2359 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#E2");
2362 static bool HasAttribute (object [] attrs, Type attributeType)
2364 foreach (object attr in attrs)
2365 if (attr.GetType () == attributeType)
2371 public void GetCustomAttributes_Type ()
2373 object [] attrs = null;
2375 attrs = typeof (A).GetCustomAttributes (
2376 typeof (VolatileModifier), false);
2377 Assert.AreEqual (1, attrs.Length, "#A1");
2378 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#A2");
2379 attrs = typeof (A).GetCustomAttributes (
2380 typeof (VolatileModifier), true);
2381 Assert.AreEqual (1, attrs.Length, "#A3");
2382 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#A4");
2384 attrs = typeof (A).GetCustomAttributes (
2385 typeof (NemerleAttribute), false);
2386 Assert.AreEqual (1, attrs.Length, "#B1");
2387 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#B2");
2388 attrs = typeof (A).GetCustomAttributes (
2389 typeof (NemerleAttribute), true);
2390 Assert.AreEqual (1, attrs.Length, "#B3");
2391 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#B4");
2393 attrs = typeof (A).GetCustomAttributes (
2394 typeof (FooAttribute), false);
2395 Assert.AreEqual (1, attrs.Length, "#C1");
2396 Assert.AreEqual (typeof (FooAttribute), attrs [0].GetType (), "#C2");
2397 attrs = typeof (A).GetCustomAttributes (
2398 typeof (FooAttribute), false);
2399 Assert.AreEqual (1, attrs.Length, "#C3");
2400 Assert.AreEqual (typeof (FooAttribute), attrs [0].GetType (), "#C4");
2402 attrs = typeof (BA).GetCustomAttributes (
2403 typeof (VolatileModifier), false);
2404 Assert.AreEqual (0, attrs.Length, "#D1");
2405 attrs = typeof (BA).GetCustomAttributes (
2406 typeof (VolatileModifier), true);
2407 Assert.AreEqual (1, attrs.Length, "#D2");
2408 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#D3");
2410 attrs = typeof (BA).GetCustomAttributes (
2411 typeof (NemerleAttribute), false);
2412 Assert.AreEqual (0, attrs.Length, "#E1");
2413 attrs = typeof (BA).GetCustomAttributes (
2414 typeof (NemerleAttribute), true);
2415 Assert.AreEqual (1, attrs.Length, "#E2");
2416 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#E3");
2418 attrs = typeof (BA).GetCustomAttributes (
2419 typeof (FooAttribute), false);
2420 Assert.AreEqual (1, attrs.Length, "#F1");
2421 Assert.AreEqual (typeof (BarAttribute), attrs [0].GetType (), "#F2");
2422 attrs = typeof (BA).GetCustomAttributes (
2423 typeof (FooAttribute), true);
2424 Assert.AreEqual (1, attrs.Length, "#F3");
2425 Assert.AreEqual (typeof (BarAttribute), attrs [0].GetType (), "#F4");
2427 attrs = typeof (bug82431A1).GetCustomAttributes (
2428 typeof (InheritAttribute), false);
2429 Assert.AreEqual (1, attrs.Length, "#G1");
2430 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#G2");
2431 attrs = typeof (bug82431A1).GetCustomAttributes (
2432 typeof (InheritAttribute), true);
2433 Assert.AreEqual (1, attrs.Length, "#G3");
2434 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#G4");
2436 attrs = typeof (bug82431A1).GetCustomAttributes (
2437 typeof (NotInheritAttribute), false);
2438 Assert.AreEqual (1, attrs.Length, "#H1");
2439 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#H2");
2440 attrs = typeof (bug82431A1).GetCustomAttributes (
2441 typeof (InheritAttribute), true);
2442 Assert.AreEqual (1, attrs.Length, "#H3");
2443 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#H4");
2445 attrs = typeof (bug82431A2).GetCustomAttributes (
2446 typeof (InheritAttribute), false);
2447 Assert.AreEqual (0, attrs.Length, "#I1");
2448 attrs = typeof (bug82431A2).GetCustomAttributes (
2449 typeof (InheritAttribute), true);
2450 Assert.AreEqual (0, attrs.Length, "#I2");
2452 attrs = typeof (bug82431A2).GetCustomAttributes (
2453 typeof (NotInheritAttribute), false);
2454 Assert.AreEqual (0, attrs.Length, "#J1");
2455 attrs = typeof (bug82431A2).GetCustomAttributes (
2456 typeof (NotInheritAttribute), true);
2457 Assert.AreEqual (0, attrs.Length, "#J2");
2459 attrs = typeof (bug82431A3).GetCustomAttributes (
2460 typeof (InheritAttribute), false);
2461 Assert.AreEqual (2, attrs.Length, "#K1");
2462 Assert.IsTrue (HasAttribute (attrs, typeof (InheritAttribute)), "#K2");
2463 Assert.IsTrue (HasAttribute (attrs, typeof (NotInheritAttribute)), "#K3");
2464 attrs = typeof (bug82431A3).GetCustomAttributes (
2465 typeof (InheritAttribute), true);
2466 Assert.AreEqual (2, attrs.Length, "#K4");
2467 Assert.IsTrue (HasAttribute (attrs, typeof (InheritAttribute)), "#K5");
2468 Assert.IsTrue (HasAttribute (attrs, typeof (NotInheritAttribute)), "#K6");
2470 attrs = typeof (bug82431A3).GetCustomAttributes (
2471 typeof (NotInheritAttribute), false);
2472 Assert.AreEqual (1, attrs.Length, "#L1");
2473 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#L2");
2474 attrs = typeof (bug82431A3).GetCustomAttributes (
2475 typeof (NotInheritAttribute), true);
2476 Assert.AreEqual (1, attrs.Length, "#L3");
2477 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#L4");
2479 attrs = typeof (bug82431B1).GetCustomAttributes (
2480 typeof (InheritAttribute), false);
2481 Assert.AreEqual (1, attrs.Length, "#M1");
2482 Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#M2");
2483 attrs = typeof (bug82431B1).GetCustomAttributes (
2484 typeof (InheritAttribute), true);
2485 Assert.AreEqual (1, attrs.Length, "#M3");
2486 Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#M4");
2488 attrs = typeof (bug82431B1).GetCustomAttributes (
2489 typeof (NotInheritAttribute), false);
2490 Assert.AreEqual (0, attrs.Length, "#N1");
2491 attrs = typeof (bug82431B1).GetCustomAttributes (
2492 typeof (NotInheritAttribute), true);
2493 Assert.AreEqual (0, attrs.Length, "#N2");
2495 attrs = typeof (bug82431B2).GetCustomAttributes (
2496 typeof (InheritAttribute), false);
2497 Assert.AreEqual (0, attrs.Length, "#O1");
2498 attrs = typeof (bug82431B2).GetCustomAttributes (
2499 typeof (InheritAttribute), true);
2500 Assert.AreEqual (1, attrs.Length, "#O2");
2501 Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#O3");
2503 attrs = typeof (bug82431B2).GetCustomAttributes (
2504 typeof (NotInheritAttribute), false);
2505 Assert.AreEqual (0, attrs.Length, "#P1");
2506 attrs = typeof (bug82431B2).GetCustomAttributes (
2507 typeof (NotInheritAttribute), true);
2508 Assert.AreEqual (0, attrs.Length, "#P2");
2510 attrs = typeof (bug82431B3).GetCustomAttributes (
2511 typeof (InheritAttribute), false);
2512 Assert.AreEqual (1, attrs.Length, "#Q1");
2513 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#Q2");
2514 attrs = typeof (bug82431B3).GetCustomAttributes (
2515 typeof (InheritAttribute), true);
2516 Assert.AreEqual (2, attrs.Length, "#Q3");
2517 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#Q4");
2518 Assert.AreEqual (typeof (InheritAttribute), attrs [1].GetType (), "#Q5");
2520 attrs = typeof (bug82431B3).GetCustomAttributes (
2521 typeof (NotInheritAttribute), false);
2522 Assert.AreEqual (1, attrs.Length, "#R1");
2523 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#R2");
2524 attrs = typeof (bug82431B3).GetCustomAttributes (
2525 typeof (NotInheritAttribute), true);
2526 Assert.AreEqual (1, attrs.Length, "#R3");
2527 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#R4");
2529 attrs = typeof (bug82431B4).GetCustomAttributes (
2530 typeof (InheritAttribute), false);
2531 Assert.AreEqual (0, attrs.Length, "#S1");
2532 attrs = typeof (bug82431B4).GetCustomAttributes (
2533 typeof (InheritAttribute), true);
2534 Assert.AreEqual (1, attrs.Length, "#S2");
2535 Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#S3");
2537 attrs = typeof (bug82431B4).GetCustomAttributes (
2538 typeof (NotInheritAttribute), false);
2539 Assert.AreEqual (0, attrs.Length, "#T1");
2540 attrs = typeof (bug82431B4).GetCustomAttributes (
2541 typeof (NotInheritAttribute), true);
2542 Assert.AreEqual (0, attrs.Length, "#T2");
2544 attrs = typeof (A).GetCustomAttributes (
2545 typeof (string), false);
2546 Assert.AreEqual (0, attrs.Length, "#U1");
2547 attrs = typeof (A).GetCustomAttributes (
2548 typeof (string), true);
2549 Assert.AreEqual (0, attrs.Length, "#U2");
2552 [Test] // bug #76150
2553 public void IsDefined ()
2555 Assert.IsTrue (typeof (A).IsDefined (typeof (NemerleAttribute), false), "#A1");
2556 Assert.IsTrue (typeof (A).IsDefined (typeof (VolatileModifier), false), "#A2");
2557 Assert.IsTrue (typeof (A).IsDefined (typeof (FooAttribute), false), "#A3");
2558 Assert.IsFalse (typeof (A).IsDefined (typeof (BarAttribute), false), "#A4");
2560 Assert.IsFalse (typeof (BA).IsDefined (typeof (NemerleAttribute), false), "#B1");
2561 Assert.IsFalse (typeof (BA).IsDefined (typeof (VolatileModifier), false), "#B2");
2562 Assert.IsTrue (typeof (BA).IsDefined (typeof (FooAttribute), false), "#B3");
2563 Assert.IsTrue (typeof (BA).IsDefined (typeof (BarAttribute), false), "#B4");
2564 Assert.IsFalse (typeof (BA).IsDefined (typeof (string), false), "#B5");
2565 Assert.IsFalse (typeof (BA).IsDefined (typeof (int), false), "#B6");
2566 Assert.IsTrue (typeof (BA).IsDefined (typeof (NemerleAttribute), true), "#B7");
2567 Assert.IsTrue (typeof (BA).IsDefined (typeof (VolatileModifier), true), "#B8");
2568 Assert.IsTrue (typeof (BA).IsDefined (typeof (FooAttribute), true), "#B9");
2569 Assert.IsTrue (typeof (BA).IsDefined (typeof (BarAttribute), true), "#B10");
2570 Assert.IsFalse (typeof (BA).IsDefined (typeof (string), true), "#B11");
2571 Assert.IsFalse (typeof (BA).IsDefined (typeof (int), true), "#B12");
2575 public void IsDefined_AttributeType_Null ()
2578 typeof (BA).IsDefined ((Type) null, false);
2580 } catch (ArgumentNullException ex) {
2581 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2582 Assert.IsNull (ex.InnerException, "#3");
2583 Assert.IsNotNull (ex.Message, "#4");
2584 Assert.IsNotNull (ex.ParamName, "#5");
2585 Assert.AreEqual ("attributeType", ex.ParamName, "#6");
2589 [Test] // bug #82431
2590 [Category ("NotWorking")]
2591 public void IsDefined_Inherited ()
2593 Assert.IsFalse (typeof (CA).IsDefined (typeof (NemerleAttribute), false), "#C1");
2594 Assert.IsFalse (typeof (CA).IsDefined (typeof (VolatileModifier), false), "#C2");
2595 Assert.IsFalse (typeof (CA).IsDefined (typeof (FooAttribute), false), "#C3");
2596 Assert.IsFalse (typeof (CA).IsDefined (typeof (BarAttribute), false), "#C4");
2597 Assert.IsTrue (typeof (CA).IsDefined (typeof (NemerleAttribute), true), "#C5");
2598 Assert.IsTrue (typeof (CA).IsDefined (typeof (VolatileModifier), true), "#C6");
2599 Assert.IsFalse (typeof (CA).IsDefined (typeof (FooAttribute), true), "#C7");
2600 Assert.IsFalse (typeof (CA).IsDefined (typeof (BarAttribute), true), "#C8");
2602 Assert.IsFalse (typeof (BBA).IsDefined (typeof (NemerleAttribute), false), "#D1");
2603 Assert.IsFalse (typeof (BBA).IsDefined (typeof (VolatileModifier), false), "#D2");
2604 Assert.IsFalse (typeof (BBA).IsDefined (typeof (FooAttribute), false), "#D3");
2605 Assert.IsFalse (typeof (BBA).IsDefined (typeof (BarAttribute), false), "#D4");
2606 Assert.IsTrue (typeof (BBA).IsDefined (typeof (NemerleAttribute), true), "#D5");
2607 Assert.IsTrue (typeof (BBA).IsDefined (typeof (VolatileModifier), true), "#D6");
2608 Assert.IsTrue (typeof (BBA).IsDefined (typeof (FooAttribute), true), "#D7");
2609 Assert.IsTrue (typeof (BBA).IsDefined (typeof (BarAttribute), true), "#D8");
2611 Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (InheritAttribute), false), "#E1");
2612 Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (NotInheritAttribute), false), "#E2");
2613 Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (InheritAttribute), true), "#E3");
2614 Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (NotInheritAttribute), true), "#E4");
2616 Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (InheritAttribute), false), "#F1");
2617 Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (NotInheritAttribute), false), "#F2");
2618 Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (InheritAttribute), true), "#F3");
2619 Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (NotInheritAttribute), true), "#F4");
2621 Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (InheritAttribute), false), "#G1");
2622 Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (NotInheritAttribute), false), "#G2");
2623 Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (InheritAttribute), true), "#G3");
2624 Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (NotInheritAttribute), true), "#G4");
2626 Assert.IsTrue (typeof (bug82431B1).IsDefined (typeof (InheritAttribute), false), "#H1");
2627 Assert.IsFalse (typeof (bug82431B1).IsDefined (typeof (NotInheritAttribute), false), "#H2");
2628 Assert.IsTrue (typeof (bug82431B1).IsDefined (typeof (InheritAttribute), true), "#H3");
2629 Assert.IsFalse (typeof (bug82431B1).IsDefined (typeof (NotInheritAttribute), true), "#H4");
2631 Assert.IsFalse (typeof (bug82431B2).IsDefined (typeof (InheritAttribute), false), "#I1");
2632 Assert.IsFalse (typeof (bug82431B2).IsDefined (typeof (NotInheritAttribute), false), "#I2");
2633 Assert.IsTrue (typeof (bug82431B2).IsDefined (typeof (InheritAttribute), true), "#I3");
2634 Assert.IsFalse (typeof (bug82431B2).IsDefined (typeof (NotInheritAttribute), true), "#I4");
2636 Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (InheritAttribute), false), "#J1");
2637 Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (NotInheritAttribute), false), "#J2");
2638 Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (InheritAttribute), true), "#J3");
2639 Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (NotInheritAttribute), true), "#J4");
2641 Assert.IsFalse (typeof (bug82431B4).IsDefined (typeof (InheritAttribute), false), "#K2");
2642 Assert.IsFalse (typeof (bug82431B4).IsDefined (typeof (NotInheritAttribute), false), "#K2");
2643 Assert.IsTrue (typeof (bug82431B4).IsDefined (typeof (InheritAttribute), true), "#K3");
2644 Assert.IsFalse (typeof (bug82431B4).IsDefined (typeof (NotInheritAttribute), true), "#K4");
2647 class Bug13767Attribute : Attribute
2649 public object[] field;
2651 public Bug13767Attribute (params object[] args)
2657 public enum Bug13767Enum
2663 [Bug13767("Demo", new[] { Bug13767Enum.Value1, Bug13767Enum.Value0 })]
2664 public void Bug13767Method(string attributeName, Bug13767Enum[]options)
2670 public void CustomAttributeWithNestedArrayOfEnum ()
2672 var m = GetType ().GetMethod ("Bug13767Method");
2674 var attr = m.GetCustomAttributes (false);
2675 Assert.AreEqual (1, attr.Length, "#1");
2677 var tc = (Bug13767Attribute)attr[0];
2678 Assert.AreEqual (2, tc.field.Length, "#2");
2679 Assert.AreEqual ("Demo", tc.field[0], "#3");
2680 Assert.IsNotNull (tc.field[1], "#4");
2682 var arr = (Bug13767Enum[])tc.field [1];
2683 Assert.AreEqual (2, arr.Length, "#5");
2684 Assert.AreEqual (Bug13767Enum.Value1, arr [0], "#6");
2685 Assert.AreEqual (Bug13767Enum.Value0, arr [1], "#7");
2688 [Test] // GetType (String)
2689 public void GetType1_TypeName_Null ()
2692 Type.GetType ((string) null);
2694 } catch (ArgumentNullException ex) {
2695 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2696 Assert.IsNull (ex.InnerException, "#3");
2697 Assert.IsNotNull (ex.Message, "#4");
2698 Assert.AreEqual ("TypeName", ex.ParamName, "#5");
2702 [Test] // GetType (String, Boolean)
2703 public void GetType2_TypeName_Null ()
2706 Type.GetType ((string) null, false);
2708 } catch (ArgumentNullException ex) {
2709 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2710 Assert.IsNull (ex.InnerException, "#3");
2711 Assert.IsNotNull (ex.Message, "#4");
2712 Assert.AreEqual ("TypeName", ex.ParamName, "#5");
2716 [Test] // GetType (String, Boolean, Boolean)
2717 public void GetType3_TypeName_Null ()
2720 Type.GetType ((string) null, false, false);
2722 } catch (ArgumentNullException ex) {
2723 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2724 Assert.IsNull (ex.InnerException, "#3");
2725 Assert.IsNotNull (ex.Message, "#4");
2726 Assert.AreEqual ("TypeName", ex.ParamName, "#5");
2731 public void GetTypeArray_Args_Null ()
2734 Type.GetTypeArray ((object []) null);
2736 } catch (ArgumentNullException ex) {
2737 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2738 Assert.IsNull (ex.InnerException, "#3");
2739 Assert.IsNotNull (ex.Message, "#4");
2740 Assert.AreEqual ("args", ex.ParamName, "#5");
2745 public void GetTypeCode ()
2747 Assert.AreEqual (TypeCode.Boolean, Type.GetTypeCode (typeof (bool)), "#1");
2748 Assert.AreEqual (TypeCode.Byte, Type.GetTypeCode (typeof (byte)), "#2");
2749 Assert.AreEqual (TypeCode.Char, Type.GetTypeCode (typeof (char)), "#3");
2750 Assert.AreEqual (TypeCode.DateTime, Type.GetTypeCode (typeof (DateTime)), "#4");
2751 Assert.AreEqual (TypeCode.DBNull, Type.GetTypeCode (typeof (DBNull)), "#5");
2752 Assert.AreEqual (TypeCode.Decimal, Type.GetTypeCode (typeof (decimal)), "#6");
2753 Assert.AreEqual (TypeCode.Double, Type.GetTypeCode (typeof (double)), "#7");
2754 Assert.AreEqual (TypeCode.Empty, Type.GetTypeCode (null), "#8");
2755 Assert.AreEqual (TypeCode.Int16, Type.GetTypeCode (typeof (short)), "#9");
2756 Assert.AreEqual (TypeCode.Int32, Type.GetTypeCode (typeof (int)), "#10");
2757 Assert.AreEqual (TypeCode.Int64, Type.GetTypeCode (typeof (long)), "#11");
2758 Assert.AreEqual (TypeCode.Object, Type.GetTypeCode (typeof (TakesInt)), "#12");
2759 Assert.AreEqual (TypeCode.SByte, Type.GetTypeCode (typeof (sbyte)), "#13");
2760 Assert.AreEqual (TypeCode.Single, Type.GetTypeCode (typeof (float)), "#14");
2761 Assert.AreEqual (TypeCode.String, Type.GetTypeCode (typeof (string)), "#15");
2762 Assert.AreEqual (TypeCode.UInt16, Type.GetTypeCode (typeof (ushort)), "#16");
2763 Assert.AreEqual (TypeCode.UInt32, Type.GetTypeCode (typeof (uint)), "#17");
2764 Assert.AreEqual (TypeCode.UInt64, Type.GetTypeCode (typeof (ulong)), "#18");
2768 public void GetTypeFromHandle_Handle_Zero ()
2770 RuntimeTypeHandle handle = new RuntimeTypeHandle ();
2772 Assert.IsNull (Type.GetTypeFromHandle (handle));
2776 public void GetTypeHandle_O_Null ()
2779 Type.GetTypeHandle (null);
2781 } catch (ArgumentNullException ex) {
2782 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2783 Assert.IsNull (ex.InnerException, "#3");
2784 Assert.IsNotNull (ex.Message, "#4");
2785 Assert.IsNull (ex.ParamName, "#5");
2789 [Test] // GetConstructor (Type [])
2790 public void GetConstructor1 ()
2793 ConstructorInfo ctor;
2795 type = typeof (CtorsA);
2796 ctor = type.GetConstructor (Type.EmptyTypes);
2797 Assert.IsNotNull (ctor, "#A1");
2798 Assert.AreEqual (0, ctor.GetParameters ().Length, "#A2");
2799 Assert.IsFalse (ctor.IsStatic, "#A3");
2800 Assert.IsTrue (ctor.IsPublic, "#A4");
2801 Assert.AreEqual (".ctor", ctor.Name, "#A5");
2803 type = typeof (CtorsB);
2804 ctor = type.GetConstructor (Type.EmptyTypes);
2805 Assert.IsNotNull (ctor, "#B1");
2806 Assert.AreEqual (0, ctor.GetParameters ().Length, "#B2");
2807 Assert.IsFalse (ctor.IsStatic, "#B3");
2808 Assert.IsTrue (ctor.IsPublic, "#B4");
2809 Assert.AreEqual (".ctor", ctor.Name, "#B5");
2811 type = typeof (CtorsC);
2812 ctor = type.GetConstructor (Type.EmptyTypes);
2813 Assert.IsNull (ctor, "#C");
2815 type = typeof (CtorsC);
2816 ctor = type.GetConstructor (new Type [] { typeof (int) });
2817 Assert.IsNotNull (ctor, "#D1");
2818 Assert.AreEqual (1, ctor.GetParameters ().Length, "#D2");
2819 Assert.IsFalse (ctor.IsStatic, "#D3");
2820 Assert.IsTrue (ctor.IsPublic, "#D4");
2821 Assert.AreEqual (".ctor", ctor.Name, "#D5");
2824 [Test] // GetConstructor (Type [])
2825 public void GetConstructor1_Types_Null ()
2828 typeof (BindingFlags).GetConstructor (null);
2830 } catch (ArgumentNullException ex) {
2831 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2832 Assert.IsNull (ex.InnerException, "#3");
2833 Assert.IsNotNull (ex.Message, "#4");
2834 Assert.IsNotNull (ex.ParamName, "#5");
2835 Assert.AreEqual ("types", ex.ParamName, "#6");
2839 [Test] // GetConstructor (Type [])
2840 public void GetConstructor1_Types_ItemNull ()
2842 Type type = typeof (BindingFlags);
2844 type.GetConstructor (new Type[1] { null });
2845 Assert.Fail ("#A1");
2846 } catch (ArgumentNullException ex) {
2847 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
2848 Assert.IsNull (ex.InnerException, "#A3");
2849 Assert.IsNotNull (ex.Message, "#A4");
2850 Assert.IsNotNull (ex.ParamName, "#A5");
2851 Assert.AreEqual ("types", ex.ParamName, "#A6");
2854 type = typeof (TakesInt);
2856 type.GetConstructor (new Type [1] { null });
2857 Assert.Fail ("#B1");
2858 } catch (ArgumentNullException ex) {
2859 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
2860 Assert.IsNull (ex.InnerException, "#B3");
2861 Assert.IsNotNull (ex.Message, "#B4");
2862 Assert.IsNotNull (ex.ParamName, "#B5");
2863 Assert.AreEqual ("types", ex.ParamName, "#B6");
2867 [Test] // GetConstructor (BindingFlags, Binder, Type [], ParameterModifier [])
2868 public void GetConstructor2_Types_ItemNull ()
2870 Type type = typeof (BindingFlags);
2872 type.GetConstructor (BindingFlags.Default, null,
2873 new Type[1] { null }, null);
2875 } catch (ArgumentNullException ex) {
2876 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2877 Assert.IsNull (ex.InnerException, "#3");
2878 Assert.IsNotNull (ex.Message, "#4");
2879 Assert.IsNotNull (ex.ParamName, "#5");
2880 Assert.AreEqual ("types", ex.ParamName, "#6");
2884 [Test] // GetConstructor (BindingFlags, Binder, CallingConventions, Type [], ParameterModifier [])
2885 public void GetConstructor3_Types_ItemNull ()
2887 Type type = typeof (BindingFlags);
2889 type.GetConstructor (BindingFlags.Default,
2890 null, CallingConventions.Any,
2891 new Type[1] { null }, null);
2893 } catch (ArgumentNullException ex) {
2894 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2895 Assert.IsNull (ex.InnerException, "#3");
2896 Assert.IsNotNull (ex.Message, "#4");
2897 Assert.IsNotNull (ex.ParamName, "#5");
2898 Assert.AreEqual ("types", ex.ParamName, "#6");
2903 public void GetMethod_Bug77367 ()
2905 MethodInfo i = typeof (Bug77367).GetMethod ("Run", Type.EmptyTypes);
2911 public void EqualsUnderlyingType ()
2913 AssemblyBuilderAccess access = AssemblyBuilderAccess.RunAndSave;
2914 TypeAttributes attribs = TypeAttributes.Public;
2916 AssemblyName name = new AssemblyName ();
2917 name.Name = "enumtest";
2918 AssemblyBuilder assembly =
2919 AppDomain.CurrentDomain.DefineDynamicAssembly (
2922 ModuleBuilder module = assembly.DefineDynamicModule
2923 ("m", "enumtest.dll");
2924 EnumBuilder e = module.DefineEnum ("E", attribs, typeof (int));
2926 Assert.IsTrue (typeof (int).Equals (e));
2931 public void Equals_Type_Null ()
2933 Assert.IsFalse (typeof (int).Equals ((Type) null), "#1");
2934 Assert.IsFalse (typeof (int).Equals ((object) null), "#2");
2938 public void GetElementType_Bug63841 ()
2940 Assert.IsNull (typeof (TheEnum).GetElementType (), "#1");
2944 public void FullNameGenerics ()
2946 Type fooType = typeof (Foo<>);
2947 FieldInfo [] fields = fooType.GetFields ();
2949 Assert.AreEqual (1, fields.Length, "#0");
2951 Assert.IsNotNull (fooType.FullName, "#1");
2952 Assert.IsNotNull (fooType.AssemblyQualifiedName, "#1a");
2954 FieldInfo field = fooType.GetField ("Whatever");
2955 Assert.IsNotNull (field, "#2");
2956 Assert.AreEqual (field, fields [0], "#2a");
2957 Assert.IsNull (field.FieldType.FullName, "#3");
2958 Assert.IsNull (field.FieldType.AssemblyQualifiedName, "#3a");
2959 Assert.IsNotNull (field.FieldType.ToString (), "#4");
2961 PropertyInfo prop = fooType.GetProperty ("Test");
2962 Assert.IsNotNull (prop, "#5");
2963 Assert.IsNull (prop.PropertyType.FullName, "#6");
2964 Assert.IsNull (prop.PropertyType.AssemblyQualifiedName, "#6a");
2965 Assert.IsNotNull (prop.PropertyType.ToString (), "#7");
2967 MethodInfo method = fooType.GetMethod("Execute");
2968 Assert.IsNotNull (method, "#8");
2969 Assert.IsNull (method.ReturnType.FullName, "#9");
2970 Assert.IsNull (method.ReturnType.AssemblyQualifiedName, "#9a");
2971 Assert.IsNotNull (method.ReturnType.ToString (), "#10");
2973 ParameterInfo[] parameters = method.GetParameters();
2974 Assert.AreEqual (1, parameters.Length, "#11");
2975 Assert.IsNull (parameters[0].ParameterType.FullName, "#12");
2976 Assert.IsNull (parameters[0].ParameterType.AssemblyQualifiedName, "#12a");
2977 Assert.IsNotNull (parameters[0].ParameterType.ToString (), "#13");
2981 public void TypeParameterIsNotGeneric ()
2983 Type fooType = typeof (Foo<>);
2984 Type type_param = fooType.GetGenericArguments () [0];
2985 Assert.IsTrue (type_param.IsGenericParameter);
2986 Assert.IsFalse (type_param.IsGenericType);
2987 Assert.IsFalse (type_param.IsGenericTypeDefinition);
2989 // LAMESPEC: MSDN claims that this should be false, but .NET v2.0.50727 says it's true
2990 // http://msdn2.microsoft.com/en-us/library/system.type.isgenerictype.aspx
2991 Assert.IsTrue (type_param.ContainsGenericParameters);
2995 public void IsAssignable ()
2997 Type foo_type = typeof (Foo<>);
2998 Type foo_int_type = typeof (Foo<int>);
2999 Assert.IsFalse (foo_type.IsAssignableFrom (foo_int_type), "Foo<int> -!-> Foo<>");
3000 Assert.IsFalse (foo_int_type.IsAssignableFrom (foo_type), "Foo<> -!-> Foo<int>");
3002 Type ibar_short_type = typeof (IBar<short>);
3003 Type ibar_int_type = typeof (IBar<int>);
3004 Type baz_short_type = typeof (Baz<short>);
3005 Type baz_int_type = typeof (Baz<int>);
3007 Assert.IsTrue (ibar_int_type.IsAssignableFrom (baz_int_type), "Baz<int> -> IBar<int>");
3008 Assert.IsTrue (ibar_short_type.IsAssignableFrom (baz_short_type), "Baz<short> -> IBar<short>");
3010 Assert.IsFalse (ibar_int_type.IsAssignableFrom (baz_short_type), "Baz<short> -!-> IBar<int>");
3011 Assert.IsFalse (ibar_short_type.IsAssignableFrom (baz_int_type), "Baz<int> -!-> IBar<short>");
3014 Assert.IsTrue (typeof (Nullable<int>).IsAssignableFrom (typeof (int)));
3015 Assert.IsFalse (typeof (int).IsAssignableFrom (typeof (Nullable<int>)));
3016 Assert.IsTrue (typeof (Nullable<FooStruct>).IsAssignableFrom (typeof (FooStruct)));
3020 public void IsInstanceOf ()
3022 Assert.IsTrue (typeof (Nullable<int>).IsInstanceOfType (5));
3026 public void IsInstanceOfArrayOfNullable ()
3028 Assert.IsTrue (typeof (Nullable<int>[]).IsInstanceOfType (new Nullable<int> [0]));
3032 public void IsInstanceOfType_Null ()
3034 Assert.IsFalse (typeof (int).IsInstanceOfType (null), "int");
3035 Assert.IsFalse (typeof (object).IsInstanceOfType (null), "object");
3036 Assert.IsFalse (typeof (int?).IsInstanceOfType (null), "int?");
3040 public void ByrefType ()
3042 Type foo_type = typeof (Foo<>);
3043 Type type_param = foo_type.GetGenericArguments () [0];
3044 Type byref_type_param = type_param.MakeByRefType ();
3045 Assert.IsFalse (byref_type_param.IsGenericParameter);
3046 Assert.IsNull (byref_type_param.DeclaringType);
3050 [ExpectedException (typeof (TypeLoadException))]
3051 public void MakeByRefByRef ()
3053 typeof (int).MakeByRefType ().MakeByRefType ();
3057 public void MakeArrayTypeTest ()
3059 // This should not crash:
3060 typeof (void).MakeArrayType ();
3065 public class ComFoo<T> {
3069 public void GetCustomAttributesGenericInstance ()
3071 Assert.AreEqual (1, typeof (ComFoo<int>).GetCustomAttributes (typeof (ComVisibleAttribute), true).Length);
3074 interface ByRef1<T> { void f (ref T t); }
3075 interface ByRef2 { void f<T> (ref T t); }
3077 interface ByRef3<T> where T:struct { void f (ref T? t); }
3078 interface ByRef4 { void f<T> (ref T? t) where T:struct; }
3080 void CheckGenericByRef (Type t)
3082 string name = t.Name;
3083 t = t.GetMethod ("f").GetParameters () [0].ParameterType;
3085 Assert.IsFalse (t.IsGenericType, name);
3086 Assert.IsFalse (t.IsGenericTypeDefinition, name);
3087 Assert.IsFalse (t.IsGenericParameter, name);
3091 public void GenericByRef ()
3093 CheckGenericByRef (typeof (ByRef1<>));
3094 CheckGenericByRef (typeof (ByRef2));
3095 CheckGenericByRef (typeof (ByRef3<>));
3096 CheckGenericByRef (typeof (ByRef4));
3099 public class Bug80242<T> {
3100 public interface IFoo { }
3101 public class Bar : IFoo { }
3102 public class Baz : Bar { }
3106 public void TestNestedTypes ()
3108 Type t = typeof (Bug80242<object>);
3109 Assert.IsFalse (t.IsGenericTypeDefinition);
3110 foreach (Type u in t.GetNestedTypes ()) {
3111 Assert.IsTrue (u.IsGenericTypeDefinition, "{0} isn't a generic definition", u);
3112 Assert.AreEqual (u, u.GetGenericArguments () [0].DeclaringType);
3116 [Test] // bug #82211
3117 public void GetMembers_GenericArgument ()
3119 Type argType = typeof (ComFoo<>).GetGenericArguments () [0];
3120 MemberInfo [] members = argType.GetMembers ();
3121 Assert.IsNotNull (members, "#1");
3122 Assert.AreEqual (4, members.Length, "#2");
3126 [ExpectedException (typeof (ArgumentNullException))]
3127 public void ReflectionOnlyGetTypeNullTypeName ()
3129 Type.ReflectionOnlyGetType (null, false, false);
3133 public void ReflectionOnlyGetTypeDoNotThrow ()
3135 Assert.IsNull (Type.ReflectionOnlyGetType ("a, nonexistent.dll", false, false));
3139 [ExpectedException (typeof (FileNotFoundException))]
3140 public void ReflectionOnlyGetTypeThrow ()
3142 Type.ReflectionOnlyGetType ("a, nonexistent.dll", true, false);
3146 public void ReflectionOnlyGetType ()
3148 Type t = Type.ReflectionOnlyGetType (typeof (int).AssemblyQualifiedName.ToString (), true, true);
3149 Assert.AreEqual ("System.Int32", t.FullName);
3153 #if MONOTOUCH || MOBILE_STATIC
3154 [ExpectedException (typeof (NotSupportedException))]
3156 public void MakeGenericType_UserDefinedType ()
3158 Type ut = new UserType (typeof (int));
3159 Type t = typeof (Foo<>).MakeGenericType (ut);
3160 Assert.IsTrue (t.IsGenericType, "#A1");
3161 Assert.AreEqual (1, t.GetGenericArguments ().Length, "#A2");
3163 Type arg = t.GetGenericArguments () [0];
3164 Assert.IsNotNull (arg, "#B1");
3165 Assert.IsFalse (arg.IsGenericType, "#B2");
3166 Assert.AreEqual (ut, arg, "#B3");
3170 #if MONOTOUCH || MOBILE_STATIC
3171 [ExpectedException (typeof (NotSupportedException))]
3173 public void MakeGenericType_NestedUserDefinedType ()
3175 Type ut = new UserType (new UserType (typeof (int)));
3176 Type t = typeof (Foo<>).MakeGenericType (ut);
3177 Assert.IsTrue (t.IsGenericType, "#A1");
3178 Assert.AreEqual (1, t.GetGenericArguments ().Length, "#A2");
3180 Type arg = t.GetGenericArguments () [0];
3181 Assert.IsNotNull (arg, "#B1");
3182 Assert.IsFalse (arg.IsGenericType, "#B2");
3183 Assert.AreEqual (ut, arg, "#B3");
3187 #if MONOTOUCH || MOBILE_STATIC
3188 [ExpectedException (typeof (NotSupportedException))]
3190 public void TestMakeGenericType_UserDefinedType_DotNet20SP1 ()
3192 Type ut = new UserType(typeof(int));
3193 Type t = typeof(Foo<>).MakeGenericType(ut);
3194 Assert.IsTrue (t.IsGenericType, "#1");
3196 Assert.AreEqual (ut, t.GetGenericArguments()[0], "#2");
3200 #if MONOTOUCH || MOBILE_STATIC
3201 [ExpectedException (typeof (NotSupportedException))]
3203 public void MakeGenericType_BadUserType ()
3205 Type ut = new UserType (null);
3206 Type t = typeof (Foo<>).MakeGenericType (ut);
3207 var g0 = t.GetGenericArguments () [0];
3208 Assert.AreSame (g0, ut, "#1");
3212 public void MakeGenericType_WrongNumOfArguments ()
3215 Type t = typeof (Foo<,>).MakeGenericType (new Type [] { typeof (int) });
3217 } catch (ArgumentException) {
3221 [AttributeUsage (AttributeTargets.All)]
3222 public class DocAttribute : Attribute {
3223 public DocAttribute (string docs) {}
3226 class GenericClassWithAttributes<[Doc ("T")] T, [Doc ("B")] B>
3227 where T : class, new ()
3230 public T Bar { get{return null;}}
3232 public void M<[Doc ("X")] X> (X x)
3237 [Test] //bug #377596
3238 public void GetGenericArguments_ArgumentsHaveAttributes ()
3240 Type type = typeof(GenericClassWithAttributes<,>);
3241 Type[] tArgs = type.GetGenericArguments ();
3242 MethodInfo m = type.GetMethod ("M");
3243 Type[] mArgs = m.GetGenericArguments ();
3244 Assert.AreEqual(1, tArgs[0].GetCustomAttributes (typeof (DocAttribute), true).Length, "#1");
3245 Assert.AreEqual(1, tArgs[1].GetCustomAttributes (typeof (DocAttribute), true).Length, "#1");
3246 Assert.AreEqual(1, mArgs[0].GetCustomAttributes (typeof (DocAttribute), true).Length, "#1");
3249 [Test] //bug #471255
3250 public void GetTypeCalledUsingReflection ()
3252 Type expectedType = Type.GetType ("NoNamespaceClass");
3253 Assert.IsNotNull (expectedType, "#1");
3254 MethodInfo m = typeof (Type).GetMethod ("GetType", BindingFlags.Public | BindingFlags.Static, null, new Type [] { typeof (string) }, null);
3255 object r = m.Invoke (null, BindingFlags.Default, null, new object [] { "NoNamespaceClass" }, CultureInfo.InvariantCulture);
3256 Assert.AreSame (expectedType, r, "#2");
3260 public void EqualsUserType () {
3261 UserType2 t1 = new UserType2(null);
3262 UserType2 t2 = new UserType2(t1);
3263 Assert.IsTrue (t1.Equals(t2));
3267 public void GetHashCodeUserType () {
3268 UserType2 t1 = new UserType2(null);
3269 UserType2 t2 = new UserType2(t1);
3270 Assert.AreEqual (42, t2.GetHashCode());
3274 public void IsGenericTypeDefinitionUserType () {
3275 Assert.IsFalse (new UserType(null).IsGenericTypeDefinition);
3279 public void IsGenericTypeUserType () {
3280 Assert.IsFalse (new UserType(null).IsGenericType);
3284 [ExpectedException (typeof (NotSupportedException))]
3285 public void GetGenericTypeDefinitionUserType () {
3286 new UserType(null).GetGenericTypeDefinition ();
3289 [ExpectedException (typeof (NotSupportedException))]
3290 public void GetGenericArgumentsUserType () {
3291 new UserType(null).GetGenericArguments ();
3295 [ExpectedException (typeof (InvalidOperationException))]
3296 public void GenericParameterPositionUserType () {
3297 Assert.IsTrue (new UserType(null).GenericParameterPosition == 0);
3301 public void TypeGetMemberReturnTypeTest ()
3304 MemberTypes memtype;
3306 object [] flagsandtypes = new object [] {
3307 MemberTypes.All, typeof (MemberInfo []),
3308 MemberTypes.Constructor, typeof (ConstructorInfo []),
3309 MemberTypes.Custom, typeof (MemberInfo []),
3310 MemberTypes.Event, typeof (EventInfo []),
3311 MemberTypes.Field, typeof (FieldInfo []),
3312 MemberTypes.Method, typeof (MethodInfo []),
3313 MemberTypes.NestedType, typeof (Type []),
3314 MemberTypes.Property, typeof (PropertyInfo []),
3315 MemberTypes.TypeInfo, typeof (Type [])};
3317 for (int i=0; i < flagsandtypes.Length; i+=2) {
3318 memtype = (MemberTypes)flagsandtypes [i];
3319 testtype = (Type)flagsandtypes [i+1];
3320 obj = GetType ().GetMember ("DummyMember", memtype,
3321 BindingFlags.Public | BindingFlags.Instance);
3322 Assert.AreEqual (testtype.GetHashCode (), obj.GetType ().GetHashCode (),
3323 "Expected #" + i + " " + testtype.FullName);
3329 public void TypeNameStartsWithSpace ()
3331 Type t1 = Type.GetType ("System.Type, mscorlib");
3332 Type t2 = Type.GetType (" System.Type, mscorlib");
3333 Assert.AreEqual (t1, t2);
3336 #if !MONOTOUCH && !MOBILE_STATIC
3338 public void SpaceAfterComma () {
3339 string strType = "System.Collections.Generic.Dictionary`2[[System.Int32,mscorlib], [System.String,mscorlib]],mscorlib";
3340 Assert.IsTrue (Type.GetType (strType) != null);
3344 #if !MONOTOUCH && !MOBILE_STATIC
3346 public void Bug506757 ()
3348 AssemblyName assemblyName = new AssemblyName ();
3349 assemblyName.Name = "customMod";
3350 assemblyName.Version = new Version (1, 2, 3, 4);
3352 AssemblyBuilder assembly
3353 = Thread.GetDomain().DefineDynamicAssembly(
3354 assemblyName, AssemblyBuilderAccess.RunAndSave);
3356 ModuleBuilder module = assembly.DefineDynamicModule("res.exe", "res.exe");
3358 TypeBuilder type0 = module.DefineType ("Base", TypeAttributes.Public, typeof (object));
3359 TypeBuilder type1 = module.DefineType ("Middle", TypeAttributes.Public, type0);
3360 TypeBuilder type2 = module.DefineType ("End", TypeAttributes.Public, type1);
3362 MethodAttributes attrs0 = MethodAttributes.Virtual | MethodAttributes.HideBySig |
3363 MethodAttributes.NewSlot | MethodAttributes.FamORAssem;
3365 MethodAttributes attrs1 = MethodAttributes.Virtual | MethodAttributes.HideBySig |
3366 MethodAttributes.FamORAssem;
3368 MethodAttributes attrs2 = MethodAttributes.Virtual | MethodAttributes.HideBySig |
3369 MethodAttributes.Public;
3372 MethodBuilder m0 = type0.DefineMethod ("Tst", attrs0, typeof (void), null);
3373 m0.GetILGenerator ().Emit (OpCodes.Ret);
3375 MethodBuilder m1 = type1.DefineMethod ("Tst", attrs1, typeof (void), null);
3376 m1.GetILGenerator ().Emit (OpCodes.Ret);
3378 MethodBuilder m2 = type2.DefineMethod ("Tst", attrs2, typeof (void), null);
3379 m2.GetILGenerator ().Emit (OpCodes.Ret);
3382 type0.CreateType ();
3383 type1.CreateType ();
3384 Type t2 = type2.CreateType ();
3386 foreach (var m in t2.GetMethods (BindingFlags.Instance | BindingFlags.NonPublic))
3387 Assert.IsTrue (m.DeclaringType == typeof (object), String.Format ("{0}::{1}", m.DeclaringType, m.Name));
3391 public void MakeArrayTypeOfOneDimension ()
3393 Type vector = typeof (int).MakeArrayType ();
3394 Type szarray = typeof (int).MakeArrayType (1);
3396 Assert.AreNotEqual (vector, szarray, "#1");
3397 Assert.AreEqual ("Int32[]", vector.Name, "#2");
3398 Assert.AreEqual ("Int32[*]", szarray.Name, "#3");
3401 public class DeclaringMethodFoo {
3402 public void Test<T> (T t) {}
3403 public void Test2<T> (ref T t) {}
3406 public class DeclaringMethodBar<T> {
3407 public void Test2 (ref T t) {}
3411 public void DeclaringMethodOnlyWorksWithGenericArgs ()
3413 MethodInfo testMethod = typeof (DeclaringMethodFoo).GetMethod ("Test");
3414 MethodBase otherMethod = testMethod.GetParameters ()[0].ParameterType.DeclaringMethod;
3416 Assert.AreEqual (testMethod, otherMethod,"#1");
3418 Assert.IsNull (typeof (DeclaringMethodBar<>).GetGenericArguments ()[0].DeclaringMethod, "#2");
3421 var x = typeof (int).DeclaringMethod;
3423 } catch (InvalidOperationException) {}
3426 var x = typeof (DeclaringMethodFoo).GetMethod ("Test2").GetParameters () [0].ParameterType.DeclaringMethod;
3428 } catch (InvalidOperationException) {}
3431 var x = typeof (DeclaringMethodBar<>).GetMethod ("Test2").GetParameters () [0].ParameterType.DeclaringMethod;
3433 } catch (InvalidOperationException) {}
3438 public void GetArrayRankThrowsForNonArrayType ()
3440 Assert.AreEqual (1, typeof (int[]).GetArrayRank (), "#1");
3441 Assert.AreEqual (2, typeof (int[,]).GetArrayRank (), "#2");
3443 typeof (int).GetArrayRank ();
3445 } catch (ArgumentException) {}
3448 [Test] //Bug #564379
3449 public void GetMethodsReturnPublicMethodsInInterfaces ()
3451 Type t = typeof (NonClosingStream);
3452 MethodInfo[] methods = t.GetMethods (BindingFlags.Public | BindingFlags.Instance);
3454 Assert.AreEqual (5, methods.Length, "#1");
3457 foreach (var m in methods) {
3458 if (m.Name.Equals ("ToString"))
3459 Assert.IsTrue (m.DeclaringType == typeof (NonClosingStream), "#" + id);
3460 else if (m.Name.Equals ("Dispose") && m.GetParameters ().Length == 0)
3461 Assert.IsTrue (m.DeclaringType == typeof (Stream), "#" + id);
3462 else if (m.Name.Equals ("Equals") || m.Name.Equals ("GetHashCode") || m.Name.Equals ("GetType"))
3463 Assert.IsTrue (m.DeclaringType == typeof (object), "#" + id);
3465 Assert.Fail ("invalid method " + m);
3470 [Test] // Bug #574696
3471 public void GetMember_DoesntReturnPrivatePropOfParent ()
3473 BindingFlags flags = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance;
3474 Assert.AreEqual (1, typeof (Bar).GetMember ("PrivInst", flags).Length);
3475 Assert.AreEqual (0, typeof (Bar).GetMember ("PrivInstBase", flags).Length);
3476 Assert.AreEqual (1, typeof (Foo).GetMember ("PrivInstBase", flags).Length);
3479 [Test] // Bug #484246
3480 public void GetInterfaceCompareAgainstGTDNames ()
3482 var t = typeof (Dictionary<string,string>);
3483 var iface = typeof (IDictionary<string,string>);
3485 Assert.AreSame (iface, t.GetInterface ("System.Collections.Generic.IDictionary`2"), "#1");
3487 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]]";
3489 Assert.IsNull (t.GetInterface (name), "#2");
3493 public void RuntimeCorrectlyNormalizeGenericTypes ()
3495 Type lst = typeof (MList<>);
3496 Type arg = lst.GetGenericArguments ()[0];
3498 Type sup = lst.BaseType;
3499 Type sa0 = sup.GetGenericArguments ()[0];
3500 Type sa1 = sup.GetGenericArguments ()[1];
3502 Assert.IsTrue (sa1 == lst, "#1");
3503 Assert.IsTrue (sa0 == arg, "#2");
3505 Type inst = typeof (Cons<,>).MakeGenericType (arg, lst.MakeGenericType (arg));
3506 Assert.IsTrue (inst == sup, "#3");
3514 class MList<A> : Cons<A, MList<A>>
3519 [Test] // Bug #331126
3520 public void IsAssignableFromWorksCorrectlyWithByRefs ()
3522 Type int_byref = typeof (int).MakeByRefType ();
3523 Type obj_byref = typeof (object).MakeByRefType ();
3524 Type long_byref = typeof (long).MakeByRefType ();
3525 Type enum1_byref = typeof (AttributeTargets).MakeByRefType ();
3526 Type enum2_byref = typeof (PlatformID).MakeByRefType ();
3527 Type uint_byref = typeof (uint).MakeByRefType ();
3528 Type string_byref = typeof (object).MakeByRefType ();
3529 Type struct0_byref = typeof (Size4).MakeByRefType ();
3530 Type struct1_byref = typeof (Size4b).MakeByRefType ();
3531 Type mvar0_byref = typeof (TypeTest).GetMethod ("Bug331126").GetGenericArguments ()[0].MakeByRefType ();
3532 Type mvar1_byref = typeof (TypeTest).GetMethod ("Bug331126").GetGenericArguments ()[1].MakeByRefType ();
3534 Assert.IsFalse (typeof (int).IsAssignableFrom (int_byref), "#1");
3535 Assert.IsFalse (int_byref.IsAssignableFrom (typeof (int)), "#2");
3536 Assert.IsFalse (obj_byref.IsAssignableFrom (long_byref), "#3");
3537 Assert.IsFalse (long_byref.IsAssignableFrom (obj_byref), "#4");
3538 Assert.IsTrue (enum1_byref.IsAssignableFrom (enum2_byref), "#5");
3539 Assert.IsTrue (enum2_byref.IsAssignableFrom (enum1_byref), "#6");
3540 Assert.IsTrue (int_byref.IsAssignableFrom (enum2_byref), "#7");
3541 Assert.IsTrue (enum2_byref.IsAssignableFrom (int_byref), "#8");
3542 Assert.IsTrue (enum2_byref.IsAssignableFrom (uint_byref), "#9");
3543 Assert.IsTrue (uint_byref.IsAssignableFrom (enum2_byref), "#10");
3544 Assert.IsTrue (int_byref.IsAssignableFrom (uint_byref), "#11");
3545 Assert.IsTrue (uint_byref.IsAssignableFrom (int_byref), "#12");
3547 Assert.IsTrue (typeof (object).IsAssignableFrom (typeof (long)), "#13");
3549 Assert.IsTrue (obj_byref.IsAssignableFrom (string_byref), "#14");
3550 Assert.IsTrue (string_byref.IsAssignableFrom (obj_byref), "#15");
3552 Assert.IsFalse (uint_byref.IsAssignableFrom (struct0_byref), "#16");
3553 Assert.IsFalse (struct0_byref.IsAssignableFrom (int_byref), "#17");
3554 Assert.IsFalse (struct0_byref.IsAssignableFrom (struct1_byref), "#18");
3556 Assert.IsFalse (obj_byref.IsAssignableFrom (mvar0_byref), "#19");
3557 Assert.IsFalse (mvar0_byref.IsAssignableFrom (mvar1_byref), "#20");
3558 Assert.IsTrue (mvar0_byref.IsAssignableFrom (mvar0_byref), "#21");
3559 Assert.IsFalse (mvar0_byref.IsAssignableFrom (obj_byref), "#22");
3562 public void Bug331126<T,K> () {}
3564 public struct Size4 {
3568 public struct Size4b {
3572 [Test] // Bug #612780
3573 public void CannotMakeDerivedTypesFromTypedByRef ()
3576 typeof (global::System.TypedReference).MakeArrayType ();
3578 } catch (TypeLoadException) { }
3581 typeof (global::System.TypedReference).MakeByRefType ();
3583 } catch (TypeLoadException) { }
3586 typeof (global::System.TypedReference).MakePointerType ();
3588 } catch (TypeLoadException) { }
3593 public void DeclaringTypeOfGenericNestedTypeInstanceIsOpen ()
3595 var type = typeof (Foo<int>.Nested<string>);
3596 Assert.AreSame (typeof (Foo<>), type.DeclaringType, "#1");
3599 interface IGetInterfaceMap<in T>
3604 class GetInterfaceMap : IGetInterfaceMap<object>
3606 public string Bar (object t)
3608 return t.GetType ().FullName;
3613 public void GetInterfaceMapWorksWithVariantIfaces ()
3615 InterfaceMapping res = typeof (GetInterfaceMap).GetInterfaceMap (typeof (IGetInterfaceMap <object>));
3616 Assert.AreEqual (typeof (IGetInterfaceMap <object>), res.InterfaceType);
3617 Assert.AreEqual (typeof (object), res.InterfaceMethods [0].GetParameters () [0].ParameterType);
3619 res = typeof (GetInterfaceMap).GetInterfaceMap (typeof (IGetInterfaceMap <string>));
3620 Assert.AreEqual (typeof (IGetInterfaceMap <string>), res.InterfaceType);
3621 Assert.AreEqual (typeof (string), res.InterfaceMethods [0].GetParameters () [0].ParameterType);
3625 public class MyType : TypeDelegator {
3628 public override bool Equals (Type t) {
3630 return base.Equals (t);
3633 public override Type UnderlyingSystemType {
3636 return typeof (int);
3642 public void NewV4EqualsBehavior ()
3644 var ta = new MyType ();
3645 var tb = new MyType ();
3646 object a = ta, b = tb;
3649 Assert.AreEqual (1, ta.eq, "#1");
3650 Assert.AreEqual (2, ta.ust, "#2");
3652 Assert.AreEqual (2, ta.eq, "#3");
3653 Assert.AreEqual (3, ta.ust, "#4");
3654 Assert.AreEqual (0, tb.eq, "#5");
3655 Assert.AreEqual (1, tb.ust, "#6");
3658 public enum MyRealEnum : short {
3663 public enum MyRealEnum2 : byte {
3667 public enum MyRealEnum3 : short {
3671 public class MyEnum : TypeDelegator {
3672 public bool is_enum { get; set; }
3673 public int fields { get; set; }
3675 public override bool IsSubclassOf (Type c) {
3676 return c == typeof (Enum) && is_enum;
3679 public override FieldInfo[] GetFields (BindingFlags bindingAttr) {
3682 FieldInfo[] res = new FieldInfo [fields];
3683 for (int i = 0; i < fields; ++i) {
3684 if ((bindingAttr & BindingFlags.Instance) != 0)
3685 res [i] = typeof (MyRealEnum).GetField ("value__");
3687 res [i] = typeof (MyRealEnum).GetField ("A");
3694 public void GetEnumUnderlyingType () {
3697 new MyEnum () { is_enum = false }.GetEnumUnderlyingType ();
3699 } catch (ArgumentException) {}
3702 new MyEnum () { is_enum = true, fields = 0 }.GetEnumUnderlyingType ();
3704 } catch (ArgumentException) {}
3707 new MyEnum () { is_enum = true, fields = 2 }.GetEnumUnderlyingType ();
3709 } catch (ArgumentException) {}
3711 Assert.AreSame (typeof (short), new MyEnum () { is_enum = true, fields = 1 }.GetEnumUnderlyingType ());
3715 public void GetEnumNames () {
3717 new MyEnum () { is_enum = false }.GetEnumNames ();
3719 } catch (ArgumentException) {}
3721 var res = new MyEnum () { is_enum = true, fields = 1 }.GetEnumNames ();
3722 Assert.AreEqual (1, res.Length, "#2");
3723 Assert.AreEqual ("A", res [0], "#3");
3725 res = typeof (MyRealEnum).GetEnumNames ();
3726 Assert.AreEqual (3, res.Length, "#4");
3727 Assert.AreEqual ("A", res [0], "#5");
3728 Assert.AreEqual ("B", res [1], "#6");
3729 Assert.AreEqual ("C", res [2], "#7");
3732 public enum OutOfOrderEnum : sbyte
3734 D = -1, C = 2, B = 1, A = 0
3738 public void GetEnumNamesSortsByUnsignedValue ()
3740 string[] names = typeof (OutOfOrderEnum).GetEnumNames ();
3741 Assert.AreEqual (4, names.Length);
3742 Assert.AreEqual ("A", names [0]);
3743 Assert.AreEqual ("B", names [1]);
3744 Assert.AreEqual ("C", names [2]);
3745 Assert.AreEqual ("D", names [3]);
3749 public void GetEnumValues () {
3751 new MyEnum () { is_enum = false }.GetEnumValues ();
3753 } catch (ArgumentException) {}
3756 new MyEnum () { is_enum = true }.GetEnumValues ();
3758 } catch (NotImplementedException) {}
3760 var array = typeof (MyRealEnum).GetEnumValues ();
3761 Assert.AreEqual (typeof (MyRealEnum[]), array.GetType (), "#3");
3762 MyRealEnum[] res = (MyRealEnum[])array;
3764 Assert.AreEqual (3, res.Length, "#4");
3765 Assert.AreEqual (MyRealEnum.A, res [0], "#5");
3766 Assert.AreEqual (MyRealEnum.B, res [1], "#6");
3767 Assert.AreEqual (MyRealEnum.C, res [2], "#7");
3771 public void GetEnumValue () {
3773 typeof (MyRealEnum).GetEnumName (null);
3775 } catch (ArgumentException) { }
3778 new MyEnum () { is_enum = false }.GetEnumName (99);
3780 } catch (ArgumentException) { }
3783 Assert.IsNull (new MyEnum () { fields = 1, is_enum = true }.GetEnumName (77), "#3");
3784 Assert.AreEqual ("A", new MyEnum () { fields = 1, is_enum = true }.GetEnumName (0), "#4");
3785 Assert.AreEqual ("A", new MyEnum () { fields = 1, is_enum = true }.GetEnumName (MyRealEnum.A), "#5");
3786 Assert.AreEqual ("A", new MyEnum () { fields = 1, is_enum = true }.GetEnumName (MyRealEnum2.A), "#6");
3788 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName (MyRealEnum.A), "#7");
3789 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((short)0), "#8");
3790 Assert.AreEqual ("C", typeof (MyRealEnum).GetEnumName (2), "#9");
3791 Assert.IsNull (typeof (MyRealEnum).GetEnumName (9), "#10");
3793 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((byte)0), "#11");
3794 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((sbyte)0), "#12");
3795 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName (false), "#13");
3796 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((short)0), "#14");
3797 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((ushort)0), "#15");
3798 Assert.IsNull (typeof (MyRealEnum).GetEnumName ('c'), "#16");
3800 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((int)0), "#17");
3801 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((uint)0), "#18");
3803 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((long)0), "#19");
3804 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((ulong)0), "#20");
3807 typeof (MyRealEnum).GetEnumName ((float)0);
3808 Assert.Fail ("#21");
3809 } catch (ArgumentException) { }
3811 typeof (MyRealEnum).GetEnumName ((double)0);
3812 Assert.Fail ("#22");
3813 } catch (ArgumentException) { }
3816 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((byte)0), "#23");
3817 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((sbyte)0), "#24");
3818 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName (false), "#25");
3820 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((short)0), "#26");
3821 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((ushort)0), "#27");
3823 Assert.IsNull (typeof (MyRealEnum2).GetEnumName ('c'), "#28");
3825 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((int)0), "#29");
3826 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((uint)0), "#30");
3828 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((long)0), "#31");
3829 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((ulong)0), "#32");
3832 typeof (MyRealEnum2).GetEnumName ((float)0);
3833 Assert.Fail ("#33");
3834 } catch (ArgumentException) { }
3836 typeof (MyRealEnum2).GetEnumName ((double)0);
3837 Assert.Fail ("#34");
3838 } catch (ArgumentException) { }
3840 Assert.IsNull (typeof (MyRealEnum2).GetEnumName (12345), "#35");
3844 public void IsEnumDefined () {
3846 typeof (MyRealEnum).IsEnumDefined (null);
3848 } catch (ArgumentException) { }
3851 new MyEnum () { is_enum = false }.IsEnumDefined (99);
3853 } catch (ArgumentException) { }
3856 typeof (MyRealEnum).IsEnumDefined (0);
3858 } catch (ArgumentException) { }
3861 typeof (MyRealEnum).IsEnumDefined ((ushort)0);
3863 } catch (ArgumentException) { }
3866 typeof (MyRealEnum).IsEnumDefined (MyRealEnum3.A);
3868 } catch (ArgumentException) { }
3871 typeof (MyRealEnum).IsEnumDefined (true);
3873 } catch (ArgumentException) { }
3876 typeof (MyRealEnum).IsEnumDefined (MyRealEnum2.A);
3878 } catch (ArgumentException) { }
3881 typeof (MyRealEnum).IsEnumDefined (typeof (MyRealEnum));
3883 } catch (InvalidOperationException) { }
3885 Assert.IsTrue (typeof (MyRealEnum).IsEnumDefined ((short)0), "#9");
3886 Assert.IsFalse (typeof (MyRealEnum).IsEnumDefined ((short)88), "#10");
3887 Assert.IsTrue (typeof (MyRealEnum).IsEnumDefined (MyRealEnum.A), "#11");
3888 Assert.IsFalse (typeof (MyRealEnum).IsEnumDefined ("d"), "#12");
3889 Assert.IsTrue (typeof (MyRealEnum).IsEnumDefined ("A"), "#13");
3890 Assert.IsFalse (new MyEnum () { is_enum = true, fields = 1 }.IsEnumDefined ((short)99), "#14");
3895 public class Outer {
3896 public class Inner {}
3900 public class Outer<T> {
3901 public class Inner {}
3905 public void GetTypeWithDelegates () {
3906 var tname = typeof (MyRealEnum).AssemblyQualifiedName;
3907 var res = Type.GetType (tname, name => {
3908 return Assembly.Load (name);
3909 },(asm,name,ignore) => {
3910 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3912 Assert.AreEqual (typeof (MyRealEnum), res, "#1");
3915 tname = typeof (Dictionary<int, string>).AssemblyQualifiedName;
3916 res = Type.GetType (tname, name => {
3917 return Assembly.Load (name);
3918 },(asm,name,ignore) => {
3919 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3921 Assert.AreEqual (typeof (Dictionary<int, string>), res, "#2");
3924 tname = typeof (Foo<int>).AssemblyQualifiedName;
3925 res = Type.GetType (tname, name => {
3926 return Assembly.Load (name);
3927 },(asm,name,ignore) => {
3928 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3930 Assert.AreEqual (typeof (Foo<int>), res, "#3");
3933 tname = typeof (Outer.Inner).AssemblyQualifiedName;
3934 res = Type.GetType (tname, name => {
3935 return Assembly.Load (name);
3936 },(asm,name,ignore) => {
3937 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3939 Assert.AreEqual (typeof (Outer.Inner), res, "#4");
3942 tname = typeof (Outer<double>.Inner).AssemblyQualifiedName;
3943 res = Type.GetType (tname, name => {
3944 return Assembly.Load (name);
3945 },(asm,name,ignore) => {
3946 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3948 Assert.AreEqual (typeof (Outer<double>.Inner), res, "#5");
3951 tname = "System.Collections.Generic.List`1[System.Int32]";
3952 res = Type.GetType (tname, name => {
3953 return Assembly.Load (name);
3954 },(asm,name,ignore) => {
3955 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3957 Assert.AreEqual (typeof (List<int>), res, "#6");
3960 tname = typeof (Foo<>).FullName + "[,][]";
3961 res = Type.GetType (tname, name => {
3962 Console.WriteLine ("resolve-asm name {0}", name);
3963 return Assembly.Load (name);
3964 },(asm,name,ignore) => {
3965 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3967 Assert.AreEqual (typeof (Foo<>).MakeArrayType (2).MakeArrayType (), res, "#7");
3969 tname = string.Format("{0}[{1}][]*&", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName);
3970 res = Type.GetType (tname, name => {
3971 return Assembly.Load (name);
3972 },(asm,name,ignore) => {
3973 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3975 Assert.AreEqual (typeof (Foo<MyRealEnum>[]).MakePointerType ().MakeByRefType (), res, "#8");
3978 tname = typeof (MyRealEnum).FullName + "[][]";
3979 res = Type.GetType (tname, name => {
3980 return Assembly.Load (name);
3981 },(asm,name,ignore) => {
3982 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3984 Assert.AreEqual (typeof (MyRealEnum[][]), res, "#9");
3987 tname = typeof (MyRealEnum).FullName + "[*]";
3988 res = Type.GetType (tname, name => {
3989 return Assembly.Load (name);
3990 },(asm,name,ignore) => {
3991 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
3993 Assert.AreEqual (typeof (MyRealEnum).MakeArrayType (1), res, "#10");
3996 tname = typeof (MyRealEnum).FullName + "&";
3997 res = Type.GetType (tname, name => {
3998 return Assembly.Load (name);
3999 },(asm,name,ignore) => {
4000 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4002 Assert.AreEqual (typeof (MyRealEnum).MakeByRefType (), res, "#11");
4005 tname = typeof (MyRealEnum).FullName + "*";
4006 res = Type.GetType (tname, name => {
4007 return Assembly.Load (name);
4008 },(asm,name,ignore) => {
4009 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4011 Assert.AreEqual (typeof (MyRealEnum).MakePointerType (), res, "#12");
4013 tname = typeof (MyRealEnum).FullName + "*&";
4014 res = Type.GetType (tname, name => {
4015 return Assembly.Load (name);
4016 },(asm,name,ignore) => {
4017 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4019 Assert.AreEqual (typeof (MyRealEnum).MakePointerType ().MakeByRefType(),
4022 tname = typeof (MyRealEnum).FullName + "[,]&";
4023 res = Type.GetType (tname, name => {
4024 return Assembly.Load (name);
4025 },(asm,name,ignore) => {
4026 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4028 Assert.AreEqual (typeof (MyRealEnum).MakeArrayType (2).MakeByRefType (),
4031 tname = typeof (MyRealEnum).FullName + "*[]";
4032 res = Type.GetType (tname, name => {
4033 return Assembly.Load (name);
4034 },(asm,name,ignore) => {
4035 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4037 Assert.AreEqual (typeof (MyRealEnum).MakePointerType().MakeArrayType(),
4040 // not a very useful type, but ought to be parsed correctly
4041 tname = typeof (MyRealEnum).FullName + "[]**[]*&";
4042 res = Type.GetType (tname, name => {
4043 return Assembly.Load (name);
4044 },(asm,name,ignore) => {
4045 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4047 Assert.AreEqual (typeof (MyRealEnum).MakeArrayType().MakePointerType().MakePointerType().MakeArrayType().MakePointerType().MakeByRefType(),
4050 // assembly resolve without type resolve
4051 res = Type.GetType ("System.String,mscorlib", delegate (AssemblyName aname) { return typeof (int).Assembly; }, null);
4052 Assert.AreEqual (typeof (string), res);
4056 public class CustomGetType : TypeDelegator {
4059 public CustomGetType (string name) { this.name = name; }
4061 public override Type MakeGenericType (Type[] args) {
4062 return new CustomGetType ("GINST");
4065 public override Type GetNestedType(String name, BindingFlags bidingAttr) {
4066 return new CustomGetType ("NESTED");
4069 public override string ToString () { return "UT_" + name; }
4071 public override string Name {
4072 get { return "UT_" + name; }
4077 public void GetTypeWithDelegatesAndUserTypes ()
4079 var tname = "Magic[System.Int32]";
4080 var res = Type.GetType (tname, name => {
4081 return Assembly.Load (name);
4082 },(asm,name,ignore) => {
4083 if (name == "Magic") return new CustomGetType ("MAGIC");
4084 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4086 Assert.AreEqual ("UT_GINST", res.Name, "#1");
4089 tname = "Magic+MyRealEnum";
4090 res = Type.GetType (tname, name => {
4091 return Assembly.Load (name);
4092 },(asm,name,ignore) => {
4093 if (name == "Magic") return new CustomGetType ("MAGIC");
4094 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4096 Assert.AreEqual ("UT_NESTED", res.Name, "#2");
4099 void MustTLE (string tname) {
4101 var res = Type.GetType (tname, name => {
4102 return Assembly.Load (name);
4103 },(asm,name,ignore) => {
4104 return (object)asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4106 Assert.Fail (tname);
4107 } catch (TypeLoadException) {}
4110 void MustANE (string tname) {
4112 var res = Type.GetType (tname, name => {
4113 return Assembly.Load (name);
4114 },(asm,name,ignore) => {
4115 return (object)asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4117 Assert.Fail (tname);
4118 } catch (ArgumentNullException) {}
4121 void MustAE_general (string tname, Func<string,Type> getType) {
4123 var res = getType (tname);
4124 Assert.Fail (tname);
4125 } catch (ArgumentException) {}
4128 void MustAE (string typename) {
4129 MustAE_general (typename, tname => {
4130 return Type.GetType (tname, name => {
4131 return Assembly.Load (name);
4132 },(asm,name,ignore) => {
4133 return (object)asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4138 void MustAEnn (string typename) {
4139 MustAE_general (typename, tname => Type.GetType (tname, null, null));
4142 void MustFNFE (string tname) {
4144 var res = Type.GetType (tname, name => {
4145 return Assembly.Load (name);
4146 },(asm,name,ignore) => {
4147 return (object)asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4149 Assert.Fail (tname);
4150 } catch (FileNotFoundException) {}
4154 public void NewGetTypeErrors () {
4156 MustAE ("!@#$%^&*");
4157 MustAE (string.Format ("{0}[{1}&]", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4158 MustAE (string.Format ("{0}[{1}*]", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4159 MustAE (string.Format ("{0}&&", typeof (MyRealEnum).FullName));
4160 MustAE (string.Format ("{0}&*", typeof (MyRealEnum).FullName));
4161 MustAE (string.Format ("{0}&[{1}]", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4162 MustAE (string.Format ("{0}[,", typeof (MyRealEnum).FullName));
4163 MustAE (string.Format ("{0}[*", typeof (MyRealEnum).FullName));
4165 MustAE (string.Format ("{0}[[{1},", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4166 MustAE (string.Format ("{0}[[{1}]", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4167 MustAE (string.Format ("{0}[[{1}],", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4168 MustAE (string.Format ("{0}[[{1}]_", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4170 MustAE (string.Format ("{0}[{1}", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4171 MustAE (string.Format ("{0}[{1},", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
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 (Foo<>).FullName));
4176 MustAE (string.Format ("{0}[**]", typeof (MyRealEnum).FullName));
4177 MustAE (string.Format ("{0}[*,*]", typeof (MyRealEnum).FullName));
4178 MustAE (string.Format ("{0}[*,]", typeof (MyRealEnum).FullName));
4179 MustAE (string.Format ("{0}[,*]", typeof (MyRealEnum).FullName));
4180 MustAE (string.Format ("{0}[,-]", typeof (MyRealEnum).FullName));
4181 MustAE (string.Format ("{0}[,{0}]", typeof (MyRealEnum).FullName));
4183 MustAE (string.Format ("{0}[{1}]]", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4184 MustAE (string.Format ("{0}[,]]", typeof (MyRealEnum).FullName));
4187 string aqn = typeof (MyRealEnum).Assembly.FullName;
4188 MustFNFE (string.Format ("{0}, ZZZ{1}", typeof (MyRealEnum).FullName, aqn));
4189 MustTLE (string.Format ("{0}ZZZZ", typeof (MyRealEnum).FullName));
4190 MustTLE (string.Format ("{0}ZZZZ,{1}", typeof (MyRealEnum).FullName, aqn));
4193 delegate void MyAction<in T>(T ag);
4195 [Test] //bug #668506
4196 public void IsAssignableFromWithVariantDelegate () {
4197 Assert.IsFalse (typeof(MyAction<string>).IsAssignableFrom(typeof(MyAction<>)), "#1");
4201 public void IsAssignableFromWithNullable () {
4202 Console.WriteLine(typeof(IEnumerable<int?>).IsAssignableFrom(typeof(IEnumerable<int>)));
4206 public void GetTypeParseGenericCorrectly () { //Bug #15124
4207 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1"), typeof (Foo<>), "#1");
4208 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32]"), typeof (Foo<int>), "#2");
4209 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[[System.Int32]]"), typeof (Foo<int>), "#3");
4210 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32][]"), typeof (Foo<int>[]), "#4");
4211 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[][System.Int32]"), null, "#5");
4212 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32][,]"), typeof (Foo<int>[,]), "#6");
4213 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[]"), typeof (Foo<>).MakeArrayType(), "#7");
4214 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[,]"), typeof (Foo<>).MakeArrayType (2), "#8");
4215 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[][]"), typeof (Foo<>).MakeArrayType ().MakeArrayType (), "#9");
4216 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1["), null, "#10");
4217 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[["), null, "#11");
4218 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[[]"), null, "#12");
4219 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[,"), null, "#13");
4220 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[*"), null, "#14");
4221 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32"), null, "#15");
4225 public void GetTypeNullDelegatesParseGenericCorrectly () {
4226 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1", null, null), typeof (Foo<>), "#1");
4227 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32]", null, null), typeof (Foo<int>), "#2");
4228 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[[System.Int32]]", null, null), typeof (Foo<int>), "#3");
4229 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32][]", null, null), typeof (Foo<int>[]), "#4");
4230 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32][,]", null, null), typeof (Foo<int>[,]), "#5");
4231 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[]", null, null), typeof (Foo<>).MakeArrayType(), "#6");
4232 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[,]", null, null), typeof (Foo<>).MakeArrayType (2), "#7");
4233 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[][]", null, null), typeof (Foo<>).MakeArrayType ().MakeArrayType (), "#8");
4235 MustAEnn ("MonoTests.System.Foo`1[][System.Int32]");
4236 MustAEnn ("MonoTests.System.Foo`1[");
4237 MustAEnn ("MonoTests.System.Foo`1[[");
4238 MustAEnn ("MonoTests.System.Foo`1[[]");
4239 MustAEnn ("MonoTests.System.Foo`1[,");
4240 MustAEnn ("MonoTests.System.Foo`1[*");
4241 MustAEnn ("MonoTests.System.Foo`1[System.Int32");
4244 Dictionary<int, T> MakeDictHelper<T> (T[] arr) {
4245 return new Dictionary<int, T>();
4249 public void GetTypeAnonymousParseCorrectly () {
4250 var x = new { X = 1 };
4251 var a = new [] { x };
4252 var d = MakeDictHelper (a);
4254 var x_type = x.GetType ();
4255 var a_type = a.GetType ();
4256 var d_type = d.GetType ();
4258 Assert.AreEqual (Type.GetType (x_type.ToString ()), x_type, "#1");
4259 Assert.AreEqual (Type.GetType (x_type.ToString (), null, null), x_type, "#2");
4260 Assert.AreEqual (Type.GetType (a_type.ToString ()), a_type, "#3");
4261 Assert.AreEqual (Type.GetType (a_type.ToString (), null, null), a_type, "#4");
4262 Assert.AreEqual (Type.GetType (d_type.ToString ()), d_type, "#5");
4263 Assert.AreEqual (Type.GetType (d_type.ToString (), null, null), d_type, "#6");
4265 Assert.AreEqual (Type.GetType (x_type.FullName), x_type, "#7");
4266 Assert.AreEqual (Type.GetType (x_type.FullName, null, null), x_type, "#8");
4267 Assert.AreEqual (Type.GetType (a_type.FullName), a_type, "#9");
4268 Assert.AreEqual (Type.GetType (a_type.FullName, null, null), a_type, "#10");
4269 Assert.AreEqual (Type.GetType (d_type.FullName), d_type, "#11");
4270 Assert.AreEqual (Type.GetType (d_type.FullName, null, null), d_type, "#12");
4274 #if !MONOTOUCH && !MOBILE_STATIC
4276 [Category ("AndroidNotWorking")] // requires symbol writer
4277 public void FullNameGetTypeParseEscapeRoundtrip () // bug #26384
4279 var nm = new AssemblyName ("asm");
4280 var ab = AssemblyBuilder.DefineDynamicAssembly (nm,
4281 AssemblyBuilderAccess.Run);
4282 var mb = ab.DefineDynamicModule("m", true);
4283 var tb = mb.DefineType ("NameSpace,+*&[]\\.Type,+*&[]\\",
4284 TypeAttributes.Class | TypeAttributes.Public);
4286 var nestedTb = tb.DefineNestedType("Nested,+*&[]\\",
4287 TypeAttributes.Class | TypeAttributes.NestedPublic);
4289 var ty = tb.CreateType();
4291 var nestedTy = nestedTb.CreateType();
4293 var escapedNestedName =
4294 "NameSpace\\,\\+\\*\\&\\[\\]\\\\"
4296 + "Type\\,\\+\\*\\&\\[\\]\\\\"
4298 + "Nested\\,\\+\\*\\&\\[\\]\\\\";
4300 Assert.AreEqual(escapedNestedName, nestedTy.FullName);
4302 var lookupNestedTy =
4303 Type.GetType(escapedNestedName + "," + nm.FullName,
4305 if (asmName.FullName.Equals(nm.FullName)) return ab;
4306 else return Assembly.Load (asmName);
4308 (asm,name,ignore) => {
4310 return Type.GetType(name, true, ignore);
4311 else return asm.GetType(name, true, ignore);
4315 Assert.AreEqual(nestedTy, lookupNestedTy);
4320 public abstract class Stream : IDisposable
4322 public void Dispose ()
4324 Console.WriteLine ("stream::dispose");
4327 protected virtual void Dispose (bool disposing)
4332 public class NonClosingStream
4333 : Stream, IDisposable
4335 void IDisposable.Dispose()
4337 Console.WriteLine ("ncs::dispose");
4340 public override string ToString () { return ""; }
4343 static bool ContainsProperty (PropertyInfo [] props, string name)
4345 foreach (PropertyInfo p in props)
4351 public class NemerleAttribute : Attribute
4355 public class VolatileModifier : NemerleAttribute
4365 [AttributeUsage (AttributeTargets.Class, Inherited=false)]
4366 public class FooAttribute : Attribute
4370 public class BarAttribute : FooAttribute
4387 [AttributeUsage (AttributeTargets.Class, Inherited=true)]
4388 public class InheritAttribute : Attribute
4392 [AttributeUsage (AttributeTargets.Class, Inherited=false)]
4393 public class NotInheritAttribute : InheritAttribute
4397 [NotInheritAttribute]
4398 public class bug82431A1
4402 public class bug82431A2 : bug82431A1
4406 [NotInheritAttribute]
4408 public class bug82431A3 : bug82431A1
4413 public class bug82431B1
4417 public class bug82431B2 : bug82431B1
4421 [NotInheritAttribute]
4422 public class bug82431B3 : bug82431B2
4426 public class bug82431B4 : bug82431B3
4434 public class Bug77367
4436 public void Run (bool b)
4443 private string PrivInstBlue
4445 get { return null; }
4448 protected string ProtInstBlue
4450 get { return null; }
4453 protected internal string ProIntInstBlue
4455 get { return null; }
4458 public long PubInstBlue
4462 if (PrivInstBlue == null)
4464 return long.MaxValue;
4468 internal int IntInstBlue
4473 private static string PrivStatBlue
4475 get { return null; }
4478 protected static string ProtStatBlue
4480 get { return null; }
4483 protected static internal string ProIntStatBlue
4485 get { return null; }
4488 public static long PubStatBlue
4492 if (PrivStatBlue == null)
4494 return long.MaxValue;
4498 internal static int IntStatBlue
4504 public class Foo : Blue
4506 private string PrivInstBase
4508 get { return null; }
4511 protected string ProtInstBase
4513 get { return null; }
4516 protected internal string ProIntInstBase
4518 get { return null; }
4521 public long PubInstBase
4525 if (PrivInstBase == null)
4527 return long.MaxValue;
4531 internal int IntInstBase
4536 private static string PrivStatBase
4538 get { return null; }
4541 protected static string ProtStatBase
4543 get { return null; }
4546 protected static internal string ProIntStatBase
4548 get { return null; }
4551 public static long PubStatBase
4555 if (PrivStatBase == null)
4557 return long.MaxValue;
4561 internal static int IntStatBase
4567 public class Bar : Foo
4569 private string PrivInst
4571 get { return null; }
4574 protected string ProtInst
4576 get { return null; }
4579 protected internal string ProIntInst
4581 get { return null; }
4588 if (PrivInst == null)
4590 return long.MaxValue;
4594 internal int IntInst
4599 private static string PrivStat
4601 get { return null; }
4604 protected static string ProtStat
4606 get { return null; }
4609 protected static internal string ProIntStat
4611 get { return null; }
4614 public static long PubStat
4618 if (PrivStat == null)
4620 return long.MaxValue;
4624 internal static int IntStat
4650 public CtorsC (int x)
4656 class UserType : Type
4658 protected Type type;
4660 public UserType(Type type) {
4664 public override Type UnderlyingSystemType { get { return this.type; } }
4666 public override Assembly Assembly { get { return this.type == null ? null : this.type.Assembly; } }
4668 public override string AssemblyQualifiedName { get { return null; } }
4670 public override Type BaseType { get { return null; } }
4672 public override Module Module { get { return this.type.Module; } }
4674 public override string Namespace { get { return null; } }
4676 public override bool IsGenericParameter { get { return true; } }
4678 public override RuntimeTypeHandle TypeHandle { get { throw new NotSupportedException(); } }
4680 public override bool ContainsGenericParameters { get { return true; } }
4682 public override string FullName { get { return this.type.Name; } }
4684 public override Guid GUID { get { throw new NotSupportedException(); } }
4687 protected override bool IsArrayImpl() {
4691 protected override bool IsByRefImpl()
4696 protected override bool IsCOMObjectImpl()
4701 protected override bool IsPointerImpl()
4706 protected override bool IsPrimitiveImpl()
4712 protected override TypeAttributes GetAttributeFlagsImpl()
4717 protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder,
4718 CallingConventions callConvention, Type[] types,
4719 ParameterModifier[] modifiers)
4724 public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr)
4729 public override Type GetElementType()
4734 public override EventInfo GetEvent(string name, BindingFlags bindingAttr)
4740 public override FieldInfo GetField(string name, BindingFlags bindingAttr)
4746 public override Type GetInterface(string name, bool ignoreCase)
4751 public override Type[] GetInterfaces()
4756 public override MemberInfo[] GetMembers(BindingFlags bindingAttr)
4761 public override object[] GetCustomAttributes(Type attributeType, bool inherit)
4766 public override object[] GetCustomAttributes(bool inherit)
4771 public override bool IsDefined(Type attributeType, bool inherit)
4776 public override string Name { get { return this.type.Name; } }
4778 public override EventInfo[] GetEvents(BindingFlags bindingAttr)
4780 throw new NotImplementedException();
4783 public override FieldInfo[] GetFields(BindingFlags bindingAttr)
4785 throw new NotImplementedException();
4788 protected override MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder,
4789 CallingConventions callConvention, Type[] types,
4790 ParameterModifier[] modifiers)
4795 public override MethodInfo[] GetMethods(BindingFlags bindingAttr)
4800 public override Type GetNestedType(string name, BindingFlags bindingAttr)
4805 public override Type[] GetNestedTypes(BindingFlags bindingAttr)
4810 public override PropertyInfo[] GetProperties(BindingFlags bindingAttr)
4815 protected override PropertyInfo GetPropertyImpl(string name, BindingFlags bindingAttr, Binder binder,
4816 Type returnType, Type[] types, ParameterModifier[] modifiers)
4821 protected override bool HasElementTypeImpl()
4826 public override object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, object target,
4827 object[] args, ParameterModifier[] modifiers, CultureInfo culture,
4828 string[] namedParameters)
4830 throw new NotSupportedException();
4834 class UserType2 : UserType {
4835 public UserType2 (Type type) : base (type) {
4838 public override Type UnderlyingSystemType { get { return this.type ?? this; } }
4840 public override int GetHashCode()
4844 return type.GetHashCode();