using System;
using System.Threading;
using System.Reflection;
-#if !MONOTOUCH
+#if !MONOTOUCH && !FULL_AOT_RUNTIME
using System.Reflection.Emit;
#endif
using System.Runtime.InteropServices;
[TestFixture]
public class MethodInfoTest
{
-#if MONOTOUCH
+#if MONOTOUCH || FULL_AOT_RUNTIME
// use an existing symbol - so we can build without dlsym. It does not matter that the signature does not match for the test
[DllImport ("libc", EntryPoint="readlink", CharSet=CharSet.Unicode, ExactSpelling=false, PreserveSig=true, SetLastError=true, BestFitMapping=true, ThrowOnUnmappableChar=true)]
#else
DllImportAttribute attr = (DllImportAttribute)((t.GetMethod ("dllImportMethod").GetCustomAttributes (typeof (DllImportAttribute), true)) [0]);
Assert.AreEqual (CallingConvention.Winapi, attr.CallingConvention, "#1");
-#if MONOTOUCH
+#if MONOTOUCH || FULL_AOT_RUNTIME
Assert.AreEqual ("readlink", attr.EntryPoint, "#2");
Assert.AreEqual ("libc", attr.Value, "#3");
#else
class GBD_D : GBD_C { public new virtual void f () {} }
class GBD_E : GBD_D { public override void f () {} }
+ class GBD_E2 : GBD_D { }
+ class GBD_F : GBD_E { }
+
+
[Test]
public void GetBaseDefinition ()
{
Assert.AreEqual (typeof (GBD_A), typeof (GBD_C).GetMethod ("f").GetBaseDefinition ().DeclaringType);
+ Assert.AreEqual (typeof (GBD_A), typeof (GBD_C).GetMethod ("f").GetBaseDefinition ().ReflectedType, "#1r");
+
Assert.AreEqual (typeof (GBD_D), typeof (GBD_D).GetMethod ("f").GetBaseDefinition ().DeclaringType);
+ Assert.AreEqual (typeof (GBD_D), typeof (GBD_D).GetMethod ("f").GetBaseDefinition ().ReflectedType, "#2r");
+
Assert.AreEqual (typeof (GBD_D), typeof (GBD_E).GetMethod ("f").GetBaseDefinition ().DeclaringType);
+ Assert.AreEqual (typeof (GBD_D), typeof (GBD_E).GetMethod ("f").GetBaseDefinition ().ReflectedType, "#3r");
+
+ Assert.AreEqual (typeof (GBD_D), typeof (GBD_E2).GetMethod ("f").GetBaseDefinition ().DeclaringType, "#4");
+ Assert.AreEqual (typeof (GBD_D), typeof (GBD_E2).GetMethod ("f").GetBaseDefinition ().ReflectedType, "#4r");
+
+ Assert.AreEqual (typeof (GBD_D), typeof (GBD_F).GetMethod ("f").GetBaseDefinition ().DeclaringType, "#5");
+ Assert.AreEqual (typeof (GBD_D), typeof (GBD_F).GetMethod ("f").GetBaseDefinition ().ReflectedType, "#5r");
+
}
class GenericBase<T,H> {
public override void f2 () { }
}
+ class DerivedFromGenericBase : GenericBase<int, int> {
+ }
+
[Test]
public void GetBaseDefinition_OpenConstructedBaseType () // 36305
{
[Test]
public void GetMethodBody ()
{
-#if MONOTOUCH && !DEBUG
+#if (MONOTOUCH || FULL_AOT_RUNTIME) && !DEBUG
Assert.Ignore ("Release app (on devices) are stripped of (managed) IL so this test would fail");
#endif
MethodBody mb = typeof (MethodInfoTest).GetMethod ("locals_method").GetMethodBody ();
} catch (InvalidOperationException ex) {
}
}
-#if !MONOTOUCH
+#if !MONOTOUCH && !FULL_AOT_RUNTIME
public TFoo SimpleGenericMethod2<TFoo, TBar> () { return default (TFoo); }
/*Test for the uggly broken behavior of SRE.*/
[Test]
Assert.AreEqual ("System.Nullable`1[System.Int32] Bug12856()", m.ToString (), "#1");
}
-#if !MONOTOUCH
+ [Test]
+ public void GetReflectedType () // #12205
+ {
+ // public method declared in base type, queried from a derived type
+ MethodInfo mi = typeof (TestInheritedMethodB).GetMethod ("TestMethod2");
+ Assert.AreEqual (mi.ReflectedType, typeof (TestInheritedMethodB), "#1");
+
+ // public method declared in a generic class,
+ // queried from a non-generic class derived
+ // from an instantiation of the generic class.
+ mi = typeof (DerivedFromGenericBase).GetMethod ("f2");
+ Assert.AreEqual (mi.ReflectedType, typeof (DerivedFromGenericBase), "#2");
+
+ // public method declared in a generic class,
+ // queried from the generic type defintion of
+ // a generic derived class.
+ mi = typeof (GenericMid<,>).GetMethod ("f2");
+ Assert.AreEqual (mi.ReflectedType, typeof (GenericMid<,>), "#3");
+
+ // public method declared in a generic class,
+ // queried from an instantiation of a generic
+ // derived class.
+ mi = typeof (GenericMid<int,int>).GetMethod ("f2");
+ Assert.AreEqual (mi.ReflectedType, typeof (GenericMid<int,int>), "#4");
+
+ }
+
+#if !MONOTOUCH && !FULL_AOT_RUNTIME
class GenericClass<T>
{
public void Method ()