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 {
86 [MethodImplAttribute (MethodImplOptions.NoInlining)]
87 public int foo (int val) {
91 [MethodImplAttribute (MethodImplOptions.NoInlining)]
92 public static int static_foo (int val) {
96 [MethodImplAttribute (MethodImplOptions.NoInlining)]
97 public int invoke_return_int () {
101 [MethodImplAttribute (MethodImplOptions.NoInlining)]
102 public static int invoke_static () {
106 [MethodImplAttribute (MethodImplOptions.NoInlining)]
107 public IntPtr invoke_return_intptr () {
111 [MethodImplAttribute (MethodImplOptions.NoInlining)]
112 public void invoke_mutate () {
117 public class GClass<T> {
119 public static T static_field;
121 [MethodImplAttribute (MethodImplOptions.NoInlining)]
125 [MethodImplAttribute (MethodImplOptions.NoInlining)]
126 public void bp<T2> () {
130 public struct GStruct<T> {
135 [MethodImplAttribute (MethodImplOptions.NoInlining)]
136 public int invoke_return_int () {
141 public struct NestedStruct {
142 NestedInner nested1, nested2;
145 public struct NestedInner {
148 public interface IRecStruct {
152 struct RecStruct : IRecStruct {
155 public void foo (object o) {
172 class TestIfaces : ITest
180 TestIfaces<int> Baz () {
185 class TestIfaces<T> : ITest<T>
187 void ITest<T>.Foo () {
190 void ITest<T>.Bar () {
194 public interface ITest2
199 public class Tests : TestsBase, ITest2
201 #pragma warning disable 0414
205 bool field_bool1, field_bool2;
218 static int static_i = 55;
219 static string static_s = "A";
220 public const int literal_i = 56;
221 public const string literal_s = "B";
223 public AStruct field_struct;
224 public object field_boxed_struct;
225 public GStruct<int> generic_field_struct;
226 public KeyValuePair<int, object> boxed_struct_field;
228 public static int tls_i;
229 public static bool is_attached = Debugger.IsAttached;
230 public NestedStruct nested_struct;
232 #pragma warning restore 0414
234 public class NestedClass {
237 public int IntProperty {
246 public int ReadOnlyProperty {
252 public int this [int index] {
258 public static void wait_one ()
260 ManualResetEvent evt = new ManualResetEvent (false);
264 public static int Main (String[] args) {
267 if (args.Length > 0 && args [0] == "suspend-test")
268 /* This contains an infinite loop, so execute it conditionally */
270 if (args.Length >0 && args [0] == "unhandled-exception") {
271 unhandled_exception ();
274 if (args.Length >0 && args [0] == "unhandled-exception-endinvoke") {
275 unhandled_exception_endinvoke ();
278 if (args.Length >0 && args [0] == "unhandled-exception-user") {
279 unhandled_exception_user ();
282 if (args.Length >0 && args [0] == "wait-one") {
306 if (args.Length > 0 && args [0] == "domain-test")
307 /* This takes a lot of time, so execute it conditionally */
309 if (args.Length > 0 && args [0] == "ref-emit-test")
311 if (args.Length > 0 && args [0] == "frames-in-native")
313 if (args.Length > 0 && args [0] == "invoke-single-threaded")
314 new Tests ().invoke_single_threaded ();
315 new Tests ().evaluate_method ();
319 public static void breakpoints () {
320 /* Call these early so it is JITted by the time a breakpoint is placed on it */
332 bp6<string> (new GClass <int> ());
337 [MethodImplAttribute (MethodImplOptions.NoInlining)]
338 public static void bp1 () {
341 [MethodImplAttribute (MethodImplOptions.NoInlining)]
342 public static void bp2 () {
345 [MethodImplAttribute (MethodImplOptions.NoInlining)]
346 public static void bp3 () {
349 [MethodImplAttribute (MethodImplOptions.NoInlining)]
350 public static void bp4 () {
353 [MethodImplAttribute (MethodImplOptions.NoInlining)]
354 public static void bp5 () {
357 [MethodImplAttribute (MethodImplOptions.NoInlining)]
358 public static void bp6<T> (GClass<int> gc) {
362 [MethodImplAttribute (MethodImplOptions.NoInlining)]
363 public static void bp7<T> () {
366 [MethodImplAttribute (MethodImplOptions.NoInlining)]
367 public static void single_stepping () {
374 ss5 (new int [] { 1, 2, 3 }, new Func<int, bool> (is_even));
381 ss_regress_654694 ();
388 [MethodImplAttribute (MethodImplOptions.NoInlining)]
389 public static void ss1 () {
392 [MethodImplAttribute (MethodImplOptions.NoInlining)]
393 public static void ss2 () {
396 [MethodImplAttribute (MethodImplOptions.NoInlining)]
397 public static int ss3 () {
400 for (int i = 0; i < 10; ++i)
406 [MethodImplAttribute (MethodImplOptions.NoInlining)]
407 public static void ss3_2 () {
411 [MethodImplAttribute (MethodImplOptions.NoInlining)]
412 public static void ss3_2_2 () {
415 [MethodImplAttribute (MethodImplOptions.NoInlining)]
416 public static int ss4 () {
422 [MethodImplAttribute (MethodImplOptions.NoInlining)]
423 public static void ss5 (int[] arr, Func<int, bool> selector) {
424 // Call into linq which calls back into this assembly
425 arr.Count (selector);
428 [MethodImplAttribute (MethodImplOptions.NoInlining)]
429 public static void ss6 (bool b) {
432 throw new Exception ();
436 [MethodImplAttribute (MethodImplOptions.NoInlining)]
437 public static void ss6_2 () {
440 [MethodImplAttribute (MethodImplOptions.NoInlining)]
441 public static void ss7 () {
450 [MethodImplAttribute (MethodImplOptions.NoInlining)]
451 public static void ss7_2 () {
454 [MethodImplAttribute (MethodImplOptions.NoInlining)]
455 public static void ss7_3 () {
456 throw new Exception ();
459 [MethodImplAttribute (MethodImplOptions.NoInlining)]
460 public static void ss_nested () {
461 ss_nested_1 (ss_nested_2 ());
462 ss_nested_1 (ss_nested_2 ());
466 [MethodImplAttribute (MethodImplOptions.NoInlining)]
467 public static void ss_nested_1 (int i) {
470 [MethodImplAttribute (MethodImplOptions.NoInlining)]
471 public static int ss_nested_2 () {
475 [MethodImplAttribute (MethodImplOptions.NoInlining)]
476 public static void ss_nested_3 () {
479 [MethodImplAttribute (MethodImplOptions.NoInlining)]
480 public static void ss_step_through () {
482 StepThroughClass.step_through_2 ();
486 [DebuggerStepThrough]
487 [MethodImplAttribute (MethodImplOptions.NoInlining)]
488 public static void step_through_1 () {
491 [DebuggerStepThrough]
492 class StepThroughClass {
493 [MethodImplAttribute (MethodImplOptions.NoInlining)]
494 public static void step_through_2 () {
498 [DebuggerStepThrough]
499 [MethodImplAttribute (MethodImplOptions.NoInlining)]
500 public static void step_through_3 () {
503 [MethodImplAttribute (MethodImplOptions.NoInlining)]
504 public static void ss_non_user_code () {
506 StepNonUserCodeClass.non_user_code_2 ();
510 [DebuggerNonUserCode]
511 [MethodImplAttribute (MethodImplOptions.NoInlining)]
512 public static void non_user_code_1 () {
515 [DebuggerNonUserCode]
516 class StepNonUserCodeClass {
517 [MethodImplAttribute (MethodImplOptions.NoInlining)]
518 public static void non_user_code_2 () {
522 [DebuggerNonUserCode]
523 [MethodImplAttribute (MethodImplOptions.NoInlining)]
524 public static void non_user_code_3 () {
527 [MethodImplAttribute (MethodImplOptions.NoInlining)]
528 public static void ss_recursive (int n) {
531 ss_recursive (n + 1);
534 [MethodImplAttribute (MethodImplOptions.NoInlining)]
535 public static void ss_fp_clobber () {
536 double v = ss_fp_clobber_1 (5.0);
540 [MethodImplAttribute (MethodImplOptions.NoInlining)]
541 public static double ss_fp_clobber_1 (double d) {
545 [MethodImplAttribute (MethodImplOptions.NoInlining)]
546 public static void ss_fp_clobber_2 (double d) {
549 [MethodImplAttribute (MethodImplOptions.NoInlining)]
550 public static bool is_even (int i) {
556 Console.WriteLine ("HIT!");
562 [MethodImplAttribute (MethodImplOptions.NoInlining)]
563 public static void arguments () {
564 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));
566 arg2 ("FOO", null, "BLA", ref i, new GClass <int> { field = 42 }, new object ());
567 Tests t = new Tests () { field_i = 42, field_s = "S" };
571 [MethodImplAttribute (MethodImplOptions.NoInlining)]
572 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) {
573 return (int)(sb + b + (bl ? 0 : 1) + s + us + (int)c + i + ui + l + (long)ul + f + d + (int)ip + (int)uip);
576 [MethodImplAttribute (MethodImplOptions.NoInlining)]
577 public static string arg2 (string s, string s3, object o, ref int i, GClass <int> gc, object o2) {
578 return s + (s3 != null ? "" : "") + o + i + gc.field + o2;
581 [MethodImplAttribute (MethodImplOptions.NoInlining)]
582 public object arg3 (string s) {
583 return s + s + s + s + this;
586 [MethodImplAttribute (MethodImplOptions.NoInlining)]
587 public static void objects () {
588 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 };
589 t.o1 (new Tests2 () { field_j = 43 }, new GClass <int> { field = 42 }, new GClass <string> { field = "FOO" });
590 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 });
593 [MethodImplAttribute (MethodImplOptions.NoInlining)]
594 public object o1 (Tests2 t, GClass <int> gc1, GClass <string> gc2) {
595 if (t == null || gc1 == null || gc2 == null)
601 [MethodImplAttribute (MethodImplOptions.NoInlining)]
602 public static string o2 (string[] s2, int[] s3, int[,] s4, int[,] s5, IList<int> s6) {
603 return s2 [0] + s3 [0] + s4 [0, 0] + s6 [0];
606 [MethodImplAttribute (MethodImplOptions.NoInlining)]
607 public static void objrefs () {
608 Tests t = new Tests () {};
616 [MethodImplAttribute (MethodImplOptions.NoInlining)]
617 public static void set_child (Tests t) {
618 t.child = new Tests ();
621 [MethodImplAttribute (MethodImplOptions.NoInlining)]
622 public void objrefs1 () {
625 [MethodImplAttribute (MethodImplOptions.NoInlining)]
626 public static void objrefs2 () {
629 public static void vtypes () {
630 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 ) };
631 AStruct s = new AStruct { i = 44, s = "T", k = 45 };
632 AStruct[] arr = new AStruct[] {
633 new AStruct () { i = 1, s = "S1" },
634 new AStruct () { i = 2, s = "S2" } };
641 [MethodImplAttribute (MethodImplOptions.NoInlining)]
642 public object vtypes1 (AStruct s, AStruct[] arr) {
649 [MethodImplAttribute (MethodImplOptions.NoInlining)]
650 public static void vtypes2 (AStruct s) {
654 [MethodImplAttribute (MethodImplOptions.NoInlining)]
655 public static void vtypes3 (AStruct s) {
656 AStruct.static_foo (5);
659 [MethodImplAttribute (MethodImplOptions.NoInlining)]
660 public static void vtypes4_2 (IRecStruct o) {
663 [MethodImplAttribute (MethodImplOptions.NoInlining)]
664 public static void vtypes4 () {
665 IRecStruct s = new RecStruct ();
670 [MethodImplAttribute (MethodImplOptions.NoInlining)]
671 public static void locals () {
673 var astruct = new AStruct () { i = 42 };
675 locals2<string> (null, 5, "ABC", ref s, ref astruct);
681 [MethodImplAttribute (MethodImplOptions.NoInlining)]
682 static void locals11 (double a, ref double b) {
685 [MethodImplAttribute (MethodImplOptions.NoInlining)]
686 public static void locals1 (string[] args) {
690 locals11 (b: ref ri, a: ri);
692 for (int j = 0; j < 10; ++j) {
697 [MethodImplAttribute (MethodImplOptions.NoInlining)]
699 [StateMachine (typeof (int))]
701 public static void locals2<T> (string[] args, int arg, T t, ref string rs, ref AStruct astruct) {
705 for (int j = 0; j < 10; ++j) {
710 astruct = new AStruct ();
716 [MethodImplAttribute (MethodImplOptions.NoInlining)]
717 public static void locals3 () {
737 [MethodImplAttribute (MethodImplOptions.NoInlining)]
738 public static void locals4 () {
741 [MethodImplAttribute (MethodImplOptions.NoInlining)]
742 public static void locals5 () {
745 [MethodImplAttribute (MethodImplOptions.NoInlining)]
746 public static void locals6 () {
749 for (i = 0; i < 10; ++i)
752 for (i = 0; i < 10; ++i)
762 [MethodImplAttribute (MethodImplOptions.NoInlining)]
763 public static void locals6_1 () {
766 [MethodImplAttribute (MethodImplOptions.NoInlining)]
767 public static void locals6_2 (int arg) {
770 [MethodImplAttribute (MethodImplOptions.NoInlining)]
771 public static void locals6_3 () {
772 // Clobber all registers
773 int sum = 0, i, j, k, l, m;
774 for (i = 0; i < 100; ++i)
776 for (j = 0; j < 100; ++j)
778 for (k = 0; k < 100; ++k)
780 for (l = 0; l < 100; ++l)
782 for (m = 0; m < 100; ++m)
786 [MethodImplAttribute (MethodImplOptions.NoInlining)]
787 public static void locals6_4 (int arg) {
790 [MethodImplAttribute (MethodImplOptions.NoInlining)]
791 public static void locals6_5 () {
794 [MethodImplAttribute (MethodImplOptions.NoInlining)]
795 public static void locals6_6 (int arg) {
798 [MethodImplAttribute (MethodImplOptions.NoInlining)]
799 public static void locals7<T> (T arg) {
804 [MethodImplAttribute (MethodImplOptions.NoInlining)]
805 public static void line_numbers () {
809 [MethodImplAttribute (MethodImplOptions.NoInlining)]
810 public static void suspend () {
818 [MethodImplAttribute (MethodImplOptions.NoInlining)]
819 public static void type_info () {
820 Tests t = new Tests () { field_i = 42, field_s = "S", base_field_i = 43, base_field_s = "T", field_enum = AnEnum.B };
821 t.ti1 (new Tests2 () { field_j = 43 }, new GClass <int> { field = 42 }, new GClass <string> { field = "FOO" });
824 AStruct s = new AStruct () { i = 42, s = "S", k = 43 };
826 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);
830 [MethodImplAttribute (MethodImplOptions.NoInlining)]
831 public object ti1 (Tests2 t, GClass <int> gc1, GClass <string> gc2) {
832 if (t == null || gc1 == null || gc2 == null)
838 [MethodImplAttribute (MethodImplOptions.NoInlining)]
839 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) {
840 return s2 [0] + s3 [0] + s4 [0, 0];
843 [MethodImplAttribute (MethodImplOptions.NoInlining)]
844 public static void assembly_load () {
848 [MethodImplAttribute (MethodImplOptions.NoInlining)]
849 public static void assembly_load_2 () {
850 // This will load System.dll while holding the loader lock
854 [MethodImplAttribute (MethodImplOptions.NoInlining)]
855 public static void invoke () {
856 new Tests ().invoke1 (new Tests2 (), new AStruct () { i = 42, j = (IntPtr)43 }, new GStruct<int> { j = 42 });
857 new Tests ().invoke_ex ();
860 [MethodImplAttribute (MethodImplOptions.NoInlining)]
861 public void invoke1 (Tests2 t, AStruct s, GStruct<int> g) {
865 [MethodImplAttribute (MethodImplOptions.NoInlining)]
866 public void invoke2 () {
869 [MethodImplAttribute (MethodImplOptions.NoInlining)]
870 public void invoke_ex () {
874 [MethodImplAttribute (MethodImplOptions.NoInlining)]
875 public void invoke_ex_inner () {
877 throw new Exception ();
884 [MethodImplAttribute (MethodImplOptions.NoInlining)]
885 public void invoke_single_threaded () {
886 // Spawn a thread incrementing a counter
887 bool finished = false;
889 new Thread (delegate () {
896 invoke_single_threaded_2 ();
901 [MethodImplAttribute (MethodImplOptions.NoInlining)]
902 public void invoke_single_threaded_2 () {
905 public void invoke_return_void () {
908 public string invoke_return_ref () {
912 public object invoke_return_null () {
916 public int invoke_return_primitive () {
920 public int? invoke_return_nullable () {
924 public int? invoke_return_nullable_null () {
928 public void invoke_type_load () {
935 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) {
936 return ub + sb + ss + us + i + ui + l + (long)ul + (int)c + (b ? 1 : 0) + (int)f + (int)d;
939 public int invoke_pass_primitive2 (bool b) {
943 public string invoke_pass_ref (string s) {
947 public static string invoke_static_pass_ref (string s) {
951 public static void invoke_static_return_void () {
954 public static void invoke_throws () {
955 throw new Exception ();
958 public int invoke_iface () {
962 public void invoke_out (out int foo, out int[] arr) {
967 [MethodImplAttribute (MethodImplOptions.NoInlining)]
968 public static void exceptions () {
970 throw new OverflowException ();
971 } catch (Exception) {
974 throw new OverflowException ();
975 } catch (Exception) {
978 throw new ArgumentException ();
979 } catch (Exception) {
982 throw new OverflowException ();
983 } catch (Exception) {
987 throw new OverflowException ();
988 } catch (Exception) {
991 throw new Exception ();
992 } catch (Exception) {
998 } catch (Exception) {
1003 } catch (Exception) {
1007 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1008 public static void unhandled_exception () {
1009 ThreadPool.QueueUserWorkItem (delegate {
1010 throw new InvalidOperationException ();
1012 Thread.Sleep (10000);
1015 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1016 public static void unhandled_exception_endinvoke_2 () {
1019 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1020 public static void unhandled_exception_endinvoke () {
1021 Action action = new Action (() =>
1023 throw new Exception ("thrown");
1025 action.BeginInvoke ((ar) => {
1027 action.EndInvoke (ar);
1028 } catch (Exception ex) {
1029 //Console.WriteLine (ex);
1032 Thread.Sleep (1000);
1033 unhandled_exception_endinvoke_2 ();
1036 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1037 public static void unhandled_exception_user () {
1039 System.Threading.Tasks.Task.Factory.StartNew (() => {
1042 Thread.Sleep (10000);
1046 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1047 public static void Throw () {
1048 throw new Exception ();
1051 internal static Delegate create_filter_delegate (Delegate dlg, MethodInfo filter_method)
1054 throw new ArgumentNullException ();
1055 if (dlg.Target != null)
1056 throw new ArgumentException ();
1057 if (dlg.Method == null)
1058 throw new ArgumentException ();
1060 var ret_type = dlg.Method.ReturnType;
1061 var param_types = dlg.Method.GetParameters ().Select (x => x.ParameterType).ToArray ();
1063 var dynamic = new DynamicMethod (Guid.NewGuid ().ToString (), ret_type, param_types, typeof (object), true);
1064 var ig = dynamic.GetILGenerator ();
1066 LocalBuilder retval = null;
1067 if (ret_type != typeof (void))
1068 retval = ig.DeclareLocal (ret_type);
1070 var label = ig.BeginExceptionBlock ();
1072 for (int i = 0; i < param_types.Length; i++)
1073 ig.Emit (OpCodes.Ldarg, i);
1074 ig.Emit (OpCodes.Call, dlg.Method);
1077 ig.Emit (OpCodes.Stloc, retval);
1079 ig.Emit (OpCodes.Leave, label);
1081 ig.BeginExceptFilterBlock ();
1083 ig.Emit (OpCodes.Call, filter_method);
1085 ig.BeginCatchBlock (null);
1087 ig.Emit (OpCodes.Pop);
1089 ig.EndExceptionBlock ();
1092 ig.Emit (OpCodes.Ldloc, retval);
1094 ig.Emit (OpCodes.Ret);
1096 return dynamic.CreateDelegate (dlg.GetType ());
1099 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1100 static void exception_filter_method () {
1101 throw new InvalidOperationException ();
1104 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1105 static int exception_filter_filter (Exception exc) {
1109 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1110 public static void exception_filter () {
1111 var method = typeof (Tests).GetMethod (
1112 "exception_filter_method", BindingFlags.NonPublic | BindingFlags.Static);
1113 var filter_method = typeof (Tests).GetMethod (
1114 "exception_filter_filter", BindingFlags.NonPublic | BindingFlags.Static);
1116 var dlg = Delegate.CreateDelegate (typeof (Action), method);
1118 var wrapper = (Action) create_filter_delegate (dlg, filter_method);
1123 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1124 public static bool return_true () {
1128 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1129 public static void exceptions2 () {
1131 throw new Exception ();
1132 Console.WriteLine ();
1135 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1136 public static void threads () {
1137 Thread t = new Thread (delegate () {});
1143 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1144 public static void domains () {
1145 AppDomain domain = AppDomain.CreateDomain ("domain");
1147 CrossDomain o = (CrossDomain)domain.CreateInstanceAndUnwrap (
1148 typeof (CrossDomain).Assembly.FullName, "CrossDomain");
1150 domains_2 (o, new CrossDomain ());
1158 AppDomain.Unload (domain);
1163 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1164 public static void domains_2 (object o, object o2) {
1167 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1168 public static void domains_3 () {
1171 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1172 public static void invoke_in_domain () {
1175 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1176 public static void invoke_in_domain_2 () {
1179 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1180 public static void dynamic_methods () {
1181 var m = new DynamicMethod ("dyn_method", typeof (void), new Type [] { typeof (int) }, typeof (object).Module);
1182 var ig = m.GetILGenerator ();
1184 ig.Emit (OpCodes.Ldstr, "FOO");
1185 ig.Emit (OpCodes.Call, typeof (Tests).GetMethod ("dyn_call"));
1186 ig.Emit (OpCodes.Ret);
1188 var del = (Action<int>)m.CreateDelegate (typeof (Action<int>));
1193 public static void dyn_call (string s) {
1196 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1197 public static void ref_emit () {
1198 AssemblyName assemblyName = new AssemblyName ();
1199 assemblyName.Name = "foo";
1201 AssemblyBuilder assembly =
1202 Thread.GetDomain ().DefineDynamicAssembly (
1203 assemblyName, AssemblyBuilderAccess.RunAndSave);
1205 ModuleBuilder module = assembly.DefineDynamicModule ("foo.dll");
1207 TypeBuilder tb = module.DefineType ("foo", TypeAttributes.Public, typeof (object));
1208 MethodBuilder mb = tb.DefineMethod ("ref_emit_method", MethodAttributes.Public|MethodAttributes.Static, CallingConventions.Standard, typeof (void), new Type [] { });
1209 ILGenerator ig = mb.GetILGenerator ();
1210 ig.Emit (OpCodes.Ldstr, "FOO");
1211 ig.Emit (OpCodes.Call, typeof (Tests).GetMethod ("ref_emit_call"));
1212 ig.Emit (OpCodes.Ret);
1214 Type t = tb.CreateType ();
1216 t.GetMethod ("ref_emit_method").Invoke (null, null);
1219 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1220 public static void ref_emit_call (string s) {
1223 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1224 public static void frames_in_native () {
1226 var evt = new ManualResetEvent (false);
1228 object mon = new object ();
1229 ThreadPool.QueueUserWorkItem (delegate {
1230 frames_in_native_2 ();
1236 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1237 static void frames_in_native_2 () {
1238 frames_in_native_3 ();
1241 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1242 static void frames_in_native_3 () {
1245 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1246 public static void string_call (string s) {
1249 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1250 public static void ss_regress_654694 () {
1257 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1258 public static void user () {
1261 Debugger.Log (5, Debugger.IsLogging () ? "A" : "", "B");
1264 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1265 public static void type_load () {
1269 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1270 static void type_load_2 () {
1271 var c1 = new Dictionary<int, int> ();
1273 var c = new TypeLoadClass ();
1275 var c2 = new TypeLoadClass2 ();
1279 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1280 public static void regress () {
1281 regress_2755 (DateTime.Now);
1284 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1285 public static unsafe void regress_2755 (DateTime d) {
1286 int* buffer = stackalloc int [128];
1291 for (int i = 0; i < 128; ++i)
1294 regress_2755_3 (sum);
1297 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1298 public static void regress_2755_2 () {
1301 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1302 public static void regress_2755_3 (int sum) {
1305 static object gc_suspend_field;
1307 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1308 static unsafe void set_gc_suspend_field () {
1309 set_gc_suspend_field_2 ();
1311 int* buffer = stackalloc int [4096];
1314 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1315 static void set_gc_suspend_field_2 () {
1316 gc_suspend_field = new object ();
1319 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1320 static void gc_suspend_1 () {
1323 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1324 public static void gc_suspend_invoke () {
1325 gc_suspend_field = null;
1327 GC.WaitForPendingFinalizers ();
1330 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1331 public static void gc_suspend () {
1332 set_gc_suspend_field ();
1336 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1337 public static void generic_method<T> () where T : class {
1340 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1341 public void evaluate_method_2 () {
1344 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1345 public void evaluate_method () {
1347 evaluate_method_2 ();
1350 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1351 static void set_ip_1 () {
1354 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1355 static void set_ip_2 () {
1358 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1359 public static void set_ip () {
1370 class TypeLoadClass {
1373 class TypeLoadClass2 {
1376 public class CrossDomain : MarshalByRefObject
1378 public void invoke () {
1379 Tests.invoke_in_domain ();
1382 public void invoke_2 () {
1383 Tests.invoke_in_domain_2 ();
1386 public int invoke_3 () {
1393 public ProcessStartInfo info;
1396 // Class used for line number info testing, don't change its layout
1397 public class LineNumbers
1399 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1400 public static void ln1 () {
1406 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1407 public static void ln2 () {
1410 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1411 public static void ln3 () {
1412 #pragma warning disable 0219
1414 #pragma warning restore 0219