1 // TypeTest.cs - NUnit Test Cases for the System.Type class
4 // Zoltan Varga (vargaz@freemail.hu)
6 // Aleksey Kliger (aleksey@xamarin.com)
8 // (C) 2003 Ximian, Inc. http://www.ximian.com
9 // Copyright (C) 2015 Xamarin, Inc. (http://www.xamarin.com)
12 using NUnit.Framework;
14 using System.Threading;
15 using System.Collections;
16 using System.Collections.Generic;
18 using System.Reflection;
19 #if !MONOTOUCH && !FULL_AOT_RUNTIME
20 using System.Reflection.Emit;
22 using System.Runtime.InteropServices;
24 using System.Globalization;
26 class NoNamespaceClass {
29 namespace MonoTests.System
31 class Super : ICloneable
33 public virtual object Clone ()
48 interface IFace2 : IFace1
53 interface IFace3 : IFace2
68 public abstract int this [byte i] {
72 public abstract int this [int i] {
76 public abstract void TestVoid ();
77 public abstract void TestInt (int i);
80 class DeriveVTable : Base
82 public override int this [byte i] {
86 public override int this [int i] {
90 public override void TestVoid ()
95 public override void TestInt (int i)
101 class NewVTable : DeriveVTable
103 public new int this [byte i] {
107 public new int this [int i] {
111 public new void TestVoid ()
116 public new void TestInt (int i)
121 public void Overload ()
125 public void Overload (int i)
129 public NewVTable (out int i)
134 public void byref_method (out int i)
142 public virtual int Foo {
147 public event EventHandler E;
154 class Derived1 : Base1
156 public override int Foo {
161 class Derived2 : Base1
168 public new event Action E;
169 public new void Dummy ()
180 get { throw new NotImplementedException (); }
183 public T Execute (T a)
188 public class Nested<K> {}
195 public interface IBar<T>
199 public class Baz<T> : IBar<T>
205 public static void Bang<S> () {}
208 public class Bug348522
210 public void Test (int __argument)
215 public class GenericIndexers<T, U>
217 // This class has two indexers that take different
218 // arguments. GetProperties on all instances of this
219 // generic type should still have 2 properties, even
220 // if T and U are instantiated with the same types.
221 public T this[T t] { get { return t; } }
222 public U this[U u] { get { return u; } }
225 public class FirstMethodBinder : Binder
227 public override MethodBase BindToMethod (BindingFlags bindingAttr, MethodBase [] match, ref object [] args,
228 ParameterModifier [] modifiers, CultureInfo culture, string [] names,
235 public override object ChangeType (object value, Type type1, CultureInfo culture)
240 // The rest is just to please the compiler
241 public override FieldInfo BindToField (BindingFlags a, FieldInfo[] b, object c, CultureInfo d)
246 public override void ReorderArgumentArray(ref object[] a, object b)
250 public override MethodBase SelectMethod(BindingFlags a, MethodBase[] b, Type[] c, ParameterModifier[] d)
255 public override PropertyInfo SelectProperty(BindingFlags a, PropertyInfo[] b, Type c, Type[] d, ParameterModifier[] e)
262 public class TypeTest
264 #if !MONOTOUCH && !FULL_AOT_RUNTIME
265 private ModuleBuilder module;
267 const string ASSEMBLY_NAME = "MonoTests.System.TypeTest";
268 static int typeIndexer = 0;
269 static bool isMono = Type.GetType ("Mono.Runtime", false) != null;
274 AssemblyName assemblyName = new AssemblyName ();
275 assemblyName.Name = ASSEMBLY_NAME;
276 #if !MONOTOUCH && !FULL_AOT_RUNTIME
277 var assembly = AppDomain.CurrentDomain.DefineDynamicAssembly (
278 assemblyName, AssemblyBuilderAccess.RunAndSave, Path.GetTempPath ());
279 module = assembly.DefineDynamicModule ("module1");
283 private string genTypeName ()
285 return "t" + (typeIndexer++);
288 private void ByrefMethod (ref int i, ref Derived1 j, ref Base1 k)
292 public interface IFace {
295 private void GenericMethod<Q, T1> (Q q, T1 t) where T1 : IFace
299 private void GenericMethod2<A, B, C, D> ()
303 where D : Baz<object>
313 public void TestIsAssignableFrom ()
315 // Simple tests for inheritance
316 Assert.AreEqual (typeof (Super).IsAssignableFrom (typeof (Duper)) , true, "#01");
317 Assert.AreEqual (typeof (Duper).IsAssignableFrom (typeof (Duper)), true, "#02");
318 Assert.AreEqual (typeof (Object).IsAssignableFrom (typeof (Duper)), true, "#03");
319 Assert.AreEqual (typeof (ICloneable).IsAssignableFrom (typeof (Duper)), true, "#04");
322 Assert.AreEqual (typeof (Super[]).IsAssignableFrom (typeof (Duper[])), true, "#05");
323 Assert.AreEqual (typeof (Duper[]).IsAssignableFrom (typeof (Super[])), false, "#06");
324 Assert.AreEqual (typeof (Object[]).IsAssignableFrom (typeof (Duper[])), true, "#07");
325 Assert.AreEqual (typeof (ICloneable[]).IsAssignableFrom (typeof (Duper[])), true, "#08");
327 // Tests for multiple dimensional arrays
328 Assert.AreEqual (typeof (Super[][]).IsAssignableFrom (typeof (Duper[][])), true, "#09");
329 Assert.AreEqual (typeof (Duper[][]).IsAssignableFrom (typeof (Super[][])), false, "#10");
330 Assert.AreEqual (typeof (Object[][]).IsAssignableFrom (typeof (Duper[][])), true, "#11");
331 Assert.AreEqual (typeof (ICloneable[][]).IsAssignableFrom (typeof (Duper[][])), true, "#12");
333 // Tests for vectors<->one dimensional arrays */
334 Array arr1 = Array.CreateInstance (typeof (int), new int[] {1}, new int[] {0});
335 Array arr2 = Array.CreateInstance (typeof (int), new int[] {1}, new int[] {10});
337 Assert.AreEqual (typeof (int[]).IsAssignableFrom (arr1.GetType ()), true, "#13");
338 Assert.AreEqual (typeof (int[]).IsAssignableFrom (arr2.GetType ()), false, "#14");
340 // Test that arrays of enums can be cast to their base types
341 Assert.AreEqual (typeof (int[]).IsAssignableFrom (typeof (TypeCode[])), true, "#15");
343 // Test that arrays of valuetypes can't be cast to arrays of
345 Assert.AreEqual (typeof (object[]).IsAssignableFrom (typeof (TypeCode[])), false, "#16");
346 Assert.AreEqual (typeof (ValueType[]).IsAssignableFrom (typeof (TypeCode[])), false, "#17");
347 Assert.AreEqual (typeof (Enum[]).IsAssignableFrom (typeof (TypeCode[])), false, "#18");
349 // Test that arrays of enums can't be cast to arrays of references
350 Assert.AreEqual (typeof (object[]).IsAssignableFrom (typeof (TheEnum[])), false, "#19");
351 Assert.AreEqual (typeof (ValueType[]).IsAssignableFrom (typeof (TheEnum[])), false, "#20");
352 Assert.AreEqual (typeof (Enum[]).IsAssignableFrom (typeof (TheEnum[])), false, "#21");
354 // Check that ValueType and Enum are recognized as reference types
355 Assert.AreEqual (typeof (object).IsAssignableFrom (typeof (ValueType)), true, "#22");
356 Assert.AreEqual (typeof (object).IsAssignableFrom (typeof (Enum)), true, "#23");
357 Assert.AreEqual (typeof (ValueType).IsAssignableFrom (typeof (Enum)), true, "#24");
359 Assert.AreEqual (typeof (object[]).IsAssignableFrom (typeof (ValueType[])), true, "#25");
360 Assert.AreEqual (typeof (ValueType[]).IsAssignableFrom (typeof (ValueType[])), true, "#26");
361 Assert.AreEqual (typeof (Enum[]).IsAssignableFrom (typeof (ValueType[])), false, "#27");
363 Assert.AreEqual (typeof (object[]).IsAssignableFrom (typeof (Enum[])), true, "#28");
364 Assert.AreEqual (typeof (ValueType[]).IsAssignableFrom (typeof (Enum[])), true, "#29");
365 Assert.AreEqual (typeof (Enum[]).IsAssignableFrom (typeof (Enum[])), true, "#30");
367 // Tests for byref types
368 MethodInfo mi = typeof (TypeTest).GetMethod ("ByrefMethod", BindingFlags.Instance|BindingFlags.NonPublic);
369 Assert.IsTrue (mi.GetParameters ()[2].ParameterType.IsAssignableFrom (mi.GetParameters ()[1].ParameterType));
370 Assert.IsTrue (mi.GetParameters ()[1].ParameterType.IsAssignableFrom (mi.GetParameters ()[1].ParameterType));
372 // Tests for type parameters
373 mi = typeof (TypeTest).GetMethod ("GenericMethod", BindingFlags.Instance|BindingFlags.NonPublic);
374 Assert.IsTrue (mi.GetParameters ()[0].ParameterType.IsAssignableFrom (mi.GetParameters ()[0].ParameterType));
375 Assert.IsFalse (mi.GetParameters ()[0].ParameterType.IsAssignableFrom (typeof (int)));
377 // Tests for parameters with generic constraints
378 mi = typeof (TypeTest).GetMethod ("GenericMethod", BindingFlags.Instance|BindingFlags.NonPublic);
379 Assert.IsTrue (typeof (IFace).IsAssignableFrom (mi.GetParameters ()[1].ParameterType));
381 // Transitivity of IsAssignableFrom for type parameters
382 mi = typeof (TypeTest).GetMethod ("GenericMethod2", BindingFlags.Instance|BindingFlags.NonPublic);
383 var gparams = mi.GetGenericArguments ();
384 // B : Duper since B : C and C : Duper
385 Assert.IsTrue (typeof (Duper).IsAssignableFrom (gparams[1]), "#36");
386 // A : Duper since A : B and B : Duper
387 Assert.IsTrue (typeof (Duper).IsAssignableFrom (gparams[0]), "#37a");
388 // A : IFace since A : IFace
389 Assert.IsTrue (typeof (IFace).IsAssignableFrom (gparams[0]), "#37b");
390 // B : Super since B : Duper and Duper : Super
391 Assert.IsTrue (typeof (Super).IsAssignableFrom (gparams[1]), "#38");
392 // A : Super since A : B and B : Super
393 Assert.IsTrue (typeof (Super).IsAssignableFrom (gparams[0]), "#39");
394 // D : IBar<object> since D : Baz<object> and Baz<object> : IBar<object>
395 Assert.IsTrue (typeof (IBar<object>).IsAssignableFrom (gparams [3]), "#40");
396 // A not assignable from B since A : B
397 Assert.IsFalse (gparams[0].IsAssignableFrom (gparams [1]), "#41");
398 Assert.IsFalse (gparams[0].IsAssignableFrom (gparams [2]), "#42");
400 // A is not assignable from Array and Delegate and vice versa
401 Assert.IsFalse (gparams[0].IsAssignableFrom (typeof (Array)), "#43");
402 Assert.IsFalse (gparams[0].IsAssignableFrom (typeof (Delegate)), "#44");
403 Assert.IsFalse (typeof (Array).IsAssignableFrom (gparams[0]), "#45");
404 Assert.IsFalse (typeof (Delegate).IsAssignableFrom (gparams[0]), "#46");
409 public void GenericParameterBaseType ()
411 var mi = typeof (TypeTest).GetMethod ("GenericMethod2", BindingFlags.Instance|BindingFlags.NonPublic);
412 var gparams = mi.GetGenericArguments ();
414 // From the .NET documentation: BaseType property of a
415 // gparam is "object" if its only constraints are other
416 // gparams or interfaces, otherwise if it has a class
417 // constraint that class is the BaseType.
419 // A : B where B is a gparam, and A : IFace which is an
420 // interface, so A.BaseType is object
421 Assert.AreEqual (typeof (object), gparams[0].BaseType, "#1");
422 // B : C where C is a gparam, so B.BaseType is object
423 Assert.AreEqual (typeof (object), gparams[1].BaseType, "#2");
424 // C : Duper where Duper is a class, so A.BaseType is Duper
425 Assert.AreEqual (typeof (Duper), gparams[2].BaseType, "#3");
427 Assert.AreEqual (typeof (Baz<object>), gparams[3].BaseType, "#4");
431 [ExpectedException (typeof (ArgumentException))]
432 public void GetInterfaceMapOnInterface ()
434 typeof (IList).GetInterfaceMap (typeof (ICollection));
438 public void TestIsSubclassOf ()
440 Assert.IsTrue (typeof (ICloneable).IsSubclassOf (typeof (object)), "#01");
442 // Tests for byref types
443 Type paramType = typeof (TypeTest).GetMethod ("ByrefMethod", BindingFlags.Instance|BindingFlags.NonPublic).GetParameters () [0].ParameterType;
444 Assert.IsFalse (paramType.IsSubclassOf (typeof(ValueType)), "#02");
445 Assert.IsNull (paramType.BaseType, "#02-b");
446 Assert.IsTrue (paramType.IsSubclassOf (typeof (Object)), "#03");
447 Assert.IsFalse (paramType.IsSubclassOf (paramType), "#04");
451 public void TestGetMethodImpl ()
453 // Test binding of new slot methods (using no types)
454 Assert.AreEqual (typeof (Base), typeof (Base).GetMethod("TestVoid").DeclaringType, "#01");
455 Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetMethod ("TestVoid").DeclaringType, "#02");
457 // Test binding of new slot methods (using types)
458 Assert.AreEqual (typeof (Base), typeof (Base).GetMethod ("TestInt", new Type[] { typeof (int) }).DeclaringType, "#03");
459 Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetMethod ("TestInt", new Type[] { typeof (int) }).DeclaringType, "#04");
461 // Test overload resolution
462 Assert.AreEqual (0, typeof (NewVTable).GetMethod ("Overload", new Type[0]).GetParameters ().Length, "#05");
464 // Test byref parameters
465 Assert.AreEqual (null, typeof (NewVTable).GetMethod ("byref_method", new Type[] { typeof (int) }), "#06");
466 Type byrefInt = typeof (NewVTable).GetMethod ("byref_method").GetParameters ()[0].ParameterType;
467 Assert.IsNotNull (typeof (NewVTable).GetMethod ("byref_method", new Type[] { byrefInt }), "#07");
471 public void TestGetPropertyImpl ()
473 // Test getting property that is exact
474 Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetProperty ("Item", new Type[1] { typeof (Int32) }).DeclaringType, "#01");
476 // Test getting property that is not exact
477 Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetProperty ("Item", new Type[1] { typeof (Int16) }).DeclaringType, "#02");
479 // Test overriding of properties when only the set accessor is overriden
480 Assert.AreEqual (1, typeof (Derived1).GetProperties ().Length, "#03");
484 public void GetEvents ()
487 Assert.AreEqual (1, typeof (Derived2).GetEvents ().Length);
488 Assert.AreEqual (typeof (Derived2), typeof (Derived2).GetEvents ()[0].DeclaringType);
492 public void GetProperties ()
494 // Test hide-by-name-and-signature
495 Assert.AreEqual (1, typeof (Derived2).GetProperties ().Length, "#1");
496 Assert.AreEqual (typeof (Derived2), typeof (Derived2).GetProperties ()[0].DeclaringType, "#2");
498 // For generics, hide-by-name-and-signature works on the unexpanded types. The
499 // GenericIndexers<T,U> class has two indexers that take different arguments.
500 // GetProperties on all instances of this generic type should still have 2 properties,
501 // even if T and U are instantiated with the same types.
503 var ps = typeof (GenericIndexers<int,int>).GetProperties ();
504 Assert.AreEqual (2, ps.Length, "#3");
505 for (int i = 0; i < ps.Length; i++) {
508 var getterResultType = p.GetGetMethod ().ReturnType;
510 var msg = String.Format ("#4-{0}", i);
511 Assert.AreEqual (typeof (int), getterResultType, msg);
516 class GetProperties_Overrides_Input
518 public class TestClass : BaseClass<object>
520 public override object TestProperty { get; set; }
523 public abstract class BaseClass<T>
525 public virtual T TestProperty { get; set; }
528 public class TestClass_Indexer : BaseClass_Indexer<object>
530 public override object this[int arg] { set { } }
533 public abstract class BaseClass_Indexer<T>
535 public virtual T this[int arg] { set { } }
538 public interface IB : IA<object>
540 new object TestProperty { get; set; }
543 public interface IA<T>
545 T TestProperty { get; set; }
548 public class TestClass_HiddenProperty : BaseClass_HiddenProperty
550 public new virtual string Prop { set { } }
553 public class BaseClass_HiddenProperty
555 public virtual string Prop { set { } }
560 public void GetProperties_Overrides ()
562 Assert.AreEqual (1, typeof (GetProperties_Overrides_Input.IB).GetProperties().Length);
564 var prop = typeof (GetProperties_Overrides_Input.TestClass).GetProperty ("TestProperty");
565 Assert.AreEqual (typeof (GetProperties_Overrides_Input.TestClass), prop.DeclaringType);
567 var prop_2 = typeof (GetProperties_Overrides_Input.TestClass_HiddenProperty).GetProperty ("Prop");
568 Assert.AreEqual (typeof (GetProperties_Overrides_Input.TestClass_HiddenProperty), prop_2.DeclaringType);
570 Assert.AreEqual (1, typeof (GetProperties_Overrides_Input.TestClass).GetProperties().Length);
571 Assert.AreEqual (1, typeof (GetProperties_Overrides_Input.TestClass_Indexer).GetProperties().Length);
572 Assert.AreEqual (1, typeof (GetProperties_Overrides_Input.TestClass_HiddenProperty).GetProperties().Length);
575 [Test] // GetProperties (BindingFlags)
576 public void GetProperties_Flags ()
578 PropertyInfo [] props;
579 Type type = typeof (Bar);
582 flags = BindingFlags.Instance | BindingFlags.NonPublic;
583 props = type.GetProperties (flags);
585 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#A1");
586 Assert.IsTrue (ContainsProperty (props, "ProtInstBase"), "#A2");
587 Assert.IsTrue (ContainsProperty (props, "ProIntInstBase"), "#A3");
588 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#A4");
589 Assert.IsTrue (ContainsProperty (props, "IntInstBase"), "#A5");
590 Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#A6");
591 Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#A7");
592 Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#A8");
593 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#A9");
594 Assert.IsTrue (ContainsProperty (props, "IntInst"), "#A10");
595 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#A11");
596 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#A12");
597 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#A13");
598 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#A14");
599 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#A15");
600 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#A16");
601 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#A17");
602 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#A18");
603 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#A19");
604 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#A20");
605 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#A21");
606 Assert.IsTrue (ContainsProperty (props, "ProtInstBlue"), "#A22");
607 Assert.IsTrue (ContainsProperty (props, "ProIntInstBlue"), "#A23");
608 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#A24");
609 Assert.IsTrue (ContainsProperty (props, "IntInstBlue"), "#A25");
610 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#A26");
611 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#A27");
612 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#A28");
613 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#A29");
614 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#A30");
616 flags = BindingFlags.Instance | BindingFlags.Public;
617 props = type.GetProperties (flags);
619 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#B1");
620 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#B2");
621 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#B3");
622 Assert.IsTrue (ContainsProperty (props, "PubInstBase"), "#B4");
623 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#B5");
624 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#B6");
625 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#B7");
626 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#B8");
627 Assert.IsTrue (ContainsProperty (props, "PubInst"), "#B9");
628 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#B10");
629 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#B11");
630 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#B12");
631 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#B13");
632 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#B14");
633 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#B15");
634 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#B16");
635 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#B17");
636 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#B18");
637 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#B19");
638 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#B20");
639 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#B21");
640 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#B22");
641 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#B23");
642 Assert.IsTrue (ContainsProperty (props, "PubInstBlue"), "#B24");
643 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#B25");
644 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#B26");
645 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#B27");
646 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#B28");
647 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#B29");
648 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#B30");
650 flags = BindingFlags.Static | BindingFlags.Public;
651 props = type.GetProperties (flags);
653 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#C1");
654 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#C2");
655 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#C3");
656 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#C4");
657 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#C5");
658 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#C6");
659 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#C7");
660 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#C8");
661 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#C9");
662 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#C10");
663 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#C11");
664 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#C12");
665 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#C13");
666 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#C14");
667 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#C15");
668 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#C16");
669 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#C17");
670 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#C18");
671 Assert.IsTrue (ContainsProperty (props, "PubStat"), "#C19");
672 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#C20");
673 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#C21");
674 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#C22");
675 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#C23");
676 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#C24");
677 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#C25");
678 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#C26");
679 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#C27");
680 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#C28");
681 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#C29");
682 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#C30");
684 flags = BindingFlags.Static | BindingFlags.NonPublic;
685 props = type.GetProperties (flags);
687 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#D1");
688 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#D2");
689 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#D3");
690 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#D4");
691 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#D5");
692 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#D6");
693 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#D7");
694 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#D8");
695 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#D9");
696 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#D10");
697 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#D11");
698 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#D12");
699 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#D13");
700 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#D14");
701 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#D15");
702 Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#D16");
703 Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#D17");
704 Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#D18");
705 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#D19");
706 Assert.IsTrue (ContainsProperty (props, "IntStat"), "#D20");
707 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#D21");
708 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#D22");
709 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#D23");
710 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#D24");
711 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#D25");
712 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#D26");
713 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#D27");
714 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#D28");
715 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#D29");
716 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#D30");
718 flags = BindingFlags.Instance | BindingFlags.NonPublic |
719 BindingFlags.FlattenHierarchy;
720 props = type.GetProperties (flags);
722 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#E1");
723 Assert.IsTrue (ContainsProperty (props, "ProtInstBase"), "#E2");
724 Assert.IsTrue (ContainsProperty (props, "ProIntInstBase"), "#E3");
725 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#E4");
726 Assert.IsTrue (ContainsProperty (props, "IntInstBase"), "#E5");
727 Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#E6");
728 Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#E7");
729 Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#E8");
730 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#E9");
731 Assert.IsTrue (ContainsProperty (props, "IntInst"), "#E10");
732 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#E11");
733 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#E12");
734 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#E13");
735 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#E14");
736 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#E15");
737 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#E16");
738 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#E17");
739 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#E18");
740 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#E19");
741 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#E20");
742 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#E21");
743 Assert.IsTrue (ContainsProperty (props, "ProtInstBlue"), "#E22");
744 Assert.IsTrue (ContainsProperty (props, "ProIntInstBlue"), "#E23");
745 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#E24");
746 Assert.IsTrue (ContainsProperty (props, "IntInstBlue"), "#E25");
747 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#E26");
748 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#E27");
749 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#E28");
750 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#E29");
751 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#E30");
753 flags = BindingFlags.Instance | BindingFlags.Public |
754 BindingFlags.FlattenHierarchy;
755 props = type.GetProperties (flags);
757 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#F1");
758 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#F2");
759 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#F3");
760 Assert.IsTrue (ContainsProperty (props, "PubInstBase"), "#F4");
761 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#F5");
762 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#F6");
763 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#F7");
764 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#F8");
765 Assert.IsTrue (ContainsProperty (props, "PubInst"), "#F9");
766 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#F10");
767 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#F11");
768 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#F12");
769 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#F13");
770 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#F14");
771 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#F15");
772 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#F16");
773 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#F17");
774 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#F18");
775 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#F19");
776 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#F20");
777 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#F21");
778 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#F22");
779 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#F23");
780 Assert.IsTrue (ContainsProperty (props, "PubInstBlue"), "#F24");
781 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#F25");
782 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#F26");
783 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#F27");
784 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#F28");
785 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#F29");
786 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#F30");
788 flags = BindingFlags.Static | BindingFlags.Public |
789 BindingFlags.FlattenHierarchy;
790 props = type.GetProperties (flags);
792 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#G1");
793 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#G2");
794 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#G3");
795 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#G4");
796 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#G5");
797 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#G6");
798 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#G7");
799 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#G8");
800 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#G9");
801 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#G10");
802 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#G11");
803 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#G12");
804 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#G13");
805 Assert.IsTrue (ContainsProperty (props, "PubStatBase"), "#G14");
806 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#G15");
807 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#G16");
808 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#G17");
809 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#G18");
810 Assert.IsTrue (ContainsProperty (props, "PubStat"), "#G19");
811 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#G20");
812 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#G21");
813 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#G22");
814 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#G23");
815 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#G24");
816 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#G25");
817 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#G26");
818 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#G27");
819 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#G28");
820 Assert.IsTrue (ContainsProperty (props, "PubStatBlue"), "#G29");
821 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#G30");
823 flags = BindingFlags.Static | BindingFlags.NonPublic |
824 BindingFlags.FlattenHierarchy;
825 props = type.GetProperties (flags);
827 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#H1");
828 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#H2");
829 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#H3");
830 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#H4");
831 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#H5");
832 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#H6");
833 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#H7");
834 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#H8");
835 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#H9");
836 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#H10");
837 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#H11");
838 Assert.IsTrue (ContainsProperty (props, "ProtStatBase"), "#H12");
839 Assert.IsTrue (ContainsProperty (props, "ProIntStatBase"), "#H13");
840 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#H14");
841 Assert.IsTrue (ContainsProperty (props, "IntStatBase"), "#H15");
842 Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#H16");
843 Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#H17");
844 Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#H18");
845 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#H19");
846 Assert.IsTrue (ContainsProperty (props, "IntStat"), "#H20");
847 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#H21");
848 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#H22");
849 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#H23");
850 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#H24");
851 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#H25");
852 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#H26");
853 Assert.IsTrue (ContainsProperty (props, "ProtStatBlue"), "#H27");
854 Assert.IsTrue (ContainsProperty (props, "ProIntStatBlue"), "#H28");
855 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#H29");
856 Assert.IsTrue (ContainsProperty (props, "IntStatBlue"), "#H30");
858 flags = BindingFlags.Instance | BindingFlags.NonPublic |
859 BindingFlags.DeclaredOnly;
860 props = type.GetProperties (flags);
862 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#I1");
863 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#I2");
864 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#I3");
865 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#I4");
866 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#I5");
867 Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#I6");
868 Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#I7");
869 Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#I8");
870 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#I9");
871 Assert.IsTrue (ContainsProperty (props, "IntInst"), "#I10");
872 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#I11");
873 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#I12");
874 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#I13");
875 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#I14");
876 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#I15");
877 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#I16");
878 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#I17");
879 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#I18");
880 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#I19");
881 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#I20");
882 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#I21");
883 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#I22");
884 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#I23");
885 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#I24");
886 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#I25");
887 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#I26");
888 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#I27");
889 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#I28");
890 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#I29");
891 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#I30");
893 flags = BindingFlags.Instance | BindingFlags.Public |
894 BindingFlags.DeclaredOnly;
895 props = type.GetProperties (flags);
897 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#J1");
898 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#J2");
899 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#J3");
900 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#J4");
901 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#J5");
902 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#J6");
903 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#J7");
904 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#J8");
905 Assert.IsTrue (ContainsProperty (props, "PubInst"), "#J9");
906 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#J10");
907 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#J11");
908 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#J12");
909 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#J13");
910 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#J14");
911 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#J15");
912 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#J16");
913 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#J17");
914 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#J18");
915 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#J19");
916 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#J20");
917 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#J21");
918 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#J22");
919 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#J23");
920 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#J24");
921 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#J25");
922 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#J26");
923 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#J27");
924 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#J28");
925 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#J29");
926 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#J30");
928 flags = BindingFlags.Static | BindingFlags.Public |
929 BindingFlags.DeclaredOnly;
930 props = type.GetProperties (flags);
932 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#K1");
933 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#K2");
934 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#K3");
935 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#K4");
936 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#K5");
937 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#K6");
938 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#K7");
939 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#K8");
940 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#K9");
941 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#K10");
942 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#K11");
943 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#K12");
944 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#K13");
945 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#K14");
946 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#K15");
947 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#K16");
948 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#K17");
949 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#K18");
950 Assert.IsTrue (ContainsProperty (props, "PubStat"), "#K19");
951 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#K20");
952 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#K21");
953 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#K22");
954 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#K23");
955 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#K24");
956 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#K25");
957 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#K26");
958 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#K27");
959 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#K28");
960 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#K29");
961 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#K30");
963 flags = BindingFlags.Static | BindingFlags.NonPublic |
964 BindingFlags.DeclaredOnly;
965 props = type.GetProperties (flags);
967 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#L1");
968 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#L2");
969 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#L3");
970 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#L4");
971 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#L5");
972 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#L6");
973 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#L7");
974 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#L8");
975 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#L9");
976 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#L10");
977 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#L11");
978 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#L12");
979 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#L13");
980 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#L14");
981 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#L15");
982 Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#L16");
983 Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#L17");
984 Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#L18");
985 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#L19");
986 Assert.IsTrue (ContainsProperty (props, "IntStat"), "#L20");
987 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#L21");
988 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#L22");
989 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#L23");
990 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#L24");
991 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#L25");
992 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#L26");
993 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#L27");
994 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#L28");
995 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#L29");
996 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#L30");
998 flags = BindingFlags.Instance | BindingFlags.NonPublic |
1000 props = type.GetProperties (flags);
1002 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#M1");
1003 Assert.IsTrue (ContainsProperty (props, "ProtInstBase"), "#M2");
1004 Assert.IsTrue (ContainsProperty (props, "ProIntInstBase"), "#M3");
1005 Assert.IsTrue (ContainsProperty (props, "PubInstBase"), "#M4");
1006 Assert.IsTrue (ContainsProperty (props, "IntInstBase"), "#M5");
1007 Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#M6");
1008 Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#M7");
1009 Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#M8");
1010 Assert.IsTrue (ContainsProperty (props, "PubInst"), "#M9");
1011 Assert.IsTrue (ContainsProperty (props, "IntInst"), "#M10");
1012 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#M11");
1013 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#M12");
1014 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#M13");
1015 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#M14");
1016 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#M15");
1017 Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#M16");
1018 Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#M17");
1019 Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#M18");
1020 Assert.IsFalse (ContainsProperty (props, "PubStat"), "#M19");
1021 Assert.IsFalse (ContainsProperty (props, "IntStat"), "#M20");
1022 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#M21");
1023 Assert.IsTrue (ContainsProperty (props, "ProtInstBlue"), "#M22");
1024 Assert.IsTrue (ContainsProperty (props, "ProIntInstBlue"), "#M23");
1025 Assert.IsTrue (ContainsProperty (props, "PubInstBlue"), "#M24");
1026 Assert.IsTrue (ContainsProperty (props, "IntInstBlue"), "#M25");
1027 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#M26");
1028 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#M27");
1029 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#M28");
1030 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#M29");
1031 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#M30");
1033 flags = BindingFlags.Static | BindingFlags.NonPublic |
1034 BindingFlags.Public;
1035 props = type.GetProperties (flags);
1037 Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#N1");
1038 Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#N2");
1039 Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#N3");
1040 Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#N4");
1041 Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#N5");
1042 Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#N6");
1043 Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#N7");
1044 Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#N8");
1045 Assert.IsFalse (ContainsProperty (props, "PubInst"), "#N9");
1046 Assert.IsFalse (ContainsProperty (props, "IntInst"), "#N10");
1047 Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#N11");
1048 Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#N12");
1049 Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#N13");
1050 Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#N14");
1051 Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#N15");
1052 Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#N16");
1053 Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#N17");
1054 Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#N18");
1055 Assert.IsTrue (ContainsProperty (props, "PubStat"), "#N19");
1056 Assert.IsTrue (ContainsProperty (props, "IntStat"), "#N20");
1057 Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#N21");
1058 Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#N22");
1059 Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#N23");
1060 Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#N24");
1061 Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#N25");
1062 Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#N26");
1063 Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#N27");
1064 Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#N28");
1065 Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#N29");
1066 Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#N30");
1069 [Test] // GetProperty (String)
1070 public void GetProperty1_Name_Null ()
1072 Type type = typeof (Bar);
1074 type.GetProperty ((string) null);
1076 } catch (ArgumentNullException ex) {
1077 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1078 Assert.IsNull (ex.InnerException, "#3");
1079 Assert.IsNotNull (ex.Message, "#4");
1080 Assert.IsNotNull (ex.ParamName, "#5");
1081 Assert.AreEqual ("name", ex.ParamName, "#6");
1085 [Test] // GetProperty (String, BindingFlags)
1086 public void GetProperty2 ()
1088 Type type = typeof (Bar);
1091 flags = BindingFlags.Instance | BindingFlags.NonPublic;
1093 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#A1");
1094 Assert.IsNotNull (type.GetProperty ("ProtInstBase", flags), "#A2");
1095 Assert.IsNotNull (type.GetProperty ("ProIntInstBase", flags), "#A3");
1096 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#A4");
1097 Assert.IsNotNull (type.GetProperty ("IntInstBase", flags), "#A5");
1098 Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#A6");
1099 Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#A7");
1100 Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#A8");
1101 Assert.IsNull (type.GetProperty ("PubInst", flags), "#A9");
1102 Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#A10");
1103 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#A11");
1104 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#A12");
1105 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#A13");
1106 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#A14");
1107 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#A15");
1108 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#A16");
1109 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#A17");
1110 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#A18");
1111 Assert.IsNull (type.GetProperty ("PubStat", flags), "#A19");
1112 Assert.IsNull (type.GetProperty ("IntStat", flags), "#A20");
1113 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#A21");
1114 Assert.IsNotNull (type.GetProperty ("ProtInstBlue", flags), "#A22");
1115 Assert.IsNotNull (type.GetProperty ("ProIntInstBlue", flags), "#A23");
1116 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#A24");
1117 Assert.IsNotNull (type.GetProperty ("IntInstBlue", flags), "#A25");
1118 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#A26");
1119 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#A27");
1120 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#A28");
1121 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#A29");
1122 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#A30");
1124 flags = BindingFlags.Instance | BindingFlags.Public;
1126 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#B1");
1127 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#B2");
1128 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#B3");
1129 Assert.IsNotNull (type.GetProperty ("PubInstBase", flags), "#B4");
1130 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#B5");
1131 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#B6");
1132 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#B7");
1133 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#B8");
1134 Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#B9");
1135 Assert.IsNull (type.GetProperty ("IntInst", flags), "#B10");
1136 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#B11");
1137 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#B12");
1138 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#B13");
1139 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#B14");
1140 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#B15");
1141 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#B16");
1142 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#B17");
1143 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#B18");
1144 Assert.IsNull (type.GetProperty ("PubStat", flags), "#B19");
1145 Assert.IsNull (type.GetProperty ("IntStat", flags), "#B20");
1146 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#B21");
1147 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#B22");
1148 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#B23");
1149 Assert.IsNotNull (type.GetProperty ("PubInstBlue", flags), "#B24");
1150 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#B25");
1151 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#B26");
1152 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#B27");
1153 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#B28");
1154 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#B29");
1155 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#B30");
1157 flags = BindingFlags.Static | BindingFlags.Public;
1159 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#C1");
1160 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#C2");
1161 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#C3");
1162 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#C4");
1163 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#C5");
1164 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#C6");
1165 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#C7");
1166 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#C8");
1167 Assert.IsNull (type.GetProperty ("PubInst", flags), "#C9");
1168 Assert.IsNull (type.GetProperty ("IntInst", flags), "#C10");
1169 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#C11");
1170 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#C12");
1171 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#C13");
1172 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#C14");
1173 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#C15");
1174 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#C16");
1175 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#C17");
1176 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#C18");
1177 Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#C19");
1178 Assert.IsNull (type.GetProperty ("IntStat", flags), "#C20");
1179 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#C21");
1180 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#C22");
1181 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#C23");
1182 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#C24");
1183 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#C25");
1184 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#C26");
1185 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#C27");
1186 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#C28");
1187 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#C29");
1188 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#C30");
1190 flags = BindingFlags.Static | BindingFlags.NonPublic;
1192 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#D1");
1193 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#D2");
1194 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#D3");
1195 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#D4");
1196 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#D5");
1197 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#D6");
1198 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#D7");
1199 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#D8");
1200 Assert.IsNull (type.GetProperty ("PubInst", flags), "#D9");
1201 Assert.IsNull (type.GetProperty ("IntInst", flags), "#D10");
1202 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#D11");
1203 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#D12");
1204 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#D13");
1205 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#D14");
1206 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#D15");
1207 Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#D16");
1208 Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#D17");
1209 Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#D18");
1210 Assert.IsNull (type.GetProperty ("PubStat", flags), "#D19");
1211 Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#D20");
1212 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#D21");
1213 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#D22");
1214 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#D23");
1215 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#D24");
1216 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#D25");
1217 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#D26");
1218 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#D27");
1219 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#D28");
1220 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#D29");
1221 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#D30");
1223 flags = BindingFlags.Instance | BindingFlags.NonPublic |
1224 BindingFlags.FlattenHierarchy;
1226 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#E1");
1227 Assert.IsNotNull (type.GetProperty ("ProtInstBase", flags), "#E2");
1228 Assert.IsNotNull (type.GetProperty ("ProIntInstBase", flags), "#E3");
1229 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#E4");
1230 Assert.IsNotNull (type.GetProperty ("IntInstBase", flags), "#E5");
1231 Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#E6");
1232 Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#E7");
1233 Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#E8");
1234 Assert.IsNull (type.GetProperty ("PubInst", flags), "#E9");
1235 Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#E10");
1236 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#E11");
1237 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#E12");
1238 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#E13");
1239 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#E14");
1240 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#E15");
1241 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#E16");
1242 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#E17");
1243 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#E18");
1244 Assert.IsNull (type.GetProperty ("PubStat", flags), "#E19");
1245 Assert.IsNull (type.GetProperty ("IntStat", flags), "#E20");
1246 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#E21");
1247 Assert.IsNotNull (type.GetProperty ("ProtInstBlue", flags), "#E22");
1248 Assert.IsNotNull (type.GetProperty ("ProIntInstBlue", flags), "#E23");
1249 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#E24");
1250 Assert.IsNotNull (type.GetProperty ("IntInstBlue", flags), "#E25");
1251 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#E26");
1252 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#E27");
1253 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#E28");
1254 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#E29");
1255 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#E30");
1257 flags = BindingFlags.Instance | BindingFlags.Public |
1258 BindingFlags.FlattenHierarchy;
1260 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#F1");
1261 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#F2");
1262 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#F3");
1263 Assert.IsNotNull (type.GetProperty ("PubInstBase", flags), "#F4");
1264 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#F5");
1265 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#F6");
1266 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#F7");
1267 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#F8");
1268 Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#F9");
1269 Assert.IsNull (type.GetProperty ("IntInst", flags), "#F10");
1270 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#F11");
1271 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#F12");
1272 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#F13");
1273 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#F14");
1274 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#F15");
1275 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#F16");
1276 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#F17");
1277 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#F18");
1278 Assert.IsNull (type.GetProperty ("PubStat", flags), "#F19");
1279 Assert.IsNull (type.GetProperty ("IntStat", flags), "#F20");
1280 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#F21");
1281 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#F22");
1282 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#F23");
1283 Assert.IsNotNull (type.GetProperty ("PubInstBlue", flags), "#F24");
1284 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#F25");
1285 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#F26");
1286 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#F27");
1287 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#F28");
1288 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#F29");
1289 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#F30");
1291 flags = BindingFlags.Static | BindingFlags.Public |
1292 BindingFlags.FlattenHierarchy;
1294 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#G1");
1295 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#G2");
1296 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#G3");
1297 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#G4");
1298 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#G5");
1299 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#G6");
1300 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#G7");
1301 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#G8");
1302 Assert.IsNull (type.GetProperty ("PubInst", flags), "#G9");
1303 Assert.IsNull (type.GetProperty ("IntInst", flags), "#G10");
1304 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#G11");
1305 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#G12");
1306 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#G13");
1307 Assert.IsNotNull (type.GetProperty ("PubStatBase", flags), "#G14");
1308 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#G15");
1309 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#G16");
1310 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#G17");
1311 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#G18");
1312 Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#G19");
1313 Assert.IsNull (type.GetProperty ("IntStat", flags), "#G20");
1314 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#G21");
1315 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#G22");
1316 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#G23");
1317 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#G24");
1318 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#G25");
1319 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#G26");
1320 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#G27");
1321 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#G28");
1322 Assert.IsNotNull (type.GetProperty ("PubStatBlue", flags), "#G29");
1323 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#G30");
1325 flags = BindingFlags.Static | BindingFlags.NonPublic |
1326 BindingFlags.FlattenHierarchy;
1328 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#H1");
1329 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#H2");
1330 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#H3");
1331 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#H4");
1332 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#H5");
1333 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#H6");
1334 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#H7");
1335 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#H8");
1336 Assert.IsNull (type.GetProperty ("PubInst", flags), "#H9");
1337 Assert.IsNull (type.GetProperty ("IntInst", flags), "#H10");
1338 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#H11");
1339 Assert.IsNotNull (type.GetProperty ("ProtStatBase", flags), "#H12");
1340 Assert.IsNotNull (type.GetProperty ("ProIntStatBase", flags), "#H13");
1341 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#H14");
1342 Assert.IsNotNull (type.GetProperty ("IntStatBase", flags), "#H15");
1343 Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#H16");
1344 Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#H17");
1345 Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#H18");
1346 Assert.IsNull (type.GetProperty ("PubStat", flags), "#H19");
1347 Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#H20");
1348 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#H21");
1349 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#H22");
1350 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#H23");
1351 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#H24");
1352 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#H25");
1353 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#H26");
1354 Assert.IsNotNull (type.GetProperty ("ProtStatBlue", flags), "#H27");
1355 Assert.IsNotNull (type.GetProperty ("ProIntStatBlue", flags), "#H28");
1356 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#H29");
1357 Assert.IsNotNull (type.GetProperty ("IntStatBlue", flags), "#H30");
1359 flags = BindingFlags.Instance | BindingFlags.NonPublic |
1360 BindingFlags.DeclaredOnly;
1362 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#I1");
1363 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#I2");
1364 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#I3");
1365 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#I4");
1366 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#I5");
1367 Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#I6");
1368 Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#I7");
1369 Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#I8");
1370 Assert.IsNull (type.GetProperty ("PubInst", flags), "#I9");
1371 Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#I10");
1372 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#I11");
1373 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#I12");
1374 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#I13");
1375 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#I14");
1376 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#I15");
1377 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#I16");
1378 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#I17");
1379 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#I18");
1380 Assert.IsNull (type.GetProperty ("PubStat", flags), "#I19");
1381 Assert.IsNull (type.GetProperty ("IntStat", flags), "#I20");
1382 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#I21");
1383 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#I22");
1384 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#I23");
1385 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#I24");
1386 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#I25");
1387 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#I26");
1388 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#I27");
1389 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#I28");
1390 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#I29");
1391 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#I30");
1393 flags = BindingFlags.Instance | BindingFlags.Public |
1394 BindingFlags.DeclaredOnly;
1396 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#J1");
1397 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#J2");
1398 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#J3");
1399 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#J4");
1400 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#J5");
1401 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#J6");
1402 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#J7");
1403 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#J8");
1404 Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#J9");
1405 Assert.IsNull (type.GetProperty ("IntInst", flags), "#J10");
1406 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#J11");
1407 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#J12");
1408 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#J13");
1409 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#J14");
1410 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#J15");
1411 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#J16");
1412 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#J17");
1413 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#J18");
1414 Assert.IsNull (type.GetProperty ("PubStat", flags), "#J19");
1415 Assert.IsNull (type.GetProperty ("IntStat", flags), "#J20");
1416 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#J21");
1417 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#J22");
1418 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#J23");
1419 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#J24");
1420 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#J25");
1421 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#J26");
1422 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#J27");
1423 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#J28");
1424 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#J29");
1425 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#J30");
1427 flags = BindingFlags.Static | BindingFlags.Public |
1428 BindingFlags.DeclaredOnly;
1430 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#K1");
1431 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#K2");
1432 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#K3");
1433 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#K4");
1434 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#K5");
1435 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#K6");
1436 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#K7");
1437 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#K8");
1438 Assert.IsNull (type.GetProperty ("PubInst", flags), "#K9");
1439 Assert.IsNull (type.GetProperty ("IntInst", flags), "#K10");
1440 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#K11");
1441 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#K12");
1442 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#K13");
1443 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#K14");
1444 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#K15");
1445 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#K16");
1446 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#K17");
1447 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#K18");
1448 Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#K19");
1449 Assert.IsNull (type.GetProperty ("IntStat", flags), "#K20");
1450 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#K21");
1451 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#K22");
1452 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#K23");
1453 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#K24");
1454 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#K25");
1455 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#K26");
1456 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#K27");
1457 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#K28");
1458 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#K29");
1459 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#K30");
1461 flags = BindingFlags.Static | BindingFlags.NonPublic |
1462 BindingFlags.DeclaredOnly;
1464 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#L1");
1465 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#L2");
1466 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#L3");
1467 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#L4");
1468 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#L5");
1469 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#L6");
1470 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#L7");
1471 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#L8");
1472 Assert.IsNull (type.GetProperty ("PubInst", flags), "#L9");
1473 Assert.IsNull (type.GetProperty ("IntInst", flags), "#L10");
1474 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#L11");
1475 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#L12");
1476 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#L13");
1477 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#L14");
1478 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#L15");
1479 Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#L16");
1480 Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#L17");
1481 Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#L18");
1482 Assert.IsNull (type.GetProperty ("PubStat", flags), "#L19");
1483 Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#L20");
1484 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#L21");
1485 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#L22");
1486 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#L23");
1487 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#L24");
1488 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#L25");
1489 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#L26");
1490 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#L27");
1491 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#L28");
1492 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#L29");
1493 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#L30");
1495 flags = BindingFlags.Instance | BindingFlags.NonPublic |
1496 BindingFlags.Public;
1498 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#M1");
1499 Assert.IsNotNull (type.GetProperty ("ProtInstBase", flags), "#M2");
1500 Assert.IsNotNull (type.GetProperty ("ProIntInstBase", flags), "#M3");
1501 Assert.IsNotNull (type.GetProperty ("PubInstBase", flags), "#M4");
1502 Assert.IsNotNull (type.GetProperty ("IntInstBase", flags), "#M5");
1503 Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#M6");
1504 Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#M7");
1505 Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#M8");
1506 Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#M9");
1507 Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#M10");
1508 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#M11");
1509 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#M12");
1510 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#M13");
1511 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#M14");
1512 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#M15");
1513 Assert.IsNull (type.GetProperty ("PrivStat", flags), "#M16");
1514 Assert.IsNull (type.GetProperty ("ProtStat", flags), "#M17");
1515 Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#M18");
1516 Assert.IsNull (type.GetProperty ("PubStat", flags), "#M19");
1517 Assert.IsNull (type.GetProperty ("IntStat", flags), "#M20");
1518 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#M21");
1519 Assert.IsNotNull (type.GetProperty ("ProtInstBlue", flags), "#M22");
1520 Assert.IsNotNull (type.GetProperty ("ProIntInstBlue", flags), "#M23");
1521 Assert.IsNotNull (type.GetProperty ("PubInstBlue", flags), "#M24");
1522 Assert.IsNotNull (type.GetProperty ("IntInstBlue", flags), "#M25");
1523 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#M26");
1524 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#M27");
1525 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#M28");
1526 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#M29");
1527 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#M30");
1529 flags = BindingFlags.Static | BindingFlags.NonPublic |
1530 BindingFlags.Public;
1532 Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#N1");
1533 Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#N2");
1534 Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#N3");
1535 Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#N4");
1536 Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#N5");
1537 Assert.IsNull (type.GetProperty ("PrivInst", flags), "#N6");
1538 Assert.IsNull (type.GetProperty ("ProtInst", flags), "#N7");
1539 Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#N8");
1540 Assert.IsNull (type.GetProperty ("PubInst", flags), "#N9");
1541 Assert.IsNull (type.GetProperty ("IntInst", flags), "#N10");
1542 Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#N11");
1543 Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#N12");
1544 Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#N13");
1545 Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#N14");
1546 Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#N15");
1547 Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#N16");
1548 Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#N17");
1549 Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#N18");
1550 Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#N19");
1551 Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#N20");
1552 Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#N21");
1553 Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#N22");
1554 Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#N23");
1555 Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#N24");
1556 Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#N25");
1557 Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#N26");
1558 Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#N27");
1559 Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#N28");
1560 Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#N29");
1561 Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#N30");
1564 [Test] // GetProperty (String, BindingFlags)
1565 public void GetProperty2_Name_Null ()
1567 Type type = typeof (Bar);
1569 type.GetProperty ((string) null);
1571 } catch (ArgumentNullException ex) {
1572 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1573 Assert.IsNull (ex.InnerException, "#3");
1574 Assert.IsNotNull (ex.Message, "#4");
1575 Assert.IsNotNull (ex.ParamName, "#5");
1576 Assert.AreEqual ("name", ex.ParamName, "#6");
1580 [Test] // GetProperty (String, Type)
1581 public void GetProperty3_Name_Null ()
1583 Type type = typeof (Bar);
1585 type.GetProperty ((string) null, typeof (int));
1587 } catch (ArgumentNullException ex) {
1588 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1589 Assert.IsNull (ex.InnerException, "#3");
1590 Assert.IsNotNull (ex.Message, "#4");
1591 Assert.IsNotNull (ex.ParamName, "#5");
1592 Assert.AreEqual ("name", ex.ParamName, "#6");
1596 [Test] // GetProperty (String, Type [])
1597 public void GetProperty4_Name_Null ()
1599 Type type = typeof (Bar);
1601 type.GetProperty ((string) null, Type.EmptyTypes);
1603 } catch (ArgumentNullException ex) {
1604 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1605 Assert.IsNull (ex.InnerException, "#3");
1606 Assert.IsNotNull (ex.Message, "#4");
1607 Assert.IsNotNull (ex.ParamName, "#5");
1608 Assert.AreEqual ("name", ex.ParamName, "#6");
1612 [Test] // GetProperty (String, Type, Type [])
1613 public void GetProperty5_Name_Null ()
1615 Type type = typeof (Bar);
1617 type.GetProperty ((string) null, typeof (int),
1620 } catch (ArgumentNullException ex) {
1621 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1622 Assert.IsNull (ex.InnerException, "#3");
1623 Assert.IsNotNull (ex.Message, "#4");
1624 Assert.IsNotNull (ex.ParamName, "#5");
1625 Assert.AreEqual ("name", ex.ParamName, "#6");
1629 [Test] // GetProperty (String, Type, Type [], ParameterModifier [])
1630 public void GetProperty6_Name_Null ()
1632 Type type = typeof (Bar);
1634 type.GetProperty ((string) null, typeof (int),
1635 Type.EmptyTypes, null);
1637 } catch (ArgumentNullException ex) {
1638 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1639 Assert.IsNull (ex.InnerException, "#3");
1640 Assert.IsNotNull (ex.Message, "#4");
1641 Assert.IsNotNull (ex.ParamName, "#5");
1642 Assert.AreEqual ("name", ex.ParamName, "#6");
1646 [Test] // GetProperty (String, BindingFlags, Binder, Type, Type [], ParameterModifier [])
1647 public void GetProperty7_Name_Null ()
1649 Type type = typeof (Bar);
1651 type.GetProperty ((string) null, BindingFlags.Public,
1652 null, typeof (int), Type.EmptyTypes, null);
1654 } catch (ArgumentNullException ex) {
1655 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
1656 Assert.IsNull (ex.InnerException, "#3");
1657 Assert.IsNotNull (ex.Message, "#4");
1658 Assert.IsNotNull (ex.ParamName, "#5");
1659 Assert.AreEqual ("name", ex.ParamName, "#6");
1664 public void GetProperty8_PropertyType ()
1666 Type type = typeof (Bar);
1667 Assert.IsNull (type.GetProperty ("PubInst", BindingFlags.Public | BindingFlags.Instance,
1668 null, typeof (int), Type.EmptyTypes, null), "#1");
1669 Assert.IsNotNull (type.GetProperty ("PubInst", BindingFlags.Public | BindingFlags.Instance, null,
1670 typeof (long), new Type[0], null), "#2");
1674 public void GetProperty9_Indexers ()
1677 var bindingFlags = BindingFlags.Public | BindingFlags.Instance;
1679 Type type1 = typeof (List<byte>);
1680 var p1 = type1.GetProperty ("Item", bindingFlags, null, typeof (byte), new Type[] { typeof (int) }, null);
1681 Assert.IsNotNull (p1, "#1");
1683 Type type2 = typeof (List<string>);
1684 var p2 = type2.GetProperty ("Item", bindingFlags, null, typeof (string), new Type[] { typeof (int) }, null);
1685 Assert.IsNotNull (p2, "#2");
1687 Type type3 = typeof (List<Type>);
1688 // result type not convertible, make sure we fail.
1689 var p3 = type3.GetProperty ("Item", bindingFlags, null, typeof (string) /*!*/,
1690 new Type[] { typeof (int) }, null);
1691 Assert.IsNull (p3, "#3");
1694 [StructLayout(LayoutKind.Explicit, Pack = 4, Size = 64)]
1699 [StructLayout(LayoutKind.Explicit, CharSet=CharSet.Unicode)]
1705 public void StructLayoutAttribute ()
1707 StructLayoutAttribute attr1 = typeof (TypeTest).StructLayoutAttribute;
1708 Assert.AreEqual (LayoutKind.Auto, attr1.Value);
1710 StructLayoutAttribute attr2 = typeof (Class1).StructLayoutAttribute;
1711 Assert.AreEqual (LayoutKind.Explicit, attr2.Value);
1712 Assert.AreEqual (4, attr2.Pack);
1713 Assert.AreEqual (64, attr2.Size);
1715 StructLayoutAttribute attr3 = typeof (Class2).StructLayoutAttribute;
1716 Assert.AreEqual (LayoutKind.Explicit, attr3.Value);
1717 Assert.AreEqual (CharSet.Unicode, attr3.CharSet);
1721 public void Namespace ()
1723 Assert.AreEqual (null, typeof (NoNamespaceClass).Namespace);
1727 public void GenericParameterNamespace ()
1729 var t = typeof (Foo<>).GetGenericArguments () [0];
1731 Assert.AreEqual ("T", t.Name);
1732 Assert.AreEqual ("MonoTests.System", t.Namespace);
1734 var s = typeof (Gazonk).GetMethod ("Bang").GetGenericArguments () [0];
1736 Assert.AreEqual ("S", s.Name);
1737 Assert.AreEqual ("MonoTests.System", s.Namespace);
1740 public static void Reflected (ref int a)
1747 Assert.AreEqual ("Int32&", typeof (TypeTest).GetMethod ("Reflected").GetParameters () [0].ParameterType.Name);
1748 Assert.AreEqual ("String[*]", Array.CreateInstance (typeof(string), new int[] { 1 }, new int[] { 1 }).GetType ().Name);
1752 public void GetInterfaces ()
1754 Type[] t = typeof (Duper).GetInterfaces ();
1755 Assert.AreEqual (1, t.Length);
1756 Assert.AreEqual (typeof (ICloneable), t[0]);
1758 Type[] t2 = typeof (IFace3).GetInterfaces ();
1759 Assert.AreEqual (2, t2.Length);
1763 public void GetInterfacesGenericVarWithConstraints ()
1765 var a = typeof (TypeTest).GetMethod ("GenericMethod");
1767 var p = a.GetParameters ();
1768 var i = p[0].ParameterType.GetElementType ();
1772 public static void GenericMethod<T, T2> (T[] arr) where T: IComparable<T> {
1778 public void GetFieldIgnoreCase ()
1780 Assert.IsNotNull (typeof (TypeTest).GetField ("afield", BindingFlags.Instance|BindingFlags.Public|BindingFlags.IgnoreCase));
1793 public void GetPropertyAccessorModifiers ()
1795 Assert.IsNotNull (typeof (TypeTest).GetProperty ("Count", BindingFlags.Instance | BindingFlags.Public));
1796 Assert.IsNull (typeof (TypeTest).GetProperty ("Count", BindingFlags.Instance | BindingFlags.NonPublic));
1800 public void IsAbstract ()
1802 Assert.IsFalse (typeof (string).IsAbstract, "#1");
1803 Assert.IsTrue (typeof (ICloneable).IsAbstract, "#2");
1804 Assert.IsTrue (typeof (ValueType).IsAbstract, "#3");
1805 Assert.IsTrue (typeof (Enum).IsAbstract, "#4");
1806 Assert.IsFalse (typeof (TimeSpan).IsAbstract, "#5");
1807 Assert.IsTrue (typeof (TextReader).IsAbstract, "#6");
1810 // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=286308
1811 Type [] typeArgs = typeof (List<>).GetGenericArguments ();
1812 Assert.IsFalse (typeArgs [0].IsAbstract, "#7");
1816 public void IsCOMObject ()
1818 Type type = typeof (string);
1819 Assert.IsFalse (type.IsCOMObject, "#1");
1821 TypeBuilder tb = module.DefineType (genTypeName ());
1822 type = tb.CreateType ();
1823 Assert.IsFalse (type.IsCOMObject, "#2");
1827 public void IsImport ()
1829 Type type = typeof (string);
1830 Assert.IsFalse (type.IsImport, "#1");
1832 TypeBuilder tb = module.DefineType (genTypeName ());
1833 type = tb.CreateType ();
1834 Assert.IsFalse (type.IsImport, "#2");
1836 tb = module.DefineType (genTypeName (), TypeAttributes.Import |
1837 TypeAttributes.Interface | TypeAttributes.Abstract);
1838 type = tb.CreateType ();
1839 Assert.IsTrue (type.IsImport, "#3");
1843 public void IsInterface ()
1845 Assert.IsFalse (typeof (string).IsInterface, "#1");
1846 Assert.IsTrue (typeof (ICloneable).IsInterface, "#2");
1850 public void IsPrimitive () {
1851 Assert.IsTrue (typeof (IntPtr).IsPrimitive, "#1");
1852 Assert.IsTrue (typeof (int).IsPrimitive, "#2");
1853 Assert.IsFalse (typeof (string).IsPrimitive, "#2");
1857 public void IsValueType ()
1859 Assert.IsTrue (typeof (int).IsValueType, "#1");
1860 Assert.IsFalse (typeof (Enum).IsValueType, "#2");
1861 Assert.IsFalse (typeof (ValueType).IsValueType, "#3");
1862 Assert.IsTrue (typeof (AttributeTargets).IsValueType, "#4");
1863 Assert.IsFalse (typeof (string).IsValueType, "#5");
1864 Assert.IsTrue (typeof (TimeSpan).IsValueType, "#6");
1868 public void IsVisible ()
1870 Assert.IsTrue (typeof (int).IsVisible, "#1");
1871 Assert.IsTrue (typeof (Nested).IsVisible, "#2");
1875 public void GetTypeNonVectorArray ()
1877 Type t = Type.GetType ("System.String[*]");
1878 Assert.AreEqual ("System.String[*]", t.ToString ());
1883 public void TypeFromCLSID ()
1885 Guid CLSID_ShellDesktop = new Guid("00021400-0000-0000-c000-000000000046");
1886 Guid CLSID_Bogus = new Guid("1ea9d7a9-f7ab-443b-b486-30d285b21f1b");
1888 Type t1 = Type.GetTypeFromCLSID (CLSID_ShellDesktop);
1890 Type t2 = Type.GetTypeFromCLSID (CLSID_Bogus);
1892 Assert.AreEqual (t1.FullName, "System.__ComObject");
1894 if (!isMono && (Environment.OSVersion.Platform == PlatformID.Win32Windows ||
1895 Environment.OSVersion.Platform == PlatformID.Win32NT))
1896 Activator.CreateInstance(t1);
1898 Assert.AreEqual (t2.FullName, "System.__ComObject");
1900 Assert.AreNotEqual (t1, t2);
1904 [Category("NotWorking")] // Mono throws TargetInvokationException
1905 [ExpectedException("System.Runtime.InteropServices.COMException")]
1906 public void TypeFromCLSIDBogus ()
1908 Guid CLSID_Bogus = new Guid("1ea9d7a9-f7ab-443b-b486-30d285b21f1b");
1909 Type t = Type.GetTypeFromCLSID (CLSID_Bogus);
1910 if (Environment.OSVersion.Platform == PlatformID.Win32Windows ||
1911 Environment.OSVersion.Platform == PlatformID.Win32NT)
1912 Activator.CreateInstance(t);
1914 throw new COMException ();
1918 public void ExerciseFilterName ()
1920 MemberInfo[] mi = typeof(Base).FindMembers(
1922 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1923 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1924 Type.FilterName, "*");
1925 Assert.AreEqual (4, mi.Length);
1926 mi = typeof(Base).FindMembers(
1928 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1929 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1930 Type.FilterName, "Test*");
1931 Assert.AreEqual (2, mi.Length);
1932 mi = typeof(Base).FindMembers(
1934 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1935 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1936 Type.FilterName, "TestVoid");
1937 Assert.AreEqual (1, mi.Length);
1938 mi = typeof(Base).FindMembers(
1940 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1941 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1942 Type.FilterName, "NonExistingMethod");
1943 Assert.AreEqual (0, mi.Length);
1947 public void ExerciseFilterNameIgnoreCase ()
1949 MemberInfo[] mi = typeof(Base).FindMembers(
1951 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1952 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1953 Type.FilterNameIgnoreCase, "*");
1954 Assert.AreEqual (4, mi.Length);
1955 mi = typeof(Base).FindMembers(
1957 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1958 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1959 Type.FilterNameIgnoreCase, "test*");
1960 Assert.AreEqual (2, mi.Length);
1961 mi = typeof(Base).FindMembers(
1963 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1964 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1965 Type.FilterNameIgnoreCase, "TESTVOID");
1966 Assert.AreEqual (1, mi.Length);
1967 mi = typeof(Base).FindMembers(
1969 BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
1970 BindingFlags.Instance | BindingFlags.DeclaredOnly,
1971 Type.FilterNameIgnoreCase, "NonExistingMethod");
1972 Assert.AreEqual (0, mi.Length);
1976 [ExpectedException (typeof (InvalidFilterCriteriaException))]
1977 public void FilterAttribute_Invalid ()
1979 Type.FilterAttribute (MethodBase.GetCurrentMethod (), (byte) 1);
1983 public void GenericParameterMemberType ()
1985 var t = typeof (Foo<>).GetGenericArguments () [0];
1986 Assert.IsNotNull (t);
1988 Assert.AreEqual (MemberTypes.TypeInfo, t.MemberType);
1994 public int property {
1997 public ByRef0 (int i) {}
1998 public void f (int i) {}
2002 public void ByrefTypes ()
2004 Type t = Type.GetType ("MonoTests.System.TypeTest+ByRef0&");
2005 Assert.IsNotNull (t);
2006 Assert.IsTrue (t.IsByRef);
2007 Assert.AreEqual (0, t.GetMethods (BindingFlags.Public | BindingFlags.Instance).Length);
2008 Assert.AreEqual (0, t.GetConstructors (BindingFlags.Public | BindingFlags.Instance).Length);
2009 Assert.AreEqual (0, t.GetEvents (BindingFlags.Public | BindingFlags.Instance).Length);
2010 Assert.AreEqual (0, t.GetProperties (BindingFlags.Public | BindingFlags.Instance).Length);
2012 Assert.IsNull (t.GetMethod ("f"));
2013 Assert.IsNull (t.GetField ("field"));
2014 Assert.IsNull (t.GetProperty ("property"));
2018 public void TestAssemblyQualifiedName ()
2020 Type t = Type.GetType ("System.Byte[]&");
2021 Assert.IsTrue (t.AssemblyQualifiedName.StartsWith ("System.Byte[]&"));
2023 t = Type.GetType ("System.Byte*&");
2024 Assert.IsTrue (t.AssemblyQualifiedName.StartsWith ("System.Byte*&"));
2026 t = Type.GetType ("System.Byte&");
2027 Assert.IsTrue (t.AssemblyQualifiedName.StartsWith ("System.Byte&"));
2032 #pragma warning disable 169
2034 #pragma warning restore 169
2038 public void CreateValueTypeNoCtor ()
2040 typeof(B).InvokeMember ("", BindingFlags.CreateInstance, null, null, null);
2044 [ExpectedException (typeof (MissingMethodException))]
2045 public void CreateValueTypeNoCtorArgs ()
2047 typeof(B).InvokeMember ("", BindingFlags.CreateInstance, null, null, new object [] { 1 });
2051 [ExpectedException (typeof (MissingMethodException))]
2052 public void InvokeGetPropertyMissing ()
2054 typeof(B).InvokeMember ("", BindingFlags.GetProperty, null, null, new object [] { 1 });
2058 [ExpectedException (typeof (MissingMethodException))]
2059 public void InvokeSetPropertyMissing ()
2061 typeof(B).InvokeMember ("", BindingFlags.SetProperty, null, null, new object [] { 1 });
2064 internal static string bug336841 (string param1, params string [] param2)
2066 StringBuilder sb = new StringBuilder ();
2070 for (int i = 0; i < param2.Length; i++) {
2073 sb.Append (param2 [i]);
2075 return sb.ToString ();
2078 internal static string bug336841 (string param1)
2080 return "#B:" + param1;
2083 internal static string bug336841 (params string [] param1)
2085 StringBuilder sb = new StringBuilder ();
2087 for (int i = 0; i < param1.Length; i++) {
2090 sb.Append (param1 [i]);
2092 return sb.ToString ();
2096 public void InvokeMember_GetSetField ()
2098 typeof (X).InvokeMember ("Value", BindingFlags.Public |
2099 BindingFlags.Static | BindingFlags.FlattenHierarchy |
2100 BindingFlags.SetField, null, null, new object [] { 5 });
2102 Assert.AreEqual (5, X.Value, "#A1");
2103 Assert.AreEqual (5, typeof (X).InvokeMember ("Value",
2104 BindingFlags.Public | BindingFlags.Static |
2105 BindingFlags.FlattenHierarchy | BindingFlags.GetField,
2106 null, null, new object [0]), "#A2");
2107 Assert.AreEqual (5, Y.Value, "#A3");
2108 Assert.AreEqual (5, typeof (Y).InvokeMember ("Value",
2109 BindingFlags.Public | BindingFlags.Static |
2110 BindingFlags.FlattenHierarchy | BindingFlags.GetField,
2111 null, null, new object [0]), "#A4");
2114 typeof (X).InvokeMember ("Value", BindingFlags.Public |
2115 BindingFlags.Static | BindingFlags.FlattenHierarchy |
2116 BindingFlags.GetField | BindingFlags.SetField,
2117 null, null, new object [] { 5 });
2118 Assert.Fail ("#B1");
2119 } catch (ArgumentException ex) {
2120 // Cannot specify both Get and Set on a field
2121 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
2122 Assert.IsNull (ex.InnerException, "#B3");
2123 Assert.IsNotNull (ex.Message, "#B4");
2124 Assert.IsNotNull (ex.ParamName, "#B5");
2125 Assert.AreEqual ("bindingFlags", ex.ParamName, "#B6");
2130 public void InvokeMember_GetSetProperty ()
2133 typeof (ArrayList).InvokeMember ("Item",
2134 BindingFlags.GetProperty | BindingFlags.SetProperty |
2135 BindingFlags.Instance | BindingFlags.Public,
2136 null, new ArrayList (), new object [] { 0, "bar" });
2138 } catch (ArgumentException ex) {
2139 // Cannot specify both Get and Set on a property
2140 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
2141 Assert.IsNull (ex.InnerException, "#3");
2142 Assert.IsNotNull (ex.Message, "#4");
2143 Assert.IsNotNull (ex.ParamName, "#5");
2144 Assert.AreEqual ("bindingFlags", ex.ParamName, "#6");
2150 public void InvokeMember_InvokeMethod_Set ()
2153 typeof (ArrayList).InvokeMember ("ToString",
2154 BindingFlags.InvokeMethod | BindingFlags.SetField |
2155 BindingFlags.Instance | BindingFlags.Public,
2156 null, new ArrayList (), new object [0]);
2157 Assert.Fail ("#A1");
2158 } catch (ArgumentException ex) {
2159 // Cannot specify Set on a field and Invoke on a method
2160 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
2161 Assert.IsNull (ex.InnerException, "#A3");
2162 Assert.IsNotNull (ex.Message, "#A4");
2163 Assert.IsNotNull (ex.ParamName, "#A5");
2164 Assert.AreEqual ("bindingFlags", ex.ParamName, "#A6");
2168 typeof (ArrayList).InvokeMember ("ToString",
2169 BindingFlags.InvokeMethod | BindingFlags.SetProperty |
2170 BindingFlags.Instance | BindingFlags.Public,
2171 null, new ArrayList (), new object [0]);
2172 Assert.Fail ("#B1");
2173 } catch (ArgumentException ex) {
2174 // Cannot specify Set on a property and Invoke on a method
2175 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
2176 Assert.IsNull (ex.InnerException, "#B3");
2177 Assert.IsNotNull (ex.Message, "#B4");
2178 Assert.IsNotNull (ex.ParamName, "#B5");
2179 Assert.AreEqual ("bindingFlags", ex.ParamName, "#B6");
2184 public void InvokeMember_MatchPrimitiveTypeWithInterface ()
2186 object [] invokeargs = { 1 };
2187 typeof (Z).InvokeMember ("", BindingFlags.DeclaredOnly |
2188 BindingFlags.Public | BindingFlags.NonPublic |
2189 BindingFlags.Instance | BindingFlags.CreateInstance,
2190 null, null, invokeargs);
2194 public void InvokeMember_Name_Null ()
2197 typeof (X).InvokeMember ((string) null,
2198 BindingFlags.Public | BindingFlags.Static |
2199 BindingFlags.FlattenHierarchy | BindingFlags.SetField,
2200 null, null, new object [] { 5 });
2202 } catch (ArgumentNullException ex) {
2203 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2204 Assert.IsNull (ex.InnerException, "#3");
2205 Assert.IsNotNull (ex.Message, "#4");
2206 Assert.IsNotNull (ex.ParamName, "#5");
2207 Assert.AreEqual ("name", ex.ParamName, "#6");
2212 public void InvokeMember_NoOperation ()
2215 typeof (TypeTest).InvokeMember ("Run", BindingFlags.Public |
2216 BindingFlags.Static, null, null, new object [0]);
2218 } catch (ArgumentException ex) {
2219 // Must specify binding flags describing the
2220 // invoke operation required
2221 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
2222 Assert.IsNull (ex.InnerException, "#3");
2223 Assert.IsNotNull (ex.Message, "#4");
2224 Assert.IsNotNull (ex.ParamName, "#5");
2225 Assert.AreEqual ("bindingFlags", ex.ParamName, "#6");
2229 [Test] // bug #321735
2230 public void InvokeMember_SetFieldProperty ()
2232 ArrayList list = new ArrayList ();
2234 list.GetType ().InvokeMember ("Item",
2235 BindingFlags.SetField | BindingFlags.SetProperty |
2236 BindingFlags.Instance | BindingFlags.Public,
2237 null, list, new object [] { 0, "bar" });
2238 Assert.AreEqual ("bar", list [0]);
2242 public void InvokeMember_SetField_ProvidedArgs ()
2245 typeof (X).InvokeMember ("Value", BindingFlags.Public |
2246 BindingFlags.Static | BindingFlags.SetField,
2247 null, null, new object [0]);
2248 Assert.Fail ("#A1");
2249 } catch (ArgumentException ex) {
2250 // Only the field value can be specified to set
2252 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
2253 Assert.IsNull (ex.InnerException, "#A3");
2254 Assert.IsNotNull (ex.Message, "#A4");
2255 Assert.IsNotNull (ex.ParamName, "#A5");
2256 Assert.AreEqual ("bindingFlags", ex.ParamName, "#6");
2260 typeof (X).InvokeMember ("Value", BindingFlags.Public |
2261 BindingFlags.Static | BindingFlags.SetField,
2263 Assert.Fail ("#B1");
2264 } catch (ArgumentNullException ex) {
2265 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
2266 Assert.IsNull (ex.InnerException, "#B3");
2267 Assert.IsNotNull (ex.Message, "#B4");
2268 Assert.IsNotNull (ex.ParamName, "#B5");
2269 Assert.AreEqual ("providedArgs", ex.ParamName, "#B6");
2273 [Test] // bug #336841
2274 [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=306797
2275 public void InvokeMember_VarArgs ()
2277 BindingFlags flags = BindingFlags.InvokeMethod | BindingFlags.Public |
2278 BindingFlags.NonPublic | BindingFlags.OptionalParamBinding |
2279 BindingFlags.Static | BindingFlags.FlattenHierarchy |
2280 BindingFlags.Instance;
2282 Type type = typeof (TypeTest);
2283 string result = (string) type.InvokeMember ("bug336841",
2284 flags, null, null, new object [] { "1" });
2285 Assert.IsNotNull (result, "#A1");
2286 Assert.AreEqual ("#B:1", result, "#A2");
2288 result = (string) type.InvokeMember ("bug336841", flags,
2289 null, null, new object [] { "1", "2", "3", "4" });
2290 Assert.IsNotNull (result, "#B1");
2291 Assert.AreEqual ("#A:1|2,3,4", result, "#B2");
2295 [Test] // bug #348522
2296 public void InvokeMember_WithoutDefaultValue ()
2298 BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod;
2300 typeof (Bug348522).InvokeMember ("Test", flags, new FirstMethodBinder (), new Bug348522(),
2301 new object [] {Missing.Value}, null, null, null);
2303 } catch (ArgumentException ex) {
2304 // Missing parameter does not have a default value
2305 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
2306 Assert.IsNull (ex.InnerException, "#3");
2307 Assert.IsNotNull (ex.Message, "#4");
2308 Assert.IsNotNull (ex.ParamName, "#5");
2309 Assert.AreEqual ("parameters", ex.ParamName, "#6");
2314 public void TestMissing () {
2315 Assert.AreEqual (Type.Missing, Missing.Value);
2319 public void GetGenericMethodDefinitionOverInflatedMethodOnGTD () {
2320 var s = new List<int> () { 1, 2, 3 }.ConvertAll ( i => i.ToString () );
2321 Assert.AreEqual (3, s.Count);
2322 var l = typeof (List<>);
2323 var m = l.GetMethod ("ConvertAll");
2324 var infl = m.MakeGenericMethod (typeof (int));
2325 var res = m.GetGenericMethodDefinition ();
2326 Assert.AreEqual (m, res, "#1");
2327 Assert.AreEqual (1, infl.GetGenericArguments().Length, "#2");
2331 public void InvokeMember_OutParam ()
2333 object[] args = new object[] { new string [0] };
2334 typeof (TypeTest).InvokeMember ("OutTest", BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.Public, null, null, args);
2335 Assert.IsTrue (args [0] is string[]);
2336 Assert.AreEqual (10, ((string[])args[0]).Length);
2339 public static void OutTest (out string[] a1)
2341 a1 = new string [10];
2346 public static int Value;
2355 public Z (IComparable value)
2360 public static void Run ()
2368 public TakesInt (int x)
2373 public int Integer {
2380 public TakesObject (object x) {}
2383 [Test] // bug #75241
2384 public void GetConstructorNullInTypes ()
2386 // This ends up calling type.GetConstructor ()
2387 Activator.CreateInstance (typeof (TakesInt), new object [] { null });
2388 Activator.CreateInstance (typeof (TakesObject), new object [] { null });
2392 public void GetConstructor_TakeInt_Object ()
2394 Assert.IsNull (typeof (TakesInt).GetConstructor (new Type[1] { typeof (object) }));
2398 public void GetCustomAttributes_All ()
2400 object [] attrs = typeof (A).GetCustomAttributes (false);
2401 Assert.AreEqual (2, attrs.Length, "#A1");
2402 Assert.IsTrue (HasAttribute (attrs, typeof (FooAttribute)), "#A2");
2403 Assert.IsTrue (HasAttribute (attrs, typeof (VolatileModifier)), "#A3");
2405 attrs = typeof (BA).GetCustomAttributes (false);
2406 Assert.AreEqual (1, attrs.Length, "#B1");
2407 Assert.AreEqual (typeof (BarAttribute), attrs [0].GetType (), "#B2");
2409 attrs = typeof (BA).GetCustomAttributes (true);
2410 Assert.AreEqual (2, attrs.Length, "#C1");
2411 Assert.IsTrue (HasAttribute (attrs, typeof (BarAttribute)), "#C2");
2412 Assert.IsTrue (HasAttribute (attrs, typeof (VolatileModifier)), "#C3");
2414 attrs = typeof (CA).GetCustomAttributes (false);
2415 Assert.AreEqual (0, attrs.Length, "#D");
2417 attrs = typeof (CA).GetCustomAttributes (true);
2418 Assert.AreEqual (1, attrs.Length, "#E1");
2419 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#E2");
2422 static bool HasAttribute (object [] attrs, Type attributeType)
2424 foreach (object attr in attrs)
2425 if (attr.GetType () == attributeType)
2431 public void GetCustomAttributes_Type ()
2433 object [] attrs = null;
2435 attrs = typeof (A).GetCustomAttributes (
2436 typeof (VolatileModifier), false);
2437 Assert.AreEqual (1, attrs.Length, "#A1");
2438 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#A2");
2439 attrs = typeof (A).GetCustomAttributes (
2440 typeof (VolatileModifier), true);
2441 Assert.AreEqual (1, attrs.Length, "#A3");
2442 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#A4");
2444 attrs = typeof (A).GetCustomAttributes (
2445 typeof (NemerleAttribute), false);
2446 Assert.AreEqual (1, attrs.Length, "#B1");
2447 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#B2");
2448 attrs = typeof (A).GetCustomAttributes (
2449 typeof (NemerleAttribute), true);
2450 Assert.AreEqual (1, attrs.Length, "#B3");
2451 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#B4");
2453 attrs = typeof (A).GetCustomAttributes (
2454 typeof (FooAttribute), false);
2455 Assert.AreEqual (1, attrs.Length, "#C1");
2456 Assert.AreEqual (typeof (FooAttribute), attrs [0].GetType (), "#C2");
2457 attrs = typeof (A).GetCustomAttributes (
2458 typeof (FooAttribute), false);
2459 Assert.AreEqual (1, attrs.Length, "#C3");
2460 Assert.AreEqual (typeof (FooAttribute), attrs [0].GetType (), "#C4");
2462 attrs = typeof (BA).GetCustomAttributes (
2463 typeof (VolatileModifier), false);
2464 Assert.AreEqual (0, attrs.Length, "#D1");
2465 attrs = typeof (BA).GetCustomAttributes (
2466 typeof (VolatileModifier), true);
2467 Assert.AreEqual (1, attrs.Length, "#D2");
2468 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#D3");
2470 attrs = typeof (BA).GetCustomAttributes (
2471 typeof (NemerleAttribute), false);
2472 Assert.AreEqual (0, attrs.Length, "#E1");
2473 attrs = typeof (BA).GetCustomAttributes (
2474 typeof (NemerleAttribute), true);
2475 Assert.AreEqual (1, attrs.Length, "#E2");
2476 Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#E3");
2478 attrs = typeof (BA).GetCustomAttributes (
2479 typeof (FooAttribute), false);
2480 Assert.AreEqual (1, attrs.Length, "#F1");
2481 Assert.AreEqual (typeof (BarAttribute), attrs [0].GetType (), "#F2");
2482 attrs = typeof (BA).GetCustomAttributes (
2483 typeof (FooAttribute), true);
2484 Assert.AreEqual (1, attrs.Length, "#F3");
2485 Assert.AreEqual (typeof (BarAttribute), attrs [0].GetType (), "#F4");
2487 attrs = typeof (bug82431A1).GetCustomAttributes (
2488 typeof (InheritAttribute), false);
2489 Assert.AreEqual (1, attrs.Length, "#G1");
2490 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#G2");
2491 attrs = typeof (bug82431A1).GetCustomAttributes (
2492 typeof (InheritAttribute), true);
2493 Assert.AreEqual (1, attrs.Length, "#G3");
2494 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#G4");
2496 attrs = typeof (bug82431A1).GetCustomAttributes (
2497 typeof (NotInheritAttribute), false);
2498 Assert.AreEqual (1, attrs.Length, "#H1");
2499 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#H2");
2500 attrs = typeof (bug82431A1).GetCustomAttributes (
2501 typeof (InheritAttribute), true);
2502 Assert.AreEqual (1, attrs.Length, "#H3");
2503 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#H4");
2505 attrs = typeof (bug82431A2).GetCustomAttributes (
2506 typeof (InheritAttribute), false);
2507 Assert.AreEqual (0, attrs.Length, "#I1");
2508 attrs = typeof (bug82431A2).GetCustomAttributes (
2509 typeof (InheritAttribute), true);
2510 Assert.AreEqual (0, attrs.Length, "#I2");
2512 attrs = typeof (bug82431A2).GetCustomAttributes (
2513 typeof (NotInheritAttribute), false);
2514 Assert.AreEqual (0, attrs.Length, "#J1");
2515 attrs = typeof (bug82431A2).GetCustomAttributes (
2516 typeof (NotInheritAttribute), true);
2517 Assert.AreEqual (0, attrs.Length, "#J2");
2519 attrs = typeof (bug82431A3).GetCustomAttributes (
2520 typeof (InheritAttribute), false);
2521 Assert.AreEqual (2, attrs.Length, "#K1");
2522 Assert.IsTrue (HasAttribute (attrs, typeof (InheritAttribute)), "#K2");
2523 Assert.IsTrue (HasAttribute (attrs, typeof (NotInheritAttribute)), "#K3");
2524 attrs = typeof (bug82431A3).GetCustomAttributes (
2525 typeof (InheritAttribute), true);
2526 Assert.AreEqual (2, attrs.Length, "#K4");
2527 Assert.IsTrue (HasAttribute (attrs, typeof (InheritAttribute)), "#K5");
2528 Assert.IsTrue (HasAttribute (attrs, typeof (NotInheritAttribute)), "#K6");
2530 attrs = typeof (bug82431A3).GetCustomAttributes (
2531 typeof (NotInheritAttribute), false);
2532 Assert.AreEqual (1, attrs.Length, "#L1");
2533 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#L2");
2534 attrs = typeof (bug82431A3).GetCustomAttributes (
2535 typeof (NotInheritAttribute), true);
2536 Assert.AreEqual (1, attrs.Length, "#L3");
2537 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#L4");
2539 attrs = typeof (bug82431B1).GetCustomAttributes (
2540 typeof (InheritAttribute), false);
2541 Assert.AreEqual (1, attrs.Length, "#M1");
2542 Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#M2");
2543 attrs = typeof (bug82431B1).GetCustomAttributes (
2544 typeof (InheritAttribute), true);
2545 Assert.AreEqual (1, attrs.Length, "#M3");
2546 Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#M4");
2548 attrs = typeof (bug82431B1).GetCustomAttributes (
2549 typeof (NotInheritAttribute), false);
2550 Assert.AreEqual (0, attrs.Length, "#N1");
2551 attrs = typeof (bug82431B1).GetCustomAttributes (
2552 typeof (NotInheritAttribute), true);
2553 Assert.AreEqual (0, attrs.Length, "#N2");
2555 attrs = typeof (bug82431B2).GetCustomAttributes (
2556 typeof (InheritAttribute), false);
2557 Assert.AreEqual (0, attrs.Length, "#O1");
2558 attrs = typeof (bug82431B2).GetCustomAttributes (
2559 typeof (InheritAttribute), true);
2560 Assert.AreEqual (1, attrs.Length, "#O2");
2561 Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#O3");
2563 attrs = typeof (bug82431B2).GetCustomAttributes (
2564 typeof (NotInheritAttribute), false);
2565 Assert.AreEqual (0, attrs.Length, "#P1");
2566 attrs = typeof (bug82431B2).GetCustomAttributes (
2567 typeof (NotInheritAttribute), true);
2568 Assert.AreEqual (0, attrs.Length, "#P2");
2570 attrs = typeof (bug82431B3).GetCustomAttributes (
2571 typeof (InheritAttribute), false);
2572 Assert.AreEqual (1, attrs.Length, "#Q1");
2573 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#Q2");
2574 attrs = typeof (bug82431B3).GetCustomAttributes (
2575 typeof (InheritAttribute), true);
2576 Assert.AreEqual (2, attrs.Length, "#Q3");
2577 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#Q4");
2578 Assert.AreEqual (typeof (InheritAttribute), attrs [1].GetType (), "#Q5");
2580 attrs = typeof (bug82431B3).GetCustomAttributes (
2581 typeof (NotInheritAttribute), false);
2582 Assert.AreEqual (1, attrs.Length, "#R1");
2583 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#R2");
2584 attrs = typeof (bug82431B3).GetCustomAttributes (
2585 typeof (NotInheritAttribute), true);
2586 Assert.AreEqual (1, attrs.Length, "#R3");
2587 Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#R4");
2589 attrs = typeof (bug82431B4).GetCustomAttributes (
2590 typeof (InheritAttribute), false);
2591 Assert.AreEqual (0, attrs.Length, "#S1");
2592 attrs = typeof (bug82431B4).GetCustomAttributes (
2593 typeof (InheritAttribute), true);
2594 Assert.AreEqual (1, attrs.Length, "#S2");
2595 Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#S3");
2597 attrs = typeof (bug82431B4).GetCustomAttributes (
2598 typeof (NotInheritAttribute), false);
2599 Assert.AreEqual (0, attrs.Length, "#T1");
2600 attrs = typeof (bug82431B4).GetCustomAttributes (
2601 typeof (NotInheritAttribute), true);
2602 Assert.AreEqual (0, attrs.Length, "#T2");
2604 attrs = typeof (A).GetCustomAttributes (
2605 typeof (string), false);
2606 Assert.AreEqual (0, attrs.Length, "#U1");
2607 attrs = typeof (A).GetCustomAttributes (
2608 typeof (string), true);
2609 Assert.AreEqual (0, attrs.Length, "#U2");
2612 [Test] // bug #76150
2613 public void IsDefined ()
2615 Assert.IsTrue (typeof (A).IsDefined (typeof (NemerleAttribute), false), "#A1");
2616 Assert.IsTrue (typeof (A).IsDefined (typeof (VolatileModifier), false), "#A2");
2617 Assert.IsTrue (typeof (A).IsDefined (typeof (FooAttribute), false), "#A3");
2618 Assert.IsFalse (typeof (A).IsDefined (typeof (BarAttribute), false), "#A4");
2620 Assert.IsFalse (typeof (BA).IsDefined (typeof (NemerleAttribute), false), "#B1");
2621 Assert.IsFalse (typeof (BA).IsDefined (typeof (VolatileModifier), false), "#B2");
2622 Assert.IsTrue (typeof (BA).IsDefined (typeof (FooAttribute), false), "#B3");
2623 Assert.IsTrue (typeof (BA).IsDefined (typeof (BarAttribute), false), "#B4");
2624 Assert.IsFalse (typeof (BA).IsDefined (typeof (string), false), "#B5");
2625 Assert.IsFalse (typeof (BA).IsDefined (typeof (int), false), "#B6");
2626 Assert.IsTrue (typeof (BA).IsDefined (typeof (NemerleAttribute), true), "#B7");
2627 Assert.IsTrue (typeof (BA).IsDefined (typeof (VolatileModifier), true), "#B8");
2628 Assert.IsTrue (typeof (BA).IsDefined (typeof (FooAttribute), true), "#B9");
2629 Assert.IsTrue (typeof (BA).IsDefined (typeof (BarAttribute), true), "#B10");
2630 Assert.IsFalse (typeof (BA).IsDefined (typeof (string), true), "#B11");
2631 Assert.IsFalse (typeof (BA).IsDefined (typeof (int), true), "#B12");
2635 public void IsDefined_AttributeType_Null ()
2638 typeof (BA).IsDefined ((Type) null, false);
2640 } catch (ArgumentNullException ex) {
2641 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2642 Assert.IsNull (ex.InnerException, "#3");
2643 Assert.IsNotNull (ex.Message, "#4");
2644 Assert.IsNotNull (ex.ParamName, "#5");
2645 Assert.AreEqual ("attributeType", ex.ParamName, "#6");
2649 [Test] // bug #82431
2650 [Category ("NotWorking")]
2651 public void IsDefined_Inherited ()
2653 Assert.IsFalse (typeof (CA).IsDefined (typeof (NemerleAttribute), false), "#C1");
2654 Assert.IsFalse (typeof (CA).IsDefined (typeof (VolatileModifier), false), "#C2");
2655 Assert.IsFalse (typeof (CA).IsDefined (typeof (FooAttribute), false), "#C3");
2656 Assert.IsFalse (typeof (CA).IsDefined (typeof (BarAttribute), false), "#C4");
2657 Assert.IsTrue (typeof (CA).IsDefined (typeof (NemerleAttribute), true), "#C5");
2658 Assert.IsTrue (typeof (CA).IsDefined (typeof (VolatileModifier), true), "#C6");
2659 Assert.IsFalse (typeof (CA).IsDefined (typeof (FooAttribute), true), "#C7");
2660 Assert.IsFalse (typeof (CA).IsDefined (typeof (BarAttribute), true), "#C8");
2662 Assert.IsFalse (typeof (BBA).IsDefined (typeof (NemerleAttribute), false), "#D1");
2663 Assert.IsFalse (typeof (BBA).IsDefined (typeof (VolatileModifier), false), "#D2");
2664 Assert.IsFalse (typeof (BBA).IsDefined (typeof (FooAttribute), false), "#D3");
2665 Assert.IsFalse (typeof (BBA).IsDefined (typeof (BarAttribute), false), "#D4");
2666 Assert.IsTrue (typeof (BBA).IsDefined (typeof (NemerleAttribute), true), "#D5");
2667 Assert.IsTrue (typeof (BBA).IsDefined (typeof (VolatileModifier), true), "#D6");
2668 Assert.IsTrue (typeof (BBA).IsDefined (typeof (FooAttribute), true), "#D7");
2669 Assert.IsTrue (typeof (BBA).IsDefined (typeof (BarAttribute), true), "#D8");
2671 Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (InheritAttribute), false), "#E1");
2672 Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (NotInheritAttribute), false), "#E2");
2673 Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (InheritAttribute), true), "#E3");
2674 Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (NotInheritAttribute), true), "#E4");
2676 Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (InheritAttribute), false), "#F1");
2677 Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (NotInheritAttribute), false), "#F2");
2678 Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (InheritAttribute), true), "#F3");
2679 Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (NotInheritAttribute), true), "#F4");
2681 Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (InheritAttribute), false), "#G1");
2682 Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (NotInheritAttribute), false), "#G2");
2683 Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (InheritAttribute), true), "#G3");
2684 Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (NotInheritAttribute), true), "#G4");
2686 Assert.IsTrue (typeof (bug82431B1).IsDefined (typeof (InheritAttribute), false), "#H1");
2687 Assert.IsFalse (typeof (bug82431B1).IsDefined (typeof (NotInheritAttribute), false), "#H2");
2688 Assert.IsTrue (typeof (bug82431B1).IsDefined (typeof (InheritAttribute), true), "#H3");
2689 Assert.IsFalse (typeof (bug82431B1).IsDefined (typeof (NotInheritAttribute), true), "#H4");
2691 Assert.IsFalse (typeof (bug82431B2).IsDefined (typeof (InheritAttribute), false), "#I1");
2692 Assert.IsFalse (typeof (bug82431B2).IsDefined (typeof (NotInheritAttribute), false), "#I2");
2693 Assert.IsTrue (typeof (bug82431B2).IsDefined (typeof (InheritAttribute), true), "#I3");
2694 Assert.IsFalse (typeof (bug82431B2).IsDefined (typeof (NotInheritAttribute), true), "#I4");
2696 Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (InheritAttribute), false), "#J1");
2697 Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (NotInheritAttribute), false), "#J2");
2698 Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (InheritAttribute), true), "#J3");
2699 Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (NotInheritAttribute), true), "#J4");
2701 Assert.IsFalse (typeof (bug82431B4).IsDefined (typeof (InheritAttribute), false), "#K2");
2702 Assert.IsFalse (typeof (bug82431B4).IsDefined (typeof (NotInheritAttribute), false), "#K2");
2703 Assert.IsTrue (typeof (bug82431B4).IsDefined (typeof (InheritAttribute), true), "#K3");
2704 Assert.IsFalse (typeof (bug82431B4).IsDefined (typeof (NotInheritAttribute), true), "#K4");
2707 class Bug13767Attribute : Attribute
2709 public object[] field;
2711 public Bug13767Attribute (params object[] args)
2717 public enum Bug13767Enum
2723 [Bug13767("Demo", new[] { Bug13767Enum.Value1, Bug13767Enum.Value0 })]
2724 public void Bug13767Method(string attributeName, Bug13767Enum[]options)
2730 public void CustomAttributeWithNestedArrayOfEnum ()
2732 var m = GetType ().GetMethod ("Bug13767Method");
2734 var attr = m.GetCustomAttributes (false);
2735 Assert.AreEqual (1, attr.Length, "#1");
2737 var tc = (Bug13767Attribute)attr[0];
2738 Assert.AreEqual (2, tc.field.Length, "#2");
2739 Assert.AreEqual ("Demo", tc.field[0], "#3");
2740 Assert.IsNotNull (tc.field[1], "#4");
2742 var arr = (Bug13767Enum[])tc.field [1];
2743 Assert.AreEqual (2, arr.Length, "#5");
2744 Assert.AreEqual (Bug13767Enum.Value1, arr [0], "#6");
2745 Assert.AreEqual (Bug13767Enum.Value0, arr [1], "#7");
2748 [Test] // GetType (String)
2749 public void GetType1_TypeName_Null ()
2752 Type.GetType ((string) null);
2754 } catch (ArgumentNullException ex) {
2755 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2756 Assert.IsNull (ex.InnerException, "#3");
2757 Assert.IsNotNull (ex.Message, "#4");
2758 Assert.AreEqual ("TypeName", ex.ParamName, "#5");
2762 [Test] // GetType (String, Boolean)
2763 public void GetType2_TypeName_Null ()
2766 Type.GetType ((string) null, false);
2768 } catch (ArgumentNullException ex) {
2769 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2770 Assert.IsNull (ex.InnerException, "#3");
2771 Assert.IsNotNull (ex.Message, "#4");
2772 Assert.AreEqual ("TypeName", ex.ParamName, "#5");
2776 [Test] // GetType (String, Boolean, Boolean)
2777 public void GetType3_TypeName_Null ()
2780 Type.GetType ((string) null, false, false);
2782 } catch (ArgumentNullException ex) {
2783 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2784 Assert.IsNull (ex.InnerException, "#3");
2785 Assert.IsNotNull (ex.Message, "#4");
2786 Assert.AreEqual ("TypeName", ex.ParamName, "#5");
2791 public void GetTypeArray_Args_Null ()
2794 Type.GetTypeArray ((object []) null);
2796 } catch (ArgumentNullException ex) {
2797 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2798 Assert.IsNull (ex.InnerException, "#3");
2799 Assert.IsNotNull (ex.Message, "#4");
2800 Assert.AreEqual ("args", ex.ParamName, "#5");
2805 public void GetTypeCode ()
2807 Assert.AreEqual (TypeCode.Boolean, Type.GetTypeCode (typeof (bool)), "#1");
2808 Assert.AreEqual (TypeCode.Byte, Type.GetTypeCode (typeof (byte)), "#2");
2809 Assert.AreEqual (TypeCode.Char, Type.GetTypeCode (typeof (char)), "#3");
2810 Assert.AreEqual (TypeCode.DateTime, Type.GetTypeCode (typeof (DateTime)), "#4");
2811 Assert.AreEqual (TypeCode.DBNull, Type.GetTypeCode (typeof (DBNull)), "#5");
2812 Assert.AreEqual (TypeCode.Decimal, Type.GetTypeCode (typeof (decimal)), "#6");
2813 Assert.AreEqual (TypeCode.Double, Type.GetTypeCode (typeof (double)), "#7");
2814 Assert.AreEqual (TypeCode.Empty, Type.GetTypeCode (null), "#8");
2815 Assert.AreEqual (TypeCode.Int16, Type.GetTypeCode (typeof (short)), "#9");
2816 Assert.AreEqual (TypeCode.Int32, Type.GetTypeCode (typeof (int)), "#10");
2817 Assert.AreEqual (TypeCode.Int64, Type.GetTypeCode (typeof (long)), "#11");
2818 Assert.AreEqual (TypeCode.Object, Type.GetTypeCode (typeof (TakesInt)), "#12");
2819 Assert.AreEqual (TypeCode.SByte, Type.GetTypeCode (typeof (sbyte)), "#13");
2820 Assert.AreEqual (TypeCode.Single, Type.GetTypeCode (typeof (float)), "#14");
2821 Assert.AreEqual (TypeCode.String, Type.GetTypeCode (typeof (string)), "#15");
2822 Assert.AreEqual (TypeCode.UInt16, Type.GetTypeCode (typeof (ushort)), "#16");
2823 Assert.AreEqual (TypeCode.UInt32, Type.GetTypeCode (typeof (uint)), "#17");
2824 Assert.AreEqual (TypeCode.UInt64, Type.GetTypeCode (typeof (ulong)), "#18");
2828 public void GetTypeFromHandle_Handle_Zero ()
2830 RuntimeTypeHandle handle = new RuntimeTypeHandle ();
2832 Assert.IsNull (Type.GetTypeFromHandle (handle));
2836 public void GetTypeHandle_O_Null ()
2839 Type.GetTypeHandle (null);
2841 } catch (ArgumentNullException ex) {
2842 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2843 Assert.IsNull (ex.InnerException, "#3");
2844 Assert.IsNotNull (ex.Message, "#4");
2845 Assert.IsNull (ex.ParamName, "#5");
2849 [Test] // GetConstructor (Type [])
2850 public void GetConstructor1 ()
2853 ConstructorInfo ctor;
2855 type = typeof (CtorsA);
2856 ctor = type.GetConstructor (Type.EmptyTypes);
2857 Assert.IsNotNull (ctor, "#A1");
2858 Assert.AreEqual (0, ctor.GetParameters ().Length, "#A2");
2859 Assert.IsFalse (ctor.IsStatic, "#A3");
2860 Assert.IsTrue (ctor.IsPublic, "#A4");
2861 Assert.AreEqual (".ctor", ctor.Name, "#A5");
2863 type = typeof (CtorsB);
2864 ctor = type.GetConstructor (Type.EmptyTypes);
2865 Assert.IsNotNull (ctor, "#B1");
2866 Assert.AreEqual (0, ctor.GetParameters ().Length, "#B2");
2867 Assert.IsFalse (ctor.IsStatic, "#B3");
2868 Assert.IsTrue (ctor.IsPublic, "#B4");
2869 Assert.AreEqual (".ctor", ctor.Name, "#B5");
2871 type = typeof (CtorsC);
2872 ctor = type.GetConstructor (Type.EmptyTypes);
2873 Assert.IsNull (ctor, "#C");
2875 type = typeof (CtorsC);
2876 ctor = type.GetConstructor (new Type [] { typeof (int) });
2877 Assert.IsNotNull (ctor, "#D1");
2878 Assert.AreEqual (1, ctor.GetParameters ().Length, "#D2");
2879 Assert.IsFalse (ctor.IsStatic, "#D3");
2880 Assert.IsTrue (ctor.IsPublic, "#D4");
2881 Assert.AreEqual (".ctor", ctor.Name, "#D5");
2884 [Test] // GetConstructor (Type [])
2885 public void GetConstructor1_Types_Null ()
2888 typeof (BindingFlags).GetConstructor (null);
2890 } catch (ArgumentNullException ex) {
2891 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2892 Assert.IsNull (ex.InnerException, "#3");
2893 Assert.IsNotNull (ex.Message, "#4");
2894 Assert.IsNotNull (ex.ParamName, "#5");
2895 Assert.AreEqual ("types", ex.ParamName, "#6");
2899 [Test] // GetConstructor (Type [])
2900 public void GetConstructor1_Types_ItemNull ()
2902 Type type = typeof (BindingFlags);
2904 type.GetConstructor (new Type[1] { null });
2905 Assert.Fail ("#A1");
2906 } catch (ArgumentNullException ex) {
2907 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
2908 Assert.IsNull (ex.InnerException, "#A3");
2909 Assert.IsNotNull (ex.Message, "#A4");
2910 Assert.IsNotNull (ex.ParamName, "#A5");
2911 Assert.AreEqual ("types", ex.ParamName, "#A6");
2914 type = typeof (TakesInt);
2916 type.GetConstructor (new Type [1] { null });
2917 Assert.Fail ("#B1");
2918 } catch (ArgumentNullException ex) {
2919 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
2920 Assert.IsNull (ex.InnerException, "#B3");
2921 Assert.IsNotNull (ex.Message, "#B4");
2922 Assert.IsNotNull (ex.ParamName, "#B5");
2923 Assert.AreEqual ("types", ex.ParamName, "#B6");
2927 [Test] // GetConstructor (BindingFlags, Binder, Type [], ParameterModifier [])
2928 public void GetConstructor2_Types_ItemNull ()
2930 Type type = typeof (BindingFlags);
2932 type.GetConstructor (BindingFlags.Default, null,
2933 new Type[1] { null }, null);
2935 } catch (ArgumentNullException ex) {
2936 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2937 Assert.IsNull (ex.InnerException, "#3");
2938 Assert.IsNotNull (ex.Message, "#4");
2939 Assert.IsNotNull (ex.ParamName, "#5");
2940 Assert.AreEqual ("types", ex.ParamName, "#6");
2944 [Test] // GetConstructor (BindingFlags, Binder, CallingConventions, Type [], ParameterModifier [])
2945 public void GetConstructor3_Types_ItemNull ()
2947 Type type = typeof (BindingFlags);
2949 type.GetConstructor (BindingFlags.Default,
2950 null, CallingConventions.Any,
2951 new Type[1] { null }, null);
2953 } catch (ArgumentNullException ex) {
2954 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
2955 Assert.IsNull (ex.InnerException, "#3");
2956 Assert.IsNotNull (ex.Message, "#4");
2957 Assert.IsNotNull (ex.ParamName, "#5");
2958 Assert.AreEqual ("types", ex.ParamName, "#6");
2963 public void GetMethod_Bug77367 ()
2965 MethodInfo i = typeof (Bug77367).GetMethod ("Run", Type.EmptyTypes);
2971 public void EqualsUnderlyingType ()
2973 AssemblyBuilderAccess access = AssemblyBuilderAccess.RunAndSave;
2974 TypeAttributes attribs = TypeAttributes.Public;
2976 AssemblyName name = new AssemblyName ();
2977 name.Name = "enumtest";
2978 AssemblyBuilder assembly =
2979 AppDomain.CurrentDomain.DefineDynamicAssembly (
2982 ModuleBuilder module = assembly.DefineDynamicModule
2983 ("m", "enumtest.dll");
2984 EnumBuilder e = module.DefineEnum ("E", attribs, typeof (int));
2986 Assert.IsTrue (typeof (int).Equals (e));
2991 public void Equals_Type_Null ()
2993 Assert.IsFalse (typeof (int).Equals ((Type) null), "#1");
2994 Assert.IsFalse (typeof (int).Equals ((object) null), "#2");
2998 public void GetElementType_Bug63841 ()
3000 Assert.IsNull (typeof (TheEnum).GetElementType (), "#1");
3004 public void FullNameGenerics ()
3006 Type fooType = typeof (Foo<>);
3007 FieldInfo [] fields = fooType.GetFields ();
3009 Assert.AreEqual (1, fields.Length, "#0");
3011 Assert.IsNotNull (fooType.FullName, "#1");
3012 Assert.IsNotNull (fooType.AssemblyQualifiedName, "#1a");
3014 FieldInfo field = fooType.GetField ("Whatever");
3015 Assert.IsNotNull (field, "#2");
3016 Assert.AreEqual (field, fields [0], "#2a");
3017 Assert.IsNull (field.FieldType.FullName, "#3");
3018 Assert.IsNull (field.FieldType.AssemblyQualifiedName, "#3a");
3019 Assert.IsNotNull (field.FieldType.ToString (), "#4");
3021 PropertyInfo prop = fooType.GetProperty ("Test");
3022 Assert.IsNotNull (prop, "#5");
3023 Assert.IsNull (prop.PropertyType.FullName, "#6");
3024 Assert.IsNull (prop.PropertyType.AssemblyQualifiedName, "#6a");
3025 Assert.IsNotNull (prop.PropertyType.ToString (), "#7");
3027 MethodInfo method = fooType.GetMethod("Execute");
3028 Assert.IsNotNull (method, "#8");
3029 Assert.IsNull (method.ReturnType.FullName, "#9");
3030 Assert.IsNull (method.ReturnType.AssemblyQualifiedName, "#9a");
3031 Assert.IsNotNull (method.ReturnType.ToString (), "#10");
3033 ParameterInfo[] parameters = method.GetParameters();
3034 Assert.AreEqual (1, parameters.Length, "#11");
3035 Assert.IsNull (parameters[0].ParameterType.FullName, "#12");
3036 Assert.IsNull (parameters[0].ParameterType.AssemblyQualifiedName, "#12a");
3037 Assert.IsNotNull (parameters[0].ParameterType.ToString (), "#13");
3041 public void TypeParameterIsNotGeneric ()
3043 Type fooType = typeof (Foo<>);
3044 Type type_param = fooType.GetGenericArguments () [0];
3045 Assert.IsTrue (type_param.IsGenericParameter);
3046 Assert.IsFalse (type_param.IsGenericType);
3047 Assert.IsFalse (type_param.IsGenericTypeDefinition);
3049 // LAMESPEC: MSDN claims that this should be false, but .NET v2.0.50727 says it's true
3050 // http://msdn2.microsoft.com/en-us/library/system.type.isgenerictype.aspx
3051 Assert.IsTrue (type_param.ContainsGenericParameters);
3055 public void IsAssignable ()
3057 Type foo_type = typeof (Foo<>);
3058 Type foo_int_type = typeof (Foo<int>);
3059 Assert.IsFalse (foo_type.IsAssignableFrom (foo_int_type), "Foo<int> -!-> Foo<>");
3060 Assert.IsFalse (foo_int_type.IsAssignableFrom (foo_type), "Foo<> -!-> Foo<int>");
3062 Type ibar_short_type = typeof (IBar<short>);
3063 Type ibar_int_type = typeof (IBar<int>);
3064 Type baz_short_type = typeof (Baz<short>);
3065 Type baz_int_type = typeof (Baz<int>);
3067 Assert.IsTrue (ibar_int_type.IsAssignableFrom (baz_int_type), "Baz<int> -> IBar<int>");
3068 Assert.IsTrue (ibar_short_type.IsAssignableFrom (baz_short_type), "Baz<short> -> IBar<short>");
3070 Assert.IsFalse (ibar_int_type.IsAssignableFrom (baz_short_type), "Baz<short> -!-> IBar<int>");
3071 Assert.IsFalse (ibar_short_type.IsAssignableFrom (baz_int_type), "Baz<int> -!-> IBar<short>");
3074 Assert.IsTrue (typeof (Nullable<int>).IsAssignableFrom (typeof (int)));
3075 Assert.IsFalse (typeof (int).IsAssignableFrom (typeof (Nullable<int>)));
3076 Assert.IsTrue (typeof (Nullable<FooStruct>).IsAssignableFrom (typeof (FooStruct)));
3080 public void IsInstanceOf ()
3082 Assert.IsTrue (typeof (Nullable<int>).IsInstanceOfType (5));
3086 public void IsInstanceOfArrayOfNullable ()
3088 Assert.IsTrue (typeof (Nullable<int>[]).IsInstanceOfType (new Nullable<int> [0]));
3092 public void IsInstanceOfType_Null ()
3094 Assert.IsFalse (typeof (int).IsInstanceOfType (null), "int");
3095 Assert.IsFalse (typeof (object).IsInstanceOfType (null), "object");
3096 Assert.IsFalse (typeof (int?).IsInstanceOfType (null), "int?");
3100 public void ByrefType ()
3102 Type foo_type = typeof (Foo<>);
3103 Type type_param = foo_type.GetGenericArguments () [0];
3104 Type byref_type_param = type_param.MakeByRefType ();
3105 Assert.IsFalse (byref_type_param.IsGenericParameter);
3106 Assert.IsNull (byref_type_param.DeclaringType);
3110 [ExpectedException (typeof (TypeLoadException))]
3111 public void MakeByRefByRef ()
3113 typeof (int).MakeByRefType ().MakeByRefType ();
3117 public void MakeArrayTypeTest ()
3119 // This should not crash:
3120 Type t = typeof (void).MakeArrayType ();
3124 [ExpectedException (typeof (InvalidProgramException))]
3125 public void MakeArrayTypedReferenceInstanceTest ()
3127 object o = Array.CreateInstance (typeof (global::System.TypedReference), 1);
3131 public void MakeArrayTypeLargeRank ()
3133 Assert.Throws<TypeLoadException> (delegate () {
3134 typeof (int).MakeArrayType (33);
3139 public class ComFoo<T> {
3143 public void GetCustomAttributesGenericInstance ()
3145 Assert.AreEqual (1, typeof (ComFoo<int>).GetCustomAttributes (typeof (ComVisibleAttribute), true).Length);
3148 interface ByRef1<T> { void f (ref T t); }
3149 interface ByRef2 { void f<T> (ref T t); }
3151 interface ByRef3<T> where T:struct { void f (ref T? t); }
3152 interface ByRef4 { void f<T> (ref T? t) where T:struct; }
3154 void CheckGenericByRef (Type t)
3156 string name = t.Name;
3157 t = t.GetMethod ("f").GetParameters () [0].ParameterType;
3159 Assert.IsFalse (t.IsGenericType, name);
3160 Assert.IsFalse (t.IsGenericTypeDefinition, name);
3161 Assert.IsFalse (t.IsGenericParameter, name);
3165 public void GenericByRef ()
3167 CheckGenericByRef (typeof (ByRef1<>));
3168 CheckGenericByRef (typeof (ByRef2));
3169 CheckGenericByRef (typeof (ByRef3<>));
3170 CheckGenericByRef (typeof (ByRef4));
3173 public class Bug80242<T> {
3174 public interface IFoo { }
3175 public class Bar : IFoo { }
3176 public class Baz : Bar { }
3180 public void TestNestedTypes ()
3182 Type t = typeof (Bug80242<object>);
3183 Assert.IsFalse (t.IsGenericTypeDefinition);
3184 foreach (Type u in t.GetNestedTypes ()) {
3185 Assert.IsTrue (u.IsGenericTypeDefinition, "{0} isn't a generic definition", u);
3186 Assert.AreEqual (u, u.GetGenericArguments () [0].DeclaringType);
3190 [Test] // bug #82211
3191 public void GetMembers_GenericArgument ()
3193 Type argType = typeof (ComFoo<>).GetGenericArguments () [0];
3194 MemberInfo [] members = argType.GetMembers ();
3195 Assert.IsNotNull (members, "#1");
3196 Assert.AreEqual (4, members.Length, "#2");
3200 [ExpectedException (typeof (ArgumentNullException))]
3201 public void ReflectionOnlyGetTypeNullTypeName ()
3203 Type.ReflectionOnlyGetType (null, false, false);
3207 public void ReflectionOnlyGetTypeDoNotThrow ()
3209 Assert.IsNull (Type.ReflectionOnlyGetType ("a, nonexistent.dll", false, false));
3213 [ExpectedException (typeof (FileNotFoundException))]
3214 public void ReflectionOnlyGetTypeThrow ()
3216 Type.ReflectionOnlyGetType ("a, nonexistent.dll", true, false);
3220 public void ReflectionOnlyGetType ()
3222 Type t = Type.ReflectionOnlyGetType (typeof (int).AssemblyQualifiedName.ToString (), true, true);
3223 Assert.AreEqual ("System.Int32", t.FullName);
3227 #if MONOTOUCH || FULL_AOT_RUNTIME
3228 [ExpectedException (typeof (NotSupportedException))]
3230 public void MakeGenericType_UserDefinedType ()
3232 Type ut = new UserType (typeof (int));
3233 Type t = typeof (Foo<>).MakeGenericType (ut);
3234 Assert.IsTrue (t.IsGenericType, "#A1");
3235 Assert.AreEqual (1, t.GetGenericArguments ().Length, "#A2");
3237 Type arg = t.GetGenericArguments () [0];
3238 Assert.IsNotNull (arg, "#B1");
3239 Assert.IsFalse (arg.IsGenericType, "#B2");
3240 Assert.AreEqual (ut, arg, "#B3");
3244 #if MONOTOUCH || FULL_AOT_RUNTIME
3245 [ExpectedException (typeof (NotSupportedException))]
3247 public void MakeGenericType_NestedUserDefinedType ()
3249 Type ut = new UserType (new UserType (typeof (int)));
3250 Type t = typeof (Foo<>).MakeGenericType (ut);
3251 Assert.IsTrue (t.IsGenericType, "#A1");
3252 Assert.AreEqual (1, t.GetGenericArguments ().Length, "#A2");
3254 Type arg = t.GetGenericArguments () [0];
3255 Assert.IsNotNull (arg, "#B1");
3256 Assert.IsFalse (arg.IsGenericType, "#B2");
3257 Assert.AreEqual (ut, arg, "#B3");
3261 #if MONOTOUCH || FULL_AOT_RUNTIME
3262 [ExpectedException (typeof (NotSupportedException))]
3264 public void TestMakeGenericType_UserDefinedType_DotNet20SP1 ()
3266 Type ut = new UserType(typeof(int));
3267 Type t = typeof(Foo<>).MakeGenericType(ut);
3268 Assert.IsTrue (t.IsGenericType, "#1");
3270 Assert.AreEqual (ut, t.GetGenericArguments()[0], "#2");
3274 #if MONOTOUCH || FULL_AOT_RUNTIME
3275 [ExpectedException (typeof (NotSupportedException))]
3277 public void MakeGenericType_BadUserType ()
3279 Type ut = new UserType (null);
3280 Type t = typeof (Foo<>).MakeGenericType (ut);
3281 var g0 = t.GetGenericArguments () [0];
3282 Assert.AreSame (g0, ut, "#1");
3286 public void MakeGenericType_WrongNumOfArguments ()
3289 Type t = typeof (Foo<,>).MakeGenericType (new Type [] { typeof (int) });
3291 } catch (ArgumentException) {
3295 [AttributeUsage (AttributeTargets.All)]
3296 public class DocAttribute : Attribute {
3297 public DocAttribute (string docs) {}
3300 class GenericClassWithAttributes<[Doc ("T")] T, [Doc ("B")] B>
3301 where T : class, new ()
3304 public T Bar { get{return null;}}
3306 public void M<[Doc ("X")] X> (X x)
3311 [Test] //bug #377596
3312 public void GetGenericArguments_ArgumentsHaveAttributes ()
3314 Type type = typeof(GenericClassWithAttributes<,>);
3315 Type[] tArgs = type.GetGenericArguments ();
3316 MethodInfo m = type.GetMethod ("M");
3317 Type[] mArgs = m.GetGenericArguments ();
3318 Assert.AreEqual(1, tArgs[0].GetCustomAttributes (typeof (DocAttribute), true).Length, "#1");
3319 Assert.AreEqual(1, tArgs[1].GetCustomAttributes (typeof (DocAttribute), true).Length, "#1");
3320 Assert.AreEqual(1, mArgs[0].GetCustomAttributes (typeof (DocAttribute), true).Length, "#1");
3323 [Test] //bug #471255
3324 public void GetTypeCalledUsingReflection ()
3326 Type expectedType = Type.GetType ("NoNamespaceClass");
3327 Assert.IsNotNull (expectedType, "#1");
3328 MethodInfo m = typeof (Type).GetMethod ("GetType", BindingFlags.Public | BindingFlags.Static, null, new Type [] { typeof (string) }, null);
3329 object r = m.Invoke (null, BindingFlags.Default, null, new object [] { "NoNamespaceClass" }, CultureInfo.InvariantCulture);
3330 Assert.AreSame (expectedType, r, "#2");
3333 public class BConstrained<Y> where Y : BConstrained<Y> {
3336 public class AConstrained<X> : BConstrained<AConstrained<X>> {
3339 [Test] // Bug https://bugzilla.xamarin.com/show_bug.cgi?id=54485
3340 public void MakeGenericType_GTD_Constraint ()
3342 // This is pretty weird, but match .NET behavior (note
3343 // that typeof(BConstrained<AConstrained<>>) is a
3344 // compile-time error with roslyn, but it's apparently
3345 // an ok thing to make with reflection.
3346 var tb = typeof (BConstrained<>);
3347 var ta = typeof (AConstrained<>);
3348 var result = tb.MakeGenericType (ta);
3349 Assert.IsNotNull (result, "#1");
3350 // lock down the answer to match what .NET makes
3351 Assert.IsTrue (result.IsGenericType, "#2");
3352 Assert.AreEqual (tb, result.GetGenericTypeDefinition (), "#3");
3353 var bargs = result.GetGenericArguments ();
3354 Assert.AreEqual (1, bargs.Length, "#4");
3355 var arg = bargs [0];
3356 Assert.IsTrue (arg.IsGenericType, "#5");
3357 // N.B. evidently AConstrained`1 and AConstrained`1<!0> are the same type
3358 Assert.IsTrue (arg.IsGenericTypeDefinition, "#6");
3359 Assert.AreEqual (ta, arg.GetGenericTypeDefinition (), "#7");
3360 var aargs = arg.GetGenericArguments ();
3361 Assert.AreEqual (1, aargs.Length, "#8");
3362 Assert.AreEqual (ta.GetGenericArguments () [0], aargs [0], "#9");
3366 public void EqualsUserType () {
3367 UserType2 t1 = new UserType2(null);
3368 UserType2 t2 = new UserType2(t1);
3369 Assert.IsTrue (t1.Equals(t2));
3373 public void GetHashCodeUserType () {
3374 UserType2 t1 = new UserType2(null);
3375 UserType2 t2 = new UserType2(t1);
3376 Assert.AreEqual (42, t2.GetHashCode());
3380 public void IsGenericTypeDefinitionUserType () {
3381 Assert.IsFalse (new UserType(null).IsGenericTypeDefinition);
3385 public void IsGenericTypeUserType () {
3386 Assert.IsFalse (new UserType(null).IsGenericType);
3390 [ExpectedException (typeof (NotSupportedException))]
3391 public void GetGenericTypeDefinitionUserType () {
3392 new UserType(null).GetGenericTypeDefinition ();
3395 [ExpectedException (typeof (NotSupportedException))]
3396 public void GetGenericArgumentsUserType () {
3397 new UserType(null).GetGenericArguments ();
3401 [ExpectedException (typeof (InvalidOperationException))]
3402 public void GenericParameterPositionUserType () {
3403 Assert.IsTrue (new UserType(null).GenericParameterPosition == 0);
3407 public void TypeGetMemberReturnTypeTest ()
3410 MemberTypes memtype;
3412 object [] flagsandtypes = new object [] {
3413 MemberTypes.All, typeof (MemberInfo []),
3414 MemberTypes.Constructor, typeof (ConstructorInfo []),
3415 MemberTypes.Custom, typeof (MemberInfo []),
3416 MemberTypes.Event, typeof (EventInfo []),
3417 MemberTypes.Field, typeof (FieldInfo []),
3418 MemberTypes.Method, typeof (MethodInfo []),
3419 MemberTypes.NestedType, typeof (Type []),
3420 MemberTypes.Property, typeof (PropertyInfo []),
3421 MemberTypes.TypeInfo, typeof (Type [])};
3423 for (int i=0; i < flagsandtypes.Length; i+=2) {
3424 memtype = (MemberTypes)flagsandtypes [i];
3425 testtype = (Type)flagsandtypes [i+1];
3426 obj = GetType ().GetMember ("DummyMember", memtype,
3427 BindingFlags.Public | BindingFlags.Instance);
3428 Assert.AreEqual (testtype.GetHashCode (), obj.GetType ().GetHashCode (),
3429 "Expected #" + i + " " + testtype.FullName);
3435 public void TypeNameStartsWithSpace ()
3437 Type t1 = Type.GetType ("System.Type, mscorlib");
3438 Type t2 = Type.GetType (" System.Type, mscorlib");
3439 Assert.AreEqual (t1, t2);
3442 #if !MONOTOUCH && !FULL_AOT_RUNTIME
3444 public void SpaceAfterComma () {
3445 string strType = "System.Collections.Generic.Dictionary`2[[System.Int32,mscorlib], [System.String,mscorlib]],mscorlib";
3446 Assert.IsTrue (Type.GetType (strType) != null);
3450 #if !MONOTOUCH && !FULL_AOT_RUNTIME
3452 public void Bug506757 ()
3454 AssemblyName assemblyName = new AssemblyName ();
3455 assemblyName.Name = "customMod";
3456 assemblyName.Version = new Version (1, 2, 3, 4);
3458 AssemblyBuilder assembly
3459 = Thread.GetDomain().DefineDynamicAssembly(
3460 assemblyName, AssemblyBuilderAccess.RunAndSave);
3462 ModuleBuilder module = assembly.DefineDynamicModule("res.exe", "res.exe");
3464 TypeBuilder type0 = module.DefineType ("Base", TypeAttributes.Public, typeof (object));
3465 TypeBuilder type1 = module.DefineType ("Middle", TypeAttributes.Public, type0);
3466 TypeBuilder type2 = module.DefineType ("End", TypeAttributes.Public, type1);
3468 MethodAttributes attrs0 = MethodAttributes.Virtual | MethodAttributes.HideBySig |
3469 MethodAttributes.NewSlot | MethodAttributes.FamORAssem;
3471 MethodAttributes attrs1 = MethodAttributes.Virtual | MethodAttributes.HideBySig |
3472 MethodAttributes.FamORAssem;
3474 MethodAttributes attrs2 = MethodAttributes.Virtual | MethodAttributes.HideBySig |
3475 MethodAttributes.Public;
3478 MethodBuilder m0 = type0.DefineMethod ("Tst", attrs0, typeof (void), null);
3479 m0.GetILGenerator ().Emit (OpCodes.Ret);
3481 MethodBuilder m1 = type1.DefineMethod ("Tst", attrs1, typeof (void), null);
3482 m1.GetILGenerator ().Emit (OpCodes.Ret);
3484 MethodBuilder m2 = type2.DefineMethod ("Tst", attrs2, typeof (void), null);
3485 m2.GetILGenerator ().Emit (OpCodes.Ret);
3488 type0.CreateType ();
3489 type1.CreateType ();
3490 Type t2 = type2.CreateType ();
3492 foreach (var m in t2.GetMethods (BindingFlags.Instance | BindingFlags.NonPublic))
3493 Assert.IsTrue (m.DeclaringType == typeof (object), String.Format ("{0}::{1}", m.DeclaringType, m.Name));
3497 public void MakeArrayTypeOfOneDimension ()
3499 Type vector = typeof (int).MakeArrayType ();
3500 Type szarray = typeof (int).MakeArrayType (1);
3502 Assert.AreNotEqual (vector, szarray, "#1");
3503 Assert.AreEqual ("Int32[]", vector.Name, "#2");
3504 Assert.AreEqual ("Int32[*]", szarray.Name, "#3");
3507 public class DeclaringMethodFoo {
3508 public void Test<T> (T t) {}
3509 public void Test2<T> (ref T t) {}
3512 public class DeclaringMethodBar<T> {
3513 public void Test2 (ref T t) {}
3517 public void DeclaringMethodOnlyWorksWithGenericArgs ()
3519 MethodInfo testMethod = typeof (DeclaringMethodFoo).GetMethod ("Test");
3520 MethodBase otherMethod = testMethod.GetParameters ()[0].ParameterType.DeclaringMethod;
3522 Assert.AreEqual (testMethod, otherMethod,"#1");
3524 Assert.IsNull (typeof (DeclaringMethodBar<>).GetGenericArguments ()[0].DeclaringMethod, "#2");
3527 var x = typeof (int).DeclaringMethod;
3529 } catch (InvalidOperationException) {}
3532 var x = typeof (DeclaringMethodFoo).GetMethod ("Test2").GetParameters () [0].ParameterType.DeclaringMethod;
3534 } catch (InvalidOperationException) {}
3537 var x = typeof (DeclaringMethodBar<>).GetMethod ("Test2").GetParameters () [0].ParameterType.DeclaringMethod;
3539 } catch (InvalidOperationException) {}
3544 public void GetArrayRankThrowsForNonArrayType ()
3546 Assert.AreEqual (1, typeof (int[]).GetArrayRank (), "#1");
3547 Assert.AreEqual (2, typeof (int[,]).GetArrayRank (), "#2");
3549 typeof (int).GetArrayRank ();
3551 } catch (ArgumentException) {}
3554 [Test] //Bug #564379
3555 public void GetMethodsReturnPublicMethodsInInterfaces ()
3557 Type t = typeof (NonClosingStream);
3558 MethodInfo[] methods = t.GetMethods (BindingFlags.Public | BindingFlags.Instance);
3560 Assert.AreEqual (5, methods.Length, "#1");
3563 foreach (var m in methods) {
3564 if (m.Name.Equals ("ToString"))
3565 Assert.IsTrue (m.DeclaringType == typeof (NonClosingStream), "#" + id);
3566 else if (m.Name.Equals ("Dispose") && m.GetParameters ().Length == 0)
3567 Assert.IsTrue (m.DeclaringType == typeof (Stream), "#" + id);
3568 else if (m.Name.Equals ("Equals") || m.Name.Equals ("GetHashCode") || m.Name.Equals ("GetType"))
3569 Assert.IsTrue (m.DeclaringType == typeof (object), "#" + id);
3571 Assert.Fail ("invalid method " + m);
3576 [Test] // Bug #574696
3577 public void GetMember_DoesntReturnPrivatePropOfParent ()
3579 BindingFlags flags = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance;
3580 Assert.AreEqual (1, typeof (Bar).GetMember ("PrivInst", flags).Length);
3581 Assert.AreEqual (0, typeof (Bar).GetMember ("PrivInstBase", flags).Length);
3582 Assert.AreEqual (1, typeof (Foo).GetMember ("PrivInstBase", flags).Length);
3585 [Test] // Bug #484246
3586 public void GetInterfaceCompareAgainstGTDNames ()
3588 var t = typeof (Dictionary<string,string>);
3589 var iface = typeof (IDictionary<string,string>);
3591 Assert.AreSame (iface, t.GetInterface ("System.Collections.Generic.IDictionary`2"), "#1");
3593 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]]";
3595 Assert.IsNull (t.GetInterface (name), "#2");
3599 public void RuntimeCorrectlyNormalizeGenericTypes ()
3601 Type lst = typeof (MList<>);
3602 Type arg = lst.GetGenericArguments ()[0];
3604 Type sup = lst.BaseType;
3605 Type sa0 = sup.GetGenericArguments ()[0];
3606 Type sa1 = sup.GetGenericArguments ()[1];
3608 Assert.IsTrue (sa1 == lst, "#1");
3609 Assert.IsTrue (sa0 == arg, "#2");
3611 Type inst = typeof (Cons<,>).MakeGenericType (arg, lst.MakeGenericType (arg));
3612 Assert.IsTrue (inst == sup, "#3");
3620 class MList<A> : Cons<A, MList<A>>
3625 [Test] // Bug #331126
3626 public void IsAssignableFromWorksCorrectlyWithByRefs ()
3628 Type int_byref = typeof (int).MakeByRefType ();
3629 Type obj_byref = typeof (object).MakeByRefType ();
3630 Type long_byref = typeof (long).MakeByRefType ();
3631 Type enum1_byref = typeof (AttributeTargets).MakeByRefType ();
3632 Type enum2_byref = typeof (PlatformID).MakeByRefType ();
3633 Type uint_byref = typeof (uint).MakeByRefType ();
3634 Type string_byref = typeof (object).MakeByRefType ();
3635 Type struct0_byref = typeof (Size4).MakeByRefType ();
3636 Type struct1_byref = typeof (Size4b).MakeByRefType ();
3637 Type mvar0_byref = typeof (TypeTest).GetMethod ("Bug331126").GetGenericArguments ()[0].MakeByRefType ();
3638 Type mvar1_byref = typeof (TypeTest).GetMethod ("Bug331126").GetGenericArguments ()[1].MakeByRefType ();
3640 Assert.IsFalse (typeof (int).IsAssignableFrom (int_byref), "#1");
3641 Assert.IsFalse (int_byref.IsAssignableFrom (typeof (int)), "#2");
3642 Assert.IsFalse (obj_byref.IsAssignableFrom (long_byref), "#3");
3643 Assert.IsFalse (long_byref.IsAssignableFrom (obj_byref), "#4");
3644 Assert.IsTrue (enum1_byref.IsAssignableFrom (enum2_byref), "#5");
3645 Assert.IsTrue (enum2_byref.IsAssignableFrom (enum1_byref), "#6");
3646 Assert.IsTrue (int_byref.IsAssignableFrom (enum2_byref), "#7");
3647 Assert.IsTrue (enum2_byref.IsAssignableFrom (int_byref), "#8");
3648 Assert.IsTrue (enum2_byref.IsAssignableFrom (uint_byref), "#9");
3649 Assert.IsTrue (uint_byref.IsAssignableFrom (enum2_byref), "#10");
3650 Assert.IsTrue (int_byref.IsAssignableFrom (uint_byref), "#11");
3651 Assert.IsTrue (uint_byref.IsAssignableFrom (int_byref), "#12");
3653 Assert.IsTrue (typeof (object).IsAssignableFrom (typeof (long)), "#13");
3655 Assert.IsTrue (obj_byref.IsAssignableFrom (string_byref), "#14");
3656 Assert.IsTrue (string_byref.IsAssignableFrom (obj_byref), "#15");
3658 Assert.IsFalse (uint_byref.IsAssignableFrom (struct0_byref), "#16");
3659 Assert.IsFalse (struct0_byref.IsAssignableFrom (int_byref), "#17");
3660 Assert.IsFalse (struct0_byref.IsAssignableFrom (struct1_byref), "#18");
3662 Assert.IsFalse (obj_byref.IsAssignableFrom (mvar0_byref), "#19");
3663 Assert.IsFalse (mvar0_byref.IsAssignableFrom (mvar1_byref), "#20");
3664 Assert.IsTrue (mvar0_byref.IsAssignableFrom (mvar0_byref), "#21");
3665 Assert.IsFalse (mvar0_byref.IsAssignableFrom (obj_byref), "#22");
3668 public void Bug331126<T,K> () {}
3670 public struct Size4 {
3674 public struct Size4b {
3679 public void IsAssignableFromGenericArgumentsWithConstraints ()
3681 // Regression test for #58809
3683 // Generic Parameters of a gtd should have their
3684 // constraints respected even when those constraints
3685 // are other generic parameters themselves.
3687 var ps = typeof (GenericWithParamConstraints<,,>).GetGenericArguments ();
3694 var fooOfC = typeof (Foo<>).MakeGenericType (c);
3696 // constraint B : Foo <C>
3697 Assert.IsTrue (fooOfC.IsAssignableFrom (b), "#1");
3700 Assert.IsTrue (b.IsAssignableFrom (a), "#2");
3702 // A : Foo<C> since A : B and B : Foo<C>
3703 Assert.IsTrue (fooOfC.IsAssignableFrom (a), "#3");
3706 class GenericWithParamConstraints<A, B, C> where B : Foo<C> where A : B
3710 [Test] // Bug #612780
3711 public void CannotMakeDerivedTypesFromTypedByRef ()
3714 typeof (global::System.TypedReference).MakeArrayType ();
3716 } catch (TypeLoadException) { }
3719 typeof (global::System.TypedReference).MakeByRefType ();
3721 } catch (TypeLoadException) { }
3724 typeof (global::System.TypedReference).MakePointerType ();
3726 } catch (TypeLoadException) { }
3731 public void DeclaringTypeOfGenericNestedTypeInstanceIsOpen ()
3733 var type = typeof (Foo<int>.Nested<string>);
3734 Assert.AreSame (typeof (Foo<>), type.DeclaringType, "#1");
3737 interface IGetInterfaceMap<in T>
3742 class GetInterfaceMap : IGetInterfaceMap<object>
3744 public string Bar (object t)
3746 return t.GetType ().FullName;
3751 public void GetInterfaceMapWorksWithVariantIfaces ()
3753 InterfaceMapping res = typeof (GetInterfaceMap).GetInterfaceMap (typeof (IGetInterfaceMap <object>));
3754 Assert.AreEqual (typeof (IGetInterfaceMap <object>), res.InterfaceType);
3755 Assert.AreEqual (typeof (object), res.InterfaceMethods [0].GetParameters () [0].ParameterType);
3757 res = typeof (GetInterfaceMap).GetInterfaceMap (typeof (IGetInterfaceMap <string>));
3758 Assert.AreEqual (typeof (IGetInterfaceMap <string>), res.InterfaceType);
3759 Assert.AreEqual (typeof (string), res.InterfaceMethods [0].GetParameters () [0].ParameterType);
3763 public class MyType : TypeDelegator {
3766 public override bool Equals (Type t) {
3768 return base.Equals (t);
3771 public override Type UnderlyingSystemType {
3774 return typeof (int);
3780 public void NewV4EqualsBehavior ()
3782 var ta = new MyType ();
3783 var tb = new MyType ();
3784 object a = ta, b = tb;
3787 Assert.AreEqual (1, ta.eq, "#1");
3788 Assert.AreEqual (2, ta.ust, "#2");
3790 Assert.AreEqual (2, ta.eq, "#3");
3791 Assert.AreEqual (3, ta.ust, "#4");
3792 Assert.AreEqual (0, tb.eq, "#5");
3793 Assert.AreEqual (1, tb.ust, "#6");
3796 public enum MyRealEnum : short {
3801 public enum MyRealEnum2 : byte {
3805 public enum MyRealEnum3 : short {
3809 public class MyEnum : TypeDelegator {
3810 public bool is_enum { get; set; }
3811 public int fields { get; set; }
3813 public override bool IsSubclassOf (Type c) {
3814 return c == typeof (Enum) && is_enum;
3817 public override FieldInfo[] GetFields (BindingFlags bindingAttr) {
3820 FieldInfo[] res = new FieldInfo [fields];
3821 for (int i = 0; i < fields; ++i) {
3822 if ((bindingAttr & BindingFlags.Instance) != 0)
3823 res [i] = typeof (MyRealEnum).GetField ("value__");
3825 res [i] = typeof (MyRealEnum).GetField ("A");
3832 public void GetEnumUnderlyingType () {
3835 new MyEnum () { is_enum = false }.GetEnumUnderlyingType ();
3837 } catch (ArgumentException) {}
3840 new MyEnum () { is_enum = true, fields = 0 }.GetEnumUnderlyingType ();
3842 } catch (ArgumentException) {}
3845 new MyEnum () { is_enum = true, fields = 2 }.GetEnumUnderlyingType ();
3847 } catch (ArgumentException) {}
3849 Assert.AreSame (typeof (short), new MyEnum () { is_enum = true, fields = 1 }.GetEnumUnderlyingType ());
3853 public void GetEnumNames () {
3855 new MyEnum () { is_enum = false }.GetEnumNames ();
3857 } catch (ArgumentException) {}
3859 var res = new MyEnum () { is_enum = true, fields = 1 }.GetEnumNames ();
3860 Assert.AreEqual (1, res.Length, "#2");
3861 Assert.AreEqual ("A", res [0], "#3");
3863 res = typeof (MyRealEnum).GetEnumNames ();
3864 Assert.AreEqual (3, res.Length, "#4");
3865 Assert.AreEqual ("A", res [0], "#5");
3866 Assert.AreEqual ("B", res [1], "#6");
3867 Assert.AreEqual ("C", res [2], "#7");
3870 public enum OutOfOrderEnum : sbyte
3872 D = -1, C = 2, B = 1, A = 0
3876 public void GetEnumNamesSortsByUnsignedValue ()
3878 string[] names = typeof (OutOfOrderEnum).GetEnumNames ();
3879 Assert.AreEqual (4, names.Length);
3880 Assert.AreEqual ("A", names [0]);
3881 Assert.AreEqual ("B", names [1]);
3882 Assert.AreEqual ("C", names [2]);
3883 Assert.AreEqual ("D", names [3]);
3887 public void GetEnumValues () {
3889 new MyEnum () { is_enum = false }.GetEnumValues ();
3891 } catch (ArgumentException) {}
3894 new MyEnum () { is_enum = true }.GetEnumValues ();
3896 } catch (NotImplementedException) {}
3898 var array = typeof (MyRealEnum).GetEnumValues ();
3899 Assert.AreEqual (typeof (MyRealEnum[]), array.GetType (), "#3");
3900 MyRealEnum[] res = (MyRealEnum[])array;
3902 Assert.AreEqual (3, res.Length, "#4");
3903 Assert.AreEqual (MyRealEnum.A, res [0], "#5");
3904 Assert.AreEqual (MyRealEnum.B, res [1], "#6");
3905 Assert.AreEqual (MyRealEnum.C, res [2], "#7");
3909 public void GetEnumValue () {
3911 typeof (MyRealEnum).GetEnumName (null);
3913 } catch (ArgumentException) { }
3916 new MyEnum () { is_enum = false }.GetEnumName (99);
3918 } catch (ArgumentException) { }
3921 Assert.IsNull (new MyEnum () { fields = 1, is_enum = true }.GetEnumName (77), "#3");
3922 Assert.AreEqual ("A", new MyEnum () { fields = 1, is_enum = true }.GetEnumName (0), "#4");
3923 Assert.AreEqual ("A", new MyEnum () { fields = 1, is_enum = true }.GetEnumName (MyRealEnum.A), "#5");
3924 Assert.AreEqual ("A", new MyEnum () { fields = 1, is_enum = true }.GetEnumName (MyRealEnum2.A), "#6");
3926 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName (MyRealEnum.A), "#7");
3927 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((short)0), "#8");
3928 Assert.AreEqual ("C", typeof (MyRealEnum).GetEnumName (2), "#9");
3929 Assert.IsNull (typeof (MyRealEnum).GetEnumName (9), "#10");
3931 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((byte)0), "#11");
3932 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((sbyte)0), "#12");
3933 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName (false), "#13");
3934 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((short)0), "#14");
3935 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((ushort)0), "#15");
3936 Assert.IsNull (typeof (MyRealEnum).GetEnumName ('c'), "#16");
3938 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((int)0), "#17");
3939 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((uint)0), "#18");
3941 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((long)0), "#19");
3942 Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((ulong)0), "#20");
3945 typeof (MyRealEnum).GetEnumName ((float)0);
3946 Assert.Fail ("#21");
3947 } catch (ArgumentException) { }
3949 typeof (MyRealEnum).GetEnumName ((double)0);
3950 Assert.Fail ("#22");
3951 } catch (ArgumentException) { }
3954 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((byte)0), "#23");
3955 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((sbyte)0), "#24");
3956 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName (false), "#25");
3958 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((short)0), "#26");
3959 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((ushort)0), "#27");
3961 Assert.IsNull (typeof (MyRealEnum2).GetEnumName ('c'), "#28");
3963 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((int)0), "#29");
3964 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((uint)0), "#30");
3966 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((long)0), "#31");
3967 Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((ulong)0), "#32");
3970 typeof (MyRealEnum2).GetEnumName ((float)0);
3971 Assert.Fail ("#33");
3972 } catch (ArgumentException) { }
3974 typeof (MyRealEnum2).GetEnumName ((double)0);
3975 Assert.Fail ("#34");
3976 } catch (ArgumentException) { }
3978 Assert.IsNull (typeof (MyRealEnum2).GetEnumName (12345), "#35");
3982 public void IsEnumDefined () {
3984 typeof (MyRealEnum).IsEnumDefined (null);
3986 } catch (ArgumentException) { }
3989 new MyEnum () { is_enum = false }.IsEnumDefined (99);
3991 } catch (ArgumentException) { }
3994 typeof (MyRealEnum).IsEnumDefined (0);
3996 } catch (ArgumentException) { }
3999 typeof (MyRealEnum).IsEnumDefined ((ushort)0);
4001 } catch (ArgumentException) { }
4004 typeof (MyRealEnum).IsEnumDefined (MyRealEnum3.A);
4006 } catch (ArgumentException) { }
4009 typeof (MyRealEnum).IsEnumDefined (true);
4011 } catch (ArgumentException) { }
4014 typeof (MyRealEnum).IsEnumDefined (MyRealEnum2.A);
4016 } catch (ArgumentException) { }
4019 typeof (MyRealEnum).IsEnumDefined (typeof (MyRealEnum));
4021 } catch (InvalidOperationException) { }
4023 Assert.IsTrue (typeof (MyRealEnum).IsEnumDefined ((short)0), "#9");
4024 Assert.IsFalse (typeof (MyRealEnum).IsEnumDefined ((short)88), "#10");
4025 Assert.IsTrue (typeof (MyRealEnum).IsEnumDefined (MyRealEnum.A), "#11");
4026 Assert.IsFalse (typeof (MyRealEnum).IsEnumDefined ("d"), "#12");
4027 Assert.IsTrue (typeof (MyRealEnum).IsEnumDefined ("A"), "#13");
4028 Assert.IsFalse (new MyEnum () { is_enum = true, fields = 1 }.IsEnumDefined ((short)99), "#14");
4033 public class Outer {
4034 public class Inner {}
4038 public class Outer<T> {
4039 public class Inner {}
4043 public void GetTypeWithDelegates () {
4044 var tname = typeof (MyRealEnum).AssemblyQualifiedName;
4045 var res = Type.GetType (tname, name => {
4046 return Assembly.Load (name);
4047 },(asm,name,ignore) => {
4048 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4050 Assert.AreEqual (typeof (MyRealEnum), res, "#1");
4053 tname = typeof (Dictionary<int, string>).AssemblyQualifiedName;
4054 res = Type.GetType (tname, name => {
4055 return Assembly.Load (name);
4056 },(asm,name,ignore) => {
4057 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4059 Assert.AreEqual (typeof (Dictionary<int, string>), res, "#2");
4062 tname = typeof (Foo<int>).AssemblyQualifiedName;
4063 res = Type.GetType (tname, name => {
4064 return Assembly.Load (name);
4065 },(asm,name,ignore) => {
4066 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4068 Assert.AreEqual (typeof (Foo<int>), res, "#3");
4071 tname = typeof (Outer.Inner).AssemblyQualifiedName;
4072 res = Type.GetType (tname, name => {
4073 return Assembly.Load (name);
4074 },(asm,name,ignore) => {
4075 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4077 Assert.AreEqual (typeof (Outer.Inner), res, "#4");
4080 tname = typeof (Outer<double>.Inner).AssemblyQualifiedName;
4081 res = Type.GetType (tname, name => {
4082 return Assembly.Load (name);
4083 },(asm,name,ignore) => {
4084 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4086 Assert.AreEqual (typeof (Outer<double>.Inner), res, "#5");
4089 tname = "System.Collections.Generic.List`1[System.Int32]";
4090 res = Type.GetType (tname, name => {
4091 return Assembly.Load (name);
4092 },(asm,name,ignore) => {
4093 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4095 Assert.AreEqual (typeof (List<int>), res, "#6");
4098 tname = typeof (Foo<>).FullName + "[,][]";
4099 res = Type.GetType (tname, name => {
4100 Console.WriteLine ("resolve-asm name {0}", name);
4101 return Assembly.Load (name);
4102 },(asm,name,ignore) => {
4103 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4105 Assert.AreEqual (typeof (Foo<>).MakeArrayType (2).MakeArrayType (), res, "#7");
4107 tname = string.Format("{0}[{1}][]*&", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName);
4108 res = Type.GetType (tname, name => {
4109 return Assembly.Load (name);
4110 },(asm,name,ignore) => {
4111 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4113 Assert.AreEqual (typeof (Foo<MyRealEnum>[]).MakePointerType ().MakeByRefType (), res, "#8");
4116 tname = typeof (MyRealEnum).FullName + "[][]";
4117 res = Type.GetType (tname, name => {
4118 return Assembly.Load (name);
4119 },(asm,name,ignore) => {
4120 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4122 Assert.AreEqual (typeof (MyRealEnum[][]), res, "#9");
4125 tname = typeof (MyRealEnum).FullName + "[*]";
4126 res = Type.GetType (tname, name => {
4127 return Assembly.Load (name);
4128 },(asm,name,ignore) => {
4129 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4131 Assert.AreEqual (typeof (MyRealEnum).MakeArrayType (1), res, "#10");
4134 tname = typeof (MyRealEnum).FullName + "&";
4135 res = Type.GetType (tname, name => {
4136 return Assembly.Load (name);
4137 },(asm,name,ignore) => {
4138 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4140 Assert.AreEqual (typeof (MyRealEnum).MakeByRefType (), res, "#11");
4143 tname = typeof (MyRealEnum).FullName + "*";
4144 res = Type.GetType (tname, name => {
4145 return Assembly.Load (name);
4146 },(asm,name,ignore) => {
4147 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4149 Assert.AreEqual (typeof (MyRealEnum).MakePointerType (), res, "#12");
4151 tname = typeof (MyRealEnum).FullName + "*&";
4152 res = Type.GetType (tname, name => {
4153 return Assembly.Load (name);
4154 },(asm,name,ignore) => {
4155 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4157 Assert.AreEqual (typeof (MyRealEnum).MakePointerType ().MakeByRefType(),
4160 tname = typeof (MyRealEnum).FullName + "[,]&";
4161 res = Type.GetType (tname, name => {
4162 return Assembly.Load (name);
4163 },(asm,name,ignore) => {
4164 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4166 Assert.AreEqual (typeof (MyRealEnum).MakeArrayType (2).MakeByRefType (),
4169 tname = typeof (MyRealEnum).FullName + "*[]";
4170 res = Type.GetType (tname, name => {
4171 return Assembly.Load (name);
4172 },(asm,name,ignore) => {
4173 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4175 Assert.AreEqual (typeof (MyRealEnum).MakePointerType().MakeArrayType(),
4178 // not a very useful type, but ought to be parsed correctly
4179 tname = typeof (MyRealEnum).FullName + "[]**[]*&";
4180 res = Type.GetType (tname, name => {
4181 return Assembly.Load (name);
4182 },(asm,name,ignore) => {
4183 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4185 Assert.AreEqual (typeof (MyRealEnum).MakeArrayType().MakePointerType().MakePointerType().MakeArrayType().MakePointerType().MakeByRefType(),
4188 // assembly resolve without type resolve
4189 res = Type.GetType ("System.String,mscorlib", delegate (AssemblyName aname) { return typeof (int).Assembly; }, null);
4190 Assert.AreEqual (typeof (string), res);
4194 public class CustomGetType : TypeDelegator {
4197 public CustomGetType (string name) { this.name = name; }
4199 public override Type MakeGenericType (Type[] args) {
4200 return new CustomGetType ("GINST");
4203 public override Type GetNestedType(String name, BindingFlags bidingAttr) {
4204 return new CustomGetType ("NESTED");
4207 public override string ToString () { return "UT_" + name; }
4209 public override string Name {
4210 get { return "UT_" + name; }
4215 public void GetTypeWithDelegatesAndUserTypes ()
4217 var tname = "Magic[System.Int32]";
4218 var res = Type.GetType (tname, name => {
4219 return Assembly.Load (name);
4220 },(asm,name,ignore) => {
4221 if (name == "Magic") return new CustomGetType ("MAGIC");
4222 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4224 Assert.AreEqual ("UT_GINST", res.Name, "#1");
4227 tname = "Magic+MyRealEnum";
4228 res = Type.GetType (tname, name => {
4229 return Assembly.Load (name);
4230 },(asm,name,ignore) => {
4231 if (name == "Magic") return new CustomGetType ("MAGIC");
4232 return asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4234 Assert.AreEqual ("UT_NESTED", res.Name, "#2");
4237 void MustTLE (string tname) {
4239 var res = Type.GetType (tname, name => {
4240 return Assembly.Load (name);
4241 },(asm,name,ignore) => {
4242 return (object)asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4244 Assert.Fail (tname);
4245 } catch (TypeLoadException) {}
4248 void MustANE (string tname) {
4250 var res = Type.GetType (tname, name => {
4251 return Assembly.Load (name);
4252 },(asm,name,ignore) => {
4253 return (object)asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4255 Assert.Fail (tname);
4256 } catch (ArgumentNullException) {}
4259 void MustAE_general (string tname, Func<string,Type> getType) {
4261 var res = getType (tname);
4262 Assert.Fail (tname);
4263 } catch (ArgumentException) {}
4266 void MustAE (string typename) {
4267 MustAE_general (typename, tname => {
4268 return Type.GetType (tname, name => {
4269 return Assembly.Load (name);
4270 },(asm,name,ignore) => {
4271 return (object)asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4276 void MustAEnn (string typename) {
4277 MustAE_general (typename, tname => Type.GetType (tname, null, null));
4280 void MustFNFE (string tname) {
4282 var res = Type.GetType (tname, name => {
4283 return Assembly.Load (name);
4284 },(asm,name,ignore) => {
4285 return (object)asm == null ? Type.GetType (name, false, ignore) : asm.GetType (name, false, ignore);
4287 Assert.Fail (tname);
4288 } catch (FileNotFoundException) {}
4292 public void NewGetTypeErrors () {
4294 MustAE ("!@#$%^&*");
4295 MustAE (string.Format ("{0}[{1}&]", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4296 MustAE (string.Format ("{0}[{1}*]", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4297 MustAE (string.Format ("{0}&&", typeof (MyRealEnum).FullName));
4298 MustAE (string.Format ("{0}&*", typeof (MyRealEnum).FullName));
4299 MustAE (string.Format ("{0}&[{1}]", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4300 MustAE (string.Format ("{0}[,", typeof (MyRealEnum).FullName));
4301 MustAE (string.Format ("{0}[*", typeof (MyRealEnum).FullName));
4303 MustAE (string.Format ("{0}[[{1},", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4304 MustAE (string.Format ("{0}[[{1}]", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4305 MustAE (string.Format ("{0}[[{1}],", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4306 MustAE (string.Format ("{0}[[{1}]_", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4308 MustAE (string.Format ("{0}[{1}", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4309 MustAE (string.Format ("{0}[{1},", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4310 MustAE (string.Format ("{0}[{1},,", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4311 MustAE (string.Format ("{0}[{1} (", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4312 MustAE (string.Format ("{0}[", typeof (Foo<>).FullName));
4314 MustAE (string.Format ("{0}[**]", typeof (MyRealEnum).FullName));
4315 MustAE (string.Format ("{0}[*,*]", typeof (MyRealEnum).FullName));
4316 MustAE (string.Format ("{0}[*,]", typeof (MyRealEnum).FullName));
4317 MustAE (string.Format ("{0}[,*]", typeof (MyRealEnum).FullName));
4318 MustAE (string.Format ("{0}[,-]", typeof (MyRealEnum).FullName));
4319 MustAE (string.Format ("{0}[,{0}]", typeof (MyRealEnum).FullName));
4321 MustAE (string.Format ("{0}[{1}]]", typeof (Foo<>).FullName, typeof (MyRealEnum).FullName));
4322 MustAE (string.Format ("{0}[,]]", typeof (MyRealEnum).FullName));
4325 string aqn = typeof (MyRealEnum).Assembly.FullName;
4326 MustFNFE (string.Format ("{0}, ZZZ{1}", typeof (MyRealEnum).FullName, aqn));
4327 MustTLE (string.Format ("{0}ZZZZ", typeof (MyRealEnum).FullName));
4328 MustTLE (string.Format ("{0}ZZZZ,{1}", typeof (MyRealEnum).FullName, aqn));
4332 public void GetTypeExceptionMsg () {
4333 string typeName = "system.int32, foo";
4335 Type.GetType(typeName, true, false);
4336 } catch (TypeLoadException ex) {
4337 Assert.IsTrue (ex.Message.Contains ("system.int32"));
4338 Assert.IsTrue (ex.Message.Contains ("foo"));
4342 delegate void MyAction<in T>(T ag);
4344 [Test] //bug #668506
4345 public void IsAssignableFromWithVariantDelegate () {
4346 Assert.IsFalse (typeof(MyAction<string>).IsAssignableFrom(typeof(MyAction<>)), "#1");
4350 public void IsAssignableFromWithNullable () {
4351 Console.WriteLine(typeof(IEnumerable<int?>).IsAssignableFrom(typeof(IEnumerable<int>)));
4355 public void GetTypeParseGenericCorrectly () { //Bug #15124
4356 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1"), typeof (Foo<>), "#1");
4357 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32]"), typeof (Foo<int>), "#2");
4358 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[[System.Int32]]"), typeof (Foo<int>), "#3");
4359 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32][]"), typeof (Foo<int>[]), "#4");
4360 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[][System.Int32]"), null, "#5");
4361 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32][,]"), typeof (Foo<int>[,]), "#6");
4362 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[]"), typeof (Foo<>).MakeArrayType(), "#7");
4363 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[,]"), typeof (Foo<>).MakeArrayType (2), "#8");
4364 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[][]"), typeof (Foo<>).MakeArrayType ().MakeArrayType (), "#9");
4365 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1["), null, "#10");
4366 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[["), null, "#11");
4367 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[[]"), null, "#12");
4368 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[,"), null, "#13");
4369 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[*"), null, "#14");
4370 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32"), null, "#15");
4374 public void GetTypeNullDelegatesParseGenericCorrectly () {
4375 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1", null, null), typeof (Foo<>), "#1");
4376 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32]", null, null), typeof (Foo<int>), "#2");
4377 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[[System.Int32]]", null, null), typeof (Foo<int>), "#3");
4378 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32][]", null, null), typeof (Foo<int>[]), "#4");
4379 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32][,]", null, null), typeof (Foo<int>[,]), "#5");
4380 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[]", null, null), typeof (Foo<>).MakeArrayType(), "#6");
4381 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[,]", null, null), typeof (Foo<>).MakeArrayType (2), "#7");
4382 Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[][]", null, null), typeof (Foo<>).MakeArrayType ().MakeArrayType (), "#8");
4384 MustAEnn ("MonoTests.System.Foo`1[][System.Int32]");
4385 MustAEnn ("MonoTests.System.Foo`1[");
4386 MustAEnn ("MonoTests.System.Foo`1[[");
4387 MustAEnn ("MonoTests.System.Foo`1[[]");
4388 MustAEnn ("MonoTests.System.Foo`1[,");
4389 MustAEnn ("MonoTests.System.Foo`1[*");
4390 MustAEnn ("MonoTests.System.Foo`1[System.Int32");
4393 Dictionary<int, T> MakeDictHelper<T> (T[] arr) {
4394 return new Dictionary<int, T>();
4398 public void GetTypeAnonymousParseCorrectly () {
4399 var x = new { X = 1 };
4400 var a = new [] { x };
4401 var d = MakeDictHelper (a);
4403 var x_type = x.GetType ();
4404 var a_type = a.GetType ();
4405 var d_type = d.GetType ();
4407 Assert.AreEqual (Type.GetType (x_type.ToString ()), x_type, "#1");
4408 Assert.AreEqual (Type.GetType (x_type.ToString (), null, null), x_type, "#2");
4409 Assert.AreEqual (Type.GetType (a_type.ToString ()), a_type, "#3");
4410 Assert.AreEqual (Type.GetType (a_type.ToString (), null, null), a_type, "#4");
4411 Assert.AreEqual (Type.GetType (d_type.ToString ()), d_type, "#5");
4412 Assert.AreEqual (Type.GetType (d_type.ToString (), null, null), d_type, "#6");
4414 Assert.AreEqual (Type.GetType (x_type.FullName), x_type, "#7");
4415 Assert.AreEqual (Type.GetType (x_type.FullName, null, null), x_type, "#8");
4416 Assert.AreEqual (Type.GetType (a_type.FullName), a_type, "#9");
4417 Assert.AreEqual (Type.GetType (a_type.FullName, null, null), a_type, "#10");
4418 Assert.AreEqual (Type.GetType (d_type.FullName), d_type, "#11");
4419 Assert.AreEqual (Type.GetType (d_type.FullName, null, null), d_type, "#12");
4423 #if !MONOTOUCH && !FULL_AOT_RUNTIME && !MONOMAC
4425 [Category ("AndroidNotWorking")] // requires symbol writer
4426 public void FullNameGetTypeParseEscapeRoundtrip () // bug #26384
4428 var nm = new AssemblyName ("asm");
4429 var ab = AssemblyBuilder.DefineDynamicAssembly (nm,
4430 AssemblyBuilderAccess.Run);
4431 var mb = ab.DefineDynamicModule("m", false);
4432 var tb = mb.DefineType ("NameSpace,+*&[]\\.Type,+*&[]\\",
4433 TypeAttributes.Class | TypeAttributes.Public);
4435 var nestedTb = tb.DefineNestedType("Nested,+*&[]\\",
4436 TypeAttributes.Class | TypeAttributes.NestedPublic);
4438 var ty = tb.CreateType();
4440 var nestedTy = nestedTb.CreateType();
4442 var escapedNestedName =
4443 "NameSpace\\,\\+\\*\\&\\[\\]\\\\"
4445 + "Type\\,\\+\\*\\&\\[\\]\\\\"
4447 + "Nested\\,\\+\\*\\&\\[\\]\\\\";
4449 Assert.AreEqual(escapedNestedName, nestedTy.FullName);
4451 var lookupNestedTy =
4452 Type.GetType(escapedNestedName + "," + nm.FullName,
4454 if (asmName.FullName.Equals(nm.FullName)) return ab;
4455 else return Assembly.Load (asmName);
4457 (asm,name,ignore) => {
4459 return Type.GetType(name, true, ignore);
4460 else return asm.GetType(name, true, ignore);
4464 Assert.AreEqual(nestedTy, lookupNestedTy);
4471 public void GetTypeBadArity()
4473 // Regression test for #46250
4475 Type.GetType ("System.Collections.Generic.Dictionary`2[System.String]", true);
4476 Assert.Fail ("Did not throw an exception (#1)");
4477 } catch (ArgumentException) {
4481 Type.GetType ("System.Collections.Generic.Dictionary`2[System.String,System.Int32,System.Int64]", true);
4482 Assert.Fail ("Did not throw an exception (#2)");
4483 } catch (ArgumentException) {
4487 public abstract class Stream : IDisposable
4489 public void Dispose ()
4491 Console.WriteLine ("stream::dispose");
4494 protected virtual void Dispose (bool disposing)
4499 public class NonClosingStream
4500 : Stream, IDisposable
4502 void IDisposable.Dispose()
4504 Console.WriteLine ("ncs::dispose");
4507 public override string ToString () { return ""; }
4510 static bool ContainsProperty (PropertyInfo [] props, string name)
4512 foreach (PropertyInfo p in props)
4518 public class NemerleAttribute : Attribute
4522 public class VolatileModifier : NemerleAttribute
4532 [AttributeUsage (AttributeTargets.Class, Inherited=false)]
4533 public class FooAttribute : Attribute
4537 public class BarAttribute : FooAttribute
4554 [AttributeUsage (AttributeTargets.Class, Inherited=true)]
4555 public class InheritAttribute : Attribute
4559 [AttributeUsage (AttributeTargets.Class, Inherited=false)]
4560 public class NotInheritAttribute : InheritAttribute
4564 [NotInheritAttribute]
4565 public class bug82431A1
4569 public class bug82431A2 : bug82431A1
4573 [NotInheritAttribute]
4575 public class bug82431A3 : bug82431A1
4580 public class bug82431B1
4584 public class bug82431B2 : bug82431B1
4588 [NotInheritAttribute]
4589 public class bug82431B3 : bug82431B2
4593 public class bug82431B4 : bug82431B3
4601 public class Bug77367
4603 public void Run (bool b)
4610 private string PrivInstBlue
4612 get { return null; }
4615 protected string ProtInstBlue
4617 get { return null; }
4620 protected internal string ProIntInstBlue
4622 get { return null; }
4625 public long PubInstBlue
4629 if (PrivInstBlue == null)
4631 return long.MaxValue;
4635 internal int IntInstBlue
4640 private static string PrivStatBlue
4642 get { return null; }
4645 protected static string ProtStatBlue
4647 get { return null; }
4650 protected static internal string ProIntStatBlue
4652 get { return null; }
4655 public static long PubStatBlue
4659 if (PrivStatBlue == null)
4661 return long.MaxValue;
4665 internal static int IntStatBlue
4671 public class Foo : Blue
4673 private string PrivInstBase
4675 get { return null; }
4678 protected string ProtInstBase
4680 get { return null; }
4683 protected internal string ProIntInstBase
4685 get { return null; }
4688 public long PubInstBase
4692 if (PrivInstBase == null)
4694 return long.MaxValue;
4698 internal int IntInstBase
4703 private static string PrivStatBase
4705 get { return null; }
4708 protected static string ProtStatBase
4710 get { return null; }
4713 protected static internal string ProIntStatBase
4715 get { return null; }
4718 public static long PubStatBase
4722 if (PrivStatBase == null)
4724 return long.MaxValue;
4728 internal static int IntStatBase
4734 public class Bar : Foo
4736 private string PrivInst
4738 get { return null; }
4741 protected string ProtInst
4743 get { return null; }
4746 protected internal string ProIntInst
4748 get { return null; }
4755 if (PrivInst == null)
4757 return long.MaxValue;
4761 internal int IntInst
4766 private static string PrivStat
4768 get { return null; }
4771 protected static string ProtStat
4773 get { return null; }
4776 protected static internal string ProIntStat
4778 get { return null; }
4781 public static long PubStat
4785 if (PrivStat == null)
4787 return long.MaxValue;
4791 internal static int IntStat
4817 public CtorsC (int x)
4823 class UserType : Type
4825 protected Type type;
4827 public UserType(Type type) {
4831 public override Type UnderlyingSystemType { get { return this.type; } }
4833 public override Assembly Assembly { get { return this.type == null ? null : this.type.Assembly; } }
4835 public override string AssemblyQualifiedName { get { return null; } }
4837 public override Type BaseType { get { return null; } }
4839 public override Module Module { get { return this.type.Module; } }
4841 public override string Namespace { get { return null; } }
4843 public override bool IsGenericParameter { get { return true; } }
4845 public override RuntimeTypeHandle TypeHandle { get { throw new NotSupportedException(); } }
4847 public override bool ContainsGenericParameters { get { return true; } }
4849 public override string FullName { get { return this.type.Name; } }
4851 public override Guid GUID { get { throw new NotSupportedException(); } }
4854 protected override bool IsArrayImpl() {
4858 protected override bool IsByRefImpl()
4863 protected override bool IsCOMObjectImpl()
4868 protected override bool IsPointerImpl()
4873 protected override bool IsPrimitiveImpl()
4879 protected override TypeAttributes GetAttributeFlagsImpl()
4884 protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder,
4885 CallingConventions callConvention, Type[] types,
4886 ParameterModifier[] modifiers)
4891 public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr)
4896 public override Type GetElementType()
4901 public override EventInfo GetEvent(string name, BindingFlags bindingAttr)
4907 public override FieldInfo GetField(string name, BindingFlags bindingAttr)
4913 public override Type GetInterface(string name, bool ignoreCase)
4918 public override Type[] GetInterfaces()
4923 public override MemberInfo[] GetMembers(BindingFlags bindingAttr)
4928 public override object[] GetCustomAttributes(Type attributeType, bool inherit)
4933 public override object[] GetCustomAttributes(bool inherit)
4938 public override bool IsDefined(Type attributeType, bool inherit)
4943 public override string Name { get { return this.type.Name; } }
4945 public override EventInfo[] GetEvents(BindingFlags bindingAttr)
4947 throw new NotImplementedException();
4950 public override FieldInfo[] GetFields(BindingFlags bindingAttr)
4952 throw new NotImplementedException();
4955 protected override MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder,
4956 CallingConventions callConvention, Type[] types,
4957 ParameterModifier[] modifiers)
4962 public override MethodInfo[] GetMethods(BindingFlags bindingAttr)
4967 public override Type GetNestedType(string name, BindingFlags bindingAttr)
4972 public override Type[] GetNestedTypes(BindingFlags bindingAttr)
4977 public override PropertyInfo[] GetProperties(BindingFlags bindingAttr)
4982 protected override PropertyInfo GetPropertyImpl(string name, BindingFlags bindingAttr, Binder binder,
4983 Type returnType, Type[] types, ParameterModifier[] modifiers)
4988 protected override bool HasElementTypeImpl()
4993 public override object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, object target,
4994 object[] args, ParameterModifier[] modifiers, CultureInfo culture,
4995 string[] namedParameters)
4997 throw new NotSupportedException();
5001 class UserType2 : UserType {
5002 public UserType2 (Type type) : base (type) {
5005 public override Type UnderlyingSystemType { get { return this.type ?? this; } }
5007 public override int GetHashCode()
5011 return type.GetHashCode();