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
26 public virtual string virtual_method () {
36 public sealed class Tests3 {
37 public static void M1 () {
51 public static class Tests4 {
56 public class AAttribute : Attribute {
60 public class BAttribute : AAttribute {
64 [DebuggerDisplay ("Tests", Name="FOO", Target=typeof (int))]
65 [DebuggerTypeProxy (typeof (Tests))]
66 [BAttribute (afield = 1, bfield = 2)]
68 [DebuggerBrowsableAttribute (DebuggerBrowsableState.Collapsed)]
70 public static int static_field_j;
72 [DebuggerBrowsableAttribute (DebuggerBrowsableState.Collapsed)]
73 public int AProperty {
79 public void invoke () {
83 public struct AStruct {
90 [MethodImplAttribute (MethodImplOptions.NoInlining)]
91 public int foo (int val) {
95 [MethodImplAttribute (MethodImplOptions.NoInlining)]
96 public static int static_foo (int val) {
100 [MethodImplAttribute (MethodImplOptions.NoInlining)]
101 public int invoke_return_int () {
105 [MethodImplAttribute (MethodImplOptions.NoInlining)]
106 public static int invoke_static () {
110 [MethodImplAttribute (MethodImplOptions.NoInlining)]
111 public IntPtr invoke_return_intptr () {
115 [MethodImplAttribute (MethodImplOptions.NoInlining)]
116 public void invoke_mutate () {
121 public class GClass<T> {
123 public static T static_field;
125 [MethodImplAttribute (MethodImplOptions.NoInlining)]
129 [MethodImplAttribute (MethodImplOptions.NoInlining)]
130 public void bp<T2> () {
134 public struct GStruct<T> {
139 [MethodImplAttribute (MethodImplOptions.NoInlining)]
140 public int invoke_return_int () {
145 public struct NestedStruct {
146 NestedInner nested1, nested2;
149 public struct NestedInner {
152 public interface IRecStruct {
156 struct RecStruct : IRecStruct {
159 public void foo (object o) {
176 class TestIfaces : ITest
184 TestIfaces<int> Baz () {
189 class TestIfaces<T> : ITest<T>
191 void ITest<T>.Foo () {
194 void ITest<T>.Bar () {
198 public interface ITest2
203 public class Tests : TestsBase, ITest2
205 #pragma warning disable 0414
209 bool field_bool1, field_bool2;
222 static int static_i = 55;
223 static string static_s = "A";
224 public const int literal_i = 56;
225 public const string literal_s = "B";
227 public AStruct field_struct;
228 public object field_boxed_struct;
229 public GStruct<int> generic_field_struct;
230 public KeyValuePair<int, object> boxed_struct_field;
232 public static int tls_i;
233 public static bool is_attached = Debugger.IsAttached;
234 public NestedStruct nested_struct;
236 #pragma warning restore 0414
238 public class NestedClass {
241 public int IntProperty {
250 public int ReadOnlyProperty {
256 public int this [int index] {
262 public static void wait_one ()
264 ManualResetEvent evt = new ManualResetEvent (false);
268 public static int Main (String[] args) {
271 if (args.Length > 0 && args [0] == "suspend-test")
272 /* This contains an infinite loop, so execute it conditionally */
274 if (args.Length >0 && args [0] == "unhandled-exception") {
275 unhandled_exception ();
278 if (args.Length >0 && args [0] == "unhandled-exception-endinvoke") {
279 unhandled_exception_endinvoke ();
282 if (args.Length >0 && args [0] == "unhandled-exception-user") {
283 unhandled_exception_user ();
286 if (args.Length >0 && args [0] == "wait-one") {
311 if (args.Length > 0 && args [0] == "domain-test")
312 /* This takes a lot of time, so execute it conditionally */
314 if (args.Length > 0 && args [0] == "ref-emit-test")
316 if (args.Length > 0 && args [0] == "frames-in-native")
318 if (args.Length > 0 && args [0] == "invoke-single-threaded")
319 new Tests ().invoke_single_threaded ();
320 new Tests ().evaluate_method ();
324 public static void breakpoints () {
325 /* Call these early so it is JITted by the time a breakpoint is placed on it */
337 bp6<string> (new GClass <int> ());
342 [MethodImplAttribute (MethodImplOptions.NoInlining)]
343 public static void bp1 () {
346 [MethodImplAttribute (MethodImplOptions.NoInlining)]
347 public static void bp2 () {
350 [MethodImplAttribute (MethodImplOptions.NoInlining)]
351 public static void bp3 () {
354 [MethodImplAttribute (MethodImplOptions.NoInlining)]
355 public static void bp4 () {
358 [MethodImplAttribute (MethodImplOptions.NoInlining)]
359 public static void bp5 () {
362 [MethodImplAttribute (MethodImplOptions.NoInlining)]
363 public static void bp6<T> (GClass<int> gc) {
367 [MethodImplAttribute (MethodImplOptions.NoInlining)]
368 public static void bp7<T> () {
371 [MethodImplAttribute (MethodImplOptions.NoInlining)]
372 public static void single_stepping () {
379 ss5 (new int [] { 1, 2, 3 }, new Func<int, bool> (is_even));
386 ss_regress_654694 ();
393 [MethodImplAttribute (MethodImplOptions.NoInlining)]
394 public static void ss1 () {
397 [MethodImplAttribute (MethodImplOptions.NoInlining)]
398 public static void ss2 () {
401 [MethodImplAttribute (MethodImplOptions.NoInlining)]
402 public static int ss3 () {
405 for (int i = 0; i < 10; ++i)
411 [MethodImplAttribute (MethodImplOptions.NoInlining)]
412 public static void ss3_2 () {
416 [MethodImplAttribute (MethodImplOptions.NoInlining)]
417 public static void ss3_2_2 () {
420 [MethodImplAttribute (MethodImplOptions.NoInlining)]
421 public static int ss4 () {
427 [MethodImplAttribute (MethodImplOptions.NoInlining)]
428 public static void ss5 (int[] arr, Func<int, bool> selector) {
429 // Call into linq which calls back into this assembly
430 arr.Count (selector);
433 [MethodImplAttribute (MethodImplOptions.NoInlining)]
434 public static void ss6 (bool b) {
437 throw new Exception ();
441 [MethodImplAttribute (MethodImplOptions.NoInlining)]
442 public static void ss6_2 () {
445 [MethodImplAttribute (MethodImplOptions.NoInlining)]
446 public static void ss7 () {
455 [MethodImplAttribute (MethodImplOptions.NoInlining)]
456 public static void ss7_2 () {
459 [MethodImplAttribute (MethodImplOptions.NoInlining)]
460 public static void ss7_3 () {
461 throw new Exception ();
464 [MethodImplAttribute (MethodImplOptions.NoInlining)]
465 public static void ss_nested () {
466 ss_nested_1 (ss_nested_2 ());
467 ss_nested_1 (ss_nested_2 ());
471 [MethodImplAttribute (MethodImplOptions.NoInlining)]
472 public static void ss_nested_1 (int i) {
475 [MethodImplAttribute (MethodImplOptions.NoInlining)]
476 public static int ss_nested_2 () {
480 [MethodImplAttribute (MethodImplOptions.NoInlining)]
481 public static void ss_nested_3 () {
484 [MethodImplAttribute (MethodImplOptions.NoInlining)]
485 public static void ss_step_through () {
487 StepThroughClass.step_through_2 ();
491 [DebuggerStepThrough]
492 [MethodImplAttribute (MethodImplOptions.NoInlining)]
493 public static void step_through_1 () {
496 [DebuggerStepThrough]
497 class StepThroughClass {
498 [MethodImplAttribute (MethodImplOptions.NoInlining)]
499 public static void step_through_2 () {
503 [DebuggerStepThrough]
504 [MethodImplAttribute (MethodImplOptions.NoInlining)]
505 public static void step_through_3 () {
508 [MethodImplAttribute (MethodImplOptions.NoInlining)]
509 public static void ss_non_user_code () {
511 StepNonUserCodeClass.non_user_code_2 ();
515 [DebuggerNonUserCode]
516 [MethodImplAttribute (MethodImplOptions.NoInlining)]
517 public static void non_user_code_1 () {
520 [DebuggerNonUserCode]
521 class StepNonUserCodeClass {
522 [MethodImplAttribute (MethodImplOptions.NoInlining)]
523 public static void non_user_code_2 () {
527 [DebuggerNonUserCode]
528 [MethodImplAttribute (MethodImplOptions.NoInlining)]
529 public static void non_user_code_3 () {
532 [MethodImplAttribute (MethodImplOptions.NoInlining)]
533 public static void ss_recursive (int n) {
536 ss_recursive (n + 1);
539 [MethodImplAttribute (MethodImplOptions.NoInlining)]
540 public static void ss_fp_clobber () {
541 double v = ss_fp_clobber_1 (5.0);
545 [MethodImplAttribute (MethodImplOptions.NoInlining)]
546 public static double ss_fp_clobber_1 (double d) {
550 [MethodImplAttribute (MethodImplOptions.NoInlining)]
551 public static void ss_fp_clobber_2 (double d) {
554 [MethodImplAttribute (MethodImplOptions.NoInlining)]
555 public static bool is_even (int i) {
561 Console.WriteLine ("HIT!");
567 [MethodImplAttribute (MethodImplOptions.NoInlining)]
568 public static void arguments () {
569 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));
571 arg2 ("FOO", null, "BLA", ref i, new GClass <int> { field = 42 }, new object ());
572 Tests t = new Tests () { field_i = 42, field_s = "S" };
576 [MethodImplAttribute (MethodImplOptions.NoInlining)]
577 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) {
578 return (int)(sb + b + (bl ? 0 : 1) + s + us + (int)c + i + ui + l + (long)ul + f + d + (int)ip + (int)uip);
581 [MethodImplAttribute (MethodImplOptions.NoInlining)]
582 public static string arg2 (string s, string s3, object o, ref int i, GClass <int> gc, object o2) {
583 return s + (s3 != null ? "" : "") + o + i + gc.field + o2;
586 [MethodImplAttribute (MethodImplOptions.NoInlining)]
587 public object arg3 (string s) {
588 return s + s + s + s + this;
591 [MethodImplAttribute (MethodImplOptions.NoInlining)]
592 public static void objects () {
593 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 };
594 t.o1 (new Tests2 () { field_j = 43 }, new GClass <int> { field = 42 }, new GClass <string> { field = "FOO" });
595 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 });
598 [MethodImplAttribute (MethodImplOptions.NoInlining)]
599 public object o1 (Tests2 t, GClass <int> gc1, GClass <string> gc2) {
600 if (t == null || gc1 == null || gc2 == null)
606 [MethodImplAttribute (MethodImplOptions.NoInlining)]
607 public static string o2 (string[] s2, int[] s3, int[,] s4, int[,] s5, IList<int> s6) {
608 return s2 [0] + s3 [0] + s4 [0, 0] + s6 [0];
611 [MethodImplAttribute (MethodImplOptions.NoInlining)]
612 public static void objrefs () {
613 Tests t = new Tests () {};
621 [MethodImplAttribute (MethodImplOptions.NoInlining)]
622 public static void set_child (Tests t) {
623 t.child = new Tests ();
626 [MethodImplAttribute (MethodImplOptions.NoInlining)]
627 public void objrefs1 () {
630 [MethodImplAttribute (MethodImplOptions.NoInlining)]
631 public static void objrefs2 () {
634 public static void vtypes () {
635 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 ) };
636 AStruct s = new AStruct { i = 44, s = "T", k = 45 };
637 AStruct[] arr = new AStruct[] {
638 new AStruct () { i = 1, s = "S1" },
639 new AStruct () { i = 2, s = "S2" } };
646 [MethodImplAttribute (MethodImplOptions.NoInlining)]
647 public object vtypes1 (AStruct s, AStruct[] arr) {
654 [MethodImplAttribute (MethodImplOptions.NoInlining)]
655 public static void vtypes2 (AStruct s) {
659 [MethodImplAttribute (MethodImplOptions.NoInlining)]
660 public static void vtypes3 (AStruct s) {
661 AStruct.static_foo (5);
664 [MethodImplAttribute (MethodImplOptions.NoInlining)]
665 public static void vtypes4_2 (IRecStruct o) {
668 [MethodImplAttribute (MethodImplOptions.NoInlining)]
669 public static void vtypes4 () {
670 IRecStruct s = new RecStruct ();
675 [MethodImplAttribute (MethodImplOptions.NoInlining)]
676 public static void locals () {
678 var astruct = new AStruct () { i = 42 };
680 locals2<string> (null, 5, "ABC", ref s, ref astruct);
686 [MethodImplAttribute (MethodImplOptions.NoInlining)]
687 static void locals11 (double a, ref double b) {
690 [MethodImplAttribute (MethodImplOptions.NoInlining)]
691 public static void locals1 (string[] args) {
695 locals11 (b: ref ri, a: ri);
697 for (int j = 0; j < 10; ++j) {
702 [MethodImplAttribute (MethodImplOptions.NoInlining)]
704 [StateMachine (typeof (int))]
706 public static void locals2<T> (string[] args, int arg, T t, ref string rs, ref AStruct astruct) {
710 for (int j = 0; j < 10; ++j) {
715 astruct = new AStruct ();
721 [MethodImplAttribute (MethodImplOptions.NoInlining)]
722 public static void locals3 () {
742 [MethodImplAttribute (MethodImplOptions.NoInlining)]
743 public static void locals4 () {
746 [MethodImplAttribute (MethodImplOptions.NoInlining)]
747 public static void locals5 () {
750 [MethodImplAttribute (MethodImplOptions.NoInlining)]
751 public static void locals6 () {
754 for (i = 0; i < 10; ++i)
757 for (i = 0; i < 10; ++i)
767 [MethodImplAttribute (MethodImplOptions.NoInlining)]
768 public static void locals6_1 () {
771 [MethodImplAttribute (MethodImplOptions.NoInlining)]
772 public static void locals6_2 (int arg) {
775 [MethodImplAttribute (MethodImplOptions.NoInlining)]
776 public static void locals6_3 () {
777 // Clobber all registers
778 int sum = 0, i, j, k, l, m;
779 for (i = 0; i < 100; ++i)
781 for (j = 0; j < 100; ++j)
783 for (k = 0; k < 100; ++k)
785 for (l = 0; l < 100; ++l)
787 for (m = 0; m < 100; ++m)
791 [MethodImplAttribute (MethodImplOptions.NoInlining)]
792 public static void locals6_4 (int arg) {
795 [MethodImplAttribute (MethodImplOptions.NoInlining)]
796 public static void locals6_5 () {
799 [MethodImplAttribute (MethodImplOptions.NoInlining)]
800 public static void locals6_6 (int arg) {
803 [MethodImplAttribute (MethodImplOptions.NoInlining)]
804 public static void locals7<T> (T arg) {
809 [MethodImplAttribute (MethodImplOptions.NoInlining)]
810 public static void line_numbers () {
814 [MethodImplAttribute (MethodImplOptions.NoInlining)]
815 public static void suspend () {
823 [MethodImplAttribute (MethodImplOptions.NoInlining)]
824 public static void type_info () {
825 Tests t = new Tests () { field_i = 42, field_s = "S", base_field_i = 43, base_field_s = "T", field_enum = AnEnum.B };
826 t.ti1 (new Tests2 () { field_j = 43 }, new GClass <int> { field = 42 }, new GClass <string> { field = "FOO" });
829 AStruct s = new AStruct () { i = 42, s = "S", k = 43 };
831 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);
835 [MethodImplAttribute (MethodImplOptions.NoInlining)]
836 public object ti1 (Tests2 t, GClass <int> gc1, GClass <string> gc2) {
837 if (t == null || gc1 == null || gc2 == null)
843 [MethodImplAttribute (MethodImplOptions.NoInlining)]
844 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) {
845 return s2 [0] + s3 [0] + s4 [0, 0];
848 [MethodImplAttribute (MethodImplOptions.NoInlining)]
849 public static void assembly_load () {
853 [MethodImplAttribute (MethodImplOptions.NoInlining)]
854 public static void assembly_load_2 () {
855 // This will load System.dll while holding the loader lock
859 [MethodImplAttribute (MethodImplOptions.NoInlining)]
860 public static void invoke () {
861 new Tests ().invoke1 (new Tests2 (), new AStruct () { i = 42, j = (IntPtr)43 }, new GStruct<int> { j = 42 });
862 new Tests ().invoke_ex ();
865 [MethodImplAttribute (MethodImplOptions.NoInlining)]
866 public void invoke1 (Tests2 t, AStruct s, GStruct<int> g) {
870 [MethodImplAttribute (MethodImplOptions.NoInlining)]
871 public void invoke2 () {
874 [MethodImplAttribute (MethodImplOptions.NoInlining)]
875 public void invoke_ex () {
879 [MethodImplAttribute (MethodImplOptions.NoInlining)]
880 public void invoke_ex_inner () {
882 throw new Exception ();
889 [MethodImplAttribute (MethodImplOptions.NoInlining)]
890 public void invoke_single_threaded () {
891 // Spawn a thread incrementing a counter
892 bool finished = false;
894 new Thread (delegate () {
901 invoke_single_threaded_2 ();
906 [MethodImplAttribute (MethodImplOptions.NoInlining)]
907 public void invoke_single_threaded_2 () {
910 public void invoke_return_void () {
913 public string invoke_return_ref () {
917 public object invoke_return_null () {
921 public int invoke_return_primitive () {
925 public int? invoke_return_nullable () {
929 public int? invoke_return_nullable_null () {
933 public void invoke_type_load () {
940 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) {
941 return ub + sb + ss + us + i + ui + l + (long)ul + (int)c + (b ? 1 : 0) + (int)f + (int)d;
944 public int invoke_pass_primitive2 (bool b) {
948 public string invoke_pass_ref (string s) {
952 public static string invoke_static_pass_ref (string s) {
956 public static void invoke_static_return_void () {
959 public static void invoke_throws () {
960 throw new Exception ();
963 public int invoke_iface () {
967 public void invoke_out (out int foo, out int[] arr) {
972 [MethodImplAttribute (MethodImplOptions.NoInlining)]
973 public static void exceptions () {
975 throw new OverflowException ();
976 } catch (Exception) {
979 throw new OverflowException ();
980 } catch (Exception) {
983 throw new ArgumentException ();
984 } catch (Exception) {
987 throw new OverflowException ();
988 } catch (Exception) {
992 throw new OverflowException ();
993 } catch (Exception) {
996 throw new Exception ();
997 } catch (Exception) {
1003 } catch (Exception) {
1008 } catch (Exception) {
1012 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1013 public static void unhandled_exception () {
1014 ThreadPool.QueueUserWorkItem (delegate {
1015 throw new InvalidOperationException ();
1017 Thread.Sleep (10000);
1020 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1021 public static void unhandled_exception_endinvoke_2 () {
1024 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1025 public static void unhandled_exception_endinvoke () {
1026 Action action = new Action (() =>
1028 throw new Exception ("thrown");
1030 action.BeginInvoke ((ar) => {
1032 action.EndInvoke (ar);
1033 } catch (Exception ex) {
1034 //Console.WriteLine (ex);
1037 Thread.Sleep (1000);
1038 unhandled_exception_endinvoke_2 ();
1041 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1042 public static void unhandled_exception_user () {
1044 System.Threading.Tasks.Task.Factory.StartNew (() => {
1047 Thread.Sleep (10000);
1051 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1052 public static void Throw () {
1053 throw new Exception ();
1056 internal static Delegate create_filter_delegate (Delegate dlg, MethodInfo filter_method)
1059 throw new ArgumentNullException ();
1060 if (dlg.Target != null)
1061 throw new ArgumentException ();
1062 if (dlg.Method == null)
1063 throw new ArgumentException ();
1065 var ret_type = dlg.Method.ReturnType;
1066 var param_types = dlg.Method.GetParameters ().Select (x => x.ParameterType).ToArray ();
1068 var dynamic = new DynamicMethod (Guid.NewGuid ().ToString (), ret_type, param_types, typeof (object), true);
1069 var ig = dynamic.GetILGenerator ();
1071 LocalBuilder retval = null;
1072 if (ret_type != typeof (void))
1073 retval = ig.DeclareLocal (ret_type);
1075 var label = ig.BeginExceptionBlock ();
1077 for (int i = 0; i < param_types.Length; i++)
1078 ig.Emit (OpCodes.Ldarg, i);
1079 ig.Emit (OpCodes.Call, dlg.Method);
1082 ig.Emit (OpCodes.Stloc, retval);
1084 ig.Emit (OpCodes.Leave, label);
1086 ig.BeginExceptFilterBlock ();
1088 ig.Emit (OpCodes.Call, filter_method);
1090 ig.BeginCatchBlock (null);
1092 ig.Emit (OpCodes.Pop);
1094 ig.EndExceptionBlock ();
1097 ig.Emit (OpCodes.Ldloc, retval);
1099 ig.Emit (OpCodes.Ret);
1101 return dynamic.CreateDelegate (dlg.GetType ());
1104 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1105 static void exception_filter_method () {
1106 throw new InvalidOperationException ();
1109 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1110 static int exception_filter_filter (Exception exc) {
1114 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1115 public static void exception_filter () {
1116 var method = typeof (Tests).GetMethod (
1117 "exception_filter_method", BindingFlags.NonPublic | BindingFlags.Static);
1118 var filter_method = typeof (Tests).GetMethod (
1119 "exception_filter_filter", BindingFlags.NonPublic | BindingFlags.Static);
1121 var dlg = Delegate.CreateDelegate (typeof (Action), method);
1123 var wrapper = (Action) create_filter_delegate (dlg, filter_method);
1128 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1129 public static bool return_true () {
1133 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1134 public static void exceptions2 () {
1136 throw new Exception ();
1137 Console.WriteLine ();
1140 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1141 public static void threads () {
1142 Thread t = new Thread (delegate () {});
1148 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1149 public static void domains () {
1150 AppDomain domain = AppDomain.CreateDomain ("domain");
1152 CrossDomain o = (CrossDomain)domain.CreateInstanceAndUnwrap (
1153 typeof (CrossDomain).Assembly.FullName, "CrossDomain");
1155 domains_2 (o, new CrossDomain ());
1163 AppDomain.Unload (domain);
1167 typeof (Tests).GetMethod ("called_from_invoke").Invoke (null, null);
1170 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1171 public static void called_from_invoke () {
1174 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1175 public static void domains_2 (object o, object o2) {
1178 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1179 public static void domains_3 () {
1182 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1183 public static void invoke_in_domain () {
1186 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1187 public static void invoke_in_domain_2 () {
1190 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1191 public static void dynamic_methods () {
1192 var m = new DynamicMethod ("dyn_method", typeof (void), new Type [] { typeof (int) }, typeof (object).Module);
1193 var ig = m.GetILGenerator ();
1195 ig.Emit (OpCodes.Ldstr, "FOO");
1196 ig.Emit (OpCodes.Call, typeof (Tests).GetMethod ("dyn_call"));
1197 ig.Emit (OpCodes.Ret);
1199 var del = (Action<int>)m.CreateDelegate (typeof (Action<int>));
1204 public static void dyn_call (string s) {
1207 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1208 public static void ref_emit () {
1209 AssemblyName assemblyName = new AssemblyName ();
1210 assemblyName.Name = "foo";
1212 AssemblyBuilder assembly =
1213 Thread.GetDomain ().DefineDynamicAssembly (
1214 assemblyName, AssemblyBuilderAccess.RunAndSave);
1216 ModuleBuilder module = assembly.DefineDynamicModule ("foo.dll");
1218 TypeBuilder tb = module.DefineType ("foo", TypeAttributes.Public, typeof (object));
1219 MethodBuilder mb = tb.DefineMethod ("ref_emit_method", MethodAttributes.Public|MethodAttributes.Static, CallingConventions.Standard, typeof (void), new Type [] { });
1220 ILGenerator ig = mb.GetILGenerator ();
1221 ig.Emit (OpCodes.Ldstr, "FOO");
1222 ig.Emit (OpCodes.Call, typeof (Tests).GetMethod ("ref_emit_call"));
1223 ig.Emit (OpCodes.Ret);
1225 Type t = tb.CreateType ();
1227 t.GetMethod ("ref_emit_method").Invoke (null, null);
1230 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1231 public static void ref_emit_call (string s) {
1234 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1235 public static void frames_in_native () {
1237 var evt = new ManualResetEvent (false);
1239 object mon = new object ();
1240 ThreadPool.QueueUserWorkItem (delegate {
1241 frames_in_native_2 ();
1247 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1248 static void frames_in_native_2 () {
1249 frames_in_native_3 ();
1252 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1253 static void frames_in_native_3 () {
1256 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1257 public static void string_call (string s) {
1260 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1261 public static void ss_regress_654694 () {
1268 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1269 public static void user () {
1272 Debugger.Log (5, Debugger.IsLogging () ? "A" : "", "B");
1275 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1276 public static void type_load () {
1280 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1281 static void type_load_2 () {
1282 var c1 = new Dictionary<int, int> ();
1284 var c = new TypeLoadClass ();
1286 var c2 = new TypeLoadClass2 ();
1290 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1291 public static void regress () {
1292 regress_2755 (DateTime.Now);
1295 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1296 public static unsafe void regress_2755 (DateTime d) {
1297 int* buffer = stackalloc int [128];
1302 for (int i = 0; i < 128; ++i)
1305 regress_2755_3 (sum);
1308 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1309 public static void regress_2755_2 () {
1312 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1313 public static void regress_2755_3 (int sum) {
1316 static object gc_suspend_field;
1318 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1319 static unsafe void set_gc_suspend_field () {
1320 set_gc_suspend_field_2 ();
1322 int* buffer = stackalloc int [4096];
1325 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1326 static void set_gc_suspend_field_2 () {
1327 gc_suspend_field = new object ();
1330 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1331 static void gc_suspend_1 () {
1334 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1335 public static void gc_suspend_invoke () {
1336 gc_suspend_field = null;
1338 GC.WaitForPendingFinalizers ();
1341 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1342 public static void gc_suspend () {
1343 set_gc_suspend_field ();
1347 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1348 public static void generic_method<T> () where T : class {
1351 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1352 public void evaluate_method_2 () {
1355 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1356 public void evaluate_method () {
1358 evaluate_method_2 ();
1361 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1362 static void set_ip_1 () {
1365 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1366 static void set_ip_2 () {
1369 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1370 public static void set_ip () {
1380 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1381 public static void step_filters () {
1382 ClassWithCctor.cctor_filter ();
1385 class ClassWithCctor {
1386 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1387 static ClassWithCctor () {
1392 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1393 public static void cctor_filter () {
1397 public override string virtual_method () {
1402 class TypeLoadClass {
1405 class TypeLoadClass2 {
1408 public class CrossDomain : MarshalByRefObject
1410 public void invoke () {
1411 Tests.invoke_in_domain ();
1414 public void invoke_2 () {
1415 Tests.invoke_in_domain_2 ();
1418 public int invoke_3 () {
1425 public ProcessStartInfo info;
1428 // Class used for line number info testing, don't change its layout
1429 public class LineNumbers
1431 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1432 public static void ln1 () {
1438 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1439 public static void ln2 () {
1442 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1443 public static void ln3 () {
1444 #pragma warning disable 0219
1446 #pragma warning restore 0219