using NUnit.Framework;
using System;
+using System.Threading;
using System.Collections;
+using System.Collections.Generic;
using System.IO;
using System.Reflection;
+using System.Reflection.Emit;
using System.Runtime.InteropServices;
+using System.Text;
+using System.Globalization;
class NoNamespaceClass {
}
namespace MonoTests.System
{
- class Super : ICloneable {
- public virtual object Clone () {
+ class Super : ICloneable
+ {
+ public virtual object Clone ()
+ {
return null;
}
}
- class Duper: Super {
+
+ class Duper: Super
+ {
}
- interface IFace1 {
+ interface IFace1
+ {
void foo ();
}
- interface IFace2 : IFace1 {
+ interface IFace2 : IFace1
+ {
void bar ();
}
- interface IFace3 : IFace2 {
+ interface IFace3 : IFace2
+ {
}
- enum TheEnum { A, B, C };
+ enum TheEnum
+ {
+ A,
+ B,
+ C
+ };
- abstract class Base {
+ abstract class Base
+ {
public int level;
- public abstract int this [byte i] { get; }
- public abstract int this [int i] { get; }
- public abstract void TestVoid();
- public abstract void TestInt(int i);
+ public abstract int this [byte i] {
+ get;
+ }
+
+ public abstract int this [int i] {
+ get;
+ }
+
+ public abstract void TestVoid ();
+ public abstract void TestInt (int i);
}
- class DeriveVTable : Base {
- public override int this [byte i] { get { return 1; } }
- public override int this [int i] { get { return 1; } }
- public override void TestVoid() { level = 1; }
- public override void TestInt(int i) { level = 1; }
+ class DeriveVTable : Base
+ {
+ public override int this [byte i] {
+ get { return 1; }
+ }
+
+ public override int this [int i] {
+ get { return 1; }
+ }
+
+ public override void TestVoid ()
+ {
+ level = 1;
+ }
+
+ public override void TestInt (int i)
+ {
+ level = 1;
+ }
}
- class NewVTable : DeriveVTable {
- public new int this [byte i] { get { return 2; } }
- public new int this [int i] { get { return 2; } }
- public new void TestVoid() { level = 2; }
- public new void TestInt(int i) { level = 2; }
+ class NewVTable : DeriveVTable
+ {
+ public new int this [byte i] {
+ get { return 2; }
+ }
+
+ public new int this [int i] {
+ get { return 2; }
+ }
- public void Overload () { }
- public void Overload (int i) { }
+ public new void TestVoid ()
+ {
+ level = 2;
+ }
- public NewVTable (out int i) {
- i = 0;
+ public new void TestInt (int i)
+ {
+ level = 2;
+ }
+
+ public void Overload ()
+ {
+ }
+
+ public void Overload (int i)
+ {
}
- public void byref_method (out int i) {
+ public NewVTable (out int i)
+ {
i = 0;
}
+ public void byref_method (out int i)
+ {
+ i = 0;
+ }
}
- class Base1 {
+ class Base1
+ {
public virtual int Foo {
- get {
- return 1;
- }
- set {
- }
+ get { return 1; }
+ set { }
}
}
- class Derived1 : Base1 {
+ class Derived1 : Base1
+ {
public override int Foo {
- set {
- }
+ set { }
}
}
-#if NET_2_0
- public class Foo<T> {
+ class Derived2 : Base1
+ {
+ public new int Foo {
+ get { return 1; }
+ set { }
+ }
+ }
+
+ public class Foo<T>
+ {
public T Whatever;
public T Test {
get { throw new NotImplementedException (); }
}
- public T Execute(T a) {
+ public T Execute (T a)
+ {
return a;
}
}
+
+ class Foo<T, U>
+ {
+ }
+
+ public interface IBar<T>
+ {
+ }
+
+ public class Baz<T> : IBar<T>
+ {
+ }
+
+ class Gazonk {
+
+ public static void Bang<S> () {}
+ }
+
+ public class Bug348522
+ {
+ public void Test (int __argument)
+ {
+ }
+ }
+
+ public class FirstMethodBinder : Binder
+ {
+ public override MethodBase BindToMethod (BindingFlags bindingAttr, MethodBase [] match, ref object [] args,
+ ParameterModifier [] modifiers, CultureInfo culture, string [] names,
+ out object state)
+ {
+ state = null;
+ return match [0];
+ }
+
+ public override object ChangeType (object value, Type type1, CultureInfo culture)
+ {
+ return value;
+ }
+
+ // The rest is just to please the compiler
+ public override FieldInfo BindToField (BindingFlags a, FieldInfo[] b, object c, CultureInfo d)
+ {
+ return null;
+ }
+
+ public override void ReorderArgumentArray(ref object[] a, object b)
+ {
+ }
+
+ public override MethodBase SelectMethod(BindingFlags a, MethodBase[] b, Type[] c, ParameterModifier[] d)
+ {
+ return null;
+ }
+
+ public override PropertyInfo SelectProperty(BindingFlags a, PropertyInfo[] b, Type c, Type[] d, ParameterModifier[] e)
+ {
+ return null;
+ }
+ }
- public interface IBar<T> { }
- public class Baz<T> : IBar<T> { }
-#endif
[TestFixture]
public class TypeTest
{
- private void ByrefMethod (ref int i, ref Derived1 j, ref Base1 k) {
+ private AssemblyBuilder assembly;
+ private ModuleBuilder module;
+ const string ASSEMBLY_NAME = "MonoTests.System.TypeTest";
+ static int typeIndexer = 0;
+
+ [SetUp]
+ public void SetUp ()
+ {
+ AssemblyName assemblyName = new AssemblyName ();
+ assemblyName.Name = ASSEMBLY_NAME;
+ assembly = AppDomain.CurrentDomain.DefineDynamicAssembly (
+ assemblyName, AssemblyBuilderAccess.RunAndSave, Path.GetTempPath ());
+ module = assembly.DefineDynamicModule ("module1");
+ }
+
+ private string genTypeName ()
+ {
+ return "t" + (typeIndexer++);
+ }
+
+ private void ByrefMethod (ref int i, ref Derived1 j, ref Base1 k)
+ {
+ }
+
+ private void GenericMethod<Q> (Q q)
+ {
}
[Test]
- public void TestIsAssignableFrom () {
+ public void TestIsAssignableFrom ()
+ {
// Simple tests for inheritance
Assert.AreEqual (typeof (Super).IsAssignableFrom (typeof (Duper)) , true, "#01");
Assert.AreEqual (typeof (Duper).IsAssignableFrom (typeof (Duper)), true, "#02");
Assert.AreEqual (typeof (ICloneable[][]).IsAssignableFrom (typeof (Duper[][])), true, "#12");
// Tests for vectors<->one dimensional arrays */
+#if TARGET_JVM // Lower bounds arrays are not supported for TARGET_JVM.
+ Array arr1 = Array.CreateInstance (typeof (int), new int[] {1});
+ Assert.AreEqual (typeof (int[]).IsAssignableFrom (arr1.GetType ()), true, "#13");
+#else
Array arr1 = Array.CreateInstance (typeof (int), new int[] {1}, new int[] {0});
Array arr2 = Array.CreateInstance (typeof (int), new int[] {1}, new int[] {10});
Assert.AreEqual (typeof (int[]).IsAssignableFrom (arr1.GetType ()), true, "#13");
Assert.AreEqual (typeof (int[]).IsAssignableFrom (arr2.GetType ()), false, "#14");
+#endif // TARGET_JVM
// Test that arrays of enums can be cast to their base types
Assert.AreEqual (typeof (int[]).IsAssignableFrom (typeof (TypeCode[])), true, "#15");
MethodInfo mi = typeof (TypeTest).GetMethod ("ByrefMethod", BindingFlags.Instance|BindingFlags.NonPublic);
Assert.IsTrue (mi.GetParameters ()[2].ParameterType.IsAssignableFrom (mi.GetParameters ()[1].ParameterType));
Assert.IsTrue (mi.GetParameters ()[1].ParameterType.IsAssignableFrom (mi.GetParameters ()[1].ParameterType));
+
+ // Tests for type parameters
+ mi = typeof (TypeTest).GetMethod ("GenericMethod", BindingFlags.Instance|BindingFlags.NonPublic);
+ Assert.IsTrue (mi.GetParameters ()[0].ParameterType.IsAssignableFrom (mi.GetParameters ()[0].ParameterType));
+ Assert.IsFalse (mi.GetParameters ()[0].ParameterType.IsAssignableFrom (typeof (int)));
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void GetInterfaceMapOnInterface ()
+ {
+ typeof (IList).GetInterfaceMap (typeof (ICollection));
}
[Test]
- public void TestIsSubclassOf () {
+ public void TestIsSubclassOf ()
+ {
Assert.IsTrue (typeof (ICloneable).IsSubclassOf (typeof (object)), "#01");
// Tests for byref types
}
[Test]
- public void TestGetMethodImpl() {
+ public void TestGetMethodImpl ()
+ {
// Test binding of new slot methods (using no types)
Assert.AreEqual (typeof (Base), typeof (Base).GetMethod("TestVoid").DeclaringType, "#01");
Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetMethod ("TestVoid").DeclaringType, "#02");
}
[Test]
- public void TestGetPropertyImpl() {
+ [Category ("TargetJvmNotWorking")]
+ public void TestGetPropertyImpl ()
+ {
// Test getting property that is exact
Assert.AreEqual (typeof (NewVTable), typeof (NewVTable).GetProperty ("Item", new Type[1] { typeof (Int32) }).DeclaringType, "#01");
Assert.AreEqual (1, typeof (Derived1).GetProperties ().Length, "#03");
}
+ [Test]
+ public void GetProperties ()
+ {
+ // Test hide-by-name-and-signature
+ Assert.AreEqual (1, typeof (Derived2).GetProperties ().Length);
+ Assert.AreEqual (typeof (Derived2), typeof (Derived2).GetProperties ()[0].DeclaringType);
+ }
+
+ [Test] // GetProperties (BindingFlags)
+ public void GetProperties_Flags ()
+ {
+ PropertyInfo [] props;
+ Type type = typeof (Bar);
+ BindingFlags flags;
+
+ flags = BindingFlags.Instance | BindingFlags.NonPublic;
+ props = type.GetProperties (flags);
+
+ Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#A1");
+ Assert.IsTrue (ContainsProperty (props, "ProtInstBase"), "#A2");
+ Assert.IsTrue (ContainsProperty (props, "ProIntInstBase"), "#A3");
+ Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#A4");
+ Assert.IsTrue (ContainsProperty (props, "IntInstBase"), "#A5");
+ Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#A6");
+ Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#A7");
+ Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#A8");
+ Assert.IsFalse (ContainsProperty (props, "PubInst"), "#A9");
+ Assert.IsTrue (ContainsProperty (props, "IntInst"), "#A10");
+ Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#A11");
+ Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#A12");
+ Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#A13");
+ Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#A14");
+ Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#A15");
+ Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#A16");
+ Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#A17");
+ Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#A18");
+ Assert.IsFalse (ContainsProperty (props, "PubStat"), "#A19");
+ Assert.IsFalse (ContainsProperty (props, "IntStat"), "#A20");
+ Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#A21");
+ Assert.IsTrue (ContainsProperty (props, "ProtInstBlue"), "#A22");
+ Assert.IsTrue (ContainsProperty (props, "ProIntInstBlue"), "#A23");
+ Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#A24");
+ Assert.IsTrue (ContainsProperty (props, "IntInstBlue"), "#A25");
+ Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#A26");
+ Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#A27");
+ Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#A28");
+ Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#A29");
+ Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#A30");
+
+ flags = BindingFlags.Instance | BindingFlags.Public;
+ props = type.GetProperties (flags);
+
+ Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#B1");
+ Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#B2");
+ Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#B3");
+ Assert.IsTrue (ContainsProperty (props, "PubInstBase"), "#B4");
+ Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#B5");
+ Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#B6");
+ Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#B7");
+ Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#B8");
+ Assert.IsTrue (ContainsProperty (props, "PubInst"), "#B9");
+ Assert.IsFalse (ContainsProperty (props, "IntInst"), "#B10");
+ Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#B11");
+ Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#B12");
+ Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#B13");
+ Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#B14");
+ Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#B15");
+ Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#B16");
+ Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#B17");
+ Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#B18");
+ Assert.IsFalse (ContainsProperty (props, "PubStat"), "#B19");
+ Assert.IsFalse (ContainsProperty (props, "IntStat"), "#B20");
+ Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#B21");
+ Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#B22");
+ Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#B23");
+ Assert.IsTrue (ContainsProperty (props, "PubInstBlue"), "#B24");
+ Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#B25");
+ Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#B26");
+ Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#B27");
+ Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#B28");
+ Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#B29");
+ Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#B30");
+
+ flags = BindingFlags.Static | BindingFlags.Public;
+ props = type.GetProperties (flags);
+
+ Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#C1");
+ Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#C2");
+ Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#C3");
+ Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#C4");
+ Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#C5");
+ Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#C6");
+ Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#C7");
+ Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#C8");
+ Assert.IsFalse (ContainsProperty (props, "PubInst"), "#C9");
+ Assert.IsFalse (ContainsProperty (props, "IntInst"), "#C10");
+ Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#C11");
+ Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#C12");
+ Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#C13");
+ Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#C14");
+ Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#C15");
+ Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#C16");
+ Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#C17");
+ Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#C18");
+ Assert.IsTrue (ContainsProperty (props, "PubStat"), "#C19");
+ Assert.IsFalse (ContainsProperty (props, "IntStat"), "#C20");
+ Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#C21");
+ Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#C22");
+ Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#C23");
+ Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#C24");
+ Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#C25");
+ Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#C26");
+ Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#C27");
+ Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#C28");
+ Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#C29");
+ Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#C30");
+
+ flags = BindingFlags.Static | BindingFlags.NonPublic;
+ props = type.GetProperties (flags);
+
+ Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#D1");
+ Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#D2");
+ Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#D3");
+ Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#D4");
+ Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#D5");
+ Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#D6");
+ Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#D7");
+ Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#D8");
+ Assert.IsFalse (ContainsProperty (props, "PubInst"), "#D9");
+ Assert.IsFalse (ContainsProperty (props, "IntInst"), "#D10");
+ Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#D11");
+ Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#D12");
+ Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#D13");
+ Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#D14");
+ Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#D15");
+ Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#D16");
+ Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#D17");
+ Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#D18");
+ Assert.IsFalse (ContainsProperty (props, "PubStat"), "#D19");
+ Assert.IsTrue (ContainsProperty (props, "IntStat"), "#D20");
+ Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#D21");
+ Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#D22");
+ Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#D23");
+ Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#D24");
+ Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#D25");
+ Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#D26");
+ Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#D27");
+ Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#D28");
+ Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#D29");
+ Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#D30");
+
+ flags = BindingFlags.Instance | BindingFlags.NonPublic |
+ BindingFlags.FlattenHierarchy;
+ props = type.GetProperties (flags);
+
+ Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#E1");
+ Assert.IsTrue (ContainsProperty (props, "ProtInstBase"), "#E2");
+ Assert.IsTrue (ContainsProperty (props, "ProIntInstBase"), "#E3");
+ Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#E4");
+ Assert.IsTrue (ContainsProperty (props, "IntInstBase"), "#E5");
+ Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#E6");
+ Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#E7");
+ Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#E8");
+ Assert.IsFalse (ContainsProperty (props, "PubInst"), "#E9");
+ Assert.IsTrue (ContainsProperty (props, "IntInst"), "#E10");
+ Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#E11");
+ Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#E12");
+ Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#E13");
+ Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#E14");
+ Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#E15");
+ Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#E16");
+ Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#E17");
+ Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#E18");
+ Assert.IsFalse (ContainsProperty (props, "PubStat"), "#E19");
+ Assert.IsFalse (ContainsProperty (props, "IntStat"), "#E20");
+ Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#E21");
+ Assert.IsTrue (ContainsProperty (props, "ProtInstBlue"), "#E22");
+ Assert.IsTrue (ContainsProperty (props, "ProIntInstBlue"), "#E23");
+ Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#E24");
+ Assert.IsTrue (ContainsProperty (props, "IntInstBlue"), "#E25");
+ Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#E26");
+ Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#E27");
+ Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#E28");
+ Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#E29");
+ Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#E30");
+
+ flags = BindingFlags.Instance | BindingFlags.Public |
+ BindingFlags.FlattenHierarchy;
+ props = type.GetProperties (flags);
+
+ Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#F1");
+ Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#F2");
+ Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#F3");
+ Assert.IsTrue (ContainsProperty (props, "PubInstBase"), "#F4");
+ Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#F5");
+ Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#F6");
+ Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#F7");
+ Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#F8");
+ Assert.IsTrue (ContainsProperty (props, "PubInst"), "#F9");
+ Assert.IsFalse (ContainsProperty (props, "IntInst"), "#F10");
+ Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#F11");
+ Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#F12");
+ Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#F13");
+ Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#F14");
+ Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#F15");
+ Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#F16");
+ Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#F17");
+ Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#F18");
+ Assert.IsFalse (ContainsProperty (props, "PubStat"), "#F19");
+ Assert.IsFalse (ContainsProperty (props, "IntStat"), "#F20");
+ Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#F21");
+ Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#F22");
+ Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#F23");
+ Assert.IsTrue (ContainsProperty (props, "PubInstBlue"), "#F24");
+ Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#F25");
+ Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#F26");
+ Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#F27");
+ Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#F28");
+ Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#F29");
+ Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#F30");
+
+ flags = BindingFlags.Static | BindingFlags.Public |
+ BindingFlags.FlattenHierarchy;
+ props = type.GetProperties (flags);
+
+ Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#G1");
+ Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#G2");
+ Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#G3");
+ Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#G4");
+ Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#G5");
+ Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#G6");
+ Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#G7");
+ Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#G8");
+ Assert.IsFalse (ContainsProperty (props, "PubInst"), "#G9");
+ Assert.IsFalse (ContainsProperty (props, "IntInst"), "#G10");
+ Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#G11");
+ Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#G12");
+ Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#G13");
+ Assert.IsTrue (ContainsProperty (props, "PubStatBase"), "#G14");
+ Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#G15");
+ Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#G16");
+ Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#G17");
+ Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#G18");
+ Assert.IsTrue (ContainsProperty (props, "PubStat"), "#G19");
+ Assert.IsFalse (ContainsProperty (props, "IntStat"), "#G20");
+ Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#G21");
+ Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#G22");
+ Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#G23");
+ Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#G24");
+ Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#G25");
+ Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#G26");
+ Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#G27");
+ Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#G28");
+ Assert.IsTrue (ContainsProperty (props, "PubStatBlue"), "#G29");
+ Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#G30");
+
+ flags = BindingFlags.Static | BindingFlags.NonPublic |
+ BindingFlags.FlattenHierarchy;
+ props = type.GetProperties (flags);
+
+ Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#H1");
+ Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#H2");
+ Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#H3");
+ Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#H4");
+ Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#H5");
+ Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#H6");
+ Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#H7");
+ Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#H8");
+ Assert.IsFalse (ContainsProperty (props, "PubInst"), "#H9");
+ Assert.IsFalse (ContainsProperty (props, "IntInst"), "#H10");
+ Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#H11");
+ Assert.IsTrue (ContainsProperty (props, "ProtStatBase"), "#H12");
+ Assert.IsTrue (ContainsProperty (props, "ProIntStatBase"), "#H13");
+ Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#H14");
+ Assert.IsTrue (ContainsProperty (props, "IntStatBase"), "#H15");
+ Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#H16");
+ Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#H17");
+ Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#H18");
+ Assert.IsFalse (ContainsProperty (props, "PubStat"), "#H19");
+ Assert.IsTrue (ContainsProperty (props, "IntStat"), "#H20");
+ Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#H21");
+ Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#H22");
+ Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#H23");
+ Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#H24");
+ Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#H25");
+ Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#H26");
+ Assert.IsTrue (ContainsProperty (props, "ProtStatBlue"), "#H27");
+ Assert.IsTrue (ContainsProperty (props, "ProIntStatBlue"), "#H28");
+ Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#H29");
+ Assert.IsTrue (ContainsProperty (props, "IntStatBlue"), "#H30");
+
+ flags = BindingFlags.Instance | BindingFlags.NonPublic |
+ BindingFlags.DeclaredOnly;
+ props = type.GetProperties (flags);
+
+ Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#I1");
+ Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#I2");
+ Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#I3");
+ Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#I4");
+ Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#I5");
+ Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#I6");
+ Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#I7");
+ Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#I8");
+ Assert.IsFalse (ContainsProperty (props, "PubInst"), "#I9");
+ Assert.IsTrue (ContainsProperty (props, "IntInst"), "#I10");
+ Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#I11");
+ Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#I12");
+ Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#I13");
+ Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#I14");
+ Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#I15");
+ Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#I16");
+ Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#I17");
+ Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#I18");
+ Assert.IsFalse (ContainsProperty (props, "PubStat"), "#I19");
+ Assert.IsFalse (ContainsProperty (props, "IntStat"), "#I20");
+ Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#I21");
+ Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#I22");
+ Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#I23");
+ Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#I24");
+ Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#I25");
+ Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#I26");
+ Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#I27");
+ Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#I28");
+ Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#I29");
+ Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#I30");
+
+ flags = BindingFlags.Instance | BindingFlags.Public |
+ BindingFlags.DeclaredOnly;
+ props = type.GetProperties (flags);
+
+ Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#J1");
+ Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#J2");
+ Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#J3");
+ Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#J4");
+ Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#J5");
+ Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#J6");
+ Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#J7");
+ Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#J8");
+ Assert.IsTrue (ContainsProperty (props, "PubInst"), "#J9");
+ Assert.IsFalse (ContainsProperty (props, "IntInst"), "#J10");
+ Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#J11");
+ Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#J12");
+ Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#J13");
+ Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#J14");
+ Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#J15");
+ Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#J16");
+ Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#J17");
+ Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#J18");
+ Assert.IsFalse (ContainsProperty (props, "PubStat"), "#J19");
+ Assert.IsFalse (ContainsProperty (props, "IntStat"), "#J20");
+ Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#J21");
+ Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#J22");
+ Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#J23");
+ Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#J24");
+ Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#J25");
+ Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#J26");
+ Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#J27");
+ Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#J28");
+ Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#J29");
+ Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#J30");
+
+ flags = BindingFlags.Static | BindingFlags.Public |
+ BindingFlags.DeclaredOnly;
+ props = type.GetProperties (flags);
+
+ Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#K1");
+ Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#K2");
+ Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#K3");
+ Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#K4");
+ Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#K5");
+ Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#K6");
+ Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#K7");
+ Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#K8");
+ Assert.IsFalse (ContainsProperty (props, "PubInst"), "#K9");
+ Assert.IsFalse (ContainsProperty (props, "IntInst"), "#K10");
+ Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#K11");
+ Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#K12");
+ Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#K13");
+ Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#K14");
+ Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#K15");
+ Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#K16");
+ Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#K17");
+ Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#K18");
+ Assert.IsTrue (ContainsProperty (props, "PubStat"), "#K19");
+ Assert.IsFalse (ContainsProperty (props, "IntStat"), "#K20");
+ Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#K21");
+ Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#K22");
+ Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#K23");
+ Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#K24");
+ Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#K25");
+ Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#K26");
+ Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#K27");
+ Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#K28");
+ Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#K29");
+ Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#K30");
+
+ flags = BindingFlags.Static | BindingFlags.NonPublic |
+ BindingFlags.DeclaredOnly;
+ props = type.GetProperties (flags);
+
+ Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#L1");
+ Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#L2");
+ Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#L3");
+ Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#L4");
+ Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#L5");
+ Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#L6");
+ Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#L7");
+ Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#L8");
+ Assert.IsFalse (ContainsProperty (props, "PubInst"), "#L9");
+ Assert.IsFalse (ContainsProperty (props, "IntInst"), "#L10");
+ Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#L11");
+ Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#L12");
+ Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#L13");
+ Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#L14");
+ Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#L15");
+ Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#L16");
+ Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#L17");
+ Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#L18");
+ Assert.IsFalse (ContainsProperty (props, "PubStat"), "#L19");
+ Assert.IsTrue (ContainsProperty (props, "IntStat"), "#L20");
+ Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#L21");
+ Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#L22");
+ Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#L23");
+ Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#L24");
+ Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#L25");
+ Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#L26");
+ Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#L27");
+ Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#L28");
+ Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#L29");
+ Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#L30");
+
+ flags = BindingFlags.Instance | BindingFlags.NonPublic |
+ BindingFlags.Public;
+ props = type.GetProperties (flags);
+
+ Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#M1");
+ Assert.IsTrue (ContainsProperty (props, "ProtInstBase"), "#M2");
+ Assert.IsTrue (ContainsProperty (props, "ProIntInstBase"), "#M3");
+ Assert.IsTrue (ContainsProperty (props, "PubInstBase"), "#M4");
+ Assert.IsTrue (ContainsProperty (props, "IntInstBase"), "#M5");
+ Assert.IsTrue (ContainsProperty (props, "PrivInst"), "#M6");
+ Assert.IsTrue (ContainsProperty (props, "ProtInst"), "#M7");
+ Assert.IsTrue (ContainsProperty (props, "ProIntInst"), "#M8");
+ Assert.IsTrue (ContainsProperty (props, "PubInst"), "#M9");
+ Assert.IsTrue (ContainsProperty (props, "IntInst"), "#M10");
+ Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#M11");
+ Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#M12");
+ Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#M13");
+ Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#M14");
+ Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#M15");
+ Assert.IsFalse (ContainsProperty (props, "PrivStat"), "#M16");
+ Assert.IsFalse (ContainsProperty (props, "ProtStat"), "#M17");
+ Assert.IsFalse (ContainsProperty (props, "ProIntStat"), "#M18");
+ Assert.IsFalse (ContainsProperty (props, "PubStat"), "#M19");
+ Assert.IsFalse (ContainsProperty (props, "IntStat"), "#M20");
+ Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#M21");
+ Assert.IsTrue (ContainsProperty (props, "ProtInstBlue"), "#M22");
+ Assert.IsTrue (ContainsProperty (props, "ProIntInstBlue"), "#M23");
+ Assert.IsTrue (ContainsProperty (props, "PubInstBlue"), "#M24");
+ Assert.IsTrue (ContainsProperty (props, "IntInstBlue"), "#M25");
+ Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#M26");
+ Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#M27");
+ Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#M28");
+ Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#M29");
+ Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#M30");
+
+ flags = BindingFlags.Static | BindingFlags.NonPublic |
+ BindingFlags.Public;
+ props = type.GetProperties (flags);
+
+ Assert.IsFalse (ContainsProperty (props, "PrivInstBase"), "#N1");
+ Assert.IsFalse (ContainsProperty (props, "ProtInstBase"), "#N2");
+ Assert.IsFalse (ContainsProperty (props, "ProIntInstBase"), "#N3");
+ Assert.IsFalse (ContainsProperty (props, "PubInstBase"), "#N4");
+ Assert.IsFalse (ContainsProperty (props, "IntInstBase"), "#N5");
+ Assert.IsFalse (ContainsProperty (props, "PrivInst"), "#N6");
+ Assert.IsFalse (ContainsProperty (props, "ProtInst"), "#N7");
+ Assert.IsFalse (ContainsProperty (props, "ProIntInst"), "#N8");
+ Assert.IsFalse (ContainsProperty (props, "PubInst"), "#N9");
+ Assert.IsFalse (ContainsProperty (props, "IntInst"), "#N10");
+ Assert.IsFalse (ContainsProperty (props, "PrivStatBase"), "#N11");
+ Assert.IsFalse (ContainsProperty (props, "ProtStatBase"), "#N12");
+ Assert.IsFalse (ContainsProperty (props, "ProIntStatBase"), "#N13");
+ Assert.IsFalse (ContainsProperty (props, "PubStatBase"), "#N14");
+ Assert.IsFalse (ContainsProperty (props, "IntStatBase"), "#N15");
+ Assert.IsTrue (ContainsProperty (props, "PrivStat"), "#N16");
+ Assert.IsTrue (ContainsProperty (props, "ProtStat"), "#N17");
+ Assert.IsTrue (ContainsProperty (props, "ProIntStat"), "#N18");
+ Assert.IsTrue (ContainsProperty (props, "PubStat"), "#N19");
+ Assert.IsTrue (ContainsProperty (props, "IntStat"), "#N20");
+ Assert.IsFalse (ContainsProperty (props, "PrivInstBlue"), "#N21");
+ Assert.IsFalse (ContainsProperty (props, "ProtInstBlue"), "#N22");
+ Assert.IsFalse (ContainsProperty (props, "ProIntInstBlue"), "#N23");
+ Assert.IsFalse (ContainsProperty (props, "PubInstBlue"), "#N24");
+ Assert.IsFalse (ContainsProperty (props, "IntInstBlue"), "#N25");
+ Assert.IsFalse (ContainsProperty (props, "PrivStatBlue"), "#N26");
+ Assert.IsFalse (ContainsProperty (props, "ProtStatBlue"), "#N27");
+ Assert.IsFalse (ContainsProperty (props, "ProIntStatBlue"), "#N28");
+ Assert.IsFalse (ContainsProperty (props, "PubStatBlue"), "#N29");
+ Assert.IsFalse (ContainsProperty (props, "IntStatBlue"), "#N30");
+ }
+
+ [Test] // GetProperty (String)
+ public void GetProperty1_Name_Null ()
+ {
+ Type type = typeof (Bar);
+ try {
+ type.GetProperty ((string) null);
+ Assert.Fail ("#1");
+ } catch (ArgumentNullException ex) {
+ Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
+ Assert.IsNull (ex.InnerException, "#3");
+ Assert.IsNotNull (ex.Message, "#4");
+ Assert.IsNotNull (ex.ParamName, "#5");
+ Assert.AreEqual ("name", ex.ParamName, "#6");
+ }
+ }
+
+ [Test] // GetProperty (String, BindingFlags)
+ public void GetProperty2 ()
+ {
+ Type type = typeof (Bar);
+ BindingFlags flags;
+
+ flags = BindingFlags.Instance | BindingFlags.NonPublic;
+
+ Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#A1");
+ Assert.IsNotNull (type.GetProperty ("ProtInstBase", flags), "#A2");
+ Assert.IsNotNull (type.GetProperty ("ProIntInstBase", flags), "#A3");
+ Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#A4");
+ Assert.IsNotNull (type.GetProperty ("IntInstBase", flags), "#A5");
+ Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#A6");
+ Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#A7");
+ Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#A8");
+ Assert.IsNull (type.GetProperty ("PubInst", flags), "#A9");
+ Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#A10");
+ Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#A11");
+ Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#A12");
+ Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#A13");
+ Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#A14");
+ Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#A15");
+ Assert.IsNull (type.GetProperty ("PrivStat", flags), "#A16");
+ Assert.IsNull (type.GetProperty ("ProtStat", flags), "#A17");
+ Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#A18");
+ Assert.IsNull (type.GetProperty ("PubStat", flags), "#A19");
+ Assert.IsNull (type.GetProperty ("IntStat", flags), "#A20");
+ Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#A21");
+ Assert.IsNotNull (type.GetProperty ("ProtInstBlue", flags), "#A22");
+ Assert.IsNotNull (type.GetProperty ("ProIntInstBlue", flags), "#A23");
+ Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#A24");
+ Assert.IsNotNull (type.GetProperty ("IntInstBlue", flags), "#A25");
+ Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#A26");
+ Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#A27");
+ Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#A28");
+ Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#A29");
+ Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#A30");
+
+ flags = BindingFlags.Instance | BindingFlags.Public;
+
+ Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#B1");
+ Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#B2");
+ Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#B3");
+ Assert.IsNotNull (type.GetProperty ("PubInstBase", flags), "#B4");
+ Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#B5");
+ Assert.IsNull (type.GetProperty ("PrivInst", flags), "#B6");
+ Assert.IsNull (type.GetProperty ("ProtInst", flags), "#B7");
+ Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#B8");
+ Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#B9");
+ Assert.IsNull (type.GetProperty ("IntInst", flags), "#B10");
+ Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#B11");
+ Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#B12");
+ Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#B13");
+ Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#B14");
+ Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#B15");
+ Assert.IsNull (type.GetProperty ("PrivStat", flags), "#B16");
+ Assert.IsNull (type.GetProperty ("ProtStat", flags), "#B17");
+ Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#B18");
+ Assert.IsNull (type.GetProperty ("PubStat", flags), "#B19");
+ Assert.IsNull (type.GetProperty ("IntStat", flags), "#B20");
+ Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#B21");
+ Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#B22");
+ Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#B23");
+ Assert.IsNotNull (type.GetProperty ("PubInstBlue", flags), "#B24");
+ Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#B25");
+ Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#B26");
+ Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#B27");
+ Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#B28");
+ Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#B29");
+ Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#B30");
+
+ flags = BindingFlags.Static | BindingFlags.Public;
+
+ Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#C1");
+ Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#C2");
+ Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#C3");
+ Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#C4");
+ Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#C5");
+ Assert.IsNull (type.GetProperty ("PrivInst", flags), "#C6");
+ Assert.IsNull (type.GetProperty ("ProtInst", flags), "#C7");
+ Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#C8");
+ Assert.IsNull (type.GetProperty ("PubInst", flags), "#C9");
+ Assert.IsNull (type.GetProperty ("IntInst", flags), "#C10");
+ Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#C11");
+ Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#C12");
+ Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#C13");
+ Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#C14");
+ Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#C15");
+ Assert.IsNull (type.GetProperty ("PrivStat", flags), "#C16");
+ Assert.IsNull (type.GetProperty ("ProtStat", flags), "#C17");
+ Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#C18");
+ Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#C19");
+ Assert.IsNull (type.GetProperty ("IntStat", flags), "#C20");
+ Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#C21");
+ Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#C22");
+ Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#C23");
+ Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#C24");
+ Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#C25");
+ Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#C26");
+ Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#C27");
+ Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#C28");
+ Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#C29");
+ Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#C30");
+
+ flags = BindingFlags.Static | BindingFlags.NonPublic;
+
+ Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#D1");
+ Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#D2");
+ Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#D3");
+ Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#D4");
+ Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#D5");
+ Assert.IsNull (type.GetProperty ("PrivInst", flags), "#D6");
+ Assert.IsNull (type.GetProperty ("ProtInst", flags), "#D7");
+ Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#D8");
+ Assert.IsNull (type.GetProperty ("PubInst", flags), "#D9");
+ Assert.IsNull (type.GetProperty ("IntInst", flags), "#D10");
+ Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#D11");
+ Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#D12");
+ Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#D13");
+ Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#D14");
+ Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#D15");
+ Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#D16");
+ Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#D17");
+ Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#D18");
+ Assert.IsNull (type.GetProperty ("PubStat", flags), "#D19");
+ Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#D20");
+ Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#D21");
+ Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#D22");
+ Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#D23");
+ Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#D24");
+ Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#D25");
+ Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#D26");
+ Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#D27");
+ Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#D28");
+ Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#D29");
+ Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#D30");
+
+ flags = BindingFlags.Instance | BindingFlags.NonPublic |
+ BindingFlags.FlattenHierarchy;
+
+ Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#E1");
+ Assert.IsNotNull (type.GetProperty ("ProtInstBase", flags), "#E2");
+ Assert.IsNotNull (type.GetProperty ("ProIntInstBase", flags), "#E3");
+ Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#E4");
+ Assert.IsNotNull (type.GetProperty ("IntInstBase", flags), "#E5");
+ Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#E6");
+ Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#E7");
+ Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#E8");
+ Assert.IsNull (type.GetProperty ("PubInst", flags), "#E9");
+ Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#E10");
+ Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#E11");
+ Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#E12");
+ Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#E13");
+ Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#E14");
+ Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#E15");
+ Assert.IsNull (type.GetProperty ("PrivStat", flags), "#E16");
+ Assert.IsNull (type.GetProperty ("ProtStat", flags), "#E17");
+ Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#E18");
+ Assert.IsNull (type.GetProperty ("PubStat", flags), "#E19");
+ Assert.IsNull (type.GetProperty ("IntStat", flags), "#E20");
+ Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#E21");
+ Assert.IsNotNull (type.GetProperty ("ProtInstBlue", flags), "#E22");
+ Assert.IsNotNull (type.GetProperty ("ProIntInstBlue", flags), "#E23");
+ Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#E24");
+ Assert.IsNotNull (type.GetProperty ("IntInstBlue", flags), "#E25");
+ Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#E26");
+ Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#E27");
+ Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#E28");
+ Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#E29");
+ Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#E30");
+
+ flags = BindingFlags.Instance | BindingFlags.Public |
+ BindingFlags.FlattenHierarchy;
+
+ Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#F1");
+ Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#F2");
+ Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#F3");
+ Assert.IsNotNull (type.GetProperty ("PubInstBase", flags), "#F4");
+ Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#F5");
+ Assert.IsNull (type.GetProperty ("PrivInst", flags), "#F6");
+ Assert.IsNull (type.GetProperty ("ProtInst", flags), "#F7");
+ Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#F8");
+ Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#F9");
+ Assert.IsNull (type.GetProperty ("IntInst", flags), "#F10");
+ Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#F11");
+ Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#F12");
+ Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#F13");
+ Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#F14");
+ Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#F15");
+ Assert.IsNull (type.GetProperty ("PrivStat", flags), "#F16");
+ Assert.IsNull (type.GetProperty ("ProtStat", flags), "#F17");
+ Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#F18");
+ Assert.IsNull (type.GetProperty ("PubStat", flags), "#F19");
+ Assert.IsNull (type.GetProperty ("IntStat", flags), "#F20");
+ Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#F21");
+ Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#F22");
+ Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#F23");
+ Assert.IsNotNull (type.GetProperty ("PubInstBlue", flags), "#F24");
+ Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#F25");
+ Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#F26");
+ Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#F27");
+ Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#F28");
+ Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#F29");
+ Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#F30");
+
+ flags = BindingFlags.Static | BindingFlags.Public |
+ BindingFlags.FlattenHierarchy;
+
+ Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#G1");
+ Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#G2");
+ Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#G3");
+ Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#G4");
+ Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#G5");
+ Assert.IsNull (type.GetProperty ("PrivInst", flags), "#G6");
+ Assert.IsNull (type.GetProperty ("ProtInst", flags), "#G7");
+ Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#G8");
+ Assert.IsNull (type.GetProperty ("PubInst", flags), "#G9");
+ Assert.IsNull (type.GetProperty ("IntInst", flags), "#G10");
+ Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#G11");
+ Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#G12");
+ Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#G13");
+ Assert.IsNotNull (type.GetProperty ("PubStatBase", flags), "#G14");
+ Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#G15");
+ Assert.IsNull (type.GetProperty ("PrivStat", flags), "#G16");
+ Assert.IsNull (type.GetProperty ("ProtStat", flags), "#G17");
+ Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#G18");
+ Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#G19");
+ Assert.IsNull (type.GetProperty ("IntStat", flags), "#G20");
+ Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#G21");
+ Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#G22");
+ Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#G23");
+ Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#G24");
+ Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#G25");
+ Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#G26");
+ Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#G27");
+ Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#G28");
+ Assert.IsNotNull (type.GetProperty ("PubStatBlue", flags), "#G29");
+ Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#G30");
+
+ flags = BindingFlags.Static | BindingFlags.NonPublic |
+ BindingFlags.FlattenHierarchy;
+
+ Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#H1");
+ Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#H2");
+ Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#H3");
+ Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#H4");
+ Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#H5");
+ Assert.IsNull (type.GetProperty ("PrivInst", flags), "#H6");
+ Assert.IsNull (type.GetProperty ("ProtInst", flags), "#H7");
+ Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#H8");
+ Assert.IsNull (type.GetProperty ("PubInst", flags), "#H9");
+ Assert.IsNull (type.GetProperty ("IntInst", flags), "#H10");
+ Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#H11");
+ Assert.IsNotNull (type.GetProperty ("ProtStatBase", flags), "#H12");
+ Assert.IsNotNull (type.GetProperty ("ProIntStatBase", flags), "#H13");
+ Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#H14");
+ Assert.IsNotNull (type.GetProperty ("IntStatBase", flags), "#H15");
+ Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#H16");
+ Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#H17");
+ Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#H18");
+ Assert.IsNull (type.GetProperty ("PubStat", flags), "#H19");
+ Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#H20");
+ Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#H21");
+ Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#H22");
+ Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#H23");
+ Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#H24");
+ Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#H25");
+ Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#H26");
+ Assert.IsNotNull (type.GetProperty ("ProtStatBlue", flags), "#H27");
+ Assert.IsNotNull (type.GetProperty ("ProIntStatBlue", flags), "#H28");
+ Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#H29");
+ Assert.IsNotNull (type.GetProperty ("IntStatBlue", flags), "#H30");
+
+ flags = BindingFlags.Instance | BindingFlags.NonPublic |
+ BindingFlags.DeclaredOnly;
+
+ Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#I1");
+ Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#I2");
+ Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#I3");
+ Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#I4");
+ Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#I5");
+ Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#I6");
+ Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#I7");
+ Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#I8");
+ Assert.IsNull (type.GetProperty ("PubInst", flags), "#I9");
+ Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#I10");
+ Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#I11");
+ Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#I12");
+ Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#I13");
+ Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#I14");
+ Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#I15");
+ Assert.IsNull (type.GetProperty ("PrivStat", flags), "#I16");
+ Assert.IsNull (type.GetProperty ("ProtStat", flags), "#I17");
+ Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#I18");
+ Assert.IsNull (type.GetProperty ("PubStat", flags), "#I19");
+ Assert.IsNull (type.GetProperty ("IntStat", flags), "#I20");
+ Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#I21");
+ Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#I22");
+ Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#I23");
+ Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#I24");
+ Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#I25");
+ Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#I26");
+ Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#I27");
+ Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#I28");
+ Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#I29");
+ Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#I30");
+
+ flags = BindingFlags.Instance | BindingFlags.Public |
+ BindingFlags.DeclaredOnly;
+
+ Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#J1");
+ Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#J2");
+ Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#J3");
+ Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#J4");
+ Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#J5");
+ Assert.IsNull (type.GetProperty ("PrivInst", flags), "#J6");
+ Assert.IsNull (type.GetProperty ("ProtInst", flags), "#J7");
+ Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#J8");
+ Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#J9");
+ Assert.IsNull (type.GetProperty ("IntInst", flags), "#J10");
+ Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#J11");
+ Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#J12");
+ Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#J13");
+ Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#J14");
+ Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#J15");
+ Assert.IsNull (type.GetProperty ("PrivStat", flags), "#J16");
+ Assert.IsNull (type.GetProperty ("ProtStat", flags), "#J17");
+ Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#J18");
+ Assert.IsNull (type.GetProperty ("PubStat", flags), "#J19");
+ Assert.IsNull (type.GetProperty ("IntStat", flags), "#J20");
+ Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#J21");
+ Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#J22");
+ Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#J23");
+ Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#J24");
+ Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#J25");
+ Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#J26");
+ Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#J27");
+ Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#J28");
+ Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#J29");
+ Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#J30");
+
+ flags = BindingFlags.Static | BindingFlags.Public |
+ BindingFlags.DeclaredOnly;
+
+ Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#K1");
+ Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#K2");
+ Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#K3");
+ Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#K4");
+ Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#K5");
+ Assert.IsNull (type.GetProperty ("PrivInst", flags), "#K6");
+ Assert.IsNull (type.GetProperty ("ProtInst", flags), "#K7");
+ Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#K8");
+ Assert.IsNull (type.GetProperty ("PubInst", flags), "#K9");
+ Assert.IsNull (type.GetProperty ("IntInst", flags), "#K10");
+ Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#K11");
+ Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#K12");
+ Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#K13");
+ Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#K14");
+ Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#K15");
+ Assert.IsNull (type.GetProperty ("PrivStat", flags), "#K16");
+ Assert.IsNull (type.GetProperty ("ProtStat", flags), "#K17");
+ Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#K18");
+ Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#K19");
+ Assert.IsNull (type.GetProperty ("IntStat", flags), "#K20");
+ Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#K21");
+ Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#K22");
+ Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#K23");
+ Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#K24");
+ Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#K25");
+ Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#K26");
+ Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#K27");
+ Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#K28");
+ Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#K29");
+ Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#K30");
+
+ flags = BindingFlags.Static | BindingFlags.NonPublic |
+ BindingFlags.DeclaredOnly;
+
+ Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#L1");
+ Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#L2");
+ Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#L3");
+ Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#L4");
+ Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#L5");
+ Assert.IsNull (type.GetProperty ("PrivInst", flags), "#L6");
+ Assert.IsNull (type.GetProperty ("ProtInst", flags), "#L7");
+ Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#L8");
+ Assert.IsNull (type.GetProperty ("PubInst", flags), "#L9");
+ Assert.IsNull (type.GetProperty ("IntInst", flags), "#L10");
+ Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#L11");
+ Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#L12");
+ Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#L13");
+ Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#L14");
+ Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#L15");
+ Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#L16");
+ Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#L17");
+ Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#L18");
+ Assert.IsNull (type.GetProperty ("PubStat", flags), "#L19");
+ Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#L20");
+ Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#L21");
+ Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#L22");
+ Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#L23");
+ Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#L24");
+ Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#L25");
+ Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#L26");
+ Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#L27");
+ Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#L28");
+ Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#L29");
+ Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#L30");
+
+ flags = BindingFlags.Instance | BindingFlags.NonPublic |
+ BindingFlags.Public;
+
+ Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#M1");
+ Assert.IsNotNull (type.GetProperty ("ProtInstBase", flags), "#M2");
+ Assert.IsNotNull (type.GetProperty ("ProIntInstBase", flags), "#M3");
+ Assert.IsNotNull (type.GetProperty ("PubInstBase", flags), "#M4");
+ Assert.IsNotNull (type.GetProperty ("IntInstBase", flags), "#M5");
+ Assert.IsNotNull (type.GetProperty ("PrivInst", flags), "#M6");
+ Assert.IsNotNull (type.GetProperty ("ProtInst", flags), "#M7");
+ Assert.IsNotNull (type.GetProperty ("ProIntInst", flags), "#M8");
+ Assert.IsNotNull (type.GetProperty ("PubInst", flags), "#M9");
+ Assert.IsNotNull (type.GetProperty ("IntInst", flags), "#M10");
+ Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#M11");
+ Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#M12");
+ Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#M13");
+ Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#M14");
+ Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#M15");
+ Assert.IsNull (type.GetProperty ("PrivStat", flags), "#M16");
+ Assert.IsNull (type.GetProperty ("ProtStat", flags), "#M17");
+ Assert.IsNull (type.GetProperty ("ProIntStat", flags), "#M18");
+ Assert.IsNull (type.GetProperty ("PubStat", flags), "#M19");
+ Assert.IsNull (type.GetProperty ("IntStat", flags), "#M20");
+ Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#M21");
+ Assert.IsNotNull (type.GetProperty ("ProtInstBlue", flags), "#M22");
+ Assert.IsNotNull (type.GetProperty ("ProIntInstBlue", flags), "#M23");
+ Assert.IsNotNull (type.GetProperty ("PubInstBlue", flags), "#M24");
+ Assert.IsNotNull (type.GetProperty ("IntInstBlue", flags), "#M25");
+ Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#M26");
+ Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#M27");
+ Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#M28");
+ Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#M29");
+ Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#M30");
+
+ flags = BindingFlags.Static | BindingFlags.NonPublic |
+ BindingFlags.Public;
+
+ Assert.IsNull (type.GetProperty ("PrivInstBase", flags), "#N1");
+ Assert.IsNull (type.GetProperty ("ProtInstBase", flags), "#N2");
+ Assert.IsNull (type.GetProperty ("ProIntInstBase", flags), "#N3");
+ Assert.IsNull (type.GetProperty ("PubInstBase", flags), "#N4");
+ Assert.IsNull (type.GetProperty ("IntInstBase", flags), "#N5");
+ Assert.IsNull (type.GetProperty ("PrivInst", flags), "#N6");
+ Assert.IsNull (type.GetProperty ("ProtInst", flags), "#N7");
+ Assert.IsNull (type.GetProperty ("ProIntInst", flags), "#N8");
+ Assert.IsNull (type.GetProperty ("PubInst", flags), "#N9");
+ Assert.IsNull (type.GetProperty ("IntInst", flags), "#N10");
+ Assert.IsNull (type.GetProperty ("PrivStatBase", flags), "#N11");
+ Assert.IsNull (type.GetProperty ("ProtStatBase", flags), "#N12");
+ Assert.IsNull (type.GetProperty ("ProIntStatBase", flags), "#N13");
+ Assert.IsNull (type.GetProperty ("PubStatBase", flags), "#N14");
+ Assert.IsNull (type.GetProperty ("IntStatBase", flags), "#N15");
+ Assert.IsNotNull (type.GetProperty ("PrivStat", flags), "#N16");
+ Assert.IsNotNull (type.GetProperty ("ProtStat", flags), "#N17");
+ Assert.IsNotNull (type.GetProperty ("ProIntStat", flags), "#N18");
+ Assert.IsNotNull (type.GetProperty ("PubStat", flags), "#N19");
+ Assert.IsNotNull (type.GetProperty ("IntStat", flags), "#N20");
+ Assert.IsNull (type.GetProperty ("PrivInstBlue", flags), "#N21");
+ Assert.IsNull (type.GetProperty ("ProtInstBlue", flags), "#N22");
+ Assert.IsNull (type.GetProperty ("ProIntInstBlue", flags), "#N23");
+ Assert.IsNull (type.GetProperty ("PubInstBlue", flags), "#N24");
+ Assert.IsNull (type.GetProperty ("IntInstBlue", flags), "#N25");
+ Assert.IsNull (type.GetProperty ("PrivStatBlue", flags), "#N26");
+ Assert.IsNull (type.GetProperty ("ProtStatBlue", flags), "#N27");
+ Assert.IsNull (type.GetProperty ("ProIntStatBlue", flags), "#N28");
+ Assert.IsNull (type.GetProperty ("PubStatBlue", flags), "#N29");
+ Assert.IsNull (type.GetProperty ("IntStatBlue", flags), "#N30");
+ }
+
+ [Test] // GetProperty (String, BindingFlags)
+ public void GetProperty2_Name_Null ()
+ {
+ Type type = typeof (Bar);
+ try {
+ type.GetProperty ((string) null);
+ Assert.Fail ("#1");
+ } catch (ArgumentNullException ex) {
+ Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
+ Assert.IsNull (ex.InnerException, "#3");
+ Assert.IsNotNull (ex.Message, "#4");
+ Assert.IsNotNull (ex.ParamName, "#5");
+ Assert.AreEqual ("name", ex.ParamName, "#6");
+ }
+ }
+
+ [Test] // GetProperty (String, Type)
+ public void GetProperty3_Name_Null ()
+ {
+ Type type = typeof (Bar);
+ try {
+ type.GetProperty ((string) null, typeof (int));
+ Assert.Fail ("#1");
+ } catch (ArgumentNullException ex) {
+ Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
+ Assert.IsNull (ex.InnerException, "#3");
+ Assert.IsNotNull (ex.Message, "#4");
+ Assert.IsNotNull (ex.ParamName, "#5");
+ Assert.AreEqual ("name", ex.ParamName, "#6");
+ }
+ }
+
+ [Test] // GetProperty (String, Type [])
+ public void GetProperty4_Name_Null ()
+ {
+ Type type = typeof (Bar);
+ try {
+ type.GetProperty ((string) null, Type.EmptyTypes);
+ Assert.Fail ("#1");
+ } catch (ArgumentNullException ex) {
+ Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
+ Assert.IsNull (ex.InnerException, "#3");
+ Assert.IsNotNull (ex.Message, "#4");
+ Assert.IsNotNull (ex.ParamName, "#5");
+ Assert.AreEqual ("name", ex.ParamName, "#6");
+ }
+ }
+
+ [Test] // GetProperty (String, Type, Type [])
+ public void GetProperty5_Name_Null ()
+ {
+ Type type = typeof (Bar);
+ try {
+ type.GetProperty ((string) null, typeof (int),
+ Type.EmptyTypes);
+ Assert.Fail ("#1");
+ } catch (ArgumentNullException ex) {
+ Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
+ Assert.IsNull (ex.InnerException, "#3");
+ Assert.IsNotNull (ex.Message, "#4");
+ Assert.IsNotNull (ex.ParamName, "#5");
+ Assert.AreEqual ("name", ex.ParamName, "#6");
+ }
+ }
+
+ [Test] // GetProperty (String, Type, Type [], ParameterModifier [])
+ public void GetProperty6_Name_Null ()
+ {
+ Type type = typeof (Bar);
+ try {
+ type.GetProperty ((string) null, typeof (int),
+ Type.EmptyTypes, null);
+ Assert.Fail ("#1");
+ } catch (ArgumentNullException ex) {
+ Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
+ Assert.IsNull (ex.InnerException, "#3");
+ Assert.IsNotNull (ex.Message, "#4");
+ Assert.IsNotNull (ex.ParamName, "#5");
+ Assert.AreEqual ("name", ex.ParamName, "#6");
+ }
+ }
+
+ [Test] // GetProperty (String, BindingFlags, Binder, Type, Type [], ParameterModifier [])
+ public void GetProperty7_Name_Null ()
+ {
+ Type type = typeof (Bar);
+ try {
+ type.GetProperty ((string) null, BindingFlags.Public,
+ null, typeof (int), Type.EmptyTypes, null);
+ Assert.Fail ("#1");
+ } catch (ArgumentNullException ex) {
+ Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
+ Assert.IsNull (ex.InnerException, "#3");
+ Assert.IsNotNull (ex.Message, "#4");
+ Assert.IsNotNull (ex.ParamName, "#5");
+ Assert.AreEqual ("name", ex.ParamName, "#6");
+ }
+ }
+
+ [Test]
+ public void GetProperty8_PropertyType ()
+ {
+ Type type = typeof (Bar);
+ Assert.IsNull (type.GetProperty ("PubInst", BindingFlags.Public | BindingFlags.Instance,
+ null, typeof (int), Type.EmptyTypes, null), "#1");
+ Assert.IsNotNull (type.GetProperty ("PubInst", BindingFlags.Public | BindingFlags.Instance, null,
+ typeof (long), new Type[0], null), "#2");
+ }
+
+#if !TARGET_JVM // StructLayout not supported for TARGET_JVM
[StructLayout(LayoutKind.Explicit, Pack = 4, Size = 64)]
- public class Class1 {
+ public class Class1
+ {
}
[StructLayout(LayoutKind.Explicit, CharSet=CharSet.Unicode)]
- public class Class2 {
+ public class Class2
+ {
}
-#if NET_2_0
[Test]
- public void StructLayoutAttribute () {
+ public void StructLayoutAttribute ()
+ {
StructLayoutAttribute attr1 = typeof (TypeTest).StructLayoutAttribute;
Assert.AreEqual (LayoutKind.Auto, attr1.Value);
Assert.AreEqual (LayoutKind.Explicit, attr3.Value);
Assert.AreEqual (CharSet.Unicode, attr3.CharSet);
}
-#endif
+#endif // TARGET_JVM
[Test]
- public void Namespace () {
+ public void Namespace ()
+ {
Assert.AreEqual (null, typeof (NoNamespaceClass).Namespace);
}
- public static void Reflected (ref int a) {
+ [Test]
+ public void GenericParameterNamespace ()
+ {
+ var t = typeof (Foo<>).GetGenericArguments () [0];
+
+ Assert.AreEqual ("T", t.Name);
+ Assert.AreEqual ("MonoTests.System", t.Namespace);
+
+ var s = typeof (Gazonk).GetMethod ("Bang").GetGenericArguments () [0];
+
+ Assert.AreEqual ("S", s.Name);
+ Assert.AreEqual ("MonoTests.System", s.Namespace);
+ }
+
+ public static void Reflected (ref int a)
+ {
}
[Test]
public void Name ()
{
Assert.AreEqual ("Int32&", typeof (TypeTest).GetMethod ("Reflected").GetParameters () [0].ParameterType.Name);
+ Assert.AreEqual ("String[*]", Array.CreateInstance (typeof(string), new int[] { 1 }, new int[] { 1 }).GetType ().Name);
}
[Test]
- public void GetInterfaces () {
+ public void GetInterfaces ()
+ {
Type[] t = typeof (Duper).GetInterfaces ();
Assert.AreEqual (1, t.Length);
Assert.AreEqual (typeof (ICloneable), t[0]);
public int AField;
[Test]
- public void GetFieldIgnoreCase () {
+ public void GetFieldIgnoreCase ()
+ {
Assert.IsNotNull (typeof (TypeTest).GetField ("afield", BindingFlags.Instance|BindingFlags.Public|BindingFlags.IgnoreCase));
}
-#if NET_2_0
public int Count {
internal get {
return 0;
}
[Test]
- public void GetPropertyAccessorModifiers () {
+ public void GetPropertyAccessorModifiers ()
+ {
Assert.IsNotNull (typeof (TypeTest).GetProperty ("Count", BindingFlags.Instance | BindingFlags.Public));
Assert.IsNull (typeof (TypeTest).GetProperty ("Count", BindingFlags.Instance | BindingFlags.NonPublic));
}
-#endif
+
+ [Test]
+ public void IsAbstract ()
+ {
+ Assert.IsFalse (typeof (string).IsAbstract, "#1");
+ Assert.IsTrue (typeof (ICloneable).IsAbstract, "#2");
+ Assert.IsTrue (typeof (ValueType).IsAbstract, "#3");
+ Assert.IsTrue (typeof (Enum).IsAbstract, "#4");
+ Assert.IsFalse (typeof (TimeSpan).IsAbstract, "#5");
+ Assert.IsTrue (typeof (TextReader).IsAbstract, "#6");
+
+ // LAMESPEC:
+ // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=286308
+ Type [] typeArgs = typeof (List<>).GetGenericArguments ();
+ Assert.IsFalse (typeArgs [0].IsAbstract, "#7");
+ }
+
+ [Test]
+ public void IsCOMObject ()
+ {
+ Type type = typeof (string);
+ Assert.IsFalse (type.IsCOMObject, "#1");
+
+ TypeBuilder tb = module.DefineType (genTypeName ());
+ type = tb.CreateType ();
+ Assert.IsFalse (type.IsCOMObject, "#2");
+ }
+
+ [Test]
+ public void IsImport ()
+ {
+ Type type = typeof (string);
+ Assert.IsFalse (type.IsImport, "#1");
+
+ TypeBuilder tb = module.DefineType (genTypeName ());
+ type = tb.CreateType ();
+ Assert.IsFalse (type.IsImport, "#2");
+
+ tb = module.DefineType (genTypeName (), TypeAttributes.Import |
+ TypeAttributes.Interface | TypeAttributes.Abstract);
+ type = tb.CreateType ();
+ Assert.IsTrue (type.IsImport, "#3");
+ }
+
+ [Test]
+ public void IsInterface ()
+ {
+ Assert.IsFalse (typeof (string).IsInterface, "#1");
+ Assert.IsTrue (typeof (ICloneable).IsInterface, "#2");
+ }
[Test]
public void IsPrimitive () {
- Assert.IsTrue (typeof (IntPtr).IsPrimitive);
+ Assert.IsTrue (typeof (IntPtr).IsPrimitive, "#1");
+ Assert.IsTrue (typeof (int).IsPrimitive, "#2");
+ Assert.IsFalse (typeof (string).IsPrimitive, "#2");
+ }
+
+ [Test]
+ public void IsValueType ()
+ {
+ Assert.IsTrue (typeof (int).IsValueType, "#1");
+ Assert.IsFalse (typeof (Enum).IsValueType, "#2");
+ Assert.IsFalse (typeof (ValueType).IsValueType, "#3");
+ Assert.IsTrue (typeof (AttributeTargets).IsValueType, "#4");
+ Assert.IsFalse (typeof (string).IsValueType, "#5");
+ Assert.IsTrue (typeof (TimeSpan).IsValueType, "#6");
}
[Test]
[Category("NotDotNet")]
// Depends on the GAC working, which it doesn't durring make distcheck.
[Category ("NotWorking")]
- public void GetTypeWithWhitespace () {
+ public void GetTypeWithWhitespace ()
+ {
Assert.IsNotNull (Type.GetType
(@"System.Configuration.NameValueSectionHandler,
System,
,
PublicKeyToken=b77a5c561934e089"));
}
+
+ [Test]
+ public void GetTypeNonVectorArray ()
+ {
+ Type t = Type.GetType ("System.String[*]");
+ Assert.AreEqual ("System.String[*]", t.ToString ());
+ }
[Test]
- public void ExerciseFilterName() {
+ public void ExerciseFilterName ()
+ {
MemberInfo[] mi = typeof(Base).FindMembers(
MemberTypes.Method,
BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
- BindingFlags.Instance | BindingFlags.DeclaredOnly,
- Type.FilterName, "*");
+ BindingFlags.Instance | BindingFlags.DeclaredOnly,
+ Type.FilterName, "*");
Assert.AreEqual (4, mi.Length);
mi = typeof(Base).FindMembers(
MemberTypes.Method,
BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
- BindingFlags.Instance | BindingFlags.DeclaredOnly,
- Type.FilterName, "Test*");
+ BindingFlags.Instance | BindingFlags.DeclaredOnly,
+ Type.FilterName, "Test*");
Assert.AreEqual (2, mi.Length);
mi = typeof(Base).FindMembers(
MemberTypes.Method,
BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
- BindingFlags.Instance | BindingFlags.DeclaredOnly,
- Type.FilterName, "TestVoid");
+ BindingFlags.Instance | BindingFlags.DeclaredOnly,
+ Type.FilterName, "TestVoid");
Assert.AreEqual (1, mi.Length);
mi = typeof(Base).FindMembers(
MemberTypes.Method,
BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
- BindingFlags.Instance | BindingFlags.DeclaredOnly,
- Type.FilterName, "NonExistingMethod");
+ BindingFlags.Instance | BindingFlags.DeclaredOnly,
+ Type.FilterName, "NonExistingMethod");
Assert.AreEqual (0, mi.Length);
}
[Test]
- public void ExerciseFilterNameIgnoreCase() {
+ public void ExerciseFilterNameIgnoreCase ()
+ {
MemberInfo[] mi = typeof(Base).FindMembers(
MemberTypes.Method,
BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
- BindingFlags.Instance | BindingFlags.DeclaredOnly,
- Type.FilterNameIgnoreCase, "*");
+ BindingFlags.Instance | BindingFlags.DeclaredOnly,
+ Type.FilterNameIgnoreCase, "*");
Assert.AreEqual (4, mi.Length);
mi = typeof(Base).FindMembers(
MemberTypes.Method,
BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
- BindingFlags.Instance | BindingFlags.DeclaredOnly,
- Type.FilterNameIgnoreCase, "test*");
+ BindingFlags.Instance | BindingFlags.DeclaredOnly,
+ Type.FilterNameIgnoreCase, "test*");
Assert.AreEqual (2, mi.Length);
mi = typeof(Base).FindMembers(
MemberTypes.Method,
BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
- BindingFlags.Instance | BindingFlags.DeclaredOnly,
- Type.FilterNameIgnoreCase, "TESTVOID");
+ BindingFlags.Instance | BindingFlags.DeclaredOnly,
+ Type.FilterNameIgnoreCase, "TESTVOID");
Assert.AreEqual (1, mi.Length);
mi = typeof(Base).FindMembers(
MemberTypes.Method,
BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
- BindingFlags.Instance | BindingFlags.DeclaredOnly,
- Type.FilterNameIgnoreCase, "NonExistingMethod");
+ BindingFlags.Instance | BindingFlags.DeclaredOnly,
+ Type.FilterNameIgnoreCase, "NonExistingMethod");
Assert.AreEqual (0, mi.Length);
}
- public class ByRef0 {
+ public class ByRef0
+ {
public int field;
public int property {
get { return 0; }
Assert.IsNull (t.GetField ("field"));
Assert.IsNull (t.GetProperty ("property"));
}
+
+ [Test]
+ public void TestAssemblyQualifiedName ()
+ {
+ Type t = Type.GetType ("System.Byte[]&");
+ Assert.IsTrue (t.AssemblyQualifiedName.StartsWith ("System.Byte[]&"));
+
+ t = Type.GetType ("System.Byte*&");
+ Assert.IsTrue (t.AssemblyQualifiedName.StartsWith ("System.Byte*&"));
+
+ t = Type.GetType ("System.Byte&");
+ Assert.IsTrue (t.AssemblyQualifiedName.StartsWith ("System.Byte&"));
+ }
struct B
{
}
[Test]
- public void CreateValueTypeNoCtor () {
+ public void CreateValueTypeNoCtor ()
+ {
typeof(B).InvokeMember ("", BindingFlags.CreateInstance, null, null, null);
}
[Test]
[ExpectedException (typeof (MissingMethodException))]
- public void CreateValueTypeNoCtorArgs () {
+ public void CreateValueTypeNoCtorArgs ()
+ {
typeof(B).InvokeMember ("", BindingFlags.CreateInstance, null, null, new object [] { 1 });
}
- class X
+ internal static string bug336841 (string param1, params string [] param2)
{
- public static int Value;
+ StringBuilder sb = new StringBuilder ();
+ sb.Append ("#A:");
+ sb.Append (param1);
+ sb.Append ("|");
+ for (int i = 0; i < param2.Length; i++) {
+ if (i > 0)
+ sb.Append (",");
+ sb.Append (param2 [i]);
+ }
+ return sb.ToString ();
}
- class Y : X
+ internal static string bug336841 (string param1)
{
+ return "#B:" + param1;
}
- [Test]
- public void InvokeMemberGetSetField () {
- typeof (X).InvokeMember ("Value", BindingFlags.Public|BindingFlags.Static|BindingFlags.FlattenHierarchy|BindingFlags.SetField, null, null, new object [] { 5 });
-
- Assert.AreEqual (5, X.Value);
- Assert.AreEqual (5, typeof (X).InvokeMember ("Value", BindingFlags.Public|BindingFlags.Static|BindingFlags.FlattenHierarchy|BindingFlags.GetField, null, null, new object [0]));
- Assert.AreEqual (5, Y.Value);
- Assert.AreEqual (5, typeof (Y).InvokeMember ("Value", BindingFlags.Public|BindingFlags.Static|BindingFlags.FlattenHierarchy|BindingFlags.GetField, null, null, new object [0]));
- }
+ internal static string bug336841 (params string [] param1)
+ {
+ StringBuilder sb = new StringBuilder ();
+ sb.Append ("#C:");
+ for (int i = 0; i < param1.Length; i++) {
+ if (i > 0)
+ sb.Append (";");
+ sb.Append (param1 [i]);
+ }
+ return sb.ToString ();
+ }
- class Z {
- public Z (IComparable value) {}
+ [Test]
+ public void InvokeMember_GetSetField ()
+ {
+ typeof (X).InvokeMember ("Value", BindingFlags.Public |
+ BindingFlags.Static | BindingFlags.FlattenHierarchy |
+ BindingFlags.SetField, null, null, new object [] { 5 });
+
+ Assert.AreEqual (5, X.Value, "#A1");
+ Assert.AreEqual (5, typeof (X).InvokeMember ("Value",
+ BindingFlags.Public | BindingFlags.Static |
+ BindingFlags.FlattenHierarchy | BindingFlags.GetField,
+ null, null, new object [0]), "#A2");
+ Assert.AreEqual (5, Y.Value, "#A3");
+ Assert.AreEqual (5, typeof (Y).InvokeMember ("Value",
+ BindingFlags.Public | BindingFlags.Static |
+ BindingFlags.FlattenHierarchy | BindingFlags.GetField,
+ null, null, new object [0]), "#A4");
+
+ try {
+ typeof (X).InvokeMember ("Value", BindingFlags.Public |
+ BindingFlags.Static | BindingFlags.FlattenHierarchy |
+ BindingFlags.GetField | BindingFlags.SetField,
+ null, null, new object [] { 5 });
+ Assert.Fail ("#B1");
+ } catch (ArgumentException ex) {
+ // Cannot specify both Get and Set on a field
+ Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
+ Assert.IsNull (ex.InnerException, "#B3");
+ Assert.IsNotNull (ex.Message, "#B4");
+ Assert.IsNotNull (ex.ParamName, "#B5");
+ Assert.AreEqual ("bindingFlags", ex.ParamName, "#B6");
+ }
}
-
+
[Test]
- public void InvokeMemberMatchPrimitiveTypeWithInterface () {
- object[] invokeargs = {1};
- typeof (Z).InvokeMember( "",
- BindingFlags.DeclaredOnly |
- BindingFlags.Public |
- BindingFlags.NonPublic |
- BindingFlags.Instance |
- BindingFlags.CreateInstance,
- null, null, invokeargs
- );
+ public void InvokeMember_GetSetProperty ()
+ {
+ try {
+ typeof (ArrayList).InvokeMember ("Item",
+ BindingFlags.GetProperty | BindingFlags.SetProperty |
+ BindingFlags.Instance | BindingFlags.Public,
+ null, new ArrayList (), new object [] { 0, "bar" });
+ Assert.Fail ("#1");
+ } catch (ArgumentException ex) {
+ // Cannot specify both Get and Set on a property
+ Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
+ Assert.IsNull (ex.InnerException, "#3");
+ Assert.IsNotNull (ex.Message, "#4");
+ Assert.IsNotNull (ex.ParamName, "#5");
+ Assert.AreEqual ("bindingFlags", ex.ParamName, "#6");
+ }
}
- class TakesInt {
- private int i;
- public TakesInt (int x)
- {
- i = x;
+ [Test]
+ public void InvokeMember_InvokeMethod_Set ()
+ {
+ try {
+ typeof (ArrayList).InvokeMember ("ToString",
+ BindingFlags.InvokeMethod | BindingFlags.SetField |
+ BindingFlags.Instance | BindingFlags.Public,
+ null, new ArrayList (), new object [0]);
+ Assert.Fail ("#A1");
+ } catch (ArgumentException ex) {
+ // Cannot specify Set on a field and Invoke on a method
+ Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
+ Assert.IsNull (ex.InnerException, "#A3");
+ Assert.IsNotNull (ex.Message, "#A4");
+ Assert.IsNotNull (ex.ParamName, "#A5");
+ Assert.AreEqual ("bindingFlags", ex.ParamName, "#A6");
}
- public int Integer {
- get { return i; }
+ try {
+ typeof (ArrayList).InvokeMember ("ToString",
+ BindingFlags.InvokeMethod | BindingFlags.SetProperty |
+ BindingFlags.Instance | BindingFlags.Public,
+ null, new ArrayList (), new object [0]);
+ Assert.Fail ("#B1");
+ } catch (ArgumentException ex) {
+ // Cannot specify Set on a property and Invoke on a method
+ Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
+ Assert.IsNull (ex.InnerException, "#B3");
+ Assert.IsNotNull (ex.Message, "#B4");
+ Assert.IsNotNull (ex.ParamName, "#B5");
+ Assert.AreEqual ("bindingFlags", ex.ParamName, "#B6");
}
}
- class TakesObject {
- public TakesObject (object x) {}
+ [Test]
+ public void InvokeMember_MatchPrimitiveTypeWithInterface ()
+ {
+ object [] invokeargs = { 1 };
+ typeof (Z).InvokeMember ("", BindingFlags.DeclaredOnly |
+ BindingFlags.Public | BindingFlags.NonPublic |
+ BindingFlags.Instance | BindingFlags.CreateInstance,
+ null, null, invokeargs);
}
- // Filed as bug #75241
[Test]
- public void GetConstructorNullInTypes ()
+ public void InvokeMember_Name_Null ()
{
- // This ends up calling type.GetConstructor ()
- Activator.CreateInstance (typeof (TakesInt), new object [] { null });
- Activator.CreateInstance (typeof (TakesObject), new object [] { null });
+ try {
+ typeof (X).InvokeMember ((string) null,
+ BindingFlags.Public | BindingFlags.Static |
+ BindingFlags.FlattenHierarchy | BindingFlags.SetField,
+ null, null, new object [] { 5 });
+ Assert.Fail ("#1");
+ } catch (ArgumentNullException ex) {
+ Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
+ Assert.IsNull (ex.InnerException, "#3");
+ Assert.IsNotNull (ex.Message, "#4");
+ Assert.IsNotNull (ex.ParamName, "#5");
+ Assert.AreEqual ("name", ex.ParamName, "#6");
+ }
}
[Test]
- [ExpectedException (typeof (ArgumentNullException))]
- public void GetConstructorNullInTypes_Bug71300 ()
+ public void InvokeMember_NoOperation ()
{
- typeof (TakesInt).GetConstructor (new Type[1] { null });
- // so null in types isn't valid for GetConstructor!
+ try {
+ typeof (TypeTest).InvokeMember ("Run", BindingFlags.Public |
+ BindingFlags.Static, null, null, new object [0]);
+ Assert.Fail ("#1");
+ } catch (ArgumentException ex) {
+ // Must specify binding flags describing the
+ // invoke operation required
+ Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
+ Assert.IsNull (ex.InnerException, "#3");
+ Assert.IsNotNull (ex.Message, "#4");
+ Assert.IsNotNull (ex.ParamName, "#5");
+ Assert.AreEqual ("bindingFlags", ex.ParamName, "#6");
+ }
}
- [Test]
- public void GetConstructor_TakeInt_Object ()
+ [Test] // bug #321735
+ public void InvokeMember_SetFieldProperty ()
{
- Assert.IsNull (typeof (TakesInt).GetConstructor (new Type[1] { typeof (object) }));
+ ArrayList list = new ArrayList ();
+ list.Add ("foo");
+ list.GetType ().InvokeMember ("Item",
+ BindingFlags.SetField | BindingFlags.SetProperty |
+ BindingFlags.Instance | BindingFlags.Public,
+ null, list, new object [] { 0, "bar" });
+ Assert.AreEqual ("bar", list [0]);
}
- // bug #76150
[Test]
- public void IsDefined ()
+ public void InvokeMember_SetField_ProvidedArgs ()
{
- Assert.IsTrue (typeof (A).IsDefined (typeof (NemerleAttribute), false), "#1");
- Assert.IsTrue (typeof (A).IsDefined (typeof (VolatileModifier), false), "#2");
+ try {
+ typeof (X).InvokeMember ("Value", BindingFlags.Public |
+ BindingFlags.Static | BindingFlags.SetField,
+ null, null, new object [0]);
+ Assert.Fail ("#A1");
+ } catch (ArgumentException ex) {
+ // Only the field value can be specified to set
+ // a field value
+ Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
+ Assert.IsNull (ex.InnerException, "#A3");
+ Assert.IsNotNull (ex.Message, "#A4");
+ Assert.IsNotNull (ex.ParamName, "#A5");
+ Assert.AreEqual ("bindingFlags", ex.ParamName, "#6");
+ }
+
+ try {
+ typeof (X).InvokeMember ("Value", BindingFlags.Public |
+ BindingFlags.Static | BindingFlags.SetField,
+ null, null, null);
+ Assert.Fail ("#B1");
+ } catch (ArgumentNullException ex) {
+ Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
+ Assert.IsNull (ex.InnerException, "#B3");
+ Assert.IsNotNull (ex.Message, "#B4");
+ Assert.IsNotNull (ex.ParamName, "#B5");
+ Assert.AreEqual ("providedArgs", ex.ParamName, "#B6");
+ }
}
- [Test]
- public void GetTypeCode ()
+ [Test] // bug #336841
+ [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=306797
+ public void InvokeMember_VarArgs ()
{
- Assert.AreEqual (TypeCode.Boolean, Type.GetTypeCode (typeof (bool)), "#1");
- Assert.AreEqual (TypeCode.Byte, Type.GetTypeCode (typeof (byte)), "#2");
- Assert.AreEqual (TypeCode.Char, Type.GetTypeCode (typeof (char)), "#3");
- Assert.AreEqual (TypeCode.DateTime, Type.GetTypeCode (typeof (DateTime)), "#4");
- Assert.AreEqual (TypeCode.DBNull, Type.GetTypeCode (typeof (DBNull)), "#5");
- Assert.AreEqual (TypeCode.Decimal, Type.GetTypeCode (typeof (decimal)), "#6");
+ BindingFlags flags = BindingFlags.InvokeMethod | BindingFlags.Public |
+ BindingFlags.NonPublic | BindingFlags.OptionalParamBinding |
+ BindingFlags.Static | BindingFlags.FlattenHierarchy |
+ BindingFlags.Instance;
+
+ Type type = typeof (TypeTest);
+ string result = (string) type.InvokeMember ("bug336841",
+ flags, null, null, new object [] { "1" });
+ Assert.IsNotNull (result, "#A1");
+ Assert.AreEqual ("#B:1", result, "#A2");
+
+ result = (string) type.InvokeMember ("bug336841", flags,
+ null, null, new object [] { "1", "2", "3", "4" });
+ Assert.IsNotNull (result, "#B1");
+ Assert.AreEqual ("#A:1|2,3,4", result, "#B2");
+ }
+
+
+ [Test] // bug #348522
+ public void InvokeMember_WithoutDefaultValue ()
+ {
+ BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod;
+ try {
+ typeof (Bug348522).InvokeMember ("Test", flags, new FirstMethodBinder (), new Bug348522(),
+ new object [] {Missing.Value}, null, null, null);
+ Assert.Fail ("#1");
+ } catch (ArgumentException ex) {
+ // Missing parameter does not have a default value
+ Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
+ Assert.IsNull (ex.InnerException, "#3");
+ Assert.IsNotNull (ex.Message, "#4");
+ Assert.IsNotNull (ex.ParamName, "#5");
+ Assert.AreEqual ("parameters", ex.ParamName, "#6");
+ }
+ }
+
+ [Test]
+ public void TestMissing () {
+ Assert.AreEqual (Type.Missing, Missing.Value);
+ }
+
+ [Test]
+ public void InvokeMember_OutParam ()
+ {
+ object[] args = new object[] { new string [0] };
+ typeof (TypeTest).InvokeMember ("OutTest", BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.Public, null, null, args);
+ Assert.IsTrue (args [0] is string[]);
+ Assert.AreEqual (10, ((string[])args[0]).Length);
+ }
+
+ public static void OutTest (out string[] a1)
+ {
+ a1 = new string [10];
+ }
+
+ class X
+ {
+ public static int Value;
+ }
+
+ class Y : X
+ {
+ }
+
+ class Z
+ {
+ public Z (IComparable value)
+ {
+ }
+ }
+
+ public static void Run ()
+ {
+ }
+
+ class TakesInt
+ {
+ private int i;
+
+ public TakesInt (int x)
+ {
+ i = x;
+ }
+
+ public int Integer {
+ get { return i; }
+ }
+ }
+
+ class TakesObject
+ {
+ public TakesObject (object x) {}
+ }
+
+ [Test] // bug #75241
+ public void GetConstructorNullInTypes ()
+ {
+ // This ends up calling type.GetConstructor ()
+ Activator.CreateInstance (typeof (TakesInt), new object [] { null });
+ Activator.CreateInstance (typeof (TakesObject), new object [] { null });
+ }
+
+ [Test]
+ public void GetConstructor_TakeInt_Object ()
+ {
+ Assert.IsNull (typeof (TakesInt).GetConstructor (new Type[1] { typeof (object) }));
+ }
+
+ [Test]
+ public void GetCustomAttributes_All ()
+ {
+ object [] attrs = typeof (A).GetCustomAttributes (false);
+ Assert.AreEqual (2, attrs.Length, "#A1");
+ Assert.IsTrue (HasAttribute (attrs, typeof (FooAttribute)), "#A2");
+ Assert.IsTrue (HasAttribute (attrs, typeof (VolatileModifier)), "#A3");
+
+ attrs = typeof (BA).GetCustomAttributes (false);
+ Assert.AreEqual (1, attrs.Length, "#B1");
+ Assert.AreEqual (typeof (BarAttribute), attrs [0].GetType (), "#B2");
+
+ attrs = typeof (BA).GetCustomAttributes (true);
+ Assert.AreEqual (2, attrs.Length, "#C1");
+ Assert.IsTrue (HasAttribute (attrs, typeof (BarAttribute)), "#C2");
+ Assert.IsTrue (HasAttribute (attrs, typeof (VolatileModifier)), "#C3");
+
+ attrs = typeof (CA).GetCustomAttributes (false);
+ Assert.AreEqual (0, attrs.Length, "#D");
+
+ attrs = typeof (CA).GetCustomAttributes (true);
+ Assert.AreEqual (1, attrs.Length, "#E1");
+ Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#E2");
+ }
+
+ static bool HasAttribute (object [] attrs, Type attributeType)
+ {
+ foreach (object attr in attrs)
+ if (attr.GetType () == attributeType)
+ return true;
+ return false;
+ }
+
+ [Test]
+ public void GetCustomAttributes_Type ()
+ {
+ object [] attrs = null;
+
+ attrs = typeof (A).GetCustomAttributes (
+ typeof (VolatileModifier), false);
+ Assert.AreEqual (1, attrs.Length, "#A1");
+ Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#A2");
+ attrs = typeof (A).GetCustomAttributes (
+ typeof (VolatileModifier), true);
+ Assert.AreEqual (1, attrs.Length, "#A3");
+ Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#A4");
+
+ attrs = typeof (A).GetCustomAttributes (
+ typeof (NemerleAttribute), false);
+ Assert.AreEqual (1, attrs.Length, "#B1");
+ Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#B2");
+ attrs = typeof (A).GetCustomAttributes (
+ typeof (NemerleAttribute), true);
+ Assert.AreEqual (1, attrs.Length, "#B3");
+ Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#B4");
+
+ attrs = typeof (A).GetCustomAttributes (
+ typeof (FooAttribute), false);
+ Assert.AreEqual (1, attrs.Length, "#C1");
+ Assert.AreEqual (typeof (FooAttribute), attrs [0].GetType (), "#C2");
+ attrs = typeof (A).GetCustomAttributes (
+ typeof (FooAttribute), false);
+ Assert.AreEqual (1, attrs.Length, "#C3");
+ Assert.AreEqual (typeof (FooAttribute), attrs [0].GetType (), "#C4");
+
+ attrs = typeof (BA).GetCustomAttributes (
+ typeof (VolatileModifier), false);
+ Assert.AreEqual (0, attrs.Length, "#D1");
+ attrs = typeof (BA).GetCustomAttributes (
+ typeof (VolatileModifier), true);
+ Assert.AreEqual (1, attrs.Length, "#D2");
+ Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#D3");
+
+ attrs = typeof (BA).GetCustomAttributes (
+ typeof (NemerleAttribute), false);
+ Assert.AreEqual (0, attrs.Length, "#E1");
+ attrs = typeof (BA).GetCustomAttributes (
+ typeof (NemerleAttribute), true);
+ Assert.AreEqual (1, attrs.Length, "#E2");
+ Assert.AreEqual (typeof (VolatileModifier), attrs [0].GetType (), "#E3");
+
+ attrs = typeof (BA).GetCustomAttributes (
+ typeof (FooAttribute), false);
+ Assert.AreEqual (1, attrs.Length, "#F1");
+ Assert.AreEqual (typeof (BarAttribute), attrs [0].GetType (), "#F2");
+ attrs = typeof (BA).GetCustomAttributes (
+ typeof (FooAttribute), true);
+ Assert.AreEqual (1, attrs.Length, "#F3");
+ Assert.AreEqual (typeof (BarAttribute), attrs [0].GetType (), "#F4");
+
+ attrs = typeof (bug82431A1).GetCustomAttributes (
+ typeof (InheritAttribute), false);
+ Assert.AreEqual (1, attrs.Length, "#G1");
+ Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#G2");
+ attrs = typeof (bug82431A1).GetCustomAttributes (
+ typeof (InheritAttribute), true);
+ Assert.AreEqual (1, attrs.Length, "#G3");
+ Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#G4");
+
+ attrs = typeof (bug82431A1).GetCustomAttributes (
+ typeof (NotInheritAttribute), false);
+ Assert.AreEqual (1, attrs.Length, "#H1");
+ Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#H2");
+ attrs = typeof (bug82431A1).GetCustomAttributes (
+ typeof (InheritAttribute), true);
+ Assert.AreEqual (1, attrs.Length, "#H3");
+ Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#H4");
+
+ attrs = typeof (bug82431A2).GetCustomAttributes (
+ typeof (InheritAttribute), false);
+ Assert.AreEqual (0, attrs.Length, "#I1");
+ attrs = typeof (bug82431A2).GetCustomAttributes (
+ typeof (InheritAttribute), true);
+ Assert.AreEqual (0, attrs.Length, "#I2");
+
+ attrs = typeof (bug82431A2).GetCustomAttributes (
+ typeof (NotInheritAttribute), false);
+ Assert.AreEqual (0, attrs.Length, "#J1");
+ attrs = typeof (bug82431A2).GetCustomAttributes (
+ typeof (NotInheritAttribute), true);
+ Assert.AreEqual (0, attrs.Length, "#J2");
+
+ attrs = typeof (bug82431A3).GetCustomAttributes (
+ typeof (InheritAttribute), false);
+ Assert.AreEqual (2, attrs.Length, "#K1");
+ Assert.IsTrue (HasAttribute (attrs, typeof (InheritAttribute)), "#K2");
+ Assert.IsTrue (HasAttribute (attrs, typeof (NotInheritAttribute)), "#K3");
+ attrs = typeof (bug82431A3).GetCustomAttributes (
+ typeof (InheritAttribute), true);
+ Assert.AreEqual (2, attrs.Length, "#K4");
+ Assert.IsTrue (HasAttribute (attrs, typeof (InheritAttribute)), "#K5");
+ Assert.IsTrue (HasAttribute (attrs, typeof (NotInheritAttribute)), "#K6");
+
+ attrs = typeof (bug82431A3).GetCustomAttributes (
+ typeof (NotInheritAttribute), false);
+ Assert.AreEqual (1, attrs.Length, "#L1");
+ Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#L2");
+ attrs = typeof (bug82431A3).GetCustomAttributes (
+ typeof (NotInheritAttribute), true);
+ Assert.AreEqual (1, attrs.Length, "#L3");
+ Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#L4");
+
+ attrs = typeof (bug82431B1).GetCustomAttributes (
+ typeof (InheritAttribute), false);
+ Assert.AreEqual (1, attrs.Length, "#M1");
+ Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#M2");
+ attrs = typeof (bug82431B1).GetCustomAttributes (
+ typeof (InheritAttribute), true);
+ Assert.AreEqual (1, attrs.Length, "#M3");
+ Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#M4");
+
+ attrs = typeof (bug82431B1).GetCustomAttributes (
+ typeof (NotInheritAttribute), false);
+ Assert.AreEqual (0, attrs.Length, "#N1");
+ attrs = typeof (bug82431B1).GetCustomAttributes (
+ typeof (NotInheritAttribute), true);
+ Assert.AreEqual (0, attrs.Length, "#N2");
+
+ attrs = typeof (bug82431B2).GetCustomAttributes (
+ typeof (InheritAttribute), false);
+ Assert.AreEqual (0, attrs.Length, "#O1");
+ attrs = typeof (bug82431B2).GetCustomAttributes (
+ typeof (InheritAttribute), true);
+ Assert.AreEqual (1, attrs.Length, "#O2");
+ Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#O3");
+
+ attrs = typeof (bug82431B2).GetCustomAttributes (
+ typeof (NotInheritAttribute), false);
+ Assert.AreEqual (0, attrs.Length, "#P1");
+ attrs = typeof (bug82431B2).GetCustomAttributes (
+ typeof (NotInheritAttribute), true);
+ Assert.AreEqual (0, attrs.Length, "#P2");
+
+ attrs = typeof (bug82431B3).GetCustomAttributes (
+ typeof (InheritAttribute), false);
+ Assert.AreEqual (1, attrs.Length, "#Q1");
+ Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#Q2");
+ attrs = typeof (bug82431B3).GetCustomAttributes (
+ typeof (InheritAttribute), true);
+ Assert.AreEqual (2, attrs.Length, "#Q3");
+ Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#Q4");
+ Assert.AreEqual (typeof (InheritAttribute), attrs [1].GetType (), "#Q5");
+
+ attrs = typeof (bug82431B3).GetCustomAttributes (
+ typeof (NotInheritAttribute), false);
+ Assert.AreEqual (1, attrs.Length, "#R1");
+ Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#R2");
+ attrs = typeof (bug82431B3).GetCustomAttributes (
+ typeof (NotInheritAttribute), true);
+ Assert.AreEqual (1, attrs.Length, "#R3");
+ Assert.AreEqual (typeof (NotInheritAttribute), attrs [0].GetType (), "#R4");
+
+ attrs = typeof (bug82431B4).GetCustomAttributes (
+ typeof (InheritAttribute), false);
+ Assert.AreEqual (0, attrs.Length, "#S1");
+ attrs = typeof (bug82431B4).GetCustomAttributes (
+ typeof (InheritAttribute), true);
+ Assert.AreEqual (1, attrs.Length, "#S2");
+ Assert.AreEqual (typeof (InheritAttribute), attrs [0].GetType (), "#S3");
+
+ attrs = typeof (bug82431B4).GetCustomAttributes (
+ typeof (NotInheritAttribute), false);
+ Assert.AreEqual (0, attrs.Length, "#T1");
+ attrs = typeof (bug82431B4).GetCustomAttributes (
+ typeof (NotInheritAttribute), true);
+ Assert.AreEqual (0, attrs.Length, "#T2");
+
+ attrs = typeof (A).GetCustomAttributes (
+ typeof (string), false);
+ Assert.AreEqual (0, attrs.Length, "#U1");
+ attrs = typeof (A).GetCustomAttributes (
+ typeof (string), true);
+ Assert.AreEqual (0, attrs.Length, "#U2");
+ }
+
+ [Test] // bug #76150
+ public void IsDefined ()
+ {
+ Assert.IsTrue (typeof (A).IsDefined (typeof (NemerleAttribute), false), "#A1");
+ Assert.IsTrue (typeof (A).IsDefined (typeof (VolatileModifier), false), "#A2");
+ Assert.IsTrue (typeof (A).IsDefined (typeof (FooAttribute), false), "#A3");
+ Assert.IsFalse (typeof (A).IsDefined (typeof (BarAttribute), false), "#A4");
+
+ Assert.IsFalse (typeof (BA).IsDefined (typeof (NemerleAttribute), false), "#B1");
+ Assert.IsFalse (typeof (BA).IsDefined (typeof (VolatileModifier), false), "#B2");
+ Assert.IsTrue (typeof (BA).IsDefined (typeof (FooAttribute), false), "#B3");
+ Assert.IsTrue (typeof (BA).IsDefined (typeof (BarAttribute), false), "#B4");
+ Assert.IsFalse (typeof (BA).IsDefined (typeof (string), false), "#B5");
+ Assert.IsFalse (typeof (BA).IsDefined (typeof (int), false), "#B6");
+ Assert.IsTrue (typeof (BA).IsDefined (typeof (NemerleAttribute), true), "#B7");
+ Assert.IsTrue (typeof (BA).IsDefined (typeof (VolatileModifier), true), "#B8");
+ Assert.IsTrue (typeof (BA).IsDefined (typeof (FooAttribute), true), "#B9");
+ Assert.IsTrue (typeof (BA).IsDefined (typeof (BarAttribute), true), "#B10");
+ Assert.IsFalse (typeof (BA).IsDefined (typeof (string), true), "#B11");
+ Assert.IsFalse (typeof (BA).IsDefined (typeof (int), true), "#B12");
+ }
+
+ [Test]
+ public void IsDefined_AttributeType_Null ()
+ {
+ try {
+ typeof (BA).IsDefined ((Type) null, false);
+ Assert.Fail ("#1");
+ } catch (ArgumentNullException ex) {
+ Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
+ Assert.IsNull (ex.InnerException, "#3");
+ Assert.IsNotNull (ex.Message, "#4");
+ Assert.IsNotNull (ex.ParamName, "#5");
+ Assert.AreEqual ("attributeType", ex.ParamName, "#6");
+ }
+ }
+
+ [Test] // bug #82431
+ [Category ("NotWorking")]
+ public void IsDefined_Inherited ()
+ {
+ Assert.IsFalse (typeof (CA).IsDefined (typeof (NemerleAttribute), false), "#C1");
+ Assert.IsFalse (typeof (CA).IsDefined (typeof (VolatileModifier), false), "#C2");
+ Assert.IsFalse (typeof (CA).IsDefined (typeof (FooAttribute), false), "#C3");
+ Assert.IsFalse (typeof (CA).IsDefined (typeof (BarAttribute), false), "#C4");
+ Assert.IsTrue (typeof (CA).IsDefined (typeof (NemerleAttribute), true), "#C5");
+ Assert.IsTrue (typeof (CA).IsDefined (typeof (VolatileModifier), true), "#C6");
+ Assert.IsFalse (typeof (CA).IsDefined (typeof (FooAttribute), true), "#C7");
+ Assert.IsFalse (typeof (CA).IsDefined (typeof (BarAttribute), true), "#C8");
+
+ Assert.IsFalse (typeof (BBA).IsDefined (typeof (NemerleAttribute), false), "#D1");
+ Assert.IsFalse (typeof (BBA).IsDefined (typeof (VolatileModifier), false), "#D2");
+ Assert.IsFalse (typeof (BBA).IsDefined (typeof (FooAttribute), false), "#D3");
+ Assert.IsFalse (typeof (BBA).IsDefined (typeof (BarAttribute), false), "#D4");
+ Assert.IsTrue (typeof (BBA).IsDefined (typeof (NemerleAttribute), true), "#D5");
+ Assert.IsTrue (typeof (BBA).IsDefined (typeof (VolatileModifier), true), "#D6");
+ Assert.IsTrue (typeof (BBA).IsDefined (typeof (FooAttribute), true), "#D7");
+ Assert.IsTrue (typeof (BBA).IsDefined (typeof (BarAttribute), true), "#D8");
+
+ Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (InheritAttribute), false), "#E1");
+ Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (NotInheritAttribute), false), "#E2");
+ Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (InheritAttribute), true), "#E3");
+ Assert.IsTrue (typeof (bug82431A1).IsDefined (typeof (NotInheritAttribute), true), "#E4");
+
+ Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (InheritAttribute), false), "#F1");
+ Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (NotInheritAttribute), false), "#F2");
+ Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (InheritAttribute), true), "#F3");
+ Assert.IsFalse (typeof (bug82431A2).IsDefined (typeof (NotInheritAttribute), true), "#F4");
+
+ Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (InheritAttribute), false), "#G1");
+ Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (NotInheritAttribute), false), "#G2");
+ Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (InheritAttribute), true), "#G3");
+ Assert.IsTrue (typeof (bug82431A3).IsDefined (typeof (NotInheritAttribute), true), "#G4");
+
+ Assert.IsTrue (typeof (bug82431B1).IsDefined (typeof (InheritAttribute), false), "#H1");
+ Assert.IsFalse (typeof (bug82431B1).IsDefined (typeof (NotInheritAttribute), false), "#H2");
+ Assert.IsTrue (typeof (bug82431B1).IsDefined (typeof (InheritAttribute), true), "#H3");
+ Assert.IsFalse (typeof (bug82431B1).IsDefined (typeof (NotInheritAttribute), true), "#H4");
+
+ Assert.IsFalse (typeof (bug82431B2).IsDefined (typeof (InheritAttribute), false), "#I1");
+ Assert.IsFalse (typeof (bug82431B2).IsDefined (typeof (NotInheritAttribute), false), "#I2");
+ Assert.IsTrue (typeof (bug82431B2).IsDefined (typeof (InheritAttribute), true), "#I3");
+ Assert.IsFalse (typeof (bug82431B2).IsDefined (typeof (NotInheritAttribute), true), "#I4");
+
+ Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (InheritAttribute), false), "#J1");
+ Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (NotInheritAttribute), false), "#J2");
+ Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (InheritAttribute), true), "#J3");
+ Assert.IsTrue (typeof (bug82431B3).IsDefined (typeof (NotInheritAttribute), true), "#J4");
+
+ Assert.IsFalse (typeof (bug82431B4).IsDefined (typeof (InheritAttribute), false), "#K2");
+ Assert.IsFalse (typeof (bug82431B4).IsDefined (typeof (NotInheritAttribute), false), "#K2");
+ Assert.IsTrue (typeof (bug82431B4).IsDefined (typeof (InheritAttribute), true), "#K3");
+ Assert.IsFalse (typeof (bug82431B4).IsDefined (typeof (NotInheritAttribute), true), "#K4");
+ }
+
+ [Test] // GetType (String)
+ public void GetType1_TypeName_Null ()
+ {
+ try {
+ Type.GetType ((string) null);
+ Assert.Fail ("#1");
+ } catch (ArgumentNullException ex) {
+ Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
+ Assert.IsNull (ex.InnerException, "#3");
+ Assert.IsNotNull (ex.Message, "#4");
+ Assert.AreEqual ("TypeName", ex.ParamName, "#5");
+ }
+ }
+
+ [Test] // GetType (String, Boolean)
+ public void GetType2_TypeName_Null ()
+ {
+ try {
+ Type.GetType ((string) null, false);
+ Assert.Fail ("#1");
+ } catch (ArgumentNullException ex) {
+ Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
+ Assert.IsNull (ex.InnerException, "#3");
+ Assert.IsNotNull (ex.Message, "#4");
+ Assert.AreEqual ("TypeName", ex.ParamName, "#5");
+ }
+ }
+
+ [Test] // GetType (String, Boolean, Boolean)
+ public void GetType3_TypeName_Null ()
+ {
+ try {
+ Type.GetType ((string) null, false, false);
+ Assert.Fail ("#1");
+ } catch (ArgumentNullException ex) {
+ Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
+ Assert.IsNull (ex.InnerException, "#3");
+ Assert.IsNotNull (ex.Message, "#4");
+ Assert.AreEqual ("TypeName", ex.ParamName, "#5");
+ }
+ }
+
+ [Test]
+ public void GetTypeArray_Args_Null ()
+ {
+ try {
+ Type.GetTypeArray ((object []) null);
+ Assert.Fail ("#1");
+ } catch (ArgumentNullException ex) {
+ Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
+ Assert.IsNull (ex.InnerException, "#3");
+ Assert.IsNotNull (ex.Message, "#4");
+ Assert.AreEqual ("args", ex.ParamName, "#5");
+ }
+ }
+
+ [Test]
+ public void GetTypeCode ()
+ {
+ Assert.AreEqual (TypeCode.Boolean, Type.GetTypeCode (typeof (bool)), "#1");
+ Assert.AreEqual (TypeCode.Byte, Type.GetTypeCode (typeof (byte)), "#2");
+ Assert.AreEqual (TypeCode.Char, Type.GetTypeCode (typeof (char)), "#3");
+ Assert.AreEqual (TypeCode.DateTime, Type.GetTypeCode (typeof (DateTime)), "#4");
+ Assert.AreEqual (TypeCode.DBNull, Type.GetTypeCode (typeof (DBNull)), "#5");
+ Assert.AreEqual (TypeCode.Decimal, Type.GetTypeCode (typeof (decimal)), "#6");
Assert.AreEqual (TypeCode.Double, Type.GetTypeCode (typeof (double)), "#7");
Assert.AreEqual (TypeCode.Empty, Type.GetTypeCode (null), "#8");
Assert.AreEqual (TypeCode.Int16, Type.GetTypeCode (typeof (short)), "#9");
}
[Test]
- [ExpectedException (typeof (ArgumentNullException))]
- public void GetConstructor1a_Bug71300 ()
+ public void GetTypeFromHandle_Handle_Zero ()
{
- typeof (BindingFlags).GetConstructor (null);
+ RuntimeTypeHandle handle = new RuntimeTypeHandle ();
+
+ Assert.IsNull (Type.GetTypeFromHandle (handle));
}
[Test]
- [ExpectedException (typeof (ArgumentNullException))]
- public void GetConstructor1b_Bug71300 ()
+ public void GetTypeHandle_O_Null ()
{
- typeof (BindingFlags).GetConstructor (new Type[1] { null });
+ try {
+ Type.GetTypeHandle (null);
+ Assert.Fail ("#1");
+ } catch (ArgumentNullException ex) {
+ Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
+ Assert.IsNull (ex.InnerException, "#3");
+ Assert.IsNotNull (ex.Message, "#4");
+ Assert.IsNull (ex.ParamName, "#5");
+ }
}
- [Test]
- [ExpectedException (typeof (ArgumentNullException))]
- public void GetConstructor4_Bug71300 ()
+ [Test] // GetConstructor (Type [])
+ public void GetConstructor1 ()
{
- typeof (BindingFlags).GetConstructor (BindingFlags.Default, null, new Type[1] { null }, null);
+ Type type;
+ ConstructorInfo ctor;
+
+ type = typeof (CtorsA);
+ ctor = type.GetConstructor (Type.EmptyTypes);
+ Assert.IsNotNull (ctor, "#A1");
+ Assert.AreEqual (0, ctor.GetParameters ().Length, "#A2");
+ Assert.IsFalse (ctor.IsStatic, "#A3");
+ Assert.IsTrue (ctor.IsPublic, "#A4");
+ Assert.AreEqual (".ctor", ctor.Name, "#A5");
+
+ type = typeof (CtorsB);
+ ctor = type.GetConstructor (Type.EmptyTypes);
+ Assert.IsNotNull (ctor, "#B1");
+ Assert.AreEqual (0, ctor.GetParameters ().Length, "#B2");
+ Assert.IsFalse (ctor.IsStatic, "#B3");
+ Assert.IsTrue (ctor.IsPublic, "#B4");
+ Assert.AreEqual (".ctor", ctor.Name, "#B5");
+
+ type = typeof (CtorsC);
+ ctor = type.GetConstructor (Type.EmptyTypes);
+ Assert.IsNull (ctor, "#C");
+
+ type = typeof (CtorsC);
+ ctor = type.GetConstructor (new Type [] { typeof (int) });
+ Assert.IsNotNull (ctor, "#D1");
+ Assert.AreEqual (1, ctor.GetParameters ().Length, "#D2");
+ Assert.IsFalse (ctor.IsStatic, "#D3");
+ Assert.IsTrue (ctor.IsPublic, "#D4");
+ Assert.AreEqual (".ctor", ctor.Name, "#D5");
}
- [Test]
- [ExpectedException (typeof (ArgumentNullException))]
- public void GetConstructor5_Bug71300 ()
+ [Test] // GetConstructor (Type [])
+ public void GetConstructor1_Types_Null ()
+ {
+ try {
+ typeof (BindingFlags).GetConstructor (null);
+ Assert.Fail ("#1");
+ } catch (ArgumentNullException ex) {
+ Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
+ Assert.IsNull (ex.InnerException, "#3");
+ Assert.IsNotNull (ex.Message, "#4");
+ Assert.IsNotNull (ex.ParamName, "#5");
+ Assert.AreEqual ("types", ex.ParamName, "#6");
+ }
+ }
+
+ [Test] // GetConstructor (Type [])
+ public void GetConstructor1_Types_ItemNull ()
+ {
+ Type type = typeof (BindingFlags);
+ try {
+ type.GetConstructor (new Type[1] { null });
+ Assert.Fail ("#A1");
+ } catch (ArgumentNullException ex) {
+ Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#A2");
+ Assert.IsNull (ex.InnerException, "#A3");
+ Assert.IsNotNull (ex.Message, "#A4");
+ Assert.IsNotNull (ex.ParamName, "#A5");
+ Assert.AreEqual ("types", ex.ParamName, "#A6");
+ }
+
+ type = typeof (TakesInt);
+ try {
+ type.GetConstructor (new Type [1] { null });
+ Assert.Fail ("#B1");
+ } catch (ArgumentNullException ex) {
+ Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#B2");
+ Assert.IsNull (ex.InnerException, "#B3");
+ Assert.IsNotNull (ex.Message, "#B4");
+ Assert.IsNotNull (ex.ParamName, "#B5");
+ Assert.AreEqual ("types", ex.ParamName, "#B6");
+ }
+ }
+
+ [Test] // GetConstructor (BindingFlags, Binder, Type [], ParameterModifier [])
+ public void GetConstructor2_Types_ItemNull ()
+ {
+ Type type = typeof (BindingFlags);
+ try {
+ type.GetConstructor (BindingFlags.Default, null,
+ new Type[1] { null }, null);
+ Assert.Fail ("#1");
+ } catch (ArgumentNullException ex) {
+ Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
+ Assert.IsNull (ex.InnerException, "#3");
+ Assert.IsNotNull (ex.Message, "#4");
+ Assert.IsNotNull (ex.ParamName, "#5");
+ Assert.AreEqual ("types", ex.ParamName, "#6");
+ }
+ }
+
+ [Test] // GetConstructor (BindingFlags, Binder, CallingConventions, Type [], ParameterModifier [])
+ public void GetConstructor3_Types_ItemNull ()
{
- typeof (BindingFlags).GetConstructor (BindingFlags.Default, null, CallingConventions.Any, new Type[1] { null }, null);
+ Type type = typeof (BindingFlags);
+ try {
+ type.GetConstructor (BindingFlags.Default,
+ null, CallingConventions.Any,
+ new Type[1] { null }, null);
+ Assert.Fail ("#1");
+ } catch (ArgumentNullException ex) {
+ Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
+ Assert.IsNull (ex.InnerException, "#3");
+ Assert.IsNotNull (ex.Message, "#4");
+ Assert.IsNotNull (ex.ParamName, "#5");
+ Assert.AreEqual ("types", ex.ParamName, "#6");
+ }
}
[Test]
Assert.IsNull (i);
}
-#if NET_2_0
+#if !TARGET_JVM // Reflection.Emit is not supported for TARGET_JVM
+ [Test]
+ public void EqualsUnderlyingType ()
+ {
+ AssemblyBuilderAccess access = AssemblyBuilderAccess.RunAndSave;
+ TypeAttributes attribs = TypeAttributes.Public;
+
+ AssemblyName name = new AssemblyName ();
+ name.Name = "enumtest";
+ AssemblyBuilder assembly =
+ AppDomain.CurrentDomain.DefineDynamicAssembly (
+ name, access);
+
+ ModuleBuilder module = assembly.DefineDynamicModule
+ ("m", "enumtest.dll");
+ EnumBuilder e = module.DefineEnum ("E", attribs, typeof (int));
+
+ Assert.IsTrue (typeof (int).Equals (e));
+ }
+#endif // TARGET_JVM
+
+ [Test]
+ public void Equals_Type_Null ()
+ {
+ Assert.IsFalse (typeof (int).Equals ((Type) null), "#1");
+ Assert.IsFalse (typeof (int).Equals ((object) null), "#2");
+ }
+
+ [Test]
+ public void GetElementType_Bug63841 ()
+ {
+ Assert.IsNull (typeof (TheEnum).GetElementType (), "#1");
+ }
+
[Test]
public void FullNameGenerics ()
{
Assert.IsTrue (typeof (Nullable<int>).IsInstanceOfType (5));
}
+ [Test]
+ public void IsInstanceOfArrayOfNullable ()
+ {
+ Assert.IsTrue (typeof (Nullable<int>[]).IsInstanceOfType (new Nullable<int> [0]));
+ }
+
+ [Test]
+ public void IsInstanceOfType_Null ()
+ {
+ Assert.IsFalse (typeof (int).IsInstanceOfType (null), "int");
+ Assert.IsFalse (typeof (object).IsInstanceOfType (null), "object");
+ Assert.IsFalse (typeof (int?).IsInstanceOfType (null), "int?");
+ }
+
[Test]
public void ByrefType ()
{
}
[Test]
- [Category ("NotWorking")] // BindingFlags.SetField throws since args.Length != 1, even though we have SetProperty
- public void Bug79023 ()
+ [ExpectedException (typeof (TypeLoadException))]
+ public void MakeByRefByRef ()
{
- ArrayList list = new ArrayList();
- list.Add("foo");
+ typeof (int).MakeByRefType ().MakeByRefType ();
+ }
- // The next line used to throw because we had SetProperty
- list.GetType().InvokeMember("Item",
- BindingFlags.SetField|BindingFlags.SetProperty|
- BindingFlags.Instance|BindingFlags.Public,
- null, list, new object[] { 0, "bar" });
- Assert.AreEqual ("bar", list[0]);
+ [Test]
+ public void MakeArrayTypeTest ()
+ {
+ // This should not crash:
+ typeof (void).MakeArrayType ();
}
+
[ComVisible (true)]
public class ComFoo<T> {
}
CheckGenericByRef (typeof (ByRef3<>));
CheckGenericByRef (typeof (ByRef4));
}
-#endif
- public class NemerleAttribute : Attribute
- { }
+ public class Bug80242<T> {
+ public interface IFoo { }
+ public class Bar : IFoo { }
+ public class Baz : Bar { }
+ }
- public class VolatileModifier : NemerleAttribute
- { }
+ [Test]
+ public void TestNestedTypes ()
+ {
+ Type t = typeof (Bug80242<object>);
+ Assert.IsFalse (t.IsGenericTypeDefinition);
+ foreach (Type u in t.GetNestedTypes ()) {
+ Assert.IsTrue (u.IsGenericTypeDefinition, "{0} isn't a generic definition", u);
+ Assert.AreEqual (u, u.GetGenericArguments () [0].DeclaringType);
+ }
+ }
- [VolatileModifier]
- class A { }
+ [Test] // bug #82211
+ public void GetMembers_GenericArgument ()
+ {
+ Type argType = typeof (ComFoo<>).GetGenericArguments () [0];
+ MemberInfo [] members = argType.GetMembers ();
+ Assert.IsNotNull (members, "#1");
+ Assert.AreEqual (4, members.Length, "#2");
+ }
- struct FooStruct {
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void ReflectionOnlyGetTypeNullTypeName ()
+ {
+ Type.ReflectionOnlyGetType (null, false, false);
}
- public class Bug77367
+ [Test]
+ public void ReflectionOnlyGetTypeDoNotThrow ()
{
- public void Run (bool b)
+ Assert.IsNull (Type.ReflectionOnlyGetType ("a, nonexistent.dll", false, false));
+ }
+
+ [Test]
+ [ExpectedException (typeof (FileNotFoundException))]
+ public void ReflectionOnlyGetTypeThrow ()
+ {
+ Type.ReflectionOnlyGetType ("a, nonexistent.dll", true, false);
+ }
+
+ [Test]
+ public void ReflectionOnlyGetType ()
+ {
+ Type t = Type.ReflectionOnlyGetType (typeof (int).AssemblyQualifiedName.ToString (), true, true);
+ Assert.AreEqual ("System.Int32", t.FullName);
+ }
+
+ [Test] //bug #331199
+ public void MakeGenericType_UserDefinedType ()
+ {
+ Type ut = new UserType (typeof (int));
+ Type t = typeof (Foo<>).MakeGenericType (ut);
+ Assert.IsTrue (t.IsGenericType, "#A1");
+ Assert.AreEqual (1, t.GetGenericArguments ().Length, "#A2");
+
+ Type arg = t.GetGenericArguments () [0];
+ Assert.IsNotNull (arg, "#B1");
+ Assert.IsFalse (arg.IsGenericType, "#B2");
+ Assert.AreEqual (ut, arg, "#B3");
+ }
+
+ [Category ("NotWorking")]
+ //We dont support instantiating a user type
+ public void MakeGenericType_NestedUserDefinedType ()
+ {
+ Type ut = new UserType (new UserType (typeof (int)));
+ Type t = typeof (Foo<>).MakeGenericType (ut);
+ Assert.IsTrue (t.IsGenericType, "#A1");
+ Assert.AreEqual (1, t.GetGenericArguments ().Length, "#A2");
+
+ Type arg = t.GetGenericArguments () [0];
+ Assert.IsNotNull (arg, "#B1");
+ Assert.IsFalse (arg.IsGenericType, "#B2");
+ Assert.AreEqual (ut, arg, "#B3");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void TestMakeGenericType_UserDefinedType_DotNet20SP1 ()
+ {
+ Type ut = new UserType(typeof(int));
+ Type t = typeof(Foo<>).MakeGenericType(ut);
+ Assert.IsTrue (t.IsGenericType, "#1");
+
+ Assert.AreEqual (ut, t.GetGenericArguments()[0], "#2");
+ }
+
+ [Test]
+ public void MakeGenericType_BadUserType ()
+ {
+ Type ut = new UserType (null);
+ try {
+ Type t = typeof (Foo<>).MakeGenericType (ut);
+ Assert.Fail ("#1");
+ } catch (ArgumentException) {
+ }
+ }
+
+ [Test]
+ public void MakeGenericType_WrongNumOfArguments ()
+ {
+ try {
+ Type t = typeof (Foo<,>).MakeGenericType (new Type [] { typeof (int) });
+ Assert.Fail ("#1");
+ } catch (ArgumentException) {
+ }
+ }
+
+ [AttributeUsage (AttributeTargets.All)]
+ public class DocAttribute : Attribute {
+ public DocAttribute (string docs) {}
+ }
+
+ class GenericClassWithAttributes<[Doc ("T")] T, [Doc ("B")] B>
+ where T : class, new ()
+ where B : Attribute
+ {
+ public T Bar { get{return null;}}
+
+ public void M<[Doc ("X")] X> (X x)
{
}
}
+
+ [Test] //bug #377596
+ public void GetGenericArguments_ArgumentsHaveAttributes ()
+ {
+ Type type = typeof(GenericClassWithAttributes<,>);
+ Type[] tArgs = type.GetGenericArguments ();
+ MethodInfo m = type.GetMethod ("M");
+ Type[] mArgs = m.GetGenericArguments ();
+ Assert.AreEqual(1, tArgs[0].GetCustomAttributes (typeof (DocAttribute), true).Length, "#1");
+ Assert.AreEqual(1, tArgs[1].GetCustomAttributes (typeof (DocAttribute), true).Length, "#1");
+ Assert.AreEqual(1, mArgs[0].GetCustomAttributes (typeof (DocAttribute), true).Length, "#1");
+ }
+
+ [Test] //bug #471255
+ public void GetTypeCalledUsingReflection ()
+ {
+ Type expectedType = Type.GetType ("NoNamespaceClass");
+ Assert.IsNotNull (expectedType, "#1");
+ MethodInfo m = typeof (Type).GetMethod ("GetType", BindingFlags.Public | BindingFlags.Static, null, new Type [] { typeof (string) }, null);
+ object r = m.Invoke (null, BindingFlags.Default, null, new object [] { "NoNamespaceClass" }, CultureInfo.InvariantCulture);
+ Assert.AreSame (expectedType, r, "#2");
+ }
+
+ [Test]
+ public void EqualsUserType () {
+ UserType2 t1 = new UserType2(null);
+ UserType2 t2 = new UserType2(t1);
+ Assert.IsTrue (t1.Equals(t2));
+ }
+
+ [Test]
+ public void GetHashCodeUserType () {
+ UserType2 t1 = new UserType2(null);
+ UserType2 t2 = new UserType2(t1);
+ Assert.AreEqual (42, t2.GetHashCode());
+ }
+
+ [Test]
+ public void IsGenericTypeDefinitionUserType () {
+ Assert.IsFalse (new UserType(null).IsGenericTypeDefinition);
+ }
+
+ [Test]
+ public void IsGenericTypeUserType () {
+ Assert.IsFalse (new UserType(null).IsGenericType);
+ }
+
+ [Test]
+ [ExpectedException (typeof (NotSupportedException))]
+ public void GetGenericTypeDefinitionUserType () {
+ new UserType(null).GetGenericTypeDefinition ();
+ }
+
+ [ExpectedException (typeof (NotSupportedException))]
+ public void GetGenericArgumentsUserType () {
+ new UserType(null).GetGenericArguments ();
+ }
+
+ [Test]
+ [ExpectedException (typeof (InvalidOperationException))]
+ public void GenericParameterPositionUserType () {
+ Assert.IsTrue (new UserType(null).GenericParameterPosition == 0);
+ }
+
+ [Test]
+ public void TypeGetMemberReturnTypeTest ()
+ {
+ object obj;
+ MemberTypes memtype;
+ Type testtype;
+ object [] flagsandtypes = new object [] {
+ MemberTypes.All, typeof (MemberInfo []),
+ MemberTypes.Constructor, typeof (ConstructorInfo []),
+ MemberTypes.Custom, typeof (MemberInfo []),
+ MemberTypes.Event, typeof (EventInfo []),
+ MemberTypes.Field, typeof (FieldInfo []),
+ MemberTypes.Method, typeof (MethodInfo []),
+ MemberTypes.NestedType, typeof (Type []),
+ MemberTypes.Property, typeof (PropertyInfo []),
+ MemberTypes.TypeInfo, typeof (Type [])};
+
+ for (int i=0; i < flagsandtypes.Length; i+=2) {
+ memtype = (MemberTypes)flagsandtypes [i];
+ testtype = (Type)flagsandtypes [i+1];
+ obj = GetType ().GetMember ("DummyMember", memtype,
+ BindingFlags.Public | BindingFlags.Instance);
+ Assert.AreEqual (testtype.GetHashCode (), obj.GetType ().GetHashCode (),
+ "Expected " + testtype.FullName);
+ }
+
+ }
+
+ [Test]
+ public void TypeNameStartsWithSpace ()
+ {
+ Type t1 = Type.GetType ("System.Type, mscorlib");
+ Type t2 = Type.GetType (" System.Type, mscorlib");
+ Assert.AreEqual (t1, t2);
+ }
+
+ [Test]
+ public void Bug506757 ()
+ {
+ AssemblyName assemblyName = new AssemblyName ();
+ assemblyName.Name = "customMod";
+ assemblyName.Version = new Version (1, 2, 3, 4);
+
+ AssemblyBuilder assembly
+ = Thread.GetDomain().DefineDynamicAssembly(
+ assemblyName, AssemblyBuilderAccess.RunAndSave);
+
+ ModuleBuilder module = assembly.DefineDynamicModule("res.exe", "res.exe");
+
+ TypeBuilder type0 = module.DefineType ("Base", TypeAttributes.Public, typeof (object));
+ TypeBuilder type1 = module.DefineType ("Middle", TypeAttributes.Public, type0);
+ TypeBuilder type2 = module.DefineType ("End", TypeAttributes.Public, type1);
+
+ MethodAttributes attrs0 = MethodAttributes.Virtual | MethodAttributes.HideBySig |
+ MethodAttributes.NewSlot | MethodAttributes.FamORAssem;
+
+ MethodAttributes attrs1 = MethodAttributes.Virtual | MethodAttributes.HideBySig |
+ MethodAttributes.FamORAssem;
+
+ MethodAttributes attrs2 = MethodAttributes.Virtual | MethodAttributes.HideBySig |
+ MethodAttributes.Public;
+
+
+ MethodBuilder m0 = type0.DefineMethod ("Tst", attrs0, typeof (void), null);
+ m0.GetILGenerator ().Emit (OpCodes.Ret);
+
+ MethodBuilder m1 = type1.DefineMethod ("Tst", attrs1, typeof (void), null);
+ m1.GetILGenerator ().Emit (OpCodes.Ret);
+
+ MethodBuilder m2 = type2.DefineMethod ("Tst", attrs2, typeof (void), null);
+ m2.GetILGenerator ().Emit (OpCodes.Ret);
+
+
+ type0.CreateType ();
+ type1.CreateType ();
+ Type t2 = type2.CreateType ();
+
+ foreach (var m in t2.GetMethods (BindingFlags.Instance | BindingFlags.NonPublic))
+ Assert.IsTrue (m.DeclaringType == typeof (object), String.Format ("{0}::{1}", m.DeclaringType, m.Name));
+ }
+
+ [Test]
+ public void MakeArrayTypeOfOneDimension ()
+ {
+ Type vector = typeof (int).MakeArrayType ();
+ Type szarray = typeof (int).MakeArrayType (1);
+
+ Assert.AreNotEqual (vector, szarray, "#1");
+ Assert.AreEqual ("Int32[]", vector.Name, "#2");
+ Assert.AreEqual ("Int32[*]", szarray.Name, "#3");
+ }
+
+ public class DeclaringMethodFoo {
+ public void Test<T> (T t) {}
+ public void Test2<T> (ref T t) {}
+ }
+
+ public class DeclaringMethodBar<T> {
+ public void Test2 (ref T t) {}
+ }
+
+ [Test]
+ public void DeclaringMethodOnlyWorksWithGenericArgs ()
+ {
+ MethodInfo testMethod = typeof (DeclaringMethodFoo).GetMethod ("Test");
+ MethodBase otherMethod = testMethod.GetParameters ()[0].ParameterType.DeclaringMethod;
+
+ Assert.AreEqual (testMethod, otherMethod,"#1");
+
+ Assert.IsNull (typeof (DeclaringMethodBar<>).GetGenericArguments ()[0].DeclaringMethod, "#2");
+
+ try {
+ var x = typeof (int).DeclaringMethod;
+ Assert.Fail ("#3");
+ } catch (InvalidOperationException) {}
+
+ try {
+ var x = typeof (DeclaringMethodFoo).GetMethod ("Test2").GetParameters () [0].ParameterType.DeclaringMethod;
+ Assert.Fail ("#4");
+ } catch (InvalidOperationException) {}
+
+ try {
+ var x = typeof (DeclaringMethodBar<>).GetMethod ("Test2").GetParameters () [0].ParameterType.DeclaringMethod;
+ Assert.Fail ("#5");
+ } catch (InvalidOperationException) {}
+
+ }
+
+ [Test]
+ public void GetArrayRankThrowsForNonArrayType ()
+ {
+ Assert.AreEqual (1, typeof (int[]).GetArrayRank (), "#1");
+ Assert.AreEqual (2, typeof (int[,]).GetArrayRank (), "#2");
+ try {
+ typeof (int).GetArrayRank ();
+ Assert.Fail ("#3");
+ } catch (ArgumentException) {}
+ }
+
+ [Test] //Bug #564379
+ public void GetMethodsReturnPublicMethodsInInterfaces ()
+ {
+ Type t = typeof (NonClosingStream);
+ MethodInfo[] methods = t.GetMethods (BindingFlags.Public | BindingFlags.Instance);
+
+ Assert.AreEqual (5, methods.Length, "#1");
+ int id = 2;
+
+ foreach (var m in methods) {
+ if (m.Name.Equals ("ToString"))
+ Assert.IsTrue (m.DeclaringType == typeof (NonClosingStream), "#" + id);
+ else if (m.Name.Equals ("Dispose") && m.GetParameters ().Length == 0)
+ Assert.IsTrue (m.DeclaringType == typeof (Stream), "#" + id);
+ else if (m.Name.Equals ("Equals") || m.Name.Equals ("GetHashCode") || m.Name.Equals ("GetType"))
+ Assert.IsTrue (m.DeclaringType == typeof (object), "#" + id);
+ else
+ Assert.Fail ("invalid method " + m);
+ ++id;
+ }
+ }
+
+ public abstract class Stream : IDisposable
+ {
+ public void Dispose ()
+ {
+ Console.WriteLine ("stream::dispose");
+ }
+
+ protected virtual void Dispose (bool disposing)
+ {
+ }
+ }
+
+ public class NonClosingStream
+ : Stream, IDisposable
+ {
+ void IDisposable.Dispose()
+ {
+ Console.WriteLine ("ncs::dispose");
+ }
+
+ public override string ToString () { return ""; }
+ }
+
+ static bool ContainsProperty (PropertyInfo [] props, string name)
+ {
+ foreach (PropertyInfo p in props)
+ if (p.Name == name)
+ return true;
+ return false;
+ }
+
+ public class NemerleAttribute : Attribute
+ {
+ }
+
+ public class VolatileModifier : NemerleAttribute
+ {
+ }
+
+ [VolatileModifier]
+ [FooAttribute]
+ class A
+ {
+ }
+
+ [AttributeUsage (AttributeTargets.Class, Inherited=false)]
+ public class FooAttribute : Attribute
+ {
+ }
+
+ public class BarAttribute : FooAttribute
+ {
+ }
+
+ [BarAttribute]
+ class BA : A
+ {
+ }
+
+ class BBA : BA
+ {
+ }
+
+ class CA : A
+ {
+ }
+
+ [AttributeUsage (AttributeTargets.Class, Inherited=true)]
+ public class InheritAttribute : Attribute
+ {
+ }
+
+ [AttributeUsage (AttributeTargets.Class, Inherited=false)]
+ public class NotInheritAttribute : InheritAttribute
+ {
+ }
+
+ [NotInheritAttribute]
+ public class bug82431A1
+ {
+ }
+
+ public class bug82431A2 : bug82431A1
+ {
+ }
+
+ [NotInheritAttribute]
+ [InheritAttribute]
+ public class bug82431A3 : bug82431A1
+ {
+ }
+
+ [InheritAttribute]
+ public class bug82431B1
+ {
+ }
+
+ public class bug82431B2 : bug82431B1
+ {
+ }
+
+ [NotInheritAttribute]
+ public class bug82431B3 : bug82431B2
+ {
+ }
+
+ public class bug82431B4 : bug82431B3
+ {
+ }
+
+ struct FooStruct
+ {
+ }
+
+ public class Bug77367
+ {
+ public void Run (bool b)
+ {
+ }
+ }
+
+ public class Blue
+ {
+ private string PrivInstBlue
+ {
+ get { return null; }
+ }
+
+ protected string ProtInstBlue
+ {
+ get { return null; }
+ }
+
+ protected internal string ProIntInstBlue
+ {
+ get { return null; }
+ }
+
+ public long PubInstBlue
+ {
+ get
+ {
+ if (PrivInstBlue == null)
+ return 0;
+ return long.MaxValue;
+ }
+ }
+
+ internal int IntInstBlue
+ {
+ get { return 0; }
+ }
+
+ private static string PrivStatBlue
+ {
+ get { return null; }
+ }
+
+ protected static string ProtStatBlue
+ {
+ get { return null; }
+ }
+
+ protected static internal string ProIntStatBlue
+ {
+ get { return null; }
+ }
+
+ public static long PubStatBlue
+ {
+ get
+ {
+ if (PrivStatBlue == null)
+ return 0;
+ return long.MaxValue;
+ }
+ }
+
+ internal static int IntStatBlue
+ {
+ get { return 0; }
+ }
+ }
+
+ public class Foo : Blue
+ {
+ private string PrivInstBase
+ {
+ get { return null; }
+ }
+
+ protected string ProtInstBase
+ {
+ get { return null; }
+ }
+
+ protected internal string ProIntInstBase
+ {
+ get { return null; }
+ }
+
+ public long PubInstBase
+ {
+ get
+ {
+ if (PrivInstBase == null)
+ return 0;
+ return long.MaxValue;
+ }
+ }
+
+ internal int IntInstBase
+ {
+ get { return 0; }
+ }
+
+ private static string PrivStatBase
+ {
+ get { return null; }
+ }
+
+ protected static string ProtStatBase
+ {
+ get { return null; }
+ }
+
+ protected static internal string ProIntStatBase
+ {
+ get { return null; }
+ }
+
+ public static long PubStatBase
+ {
+ get
+ {
+ if (PrivStatBase == null)
+ return 0;
+ return long.MaxValue;
+ }
+ }
+
+ internal static int IntStatBase
+ {
+ get { return 0; }
+ }
+ }
+
+ public class Bar : Foo
+ {
+ private string PrivInst
+ {
+ get { return null; }
+ }
+
+ protected string ProtInst
+ {
+ get { return null; }
+ }
+
+ protected internal string ProIntInst
+ {
+ get { return null; }
+ }
+
+ public long PubInst
+ {
+ get
+ {
+ if (PrivInst == null)
+ return 0;
+ return long.MaxValue;
+ }
+ }
+
+ internal int IntInst
+ {
+ get { return 0; }
+ }
+
+ private static string PrivStat
+ {
+ get { return null; }
+ }
+
+ protected static string ProtStat
+ {
+ get { return null; }
+ }
+
+ protected static internal string ProIntStat
+ {
+ get { return null; }
+ }
+
+ public static long PubStat
+ {
+ get
+ {
+ if (PrivStat == null)
+ return 0;
+ return long.MaxValue;
+ }
+ }
+
+ internal static int IntStat
+ {
+ get { return 0; }
+ }
+ }
+
+ class CtorsA
+ {
+ static CtorsA ()
+ {
+ }
+ }
+
+ class CtorsB
+ {
+ public CtorsB ()
+ {
+ }
+ }
+
+ class CtorsC
+ {
+ static CtorsC ()
+ {
+ }
+
+ public CtorsC (int x)
+ {
+ }
+ }
+ }
+
+ class UserType : Type
+ {
+ protected Type type;
+
+ public UserType(Type type) {
+ this.type = type;
+ }
+
+ public override Type UnderlyingSystemType { get { return this.type; } }
+
+ public override Assembly Assembly { get { return this.type == null ? null : this.type.Assembly; } }
+
+ public override string AssemblyQualifiedName { get { return null; } }
+
+ public override Type BaseType { get { return null; } }
+
+ public override Module Module { get { return this.type.Module; } }
+
+ public override string Namespace { get { return null; } }
+
+ public override bool IsGenericParameter { get { return true; } }
+
+ public override RuntimeTypeHandle TypeHandle { get { throw new NotSupportedException(); } }
+
+ public override bool ContainsGenericParameters { get { return true; } }
+
+ public override string FullName { get { return this.type.Name; } }
+
+ public override Guid GUID { get { throw new NotSupportedException(); } }
+
+
+ protected override bool IsArrayImpl() {
+ return false;
+ }
+
+ protected override bool IsByRefImpl()
+ {
+ return false;
+ }
+
+ protected override bool IsCOMObjectImpl()
+ {
+ return false;
+ }
+
+ protected override bool IsPointerImpl()
+ {
+ return false;
+ }
+
+ protected override bool IsPrimitiveImpl()
+ {
+ return false;
+ }
+
+
+ protected override TypeAttributes GetAttributeFlagsImpl()
+ {
+ return 0;
+ }
+
+ protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder,
+ CallingConventions callConvention, Type[] types,
+ ParameterModifier[] modifiers)
+ {
+ return null;
+ }
+
+ public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr)
+ {
+ return null;
+ }
+
+ public override Type GetElementType()
+ {
+ return null;
+ }
+
+ public override EventInfo GetEvent(string name, BindingFlags bindingAttr)
+ {
+ return null;
+ }
+
+
+ public override FieldInfo GetField(string name, BindingFlags bindingAttr)
+ {
+ return null;
+ }
+
+
+ public override Type GetInterface(string name, bool ignoreCase)
+ {
+ return null;
+ }
+
+ public override Type[] GetInterfaces()
+ {
+ return null;
+ }
+
+ public override MemberInfo[] GetMembers(BindingFlags bindingAttr)
+ {
+ return null;
+ }
+
+ public override object[] GetCustomAttributes(Type attributeType, bool inherit)
+ {
+ return null;
+ }
+
+ public override object[] GetCustomAttributes(bool inherit)
+ {
+ return null;
+ }
+
+ public override bool IsDefined(Type attributeType, bool inherit)
+ {
+ return false;
+ }
+
+ public override string Name { get { return this.type.Name; } }
+
+ public override EventInfo[] GetEvents(BindingFlags bindingAttr)
+ {
+ throw new NotImplementedException();
+ }
+
+ public override FieldInfo[] GetFields(BindingFlags bindingAttr)
+ {
+ throw new NotImplementedException();
+ }
+
+ protected override MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder,
+ CallingConventions callConvention, Type[] types,
+ ParameterModifier[] modifiers)
+ {
+ return null;
+ }
+
+ public override MethodInfo[] GetMethods(BindingFlags bindingAttr)
+ {
+ return null;
+ }
+
+ public override Type GetNestedType(string name, BindingFlags bindingAttr)
+ {
+ return null;
+ }
+
+ public override Type[] GetNestedTypes(BindingFlags bindingAttr)
+ {
+ return null;
+ }
+
+ public override PropertyInfo[] GetProperties(BindingFlags bindingAttr)
+ {
+ return null;
+ }
+
+ protected override PropertyInfo GetPropertyImpl(string name, BindingFlags bindingAttr, Binder binder,
+ Type returnType, Type[] types, ParameterModifier[] modifiers)
+ {
+ return null;
+ }
+
+ protected override bool HasElementTypeImpl()
+ {
+ return false;
+ }
+
+ public override object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, object target,
+ object[] args, ParameterModifier[] modifiers, CultureInfo culture,
+ string[] namedParameters)
+ {
+ throw new NotSupportedException();
+ }
+ }
+
+ class UserType2 : UserType {
+ public UserType2 (Type type) : base (type) {
+ }
+
+ public override Type UnderlyingSystemType { get { return this.type ?? this; } }
+
+ public override int GetHashCode()
+ {
+ if (type == null)
+ return 42;
+ return type.GetHashCode();
+ }
}
}