Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / tests / bug-322722_patch_bx.2.cs
1 using System;
2 using System.Reflection;
3 using System.Reflection.Emit;
4
5
6 class Driver {
7         public void AvoidInlining()
8         {
9         }
10
11         public int Foo()
12         {
13                 AvoidInlining();
14                 return -99;
15         }
16
17         public static int Main()
18         {
19
20                 DynamicMethod method_builder = new DynamicMethod ("WriteHello" , typeof (int), new Type[] {typeof (Driver)}, typeof (Driver));
21                 ILGenerator ilg = method_builder.GetILGenerator ();
22
23                 ilg.Emit (OpCodes.Ldarg_0);
24                 ilg.Emit (OpCodes.Call, typeof (Driver).GetMethod ("Foo"));
25                 ilg.Emit (OpCodes.Ret);
26
27                 int res = (int) method_builder.Invoke (null, new object[] {new Driver()});
28                 return res == -99 ? 0 : 1;
29         }
30 }