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 {
142 public interface IRecStruct {
146 struct RecStruct : IRecStruct {
149 public void foo (object o) {
166 class TestIfaces : ITest
174 TestIfaces<int> Baz () {
179 class TestIfaces<T> : ITest<T>
181 void ITest<T>.Foo () {
184 void ITest<T>.Bar () {
188 public interface ITest2
193 public class Tests : TestsBase, ITest2
195 #pragma warning disable 0414
199 bool field_bool1, field_bool2;
212 static int static_i = 55;
213 static string static_s = "A";
214 public const int literal_i = 56;
215 public const string literal_s = "B";
217 public AStruct field_struct;
218 public object field_boxed_struct;
219 public GStruct<int> generic_field_struct;
220 public KeyValuePair<int, object> boxed_struct_field;
222 public static int tls_i;
223 public static bool is_attached = Debugger.IsAttached;
224 public NestedStruct nested_struct;
226 #pragma warning restore 0414
228 public class NestedClass {
231 public int IntProperty {
240 public int ReadOnlyProperty {
246 public int this [int index] {
252 public static void wait_one ()
254 ManualResetEvent evt = new ManualResetEvent (false);
258 public static int Main (String[] args) {
261 if (args.Length > 0 && args [0] == "suspend-test")
262 /* This contains an infinite loop, so execute it conditionally */
264 if (args.Length >0 && args [0] == "unhandled-exception") {
265 unhandled_exception ();
268 if (args.Length >0 && args [0] == "unhandled-exception-endinvoke") {
269 unhandled_exception_endinvoke ();
272 if (args.Length >0 && args [0] == "unhandled-exception-user") {
273 unhandled_exception_user ();
276 if (args.Length >0 && args [0] == "wait-one") {
300 if (args.Length > 0 && args [0] == "domain-test")
301 /* This takes a lot of time, so execute it conditionally */
303 if (args.Length > 0 && args [0] == "ref-emit-test")
305 if (args.Length > 0 && args [0] == "frames-in-native")
307 if (args.Length > 0 && args [0] == "invoke-single-threaded")
308 new Tests ().invoke_single_threaded ();
309 new Tests ().evaluate_method ();
313 public static void breakpoints () {
314 /* Call these early so it is JITted by the time a breakpoint is placed on it */
326 bp6<string> (new GClass <int> ());
331 [MethodImplAttribute (MethodImplOptions.NoInlining)]
332 public static void bp1 () {
335 [MethodImplAttribute (MethodImplOptions.NoInlining)]
336 public static void bp2 () {
339 [MethodImplAttribute (MethodImplOptions.NoInlining)]
340 public static void bp3 () {
343 [MethodImplAttribute (MethodImplOptions.NoInlining)]
344 public static void bp4 () {
347 [MethodImplAttribute (MethodImplOptions.NoInlining)]
348 public static void bp5 () {
351 [MethodImplAttribute (MethodImplOptions.NoInlining)]
352 public static void bp6<T> (GClass<int> gc) {
356 [MethodImplAttribute (MethodImplOptions.NoInlining)]
357 public static void bp7<T> () {
360 [MethodImplAttribute (MethodImplOptions.NoInlining)]
361 public static void single_stepping () {
368 ss5 (new int [] { 1, 2, 3 }, new Func<int, bool> (is_even));
375 ss_regress_654694 ();
382 [MethodImplAttribute (MethodImplOptions.NoInlining)]
383 public static void ss1 () {
386 [MethodImplAttribute (MethodImplOptions.NoInlining)]
387 public static void ss2 () {
390 [MethodImplAttribute (MethodImplOptions.NoInlining)]
391 public static int ss3 () {
394 for (int i = 0; i < 10; ++i)
400 [MethodImplAttribute (MethodImplOptions.NoInlining)]
401 public static void ss3_2 () {
405 [MethodImplAttribute (MethodImplOptions.NoInlining)]
406 public static void ss3_2_2 () {
409 [MethodImplAttribute (MethodImplOptions.NoInlining)]
410 public static int ss4 () {
416 [MethodImplAttribute (MethodImplOptions.NoInlining)]
417 public static void ss5 (int[] arr, Func<int, bool> selector) {
418 // Call into linq which calls back into this assembly
419 arr.Count (selector);
422 [MethodImplAttribute (MethodImplOptions.NoInlining)]
423 public static void ss6 (bool b) {
426 throw new Exception ();
430 [MethodImplAttribute (MethodImplOptions.NoInlining)]
431 public static void ss6_2 () {
434 [MethodImplAttribute (MethodImplOptions.NoInlining)]
435 public static void ss7 () {
444 [MethodImplAttribute (MethodImplOptions.NoInlining)]
445 public static void ss7_2 () {
448 [MethodImplAttribute (MethodImplOptions.NoInlining)]
449 public static void ss7_3 () {
450 throw new Exception ();
453 [MethodImplAttribute (MethodImplOptions.NoInlining)]
454 public static void ss_nested () {
455 ss_nested_1 (ss_nested_2 ());
456 ss_nested_1 (ss_nested_2 ());
460 [MethodImplAttribute (MethodImplOptions.NoInlining)]
461 public static void ss_nested_1 (int i) {
464 [MethodImplAttribute (MethodImplOptions.NoInlining)]
465 public static int ss_nested_2 () {
469 [MethodImplAttribute (MethodImplOptions.NoInlining)]
470 public static void ss_nested_3 () {
473 [MethodImplAttribute (MethodImplOptions.NoInlining)]
474 public static void ss_step_through () {
476 StepThroughClass.step_through_2 ();
480 [DebuggerStepThrough]
481 [MethodImplAttribute (MethodImplOptions.NoInlining)]
482 public static void step_through_1 () {
485 [DebuggerStepThrough]
486 class StepThroughClass {
487 [MethodImplAttribute (MethodImplOptions.NoInlining)]
488 public static void step_through_2 () {
492 [DebuggerStepThrough]
493 [MethodImplAttribute (MethodImplOptions.NoInlining)]
494 public static void step_through_3 () {
497 [MethodImplAttribute (MethodImplOptions.NoInlining)]
498 public static void ss_non_user_code () {
500 StepNonUserCodeClass.non_user_code_2 ();
504 [DebuggerNonUserCode]
505 [MethodImplAttribute (MethodImplOptions.NoInlining)]
506 public static void non_user_code_1 () {
509 [DebuggerNonUserCode]
510 class StepNonUserCodeClass {
511 [MethodImplAttribute (MethodImplOptions.NoInlining)]
512 public static void non_user_code_2 () {
516 [DebuggerNonUserCode]
517 [MethodImplAttribute (MethodImplOptions.NoInlining)]
518 public static void non_user_code_3 () {
521 [MethodImplAttribute (MethodImplOptions.NoInlining)]
522 public static void ss_recursive (int n) {
525 ss_recursive (n + 1);
528 [MethodImplAttribute (MethodImplOptions.NoInlining)]
529 public static void ss_fp_clobber () {
530 double v = ss_fp_clobber_1 (5.0);
534 [MethodImplAttribute (MethodImplOptions.NoInlining)]
535 public static double ss_fp_clobber_1 (double d) {
539 [MethodImplAttribute (MethodImplOptions.NoInlining)]
540 public static void ss_fp_clobber_2 (double d) {
543 [MethodImplAttribute (MethodImplOptions.NoInlining)]
544 public static bool is_even (int i) {
550 Console.WriteLine ("HIT!");
556 [MethodImplAttribute (MethodImplOptions.NoInlining)]
557 public static void arguments () {
558 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));
560 arg2 ("FOO", null, "BLA", ref i, new GClass <int> { field = 42 }, new object ());
561 Tests t = new Tests () { field_i = 42, field_s = "S" };
565 [MethodImplAttribute (MethodImplOptions.NoInlining)]
566 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) {
567 return (int)(sb + b + (bl ? 0 : 1) + s + us + (int)c + i + ui + l + (long)ul + f + d + (int)ip + (int)uip);
570 [MethodImplAttribute (MethodImplOptions.NoInlining)]
571 public static string arg2 (string s, string s3, object o, ref int i, GClass <int> gc, object o2) {
572 return s + (s3 != null ? "" : "") + o + i + gc.field + o2;
575 [MethodImplAttribute (MethodImplOptions.NoInlining)]
576 public object arg3 (string s) {
577 return s + s + s + s + this;
580 [MethodImplAttribute (MethodImplOptions.NoInlining)]
581 public static void objects () {
582 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 };
583 t.o1 (new Tests2 () { field_j = 43 }, new GClass <int> { field = 42 }, new GClass <string> { field = "FOO" });
584 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 });
587 [MethodImplAttribute (MethodImplOptions.NoInlining)]
588 public object o1 (Tests2 t, GClass <int> gc1, GClass <string> gc2) {
589 if (t == null || gc1 == null || gc2 == null)
595 [MethodImplAttribute (MethodImplOptions.NoInlining)]
596 public static string o2 (string[] s2, int[] s3, int[,] s4, int[,] s5, IList<int> s6) {
597 return s2 [0] + s3 [0] + s4 [0, 0] + s6 [0];
600 [MethodImplAttribute (MethodImplOptions.NoInlining)]
601 public static void objrefs () {
602 Tests t = new Tests () {};
610 [MethodImplAttribute (MethodImplOptions.NoInlining)]
611 public static void set_child (Tests t) {
612 t.child = new Tests ();
615 [MethodImplAttribute (MethodImplOptions.NoInlining)]
616 public void objrefs1 () {
619 [MethodImplAttribute (MethodImplOptions.NoInlining)]
620 public static void objrefs2 () {
623 public static void vtypes () {
624 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 ) };
625 AStruct s = new AStruct { i = 44, s = "T", k = 45 };
626 AStruct[] arr = new AStruct[] {
627 new AStruct () { i = 1, s = "S1" },
628 new AStruct () { i = 2, s = "S2" } };
635 [MethodImplAttribute (MethodImplOptions.NoInlining)]
636 public object vtypes1 (AStruct s, AStruct[] arr) {
643 [MethodImplAttribute (MethodImplOptions.NoInlining)]
644 public static void vtypes2 (AStruct s) {
648 [MethodImplAttribute (MethodImplOptions.NoInlining)]
649 public static void vtypes3 (AStruct s) {
650 AStruct.static_foo (5);
653 [MethodImplAttribute (MethodImplOptions.NoInlining)]
654 public static void vtypes4_2 (IRecStruct o) {
657 [MethodImplAttribute (MethodImplOptions.NoInlining)]
658 public static void vtypes4 () {
659 IRecStruct s = new RecStruct ();
664 [MethodImplAttribute (MethodImplOptions.NoInlining)]
665 public static void locals () {
667 var astruct = new AStruct () { i = 42 };
669 locals2<string> (null, 5, "ABC", ref s, ref astruct);
675 [MethodImplAttribute (MethodImplOptions.NoInlining)]
676 static void locals11 (double a, ref double b) {
679 [MethodImplAttribute (MethodImplOptions.NoInlining)]
680 public static void locals1 (string[] args) {
684 locals11 (b: ref ri, a: ri);
686 for (int j = 0; j < 10; ++j) {
691 [MethodImplAttribute (MethodImplOptions.NoInlining)]
693 [StateMachine (typeof (int))]
695 public static void locals2<T> (string[] args, int arg, T t, ref string rs, ref AStruct astruct) {
699 for (int j = 0; j < 10; ++j) {
704 astruct = new AStruct ();
710 [MethodImplAttribute (MethodImplOptions.NoInlining)]
711 public static void locals3 () {
731 [MethodImplAttribute (MethodImplOptions.NoInlining)]
732 public static void locals4 () {
735 [MethodImplAttribute (MethodImplOptions.NoInlining)]
736 public static void locals5 () {
739 [MethodImplAttribute (MethodImplOptions.NoInlining)]
740 public static void locals6 () {
743 for (i = 0; i < 10; ++i)
746 for (i = 0; i < 10; ++i)
756 [MethodImplAttribute (MethodImplOptions.NoInlining)]
757 public static void locals6_1 () {
760 [MethodImplAttribute (MethodImplOptions.NoInlining)]
761 public static void locals6_2 (int arg) {
764 [MethodImplAttribute (MethodImplOptions.NoInlining)]
765 public static void locals6_3 () {
766 // Clobber all registers
767 int sum = 0, i, j, k, l, m;
768 for (i = 0; i < 100; ++i)
770 for (j = 0; j < 100; ++j)
772 for (k = 0; k < 100; ++k)
774 for (l = 0; l < 100; ++l)
776 for (m = 0; m < 100; ++m)
780 [MethodImplAttribute (MethodImplOptions.NoInlining)]
781 public static void locals6_4 (int arg) {
784 [MethodImplAttribute (MethodImplOptions.NoInlining)]
785 public static void locals6_5 () {
788 [MethodImplAttribute (MethodImplOptions.NoInlining)]
789 public static void locals6_6 (int arg) {
792 [MethodImplAttribute (MethodImplOptions.NoInlining)]
793 public static void locals7<T> (T arg) {
798 [MethodImplAttribute (MethodImplOptions.NoInlining)]
799 public static void line_numbers () {
803 [MethodImplAttribute (MethodImplOptions.NoInlining)]
804 public static void suspend () {
812 [MethodImplAttribute (MethodImplOptions.NoInlining)]
813 public static void type_info () {
814 Tests t = new Tests () { field_i = 42, field_s = "S", base_field_i = 43, base_field_s = "T", field_enum = AnEnum.B };
815 t.ti1 (new Tests2 () { field_j = 43 }, new GClass <int> { field = 42 }, new GClass <string> { field = "FOO" });
818 AStruct s = new AStruct () { i = 42, s = "S", k = 43 };
820 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);
824 [MethodImplAttribute (MethodImplOptions.NoInlining)]
825 public object ti1 (Tests2 t, GClass <int> gc1, GClass <string> gc2) {
826 if (t == null || gc1 == null || gc2 == null)
832 [MethodImplAttribute (MethodImplOptions.NoInlining)]
833 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) {
834 return s2 [0] + s3 [0] + s4 [0, 0];
837 [MethodImplAttribute (MethodImplOptions.NoInlining)]
838 public static void assembly_load () {
842 [MethodImplAttribute (MethodImplOptions.NoInlining)]
843 public static void assembly_load_2 () {
844 // This will load System.dll while holding the loader lock
848 [MethodImplAttribute (MethodImplOptions.NoInlining)]
849 public static void invoke () {
850 new Tests ().invoke1 (new Tests2 (), new AStruct () { i = 42, j = (IntPtr)43 }, new GStruct<int> { j = 42 });
851 new Tests ().invoke_ex ();
854 [MethodImplAttribute (MethodImplOptions.NoInlining)]
855 public void invoke1 (Tests2 t, AStruct s, GStruct<int> g) {
859 [MethodImplAttribute (MethodImplOptions.NoInlining)]
860 public void invoke2 () {
863 [MethodImplAttribute (MethodImplOptions.NoInlining)]
864 public void invoke_ex () {
868 [MethodImplAttribute (MethodImplOptions.NoInlining)]
869 public void invoke_ex_inner () {
871 throw new Exception ();
878 [MethodImplAttribute (MethodImplOptions.NoInlining)]
879 public void invoke_single_threaded () {
880 // Spawn a thread incrementing a counter
881 bool finished = false;
883 new Thread (delegate () {
890 invoke_single_threaded_2 ();
895 [MethodImplAttribute (MethodImplOptions.NoInlining)]
896 public void invoke_single_threaded_2 () {
899 public void invoke_return_void () {
902 public string invoke_return_ref () {
906 public object invoke_return_null () {
910 public int invoke_return_primitive () {
914 public int? invoke_return_nullable () {
918 public int? invoke_return_nullable_null () {
922 public void invoke_type_load () {
929 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) {
930 return ub + sb + ss + us + i + ui + l + (long)ul + (int)c + (b ? 1 : 0) + (int)f + (int)d;
933 public int invoke_pass_primitive2 (bool b) {
937 public string invoke_pass_ref (string s) {
941 public static string invoke_static_pass_ref (string s) {
945 public static void invoke_static_return_void () {
948 public static void invoke_throws () {
949 throw new Exception ();
952 public int invoke_iface () {
956 [MethodImplAttribute (MethodImplOptions.NoInlining)]
957 public static void exceptions () {
959 throw new OverflowException ();
960 } catch (Exception) {
963 throw new OverflowException ();
964 } catch (Exception) {
967 throw new ArgumentException ();
968 } catch (Exception) {
971 throw new OverflowException ();
972 } catch (Exception) {
976 throw new OverflowException ();
977 } catch (Exception) {
980 throw new Exception ();
981 } catch (Exception) {
987 } catch (Exception) {
992 } catch (Exception) {
996 [MethodImplAttribute (MethodImplOptions.NoInlining)]
997 public static void unhandled_exception () {
998 ThreadPool.QueueUserWorkItem (delegate {
999 throw new InvalidOperationException ();
1001 Thread.Sleep (10000);
1004 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1005 public static void unhandled_exception_endinvoke_2 () {
1008 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1009 public static void unhandled_exception_endinvoke () {
1010 Action action = new Action (() =>
1012 throw new Exception ("thrown");
1014 action.BeginInvoke ((ar) => {
1016 action.EndInvoke (ar);
1017 } catch (Exception ex) {
1018 //Console.WriteLine (ex);
1021 Thread.Sleep (1000);
1022 unhandled_exception_endinvoke_2 ();
1025 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1026 public static void unhandled_exception_user () {
1028 System.Threading.Tasks.Task.Factory.StartNew (() => {
1031 Thread.Sleep (10000);
1035 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1036 public static void Throw () {
1037 throw new Exception ();
1040 internal static Delegate create_filter_delegate (Delegate dlg, MethodInfo filter_method)
1043 throw new ArgumentNullException ();
1044 if (dlg.Target != null)
1045 throw new ArgumentException ();
1046 if (dlg.Method == null)
1047 throw new ArgumentException ();
1049 var ret_type = dlg.Method.ReturnType;
1050 var param_types = dlg.Method.GetParameters ().Select (x => x.ParameterType).ToArray ();
1052 var dynamic = new DynamicMethod (Guid.NewGuid ().ToString (), ret_type, param_types, typeof (object), true);
1053 var ig = dynamic.GetILGenerator ();
1055 LocalBuilder retval = null;
1056 if (ret_type != typeof (void))
1057 retval = ig.DeclareLocal (ret_type);
1059 var label = ig.BeginExceptionBlock ();
1061 for (int i = 0; i < param_types.Length; i++)
1062 ig.Emit (OpCodes.Ldarg, i);
1063 ig.Emit (OpCodes.Call, dlg.Method);
1066 ig.Emit (OpCodes.Stloc, retval);
1068 ig.Emit (OpCodes.Leave, label);
1070 ig.BeginExceptFilterBlock ();
1072 ig.Emit (OpCodes.Call, filter_method);
1074 ig.BeginCatchBlock (null);
1076 ig.Emit (OpCodes.Pop);
1078 ig.EndExceptionBlock ();
1081 ig.Emit (OpCodes.Ldloc, retval);
1083 ig.Emit (OpCodes.Ret);
1085 return dynamic.CreateDelegate (dlg.GetType ());
1088 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1089 static void exception_filter_method () {
1090 throw new InvalidOperationException ();
1093 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1094 static int exception_filter_filter (Exception exc) {
1098 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1099 public static void exception_filter () {
1100 var method = typeof (Tests).GetMethod (
1101 "exception_filter_method", BindingFlags.NonPublic | BindingFlags.Static);
1102 var filter_method = typeof (Tests).GetMethod (
1103 "exception_filter_filter", BindingFlags.NonPublic | BindingFlags.Static);
1105 var dlg = Delegate.CreateDelegate (typeof (Action), method);
1107 var wrapper = (Action) create_filter_delegate (dlg, filter_method);
1112 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1113 public static bool return_true () {
1117 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1118 public static void exceptions2 () {
1120 throw new Exception ();
1121 Console.WriteLine ();
1124 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1125 public static void threads () {
1126 Thread t = new Thread (delegate () {});
1132 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1133 public static void domains () {
1134 AppDomain domain = AppDomain.CreateDomain ("domain");
1136 CrossDomain o = (CrossDomain)domain.CreateInstanceAndUnwrap (
1137 typeof (CrossDomain).Assembly.FullName, "CrossDomain");
1139 domains_2 (o, new CrossDomain ());
1147 AppDomain.Unload (domain);
1152 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1153 public static void domains_2 (object o, object o2) {
1156 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1157 public static void domains_3 () {
1160 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1161 public static void invoke_in_domain () {
1164 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1165 public static void invoke_in_domain_2 () {
1168 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1169 public static void dynamic_methods () {
1170 var m = new DynamicMethod ("dyn_method", typeof (void), new Type [] { typeof (int) }, typeof (object).Module);
1171 var ig = m.GetILGenerator ();
1173 ig.Emit (OpCodes.Ldstr, "FOO");
1174 ig.Emit (OpCodes.Call, typeof (Tests).GetMethod ("dyn_call"));
1175 ig.Emit (OpCodes.Ret);
1177 var del = (Action<int>)m.CreateDelegate (typeof (Action<int>));
1182 public static void dyn_call (string s) {
1185 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1186 public static void ref_emit () {
1187 AssemblyName assemblyName = new AssemblyName ();
1188 assemblyName.Name = "foo";
1190 AssemblyBuilder assembly =
1191 Thread.GetDomain ().DefineDynamicAssembly (
1192 assemblyName, AssemblyBuilderAccess.RunAndSave);
1194 ModuleBuilder module = assembly.DefineDynamicModule ("foo.dll");
1196 TypeBuilder tb = module.DefineType ("foo", TypeAttributes.Public, typeof (object));
1197 MethodBuilder mb = tb.DefineMethod ("ref_emit_method", MethodAttributes.Public|MethodAttributes.Static, CallingConventions.Standard, typeof (void), new Type [] { });
1198 ILGenerator ig = mb.GetILGenerator ();
1199 ig.Emit (OpCodes.Ldstr, "FOO");
1200 ig.Emit (OpCodes.Call, typeof (Tests).GetMethod ("ref_emit_call"));
1201 ig.Emit (OpCodes.Ret);
1203 Type t = tb.CreateType ();
1205 t.GetMethod ("ref_emit_method").Invoke (null, null);
1208 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1209 public static void ref_emit_call (string s) {
1212 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1213 public static void frames_in_native () {
1215 var evt = new ManualResetEvent (false);
1217 object mon = new object ();
1218 ThreadPool.QueueUserWorkItem (delegate {
1219 frames_in_native_2 ();
1225 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1226 static void frames_in_native_2 () {
1227 frames_in_native_3 ();
1230 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1231 static void frames_in_native_3 () {
1234 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1235 public static void string_call (string s) {
1238 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1239 public static void ss_regress_654694 () {
1246 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1247 public static void user () {
1250 Debugger.Log (5, Debugger.IsLogging () ? "A" : "", "B");
1253 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1254 public static void type_load () {
1258 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1259 static void type_load_2 () {
1260 var c1 = new Dictionary<int, int> ();
1262 var c = new TypeLoadClass ();
1264 var c2 = new TypeLoadClass2 ();
1268 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1269 public static void regress () {
1270 regress_2755 (DateTime.Now);
1273 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1274 public static unsafe void regress_2755 (DateTime d) {
1275 int* buffer = stackalloc int [128];
1280 for (int i = 0; i < 128; ++i)
1283 regress_2755_3 (sum);
1286 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1287 public static void regress_2755_2 () {
1290 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1291 public static void regress_2755_3 (int sum) {
1294 static object gc_suspend_field;
1296 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1297 static unsafe void set_gc_suspend_field () {
1298 set_gc_suspend_field_2 ();
1300 int* buffer = stackalloc int [4096];
1303 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1304 static void set_gc_suspend_field_2 () {
1305 gc_suspend_field = new object ();
1308 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1309 static void gc_suspend_1 () {
1312 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1313 public static void gc_suspend_invoke () {
1314 gc_suspend_field = null;
1316 GC.WaitForPendingFinalizers ();
1319 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1320 public static void gc_suspend () {
1321 set_gc_suspend_field ();
1325 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1326 public static void generic_method<T> () where T : class {
1329 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1330 public void evaluate_method_2 () {
1333 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1334 public void evaluate_method () {
1336 evaluate_method_2 ();
1339 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1340 static void set_ip_1 () {
1343 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1344 static void set_ip_2 () {
1347 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1348 public static void set_ip () {
1359 class TypeLoadClass {
1362 class TypeLoadClass2 {
1365 public class CrossDomain : MarshalByRefObject
1367 public void invoke () {
1368 Tests.invoke_in_domain ();
1371 public void invoke_2 () {
1372 Tests.invoke_in_domain_2 ();
1375 public int invoke_3 () {
1382 public ProcessStartInfo info;
1385 // Class used for line number info testing, don't change its layout
1386 public class LineNumbers
1388 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1389 public static void ln1 () {
1395 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1396 public static void ln2 () {
1399 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1400 public static void ln3 () {
1401 #pragma warning disable 0219
1403 #pragma warning restore 0219