Update Haiku support (#15674)
[mono-project.git] / mono / tests / dynamic-method-churn.cs
blob56233d58ea2169f4ae1c1d6d134fd5acee9282f9
1 using System;
2 using System.Reflection;
3 using System.Reflection.Emit;
5 class Program
7 //See GH #9176
8 static int Main (string[] args) {
9 for (int i = 0; i < 20000; ++i) {
10 DynamicMethod dm = new DynamicMethod(
11 $"dm_{i}",
12 null,
13 new Type[0],
14 typeof(Program).Module);
16 ILGenerator il = dm.GetILGenerator();
17 il.Emit(OpCodes.Ret);
19 Action a = (Action) dm.CreateDelegate(typeof(Action));
20 a();
21 var m = a.Method;
22 m.Invoke (null, null);
23 if ((i % 50) == 0) {
24 GC.Collect ();
25 GC.WaitForPendingFinalizers ();
28 return 0;