get { return 1; }
set { }
}
+
+ public event EventHandler E;
+ public void Dummy ()
+ {
+ E += delegate {};
+ }
}
class Derived1 : Base1
get { return 1; }
set { }
}
+
+ public new event Action E;
+ public new void Dummy ()
+ {
+ E += delegate {};
+ }
}
public class Foo<T>
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");
}
[Test]
- [Category ("TargetJvmNotWorking")]
public void TestGetPropertyImpl ()
{
// Test getting property that is exact
Assert.AreEqual (1, typeof (Derived1).GetProperties ().Length, "#03");
}
+ [Test]
+ public void GetEvents ()
+ {
+ // Test hide-by-name
+ Assert.AreEqual (1, typeof (Derived2).GetEvents ().Length);
+ Assert.AreEqual (typeof (Derived2), typeof (Derived2).GetEvents ()[0].DeclaringType);
+ }
+
[Test]
public void GetProperties ()
{
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
{
Assert.AreEqual (LayoutKind.Explicit, attr3.Value);
Assert.AreEqual (CharSet.Unicode, attr3.CharSet);
}
-#endif // TARGET_JVM
[Test]
public void Namespace ()
}
[Test]
- [Category("NotDotNet")]
- // Depends on the GAC working, which it doesn't durring make distcheck.
- [Category ("NotWorking")]
- public void GetTypeWithWhitespace ()
+ public void GetTypeNonVectorArray ()
{
- Assert.IsNotNull (Type.GetType
- (@"System.Configuration.NameValueSectionHandler,
- System,
-Version=1.0.5000.0,
-Culture=neutral
-,
-PublicKeyToken=b77a5c561934e089"));
+ Type t = Type.GetType ("System.String[*]");
+ Assert.AreEqual ("System.String[*]", t.ToString ());
}
+#if MONOTOUCH
+ // feature not available when compiled under FULL_AOT_RUNTIME
+ [ExpectedException (typeof (NotImplementedException))]
+#endif
[Test]
- public void GetTypeNonVectorArray ()
+ public void TypeFromCLSID ()
{
- Type t = Type.GetType ("System.String[*]");
- Assert.AreEqual ("System.String[*]", t.ToString ());
+ Guid CLSID_ShellDesktop = new Guid("00021400-0000-0000-c000-000000000046");
+ Guid CLSID_Bogus = new Guid("1ea9d7a9-f7ab-443b-b486-30d285b21f1b");
+
+ Type t1 = Type.GetTypeFromCLSID (CLSID_ShellDesktop);
+
+ Type t2 = Type.GetTypeFromCLSID (CLSID_Bogus);
+
+ Assert.AreEqual (t1.FullName, "System.__ComObject");
+
+ if (Environment.OSVersion.Platform == PlatformID.Win32Windows ||
+ Environment.OSVersion.Platform == PlatformID.Win32NT)
+ Activator.CreateInstance(t1);
+
+ Assert.AreEqual (t2.FullName, "System.__ComObject");
+
+ Assert.AreNotEqual (t1, t2);
+ }
+
+ [Test]
+ [Category("NotWorking")] // Mono throws TargetInvokationException
+ [ExpectedException("System.Runtime.InteropServices.COMException")]
+ public void TypeFromCLSIDBogus ()
+ {
+ Guid CLSID_Bogus = new Guid("1ea9d7a9-f7ab-443b-b486-30d285b21f1b");
+ Type t = Type.GetTypeFromCLSID (CLSID_Bogus);
+ if (Environment.OSVersion.Platform == PlatformID.Win32Windows ||
+ Environment.OSVersion.Platform == PlatformID.Win32NT)
+ Activator.CreateInstance(t);
+ else
+ throw new COMException ();
}
[Test]
struct B
{
+ #pragma warning disable 169
int value;
+ #pragma warning restore 169
}
[Test]
typeof(B).InvokeMember ("", BindingFlags.CreateInstance, null, null, new object [] { 1 });
}
+ [Test]
+ [ExpectedException (typeof (MissingMethodException))]
+ public void InvokeGetPropertyMissing ()
+ {
+ typeof(B).InvokeMember ("", BindingFlags.GetProperty, null, null, new object [] { 1 });
+ }
+
+ [Test]
+ [ExpectedException (typeof (MissingMethodException))]
+ public void InvokeSetPropertyMissing ()
+ {
+ typeof(B).InvokeMember ("", BindingFlags.SetProperty, null, null, new object [] { 1 });
+ }
+
internal static string bug336841 (string param1, params string [] param2)
{
StringBuilder sb = new StringBuilder ();
a1 = new string [10];
}
- class X
+ public class X
{
public static int Value;
}
Assert.IsFalse (typeof (bug82431B4).IsDefined (typeof (NotInheritAttribute), true), "#K4");
}
+ class Bug13767Attribute : Attribute
+ {
+ public object[] field;
+
+ public Bug13767Attribute (params object[] args)
+ {
+ field = args;
+ }
+ }
+
+ public enum Bug13767Enum
+ {
+ Value0,
+ Value1,
+ }
+
+ [Bug13767("Demo", new[] { Bug13767Enum.Value1, Bug13767Enum.Value0 })]
+ public void Bug13767Method(string attributeName, Bug13767Enum[]options)
+ {
+
+ }
+
+ [Test] //Bug 13767
+ public void CustomAttributeWithNestedArrayOfEnum ()
+ {
+ var m = GetType ().GetMethod ("Bug13767Method");
+
+ var attr = m.GetCustomAttributes (false);
+ Assert.AreEqual (1, attr.Length, "#1");
+
+ var tc = (Bug13767Attribute)attr[0];
+ Assert.AreEqual (2, tc.field.Length, "#2");
+ Assert.AreEqual ("Demo", tc.field[0], "#3");
+ Assert.IsNotNull (tc.field[1], "#4");
+
+ var arr = (Bug13767Enum[])tc.field [1];
+ Assert.AreEqual (2, arr.Length, "#5");
+ Assert.AreEqual (Bug13767Enum.Value1, arr [0], "#6");
+ Assert.AreEqual (Bug13767Enum.Value0, arr [1], "#7");
+ }
+
[Test] // GetType (String)
public void GetType1_TypeName_Null ()
{
Assert.IsNull (i);
}
-#if !TARGET_JVM && !MOBILE // Reflection.Emit is not supported for TARGET_JVM
+#if !MOBILE
[Test]
public void EqualsUnderlyingType ()
{
Assert.IsTrue (typeof (int).Equals (e));
}
-#endif // TARGET_JVM
+#endif
[Test]
public void Equals_Type_Null ()
Assert.AreEqual (t1, t2);
}
+#if !MONOTOUCH
+ [Test]
+ public void SpaceAfterComma () {
+ string strType = "System.Collections.Generic.Dictionary`2[[System.Int32,mscorlib], [System.String,mscorlib]],mscorlib";
+ Assert.IsTrue (Type.GetType (strType) != null);
+ }
+#endif
+
#if !MONOTOUCH
[Test]
public void Bug506757 ()
Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((byte)0), "#11");
Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((sbyte)0), "#12");
- try {
- typeof (MyRealEnum).GetEnumName (false);
- Assert.Fail ("#13");
- } catch (ArgumentException) { }
-
+ Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName (false), "#13");
Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((short)0), "#14");
Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((ushort)0), "#15");
- try {
- typeof (MyRealEnum).GetEnumName ('c');
- Assert.Fail ("#16");
- } catch (ArgumentException) { }
+ Assert.IsNull (typeof (MyRealEnum).GetEnumName ('c'), "#16");
Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((int)0), "#17");
Assert.AreEqual ("A", typeof (MyRealEnum).GetEnumName ((uint)0), "#18");
Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((byte)0), "#23");
Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((sbyte)0), "#24");
- try {
- typeof (MyRealEnum2).GetEnumName (false);
- Assert.Fail ("#22", "#25");
- } catch (ArgumentException) { }
+ Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName (false), "#25");
Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((short)0), "#26");
Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((ushort)0), "#27");
- try {
- typeof (MyRealEnum2).GetEnumName ('c');
- Assert.Fail ("#28");
- } catch (ArgumentException) { }
+ Assert.IsNull (typeof (MyRealEnum2).GetEnumName ('c'), "#28");
Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((int)0), "#29");
Assert.AreEqual ("A", typeof (MyRealEnum2).GetEnumName ((uint)0), "#30");
try {
typeof (MyRealEnum).IsEnumDefined (true);
Assert.Fail ("#6");
- } catch (InvalidOperationException) { }
+ } catch (ArgumentException) { }
try {
typeof (MyRealEnum).IsEnumDefined (MyRealEnum2.A);
try {
typeof (MyRealEnum).IsEnumDefined (typeof (MyRealEnum));
Assert.Fail ("#8");
- } catch (InvalidOperationException) { }
+ } catch (ArgumentException) { }
Assert.IsTrue (typeof (MyRealEnum).IsEnumDefined ((short)0), "#9");
Assert.IsFalse (typeof (MyRealEnum).IsEnumDefined ((short)88), "#10");
}
#endif
+ [Test]
+ public void GetTypeParseGenericCorrectly () { //Bug #15124
+ Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1"), typeof (Foo<>), "#1");
+ Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32]"), typeof (Foo<int>), "#2");
+ Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[[System.Int32]]"), typeof (Foo<int>), "#3");
+ Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32][]"), typeof (Foo<int>[]), "#4");
+ Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[][System.Int32]"), null, "#5");
+ Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32][,]"), typeof (Foo<int>[,]), "#6");
+ Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[]"), typeof (Foo<>).MakeArrayType(), "#7");
+ Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[,]"), typeof (Foo<>).MakeArrayType (2), "#8");
+ Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[][]"), typeof (Foo<>).MakeArrayType ().MakeArrayType (), "#9");
+ Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1["), null, "#10");
+ Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[["), null, "#11");
+ Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[[]"), null, "#12");
+ Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[,"), null, "#13");
+ Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[*"), null, "#14");
+ Assert.AreEqual (Type.GetType ("MonoTests.System.Foo`1[System.Int32"), null, "#15");
+ }
+
public abstract class Stream : IDisposable
{
public void Dispose ()