linux-packaging-mono/mono/tests/bug-322722_patch_bx.2.cs
Jo Shields a575963da9 Imported Upstream version 3.6.0
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
2014-08-13 10:39:27 +01:00

31 lines
624 B
C#

using System;
using System.Reflection;
using System.Reflection.Emit;
class Driver {
public void AvoidInlining()
{
}
public int Foo()
{
AvoidInlining();
return -99;
}
public static int Main()
{
DynamicMethod method_builder = new DynamicMethod ("WriteHello" , typeof (int), new Type[] {typeof (Driver)}, typeof (Driver));
ILGenerator ilg = method_builder.GetILGenerator ();
ilg.Emit (OpCodes.Ldarg_0);
ilg.Emit (OpCodes.Call, typeof (Driver).GetMethod ("Foo"));
ilg.Emit (OpCodes.Ret);
int res = (int) method_builder.Invoke (null, new object[] {new Driver()});
return res == -99 ? 0 : 1;
}
}