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 : ITest2 {
98 public AStruct (int arg) {
106 [MethodImplAttribute (MethodImplOptions.NoInlining)]
107 public int foo (int val) {
111 [MethodImplAttribute (MethodImplOptions.NoInlining)]
112 public static int static_foo (int val) {
116 [MethodImplAttribute (MethodImplOptions.NoInlining)]
117 public int invoke_return_int () {
121 [MethodImplAttribute (MethodImplOptions.NoInlining)]
122 public static int invoke_static () {
126 [MethodImplAttribute (MethodImplOptions.NoInlining)]
127 public IntPtr invoke_return_intptr () {
131 [MethodImplAttribute (MethodImplOptions.NoInlining)]
132 public void invoke_mutate () {
136 public int invoke_iface () {
140 public override string ToString () {
141 return i.ToString ();
145 public class GClass<T> {
147 public static T static_field;
149 [MethodImplAttribute (MethodImplOptions.NoInlining)]
153 [MethodImplAttribute (MethodImplOptions.NoInlining)]
154 public void bp<T2> () {
158 public struct GStruct<T> {
163 [MethodImplAttribute (MethodImplOptions.NoInlining)]
164 public int invoke_return_int () {
169 public struct NestedStruct {
170 NestedInner nested1, nested2;
173 public struct NestedInner {
176 public interface IRecStruct {
180 struct RecStruct : IRecStruct {
183 public void foo (object o) {
200 class TestIfaces : ITest
208 TestIfaces<int> Baz () {
213 class TestIfaces<T> : ITest<T>
215 void ITest<T>.Foo () {
218 void ITest<T>.Bar () {
222 public interface ITest2
227 public class Tests : TestsBase, ITest2
229 #pragma warning disable 0414
233 bool field_bool1, field_bool2;
246 static int static_i = 55;
247 static string static_s = "A";
248 public const int literal_i = 56;
249 public const string literal_s = "B";
251 public AStruct field_struct;
252 public object field_boxed_struct;
253 public GStruct<int> generic_field_struct;
254 public KeyValuePair<int, object> boxed_struct_field;
256 public static int tls_i;
257 public static bool is_attached = Debugger.IsAttached;
258 public NestedStruct nested_struct;
260 #pragma warning restore 0414
262 public class NestedClass {
265 public int IntProperty {
274 public int ReadOnlyProperty {
280 public int this [int index] {
286 public static void wait_one ()
288 ManualResetEvent evt = new ManualResetEvent (false);
292 public static int Main (String[] args) {
295 if (args.Length > 0 && args [0] == "suspend-test")
296 /* This contains an infinite loop, so execute it conditionally */
298 if (args.Length >0 && args [0] == "unhandled-exception") {
299 unhandled_exception ();
302 if (args.Length >0 && args [0] == "unhandled-exception-endinvoke") {
303 unhandled_exception_endinvoke ();
306 if (args.Length >0 && args [0] == "unhandled-exception-user") {
307 unhandled_exception_user ();
310 if (args.Length >0 && args [0] == "wait-one") {
336 if (args.Length > 0 && args [0] == "domain-test")
337 /* This takes a lot of time, so execute it conditionally */
339 if (args.Length > 0 && args [0] == "ref-emit-test")
341 if (args.Length > 0 && args [0] == "frames-in-native")
343 if (args.Length > 0 && args [0] == "invoke-single-threaded")
344 new Tests ().invoke_single_threaded ();
345 if (args.Length > 0 && args [0] == "invoke-abort")
346 new Tests ().invoke_abort ();
347 new Tests ().evaluate_method ();
351 public static void local_reflect () {
352 //Breakpoint line below, and reflect someField via ObjectMirror;
353 LocalReflectClass.RunMe ();
356 public static void breakpoints () {
357 /* Call these early so it is JITted by the time a breakpoint is placed on it */
369 bp6<string> (new GClass <int> ());
374 [MethodImplAttribute (MethodImplOptions.NoInlining)]
375 public static void bp1 () {
378 [MethodImplAttribute (MethodImplOptions.NoInlining)]
379 public static void bp2 () {
382 [MethodImplAttribute (MethodImplOptions.NoInlining)]
383 public static void bp3 () {
386 [MethodImplAttribute (MethodImplOptions.NoInlining)]
387 public static void bp4 () {
390 [MethodImplAttribute (MethodImplOptions.NoInlining)]
391 public static void bp5 () {
394 [MethodImplAttribute (MethodImplOptions.NoInlining)]
395 public static void bp6<T> (GClass<int> gc) {
399 [MethodImplAttribute (MethodImplOptions.NoInlining)]
400 public static void bp7<T> () {
403 [MethodImplAttribute (MethodImplOptions.NoInlining)]
404 public static void single_stepping () {
411 ss5 (new int [] { 1, 2, 3 }, new Func<int, bool> (is_even));
418 ss_regress_654694 ();
425 [MethodImplAttribute (MethodImplOptions.NoInlining)]
426 public static void ss1 () {
429 [MethodImplAttribute (MethodImplOptions.NoInlining)]
430 public static void ss2 () {
433 [MethodImplAttribute (MethodImplOptions.NoInlining)]
434 public static int ss3 () {
437 for (int i = 0; i < 10; ++i)
443 [MethodImplAttribute (MethodImplOptions.NoInlining)]
444 public static void ss3_2 () {
448 [MethodImplAttribute (MethodImplOptions.NoInlining)]
449 public static void ss3_2_2 () {
452 [MethodImplAttribute (MethodImplOptions.NoInlining)]
453 public static int ss4 () {
459 [MethodImplAttribute (MethodImplOptions.NoInlining)]
460 public static void ss5 (int[] arr, Func<int, bool> selector) {
461 // Call into linq which calls back into this assembly
462 arr.Count (selector);
465 [MethodImplAttribute (MethodImplOptions.NoInlining)]
466 public static void ss6 (bool b) {
469 throw new Exception ();
473 [MethodImplAttribute (MethodImplOptions.NoInlining)]
474 public static void ss6_2 () {
477 [MethodImplAttribute (MethodImplOptions.NoInlining)]
478 public static void ss7 () {
487 [MethodImplAttribute (MethodImplOptions.NoInlining)]
488 public static void ss7_2 () {
491 [MethodImplAttribute (MethodImplOptions.NoInlining)]
492 public static void ss7_3 () {
493 throw new Exception ();
496 [MethodImplAttribute (MethodImplOptions.NoInlining)]
497 public static void ss_nested () {
498 ss_nested_1 (ss_nested_2 ());
499 ss_nested_1 (ss_nested_2 ());
503 [MethodImplAttribute (MethodImplOptions.NoInlining)]
504 public static void ss_nested_1 (int i) {
507 [MethodImplAttribute (MethodImplOptions.NoInlining)]
508 public static int ss_nested_2 () {
512 [MethodImplAttribute (MethodImplOptions.NoInlining)]
513 public static void ss_nested_3 () {
516 [MethodImplAttribute (MethodImplOptions.NoInlining)]
517 public static void ss_step_through () {
519 StepThroughClass.step_through_2 ();
523 [DebuggerStepThrough]
524 [MethodImplAttribute (MethodImplOptions.NoInlining)]
525 public static void step_through_1 () {
528 [DebuggerStepThrough]
529 class StepThroughClass {
530 [MethodImplAttribute (MethodImplOptions.NoInlining)]
531 public static void step_through_2 () {
535 [DebuggerStepThrough]
536 [MethodImplAttribute (MethodImplOptions.NoInlining)]
537 public static void step_through_3 () {
540 [MethodImplAttribute (MethodImplOptions.NoInlining)]
541 public static void ss_non_user_code () {
543 StepNonUserCodeClass.non_user_code_2 ();
547 [DebuggerNonUserCode]
548 [MethodImplAttribute (MethodImplOptions.NoInlining)]
549 public static void non_user_code_1 () {
552 [DebuggerNonUserCode]
553 class StepNonUserCodeClass {
554 [MethodImplAttribute (MethodImplOptions.NoInlining)]
555 public static void non_user_code_2 () {
559 [DebuggerNonUserCode]
560 [MethodImplAttribute (MethodImplOptions.NoInlining)]
561 public static void non_user_code_3 () {
564 [MethodImplAttribute (MethodImplOptions.NoInlining)]
565 public static void ss_recursive (int n) {
568 ss_recursive (n + 1);
571 [MethodImplAttribute (MethodImplOptions.NoInlining)]
572 public static void ss_fp_clobber () {
573 double v = ss_fp_clobber_1 (5.0);
577 [MethodImplAttribute (MethodImplOptions.NoInlining)]
578 public static double ss_fp_clobber_1 (double d) {
582 [MethodImplAttribute (MethodImplOptions.NoInlining)]
583 public static void ss_fp_clobber_2 (double d) {
586 [MethodImplAttribute (MethodImplOptions.NoInlining)]
587 public static bool is_even (int i) {
593 Console.WriteLine ("HIT!");
599 [MethodImplAttribute (MethodImplOptions.NoInlining)]
600 public static void arguments () {
601 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));
603 arg2 ("FOO", null, "BLA", ref i, new GClass <int> { field = 42 }, new object (), '\0'.ToString () + "A");
604 Tests t = new Tests () { field_i = 42, field_s = "S" };
608 [MethodImplAttribute (MethodImplOptions.NoInlining)]
609 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) {
610 return (int)(sb + b + (bl ? 0 : 1) + s + us + (int)c + i + ui + l + (long)ul + f + d + (int)ip + (int)uip);
613 [MethodImplAttribute (MethodImplOptions.NoInlining)]
614 public static string arg2 (string s, string s3, object o, ref int i, GClass <int> gc, object o2, string s4) {
615 return s + (s3 != null ? "" : "") + o + i + gc.field + o2;
618 [MethodImplAttribute (MethodImplOptions.NoInlining)]
619 public object arg3 (string s) {
620 return s + s + s + s + this;
623 [MethodImplAttribute (MethodImplOptions.NoInlining)]
624 public static void objects () {
625 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 };
626 t.o1 (new Tests2 () { field_j = 43 }, new GClass <int> { field = 42 }, new GClass <string> { field = "FOO" });
627 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 });
630 [MethodImplAttribute (MethodImplOptions.NoInlining)]
631 public object o1 (Tests2 t, GClass <int> gc1, GClass <string> gc2) {
632 if (t == null || gc1 == null || gc2 == null)
638 [MethodImplAttribute (MethodImplOptions.NoInlining)]
639 public static string o2 (string[] s2, int[] s3, int[,] s4, int[,] s5, IList<int> s6) {
640 return s2 [0] + s3 [0] + s4 [0, 0] + s6 [0];
643 [MethodImplAttribute (MethodImplOptions.NoInlining)]
644 public static void objrefs () {
645 Tests t = new Tests () {};
653 [MethodImplAttribute (MethodImplOptions.NoInlining)]
654 public static void set_child (Tests t) {
655 t.child = new Tests ();
658 [MethodImplAttribute (MethodImplOptions.NoInlining)]
659 public void objrefs1 () {
662 [MethodImplAttribute (MethodImplOptions.NoInlining)]
663 public static void objrefs2 () {
666 public static void vtypes () {
667 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 ) };
668 AStruct s = new AStruct { i = 44, s = "T", k = 45 };
669 AStruct[] arr = new AStruct[] {
670 new AStruct () { i = 1, s = "S1" },
671 new AStruct () { i = 2, s = "S2" } };
672 TypedReference typedref = __makeref (s);
673 t.vtypes1 (s, arr, typedref);
679 [MethodImplAttribute (MethodImplOptions.NoInlining)]
680 public object vtypes1 (AStruct s, AStruct[] arr, TypedReference typedref) {
687 [MethodImplAttribute (MethodImplOptions.NoInlining)]
688 public static void vtypes2 (AStruct s) {
692 [MethodImplAttribute (MethodImplOptions.NoInlining)]
693 public static void vtypes3 (AStruct s) {
694 AStruct.static_foo (5);
697 [MethodImplAttribute (MethodImplOptions.NoInlining)]
698 public static void vtypes4_2 (IRecStruct o) {
701 [MethodImplAttribute (MethodImplOptions.NoInlining)]
702 public static void vtypes4 () {
703 IRecStruct s = new RecStruct ();
708 [MethodImplAttribute (MethodImplOptions.NoInlining)]
709 public static void locals () {
711 var astruct = new AStruct () { i = 42 };
713 locals2<string> (null, 5, "ABC", ref s, ref astruct);
719 [MethodImplAttribute (MethodImplOptions.NoInlining)]
720 static void locals11 (double a, ref double b) {
723 [MethodImplAttribute (MethodImplOptions.NoInlining)]
724 public static void locals1 (string[] args) {
728 locals11 (b: ref ri, a: ri);
730 for (int j = 0; j < 10; ++j) {
735 [MethodImplAttribute (MethodImplOptions.NoInlining)]
737 [StateMachine (typeof (int))]
739 public static void locals2<T> (string[] args, int arg, T t, ref string rs, ref AStruct astruct) {
743 for (int j = 0; j < 10; ++j) {
748 astruct = new AStruct ();
751 List<int> alist = new List<int> () { 12 };
755 [MethodImplAttribute (MethodImplOptions.NoInlining)]
756 public static void locals3 () {
776 [MethodImplAttribute (MethodImplOptions.NoInlining)]
777 public static void locals4 () {
780 [MethodImplAttribute (MethodImplOptions.NoInlining)]
781 public static void locals5 () {
784 [MethodImplAttribute (MethodImplOptions.NoInlining)]
785 public static void locals6 () {
788 for (i = 0; i < 10; ++i)
791 for (i = 0; i < 10; ++i)
801 [MethodImplAttribute (MethodImplOptions.NoInlining)]
802 public static void locals6_1 () {
805 [MethodImplAttribute (MethodImplOptions.NoInlining)]
806 public static void locals6_2 (int arg) {
809 [MethodImplAttribute (MethodImplOptions.NoInlining)]
810 public static void locals6_3 () {
811 // Clobber all registers
812 int sum = 0, i, j, k, l, m;
813 for (i = 0; i < 100; ++i)
815 for (j = 0; j < 100; ++j)
817 for (k = 0; k < 100; ++k)
819 for (l = 0; l < 100; ++l)
821 for (m = 0; m < 100; ++m)
825 [MethodImplAttribute (MethodImplOptions.NoInlining)]
826 public static void locals6_4 (int arg) {
829 [MethodImplAttribute (MethodImplOptions.NoInlining)]
830 public static void locals6_5 () {
833 [MethodImplAttribute (MethodImplOptions.NoInlining)]
834 public static void locals6_6 (int arg) {
837 [MethodImplAttribute (MethodImplOptions.NoInlining)]
838 public static void locals7<T> (T arg) {
843 [MethodImplAttribute (MethodImplOptions.NoInlining)]
844 public static void line_numbers () {
848 [MethodImplAttribute (MethodImplOptions.NoInlining)]
849 public static void suspend () {
857 struct TypedRefTest {
861 [MethodImplAttribute (MethodImplOptions.NoInlining)]
862 public static void type_info () {
863 Tests t = new Tests () { field_i = 42, field_s = "S", base_field_i = 43, base_field_s = "T", field_enum = AnEnum.B };
864 t.ti1 (new Tests2 () { field_j = 43 }, new GClass <int> { field = 42 }, new GClass <string> { field = "FOO" });
867 AStruct s = new AStruct () { i = 42, s = "S", k = 43 };
868 TypedRefTest reftest = new TypedRefTest () { MaxValue = 12 };
869 TypedReference typedref = __makeref (reftest);
870 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, typedref);
874 [MethodImplAttribute (MethodImplOptions.NoInlining)]
875 public object ti1 (Tests2 t, GClass <int> gc1, GClass <string> gc2) {
876 if (t == null || gc1 == null || gc2 == null)
882 [MethodImplAttribute (MethodImplOptions.NoInlining)]
883 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, TypedReference typedref) {
884 return s2 [0] + s3 [0] + s4 [0, 0];
887 [MethodImplAttribute (MethodImplOptions.NoInlining)]
888 public static void assembly_load () {
892 [MethodImplAttribute (MethodImplOptions.NoInlining)]
893 public static void assembly_load_2 () {
894 // This will load System.dll while holding the loader lock
898 [MethodImplAttribute (MethodImplOptions.NoInlining)]
899 public static void invoke () {
900 new Tests ().invoke1 (new Tests2 (), new AStruct () { i = 42, j = (IntPtr)43 }, new GStruct<int> { j = 42 });
901 new Tests ().invoke_ex ();
904 [MethodImplAttribute (MethodImplOptions.NoInlining)]
905 public void invoke1 (Tests2 t, AStruct s, GStruct<int> g) {
909 [MethodImplAttribute (MethodImplOptions.NoInlining)]
910 public void invoke2 () {
913 [MethodImplAttribute (MethodImplOptions.NoInlining)]
914 public void invoke_ex () {
918 [MethodImplAttribute (MethodImplOptions.NoInlining)]
919 public void invoke_ex_inner () {
921 throw new Exception ();
928 [MethodImplAttribute (MethodImplOptions.NoInlining)]
929 public void invoke_single_threaded () {
930 // Spawn a thread incrementing a counter
931 bool finished = false;
933 new Thread (delegate () {
940 invoke_single_threaded_2 ();
945 [MethodImplAttribute (MethodImplOptions.NoInlining)]
946 public void invoke_single_threaded_2 () {
949 [MethodImplAttribute (MethodImplOptions.NoInlining)]
950 public void invoke_abort () {
953 [MethodImplAttribute (MethodImplOptions.NoInlining)]
954 public void invoke_abort_2 () {
955 Thread.Sleep (1000000);
958 public void invoke_return_void () {
961 public string invoke_return_ref () {
965 public object invoke_return_null () {
969 public int invoke_return_primitive () {
973 public int? invoke_return_nullable () {
977 public int? invoke_return_nullable_null () {
981 public void invoke_type_load () {
988 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) {
989 return ub + sb + ss + us + i + ui + l + (long)ul + (int)c + (b ? 1 : 0) + (int)f + (int)d;
992 public int invoke_pass_primitive2 (bool b) {
996 public string invoke_pass_ref (string s) {
1000 public static string invoke_static_pass_ref (string s) {
1004 public static void invoke_static_return_void () {
1007 public static void invoke_throws () {
1008 throw new Exception ();
1011 public int invoke_iface () {
1015 public void invoke_out (out int foo, out int[] arr) {
1020 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1021 public static void exceptions () {
1023 throw new OverflowException ();
1024 } catch (Exception) {
1027 throw new OverflowException ();
1028 } catch (Exception) {
1031 throw new ArgumentException ();
1032 } catch (Exception) {
1035 throw new OverflowException ();
1036 } catch (Exception) {
1040 throw new OverflowException ();
1041 } catch (Exception) {
1044 throw new Exception ();
1045 } catch (Exception) {
1051 } catch (Exception) {
1056 } catch (Exception) {
1060 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1061 public static void unhandled_exception () {
1062 ThreadPool.QueueUserWorkItem (delegate {
1063 throw new InvalidOperationException ();
1065 Thread.Sleep (10000);
1068 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1069 public static void unhandled_exception_endinvoke_2 () {
1072 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1073 public static void unhandled_exception_endinvoke () {
1074 Action action = new Action (() =>
1076 throw new Exception ("thrown");
1078 action.BeginInvoke ((ar) => {
1080 action.EndInvoke (ar);
1081 } catch (Exception ex) {
1082 //Console.WriteLine (ex);
1085 Thread.Sleep (1000);
1086 unhandled_exception_endinvoke_2 ();
1089 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1090 public static void unhandled_exception_user () {
1092 System.Threading.Tasks.Task.Factory.StartNew (() => {
1095 Thread.Sleep (10000);
1099 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1100 public static void Throw () {
1101 throw new Exception ();
1104 internal static Delegate create_filter_delegate (Delegate dlg, MethodInfo filter_method)
1107 throw new ArgumentNullException ();
1108 if (dlg.Target != null)
1109 throw new ArgumentException ();
1110 if (dlg.Method == null)
1111 throw new ArgumentException ();
1113 var ret_type = dlg.Method.ReturnType;
1114 var param_types = dlg.Method.GetParameters ().Select (x => x.ParameterType).ToArray ();
1116 var dynamic = new DynamicMethod (Guid.NewGuid ().ToString (), ret_type, param_types, typeof (object), true);
1117 var ig = dynamic.GetILGenerator ();
1119 LocalBuilder retval = null;
1120 if (ret_type != typeof (void))
1121 retval = ig.DeclareLocal (ret_type);
1123 var label = ig.BeginExceptionBlock ();
1125 for (int i = 0; i < param_types.Length; i++)
1126 ig.Emit (OpCodes.Ldarg, i);
1127 ig.Emit (OpCodes.Call, dlg.Method);
1130 ig.Emit (OpCodes.Stloc, retval);
1132 ig.Emit (OpCodes.Leave, label);
1134 ig.BeginExceptFilterBlock ();
1136 ig.Emit (OpCodes.Call, filter_method);
1138 ig.BeginCatchBlock (null);
1140 ig.Emit (OpCodes.Pop);
1142 ig.EndExceptionBlock ();
1145 ig.Emit (OpCodes.Ldloc, retval);
1147 ig.Emit (OpCodes.Ret);
1149 return dynamic.CreateDelegate (dlg.GetType ());
1152 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1153 static void exception_filter_method () {
1154 throw new InvalidOperationException ();
1157 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1158 static int exception_filter_filter (Exception exc) {
1162 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1163 public static void exception_filter () {
1164 var method = typeof (Tests).GetMethod (
1165 "exception_filter_method", BindingFlags.NonPublic | BindingFlags.Static);
1166 var filter_method = typeof (Tests).GetMethod (
1167 "exception_filter_filter", BindingFlags.NonPublic | BindingFlags.Static);
1169 var dlg = Delegate.CreateDelegate (typeof (Action), method);
1171 var wrapper = (Action) create_filter_delegate (dlg, filter_method);
1176 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1177 public static bool return_true () {
1181 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1182 public static void exceptions2 () {
1184 throw new Exception ();
1185 Console.WriteLine ();
1188 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1189 public static void threads () {
1190 Thread t = new Thread (delegate () {});
1196 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1197 public static void domains () {
1198 AppDomain domain = AppDomain.CreateDomain ("domain");
1200 CrossDomain o = (CrossDomain)domain.CreateInstanceAndUnwrap (
1201 typeof (CrossDomain).Assembly.FullName, "CrossDomain");
1203 domains_print_across (o);
1205 domains_2 (o, new CrossDomain ());
1213 AppDomain.Unload (domain);
1217 typeof (Tests).GetMethod ("called_from_invoke").Invoke (null, null);
1220 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1221 public static void called_from_invoke () {
1224 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1225 public static void domains_2 (object o, object o2) {
1228 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1229 public static void domains_print_across (object o) {
1232 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1233 public static void domains_3 () {
1236 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1237 public static void invoke_in_domain () {
1240 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1241 public static void invoke_in_domain_2 () {
1244 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1245 public static void dynamic_methods () {
1246 var m = new DynamicMethod ("dyn_method", typeof (void), new Type [] { typeof (int) }, typeof (object).Module);
1247 var ig = m.GetILGenerator ();
1249 ig.Emit (OpCodes.Ldstr, "FOO");
1250 ig.Emit (OpCodes.Call, typeof (Tests).GetMethod ("dyn_call"));
1251 ig.Emit (OpCodes.Ret);
1253 var del = (Action<int>)m.CreateDelegate (typeof (Action<int>));
1258 public static void dyn_call (string s) {
1261 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1262 public static void ref_emit () {
1263 AssemblyName assemblyName = new AssemblyName ();
1264 assemblyName.Name = "foo";
1266 AssemblyBuilder assembly =
1267 Thread.GetDomain ().DefineDynamicAssembly (
1268 assemblyName, AssemblyBuilderAccess.RunAndSave);
1270 ModuleBuilder module = assembly.DefineDynamicModule ("foo.dll");
1272 TypeBuilder tb = module.DefineType ("foo", TypeAttributes.Public, typeof (object));
1273 MethodBuilder mb = tb.DefineMethod ("ref_emit_method", MethodAttributes.Public|MethodAttributes.Static, CallingConventions.Standard, typeof (void), new Type [] { });
1274 ILGenerator ig = mb.GetILGenerator ();
1275 ig.Emit (OpCodes.Ldstr, "FOO");
1276 ig.Emit (OpCodes.Call, typeof (Tests).GetMethod ("ref_emit_call"));
1277 ig.Emit (OpCodes.Ret);
1279 Type t = tb.CreateType ();
1281 t.GetMethod ("ref_emit_method").Invoke (null, null);
1284 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1285 public static void ref_emit_call (string s) {
1288 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1289 public static void frames_in_native () {
1291 var evt = new ManualResetEvent (false);
1293 object mon = new object ();
1294 ThreadPool.QueueUserWorkItem (delegate {
1295 frames_in_native_2 ();
1301 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1302 static void frames_in_native_2 () {
1303 frames_in_native_3 ();
1306 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1307 static void frames_in_native_3 () {
1310 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1311 public static void string_call (string s) {
1314 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1315 public static void ss_regress_654694 () {
1322 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1323 public static void user () {
1326 Debugger.Log (5, Debugger.IsLogging () ? "A" : "", "B");
1329 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1330 public static void type_load () {
1334 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1335 static void type_load_2 () {
1336 var c1 = new Dictionary<int, int> ();
1338 var c = new TypeLoadClass ();
1340 var c2 = new TypeLoadClass2 ();
1344 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1345 public static void regress () {
1346 regress_2755 (DateTime.Now);
1349 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1350 public static unsafe void regress_2755 (DateTime d) {
1351 int* buffer = stackalloc int [128];
1356 for (int i = 0; i < 128; ++i)
1359 regress_2755_3 (sum);
1362 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1363 public static void regress_2755_2 () {
1366 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1367 public static void regress_2755_3 (int sum) {
1370 static object gc_suspend_field;
1372 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1373 static unsafe void set_gc_suspend_field () {
1374 set_gc_suspend_field_2 ();
1376 int* buffer = stackalloc int [4096];
1379 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1380 static void set_gc_suspend_field_2 () {
1381 gc_suspend_field = new object ();
1384 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1385 static void gc_suspend_1 () {
1388 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1389 public static void gc_suspend_invoke () {
1390 gc_suspend_field = null;
1392 GC.WaitForPendingFinalizers ();
1395 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1396 public static void gc_suspend () {
1397 set_gc_suspend_field ();
1401 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1402 public static void generic_method<T> () where T : class {
1405 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1406 public void evaluate_method_2 () {
1409 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1410 public void evaluate_method () {
1412 evaluate_method_2 ();
1415 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1416 static void set_ip_1 () {
1419 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1420 static void set_ip_2 () {
1423 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1424 public static void set_ip () {
1435 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1436 public static void step_filters () {
1437 ClassWithCctor.cctor_filter ();
1440 class ClassWithCctor {
1441 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1442 static ClassWithCctor () {
1447 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1448 public static void cctor_filter () {
1452 public override string virtual_method () {
1457 class TypeLoadClass {
1460 class TypeLoadClass2 {
1463 public class SentinelClass : MarshalByRefObject {
1466 public class CrossDomain : MarshalByRefObject
1468 SentinelClass printMe = new SentinelClass ();
1470 public void invoke () {
1471 Tests.invoke_in_domain ();
1474 public void invoke_2 () {
1475 Tests.invoke_in_domain_2 ();
1478 public int invoke_3 () {
1485 public ProcessStartInfo info;
1488 // Class used for line number info testing, don't change its layout
1489 public class LineNumbers
1491 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1492 public static void ln1 () {
1498 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1499 public static void ln2 () {
1502 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1503 public static void ln3 () {
1504 #pragma warning disable 0219
1506 #pragma warning restore 0219
1511 class LocalReflectClass
1513 public static void RunMe ()
1515 var reflectMe = new someClass ();
1516 reflectMe.someMethod ();
1519 class someClass : ContextBoundObject
1521 public object someField;
1523 public void someMethod ()