4 * Application program used by the debugger tests.
7 using System.Runtime.CompilerServices;
8 using System.Reflection;
9 using System.Reflection.Emit;
10 using System.Diagnostics;
11 using System.Threading;
12 using System.Collections.Generic;
15 public class TestsBase
17 #pragma warning disable 0414
18 #pragma warning disable 0169
19 public int base_field_i;
20 public string base_field_s;
21 static int base_static_i = 57;
22 static string base_static_s = "C";
23 #pragma warning restore 0414
24 #pragma warning restore 0169
32 public sealed class Tests3 {
33 public static void M1 () {
47 public static class Tests4 {
52 public class AAttribute : Attribute {
56 public class BAttribute : AAttribute {
60 [DebuggerDisplay ("Tests", Name="FOO", Target=typeof (int))]
61 [DebuggerTypeProxy (typeof (Tests))]
62 [BAttribute (afield = 1, bfield = 2)]
64 [DebuggerBrowsableAttribute (DebuggerBrowsableState.Collapsed)]
66 public static int static_field_j;
68 [DebuggerBrowsableAttribute (DebuggerBrowsableState.Collapsed)]
69 public int AProperty {
75 public void invoke () {
79 public struct AStruct {
85 [MethodImplAttribute (MethodImplOptions.NoInlining)]
86 public int foo (int val) {
90 [MethodImplAttribute (MethodImplOptions.NoInlining)]
91 public static int static_foo (int val) {
95 [MethodImplAttribute (MethodImplOptions.NoInlining)]
96 public int invoke_return_int () {
100 [MethodImplAttribute (MethodImplOptions.NoInlining)]
101 public static int invoke_static () {
105 [MethodImplAttribute (MethodImplOptions.NoInlining)]
106 public IntPtr invoke_return_intptr () {
111 public class GClass<T> {
113 public static T static_field;
115 [MethodImplAttribute (MethodImplOptions.NoInlining)]
119 [MethodImplAttribute (MethodImplOptions.NoInlining)]
120 public void bp<T2> () {
124 public struct GStruct<T> {
129 [MethodImplAttribute (MethodImplOptions.NoInlining)]
130 public int invoke_return_int () {
135 public struct NestedStruct {
136 NestedInner nested1, nested2;
139 public struct NestedInner {
154 class TestIfaces : ITest
162 TestIfaces<int> Baz () {
167 class TestIfaces<T> : ITest<T>
169 void ITest<T>.Foo () {
172 void ITest<T>.Bar () {
176 public interface ITest2
181 public class Tests : TestsBase, ITest2
183 #pragma warning disable 0414
187 bool field_bool1, field_bool2;
200 static int static_i = 55;
201 static string static_s = "A";
202 public const int literal_i = 56;
203 public const string literal_s = "B";
205 public AStruct field_struct;
206 public object field_boxed_struct;
207 public GStruct<int> generic_field_struct;
208 public KeyValuePair<int, object> boxed_struct_field;
210 public static int tls_i;
211 public static bool is_attached = Debugger.IsAttached;
212 public NestedStruct nested_struct;
214 #pragma warning restore 0414
216 public class NestedClass {
219 public int IntProperty {
228 public int ReadOnlyProperty {
234 public int this [int index] {
240 public static void wait_one ()
242 ManualResetEvent evt = new ManualResetEvent (false);
246 public static int Main (String[] args) {
249 if (args.Length > 0 && args [0] == "suspend-test")
250 /* This contains an infinite loop, so execute it conditionally */
252 if (args.Length >0 && args [0] == "unhandled-exception") {
253 unhandled_exception ();
256 if (args.Length >0 && args [0] == "unhandled-exception-endinvoke") {
257 unhandled_exception_endinvoke ();
260 if (args.Length >0 && args [0] == "unhandled-exception-user") {
261 unhandled_exception_user ();
264 if (args.Length >0 && args [0] == "wait-one") {
288 if (args.Length > 0 && args [0] == "domain-test")
289 /* This takes a lot of time, so execute it conditionally */
291 if (args.Length > 0 && args [0] == "ref-emit-test")
293 if (args.Length > 0 && args [0] == "frames-in-native")
295 if (args.Length > 0 && args [0] == "invoke-single-threaded")
296 new Tests ().invoke_single_threaded ();
297 new Tests ().evaluate_method ();
301 public static void breakpoints () {
302 /* Call these early so it is JITted by the time a breakpoint is placed on it */
314 bp6<string> (new GClass <int> ());
319 [MethodImplAttribute (MethodImplOptions.NoInlining)]
320 public static void bp1 () {
323 [MethodImplAttribute (MethodImplOptions.NoInlining)]
324 public static void bp2 () {
327 [MethodImplAttribute (MethodImplOptions.NoInlining)]
328 public static void bp3 () {
331 [MethodImplAttribute (MethodImplOptions.NoInlining)]
332 public static void bp4 () {
335 [MethodImplAttribute (MethodImplOptions.NoInlining)]
336 public static void bp5 () {
339 [MethodImplAttribute (MethodImplOptions.NoInlining)]
340 public static void bp6<T> (GClass<int> gc) {
344 [MethodImplAttribute (MethodImplOptions.NoInlining)]
345 public static void bp7<T> () {
348 [MethodImplAttribute (MethodImplOptions.NoInlining)]
349 public static void single_stepping () {
356 ss5 (new int [] { 1, 2, 3 }, new Func<int, bool> (is_even));
363 ss_regress_654694 ();
369 [MethodImplAttribute (MethodImplOptions.NoInlining)]
370 public static void ss1 () {
373 [MethodImplAttribute (MethodImplOptions.NoInlining)]
374 public static void ss2 () {
377 [MethodImplAttribute (MethodImplOptions.NoInlining)]
378 public static int ss3 () {
381 for (int i = 0; i < 10; ++i)
387 [MethodImplAttribute (MethodImplOptions.NoInlining)]
388 public static void ss3_2 () {
392 [MethodImplAttribute (MethodImplOptions.NoInlining)]
393 public static void ss3_2_2 () {
396 [MethodImplAttribute (MethodImplOptions.NoInlining)]
397 public static int ss4 () {
403 [MethodImplAttribute (MethodImplOptions.NoInlining)]
404 public static void ss5 (int[] arr, Func<int, bool> selector) {
405 // Call into linq which calls back into this assembly
406 arr.Count (selector);
409 [MethodImplAttribute (MethodImplOptions.NoInlining)]
410 public static void ss6 (bool b) {
413 throw new Exception ();
417 [MethodImplAttribute (MethodImplOptions.NoInlining)]
418 public static void ss6_2 () {
421 [MethodImplAttribute (MethodImplOptions.NoInlining)]
422 public static void ss7 () {
431 [MethodImplAttribute (MethodImplOptions.NoInlining)]
432 public static void ss7_2 () {
435 [MethodImplAttribute (MethodImplOptions.NoInlining)]
436 public static void ss7_3 () {
437 throw new Exception ();
440 [MethodImplAttribute (MethodImplOptions.NoInlining)]
441 public static void ss_nested () {
442 ss_nested_1 (ss_nested_2 ());
443 ss_nested_1 (ss_nested_2 ());
447 [MethodImplAttribute (MethodImplOptions.NoInlining)]
448 public static void ss_nested_1 (int i) {
451 [MethodImplAttribute (MethodImplOptions.NoInlining)]
452 public static int ss_nested_2 () {
456 [MethodImplAttribute (MethodImplOptions.NoInlining)]
457 public static void ss_nested_3 () {
460 [MethodImplAttribute (MethodImplOptions.NoInlining)]
461 public static void ss_step_through () {
463 StepThroughClass.step_through_2 ();
467 [DebuggerStepThrough]
468 [MethodImplAttribute (MethodImplOptions.NoInlining)]
469 public static void step_through_1 () {
472 [DebuggerStepThrough]
473 class StepThroughClass {
474 [MethodImplAttribute (MethodImplOptions.NoInlining)]
475 public static void step_through_2 () {
479 [DebuggerStepThrough]
480 [MethodImplAttribute (MethodImplOptions.NoInlining)]
481 public static void step_through_3 () {
484 [MethodImplAttribute (MethodImplOptions.NoInlining)]
485 public static void ss_recursive (int n) {
488 ss_recursive (n + 1);
491 [MethodImplAttribute (MethodImplOptions.NoInlining)]
492 public static void ss_fp_clobber () {
493 double v = ss_fp_clobber_1 (5.0);
497 [MethodImplAttribute (MethodImplOptions.NoInlining)]
498 public static double ss_fp_clobber_1 (double d) {
502 [MethodImplAttribute (MethodImplOptions.NoInlining)]
503 public static void ss_fp_clobber_2 (double d) {
506 [MethodImplAttribute (MethodImplOptions.NoInlining)]
507 public static bool is_even (int i) {
513 Console.WriteLine ("HIT!");
519 [MethodImplAttribute (MethodImplOptions.NoInlining)]
520 public static void arguments () {
521 arg1 (SByte.MaxValue - 5, Byte.MaxValue - 5, true, Int16.MaxValue - 5, UInt16.MaxValue - 5, 'F', Int32.MaxValue - 5, UInt32.MaxValue - 5, Int64.MaxValue - 5, UInt64.MaxValue - 5, 1.2345f, 6.78910, new IntPtr (Int32.MaxValue - 5), new UIntPtr (UInt32.MaxValue - 5));
523 arg2 ("FOO", null, "BLA", ref i, new GClass <int> { field = 42 }, new object ());
524 Tests t = new Tests () { field_i = 42, field_s = "S" };
528 [MethodImplAttribute (MethodImplOptions.NoInlining)]
529 public static int arg1 (sbyte sb, byte b, bool bl, short s, ushort us, char c, int i, uint ui, long l, ulong ul, float f, double d, IntPtr ip, UIntPtr uip) {
530 return (int)(sb + b + (bl ? 0 : 1) + s + us + (int)c + i + ui + l + (long)ul + f + d + (int)ip + (int)uip);
533 [MethodImplAttribute (MethodImplOptions.NoInlining)]
534 public static string arg2 (string s, string s3, object o, ref int i, GClass <int> gc, object o2) {
535 return s + (s3 != null ? "" : "") + o + i + gc.field + o2;
538 [MethodImplAttribute (MethodImplOptions.NoInlining)]
539 public object arg3 (string s) {
540 return s + s + s + s + this;
543 [MethodImplAttribute (MethodImplOptions.NoInlining)]
544 public static void objects () {
545 Tests t = new Tests () { field_i = 42, field_bool1 = true, field_bool2 = false, field_char = 'A', field_byte = 129, field_sbyte = -33, field_short = Int16.MaxValue - 5, field_ushort = UInt16.MaxValue - 5, field_long = Int64.MaxValue - 5, field_ulong = UInt64.MaxValue - 5, field_float = 3.14f, field_double = 3.14f, field_s = "S", base_field_i = 43, base_field_s = "T", field_enum = AnEnum.B, field_class = null, field_intptr = new IntPtr (Int32.MaxValue - 5), field_nullable = null };
546 t.o1 (new Tests2 () { field_j = 43 }, new GClass <int> { field = 42 }, new GClass <string> { field = "FOO" });
547 o2 (new string [] { "BAR", "BAZ" }, new int[] { 42, 43 }, new int [,] { { 1, 2 }, { 3, 4 }}, (int[,])Array.CreateInstance (typeof (int), new int [] { 2, 2}, new int [] { 1, 3}), new int[] { 0 });
550 [MethodImplAttribute (MethodImplOptions.NoInlining)]
551 public object o1 (Tests2 t, GClass <int> gc1, GClass <string> gc2) {
552 if (t == null || gc1 == null || gc2 == null)
558 [MethodImplAttribute (MethodImplOptions.NoInlining)]
559 public static string o2 (string[] s2, int[] s3, int[,] s4, int[,] s5, IList<int> s6) {
560 return s2 [0] + s3 [0] + s4 [0, 0] + s6 [0];
563 [MethodImplAttribute (MethodImplOptions.NoInlining)]
564 public static void objrefs () {
565 Tests t = new Tests () {};
573 [MethodImplAttribute (MethodImplOptions.NoInlining)]
574 public static void set_child (Tests t) {
575 t.child = new Tests ();
578 [MethodImplAttribute (MethodImplOptions.NoInlining)]
579 public void objrefs1 () {
582 [MethodImplAttribute (MethodImplOptions.NoInlining)]
583 public static void objrefs2 () {
586 public static void vtypes () {
587 Tests t = new Tests () { field_struct = new AStruct () { i = 42, s = "S", k = 43 }, generic_field_struct = new GStruct<int> () { i = 42 }, field_boxed_struct = new AStruct () { i = 42 }, boxed_struct_field = new KeyValuePair<int, object> (1, (long)42 ) };
588 AStruct s = new AStruct { i = 44, s = "T", k = 45 };
589 AStruct[] arr = new AStruct[] {
590 new AStruct () { i = 1, s = "S1" },
591 new AStruct () { i = 2, s = "S2" } };
597 [MethodImplAttribute (MethodImplOptions.NoInlining)]
598 public object vtypes1 (AStruct s, AStruct[] arr) {
605 [MethodImplAttribute (MethodImplOptions.NoInlining)]
606 public static void vtypes2 (AStruct s) {
610 [MethodImplAttribute (MethodImplOptions.NoInlining)]
611 public static void vtypes3 (AStruct s) {
612 AStruct.static_foo (5);
615 [MethodImplAttribute (MethodImplOptions.NoInlining)]
616 public static void locals () {
618 var astruct = new AStruct () { i = 42 };
620 locals2<string> (null, 5, "ABC", ref s, ref astruct);
626 [MethodImplAttribute (MethodImplOptions.NoInlining)]
627 static void locals11 (double a, ref double b) {
630 [MethodImplAttribute (MethodImplOptions.NoInlining)]
631 public static void locals1 (string[] args) {
635 locals11 (b: ref ri, a: ri);
637 for (int j = 0; j < 10; ++j) {
642 [MethodImplAttribute (MethodImplOptions.NoInlining)]
644 [StateMachine (typeof (int))]
646 public static void locals2<T> (string[] args, int arg, T t, ref string rs, ref AStruct astruct) {
650 for (int j = 0; j < 10; ++j) {
655 astruct = new AStruct ();
661 [MethodImplAttribute (MethodImplOptions.NoInlining)]
662 public static void locals3 () {
682 [MethodImplAttribute (MethodImplOptions.NoInlining)]
683 public static void locals4 () {
686 [MethodImplAttribute (MethodImplOptions.NoInlining)]
687 public static void locals5 () {
690 [MethodImplAttribute (MethodImplOptions.NoInlining)]
691 public static void locals6 () {
694 for (i = 0; i < 10; ++i)
697 for (i = 0; i < 10; ++i)
707 [MethodImplAttribute (MethodImplOptions.NoInlining)]
708 public static void locals6_1 () {
711 [MethodImplAttribute (MethodImplOptions.NoInlining)]
712 public static void locals6_2 (int arg) {
715 [MethodImplAttribute (MethodImplOptions.NoInlining)]
716 public static void locals6_3 () {
717 // Clobber all registers
718 int sum = 0, i, j, k, l, m;
719 for (i = 0; i < 100; ++i)
721 for (j = 0; j < 100; ++j)
723 for (k = 0; k < 100; ++k)
725 for (l = 0; l < 100; ++l)
727 for (m = 0; m < 100; ++m)
731 [MethodImplAttribute (MethodImplOptions.NoInlining)]
732 public static void locals6_4 (int arg) {
735 [MethodImplAttribute (MethodImplOptions.NoInlining)]
736 public static void locals6_5 () {
739 [MethodImplAttribute (MethodImplOptions.NoInlining)]
740 public static void locals6_6 (int arg) {
743 [MethodImplAttribute (MethodImplOptions.NoInlining)]
744 public static void locals7<T> (T arg) {
749 [MethodImplAttribute (MethodImplOptions.NoInlining)]
750 public static void line_numbers () {
754 [MethodImplAttribute (MethodImplOptions.NoInlining)]
755 public static void suspend () {
763 [MethodImplAttribute (MethodImplOptions.NoInlining)]
764 public static void type_info () {
765 Tests t = new Tests () { field_i = 42, field_s = "S", base_field_i = 43, base_field_s = "T", field_enum = AnEnum.B };
766 t.ti1 (new Tests2 () { field_j = 43 }, new GClass <int> { field = 42 }, new GClass <string> { field = "FOO" });
769 AStruct s = new AStruct () { i = 42, s = "S", k = 43 };
771 ti2 (new string [] { "BAR", "BAZ" }, new int[] { 42, 43 }, new int [,] { { 1, 2 }, { 3, 4 }}, ref val, (int*)IntPtr.Zero, 5, s, new Tests (), new Tests2 (), new GClass <int> (), AnEnum.B);
775 [MethodImplAttribute (MethodImplOptions.NoInlining)]
776 public object ti1 (Tests2 t, GClass <int> gc1, GClass <string> gc2) {
777 if (t == null || gc1 == null || gc2 == null)
783 [MethodImplAttribute (MethodImplOptions.NoInlining)]
784 public static unsafe string ti2 (string[] s2, int[] s3, int[,] s4, ref int ri, int* ptr, int i, AStruct s, Tests t, Tests2 t2, GClass<int> g, AnEnum ae) {
785 return s2 [0] + s3 [0] + s4 [0, 0];
788 [MethodImplAttribute (MethodImplOptions.NoInlining)]
789 public static void assembly_load () {
793 [MethodImplAttribute (MethodImplOptions.NoInlining)]
794 public static void assembly_load_2 () {
795 // This will load System.dll while holding the loader lock
799 [MethodImplAttribute (MethodImplOptions.NoInlining)]
800 public static void invoke () {
801 new Tests ().invoke1 (new Tests2 (), new AStruct () { i = 42, j = (IntPtr)43 }, new GStruct<int> { j = 42 });
802 new Tests ().invoke_ex ();
805 [MethodImplAttribute (MethodImplOptions.NoInlining)]
806 public void invoke1 (Tests2 t, AStruct s, GStruct<int> g) {
810 [MethodImplAttribute (MethodImplOptions.NoInlining)]
811 public void invoke2 () {
814 [MethodImplAttribute (MethodImplOptions.NoInlining)]
815 public void invoke_ex () {
819 [MethodImplAttribute (MethodImplOptions.NoInlining)]
820 public void invoke_ex_inner () {
822 throw new Exception ();
829 [MethodImplAttribute (MethodImplOptions.NoInlining)]
830 public void invoke_single_threaded () {
831 // Spawn a thread incrementing a counter
832 bool finished = false;
834 new Thread (delegate () {
841 invoke_single_threaded_2 ();
846 [MethodImplAttribute (MethodImplOptions.NoInlining)]
847 public void invoke_single_threaded_2 () {
850 public void invoke_return_void () {
853 public string invoke_return_ref () {
857 public object invoke_return_null () {
861 public int invoke_return_primitive () {
865 public int? invoke_return_nullable () {
869 public int? invoke_return_nullable_null () {
873 public void invoke_type_load () {
880 public long invoke_pass_primitive (byte ub, sbyte sb, short ss, ushort us, int i, uint ui, long l, ulong ul, char c, bool b, float f, double d) {
881 return ub + sb + ss + us + i + ui + l + (long)ul + (int)c + (b ? 1 : 0) + (int)f + (int)d;
884 public int invoke_pass_primitive2 (bool b) {
888 public string invoke_pass_ref (string s) {
892 public static string invoke_static_pass_ref (string s) {
896 public static void invoke_static_return_void () {
899 public static void invoke_throws () {
900 throw new Exception ();
903 public int invoke_iface () {
907 [MethodImplAttribute (MethodImplOptions.NoInlining)]
908 public static void exceptions () {
910 throw new OverflowException ();
911 } catch (Exception) {
914 throw new OverflowException ();
915 } catch (Exception) {
918 throw new ArgumentException ();
919 } catch (Exception) {
922 throw new OverflowException ();
923 } catch (Exception) {
927 throw new OverflowException ();
928 } catch (Exception) {
931 throw new Exception ();
932 } catch (Exception) {
938 } catch (Exception) {
943 } catch (Exception) {
947 [MethodImplAttribute (MethodImplOptions.NoInlining)]
948 public static void unhandled_exception () {
949 ThreadPool.QueueUserWorkItem (delegate {
950 throw new InvalidOperationException ();
952 Thread.Sleep (10000);
955 [MethodImplAttribute (MethodImplOptions.NoInlining)]
956 public static void unhandled_exception_endinvoke_2 () {
959 [MethodImplAttribute (MethodImplOptions.NoInlining)]
960 public static void unhandled_exception_endinvoke () {
961 Action action = new Action (() =>
963 throw new Exception ("thrown");
965 action.BeginInvoke ((ar) => {
967 action.EndInvoke (ar);
968 } catch (Exception ex) {
969 //Console.WriteLine (ex);
973 unhandled_exception_endinvoke_2 ();
976 [MethodImplAttribute (MethodImplOptions.NoInlining)]
977 public static void unhandled_exception_user () {
979 System.Threading.Tasks.Task.Factory.StartNew (() => {
982 Thread.Sleep (10000);
986 [MethodImplAttribute (MethodImplOptions.NoInlining)]
987 public static void Throw () {
988 throw new Exception ();
991 internal static Delegate create_filter_delegate (Delegate dlg, MethodInfo filter_method)
994 throw new ArgumentNullException ();
995 if (dlg.Target != null)
996 throw new ArgumentException ();
997 if (dlg.Method == null)
998 throw new ArgumentException ();
1000 var ret_type = dlg.Method.ReturnType;
1001 var param_types = dlg.Method.GetParameters ().Select (x => x.ParameterType).ToArray ();
1003 var dynamic = new DynamicMethod (Guid.NewGuid ().ToString (), ret_type, param_types, typeof (object), true);
1004 var ig = dynamic.GetILGenerator ();
1006 LocalBuilder retval = null;
1007 if (ret_type != typeof (void))
1008 retval = ig.DeclareLocal (ret_type);
1010 var label = ig.BeginExceptionBlock ();
1012 for (int i = 0; i < param_types.Length; i++)
1013 ig.Emit (OpCodes.Ldarg, i);
1014 ig.Emit (OpCodes.Call, dlg.Method);
1017 ig.Emit (OpCodes.Stloc, retval);
1019 ig.Emit (OpCodes.Leave, label);
1021 ig.BeginExceptFilterBlock ();
1023 ig.Emit (OpCodes.Call, filter_method);
1025 ig.BeginCatchBlock (null);
1027 ig.Emit (OpCodes.Pop);
1029 ig.EndExceptionBlock ();
1032 ig.Emit (OpCodes.Ldloc, retval);
1034 ig.Emit (OpCodes.Ret);
1036 return dynamic.CreateDelegate (dlg.GetType ());
1039 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1040 static void exception_filter_method () {
1041 throw new InvalidOperationException ();
1044 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1045 static int exception_filter_filter (Exception exc) {
1049 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1050 public static void exception_filter () {
1051 var method = typeof (Tests).GetMethod (
1052 "exception_filter_method", BindingFlags.NonPublic | BindingFlags.Static);
1053 var filter_method = typeof (Tests).GetMethod (
1054 "exception_filter_filter", BindingFlags.NonPublic | BindingFlags.Static);
1056 var dlg = Delegate.CreateDelegate (typeof (Action), method);
1058 var wrapper = (Action) create_filter_delegate (dlg, filter_method);
1063 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1064 public static bool return_true () {
1068 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1069 public static void exceptions2 () {
1071 throw new Exception ();
1072 Console.WriteLine ();
1075 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1076 public static void threads () {
1077 Thread t = new Thread (delegate () {});
1083 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1084 public static void domains () {
1085 AppDomain domain = AppDomain.CreateDomain ("domain");
1087 CrossDomain o = (CrossDomain)domain.CreateInstanceAndUnwrap (
1088 typeof (CrossDomain).Assembly.FullName, "CrossDomain");
1090 domains_2 (o, new CrossDomain ());
1098 AppDomain.Unload (domain);
1103 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1104 public static void domains_2 (object o, object o2) {
1107 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1108 public static void domains_3 () {
1111 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1112 public static void invoke_in_domain () {
1115 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1116 public static void invoke_in_domain_2 () {
1119 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1120 public static void dynamic_methods () {
1121 var m = new DynamicMethod ("dyn_method", typeof (void), new Type [] { typeof (int) }, typeof (object).Module);
1122 var ig = m.GetILGenerator ();
1124 ig.Emit (OpCodes.Ldstr, "FOO");
1125 ig.Emit (OpCodes.Call, typeof (Tests).GetMethod ("dyn_call"));
1126 ig.Emit (OpCodes.Ret);
1128 var del = (Action<int>)m.CreateDelegate (typeof (Action<int>));
1133 public static void dyn_call (string s) {
1136 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1137 public static void ref_emit () {
1138 AssemblyName assemblyName = new AssemblyName ();
1139 assemblyName.Name = "foo";
1141 AssemblyBuilder assembly =
1142 Thread.GetDomain ().DefineDynamicAssembly (
1143 assemblyName, AssemblyBuilderAccess.RunAndSave);
1145 ModuleBuilder module = assembly.DefineDynamicModule ("foo.dll");
1147 TypeBuilder tb = module.DefineType ("foo", TypeAttributes.Public, typeof (object));
1148 MethodBuilder mb = tb.DefineMethod ("ref_emit_method", MethodAttributes.Public|MethodAttributes.Static, CallingConventions.Standard, typeof (void), new Type [] { });
1149 ILGenerator ig = mb.GetILGenerator ();
1150 ig.Emit (OpCodes.Ldstr, "FOO");
1151 ig.Emit (OpCodes.Call, typeof (Tests).GetMethod ("ref_emit_call"));
1152 ig.Emit (OpCodes.Ret);
1154 Type t = tb.CreateType ();
1156 t.GetMethod ("ref_emit_method").Invoke (null, null);
1159 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1160 public static void ref_emit_call (string s) {
1163 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1164 public static void frames_in_native () {
1166 var evt = new ManualResetEvent (false);
1168 object mon = new object ();
1169 ThreadPool.QueueUserWorkItem (delegate {
1170 frames_in_native_2 ();
1176 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1177 static void frames_in_native_2 () {
1178 frames_in_native_3 ();
1181 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1182 static void frames_in_native_3 () {
1185 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1186 public static void string_call (string s) {
1189 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1190 public static void ss_regress_654694 () {
1197 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1198 public static void user () {
1201 Debugger.Log (5, Debugger.IsLogging () ? "A" : "", "B");
1204 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1205 public static void type_load () {
1209 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1210 static void type_load_2 () {
1211 var c1 = new Dictionary<int, int> ();
1213 var c = new TypeLoadClass ();
1215 var c2 = new TypeLoadClass2 ();
1219 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1220 public static void regress () {
1221 regress_2755 (DateTime.Now);
1224 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1225 public static unsafe void regress_2755 (DateTime d) {
1226 int* buffer = stackalloc int [128];
1231 for (int i = 0; i < 128; ++i)
1234 regress_2755_3 (sum);
1237 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1238 public static void regress_2755_2 () {
1241 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1242 public static void regress_2755_3 (int sum) {
1245 static object gc_suspend_field;
1247 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1248 static unsafe void set_gc_suspend_field () {
1249 set_gc_suspend_field_2 ();
1251 int* buffer = stackalloc int [4096];
1254 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1255 static void set_gc_suspend_field_2 () {
1256 gc_suspend_field = new object ();
1259 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1260 static void gc_suspend_1 () {
1263 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1264 public static void gc_suspend_invoke () {
1265 gc_suspend_field = null;
1267 GC.WaitForPendingFinalizers ();
1270 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1271 public static void gc_suspend () {
1272 set_gc_suspend_field ();
1276 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1277 public static void generic_method<T> () where T : class {
1280 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1281 public void evaluate_method_2 () {
1284 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1285 public void evaluate_method () {
1287 evaluate_method_2 ();
1290 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1291 static void set_ip_1 () {
1294 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1295 static void set_ip_2 () {
1298 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1299 public static void set_ip () {
1310 class TypeLoadClass {
1313 class TypeLoadClass2 {
1316 public class CrossDomain : MarshalByRefObject
1318 public void invoke () {
1319 Tests.invoke_in_domain ();
1322 public void invoke_2 () {
1323 Tests.invoke_in_domain_2 ();
1326 public int invoke_3 () {
1333 public ProcessStartInfo info;
1336 // Class used for line number info testing, don't change its layout
1337 public class LineNumbers
1339 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1340 public static void ln1 () {
1346 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1347 public static void ln2 () {
1350 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1351 public static void ln3 () {
1352 #pragma warning disable 0219
1354 #pragma warning restore 0219