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" } };
640 TypedReference typedref = __makeref (s);
641 t.vtypes1 (s, arr, typedref);
647 [MethodImplAttribute (MethodImplOptions.NoInlining)]
648 public object vtypes1 (AStruct s, AStruct[] arr, TypedReference typedref) {
655 [MethodImplAttribute (MethodImplOptions.NoInlining)]
656 public static void vtypes2 (AStruct s) {
660 [MethodImplAttribute (MethodImplOptions.NoInlining)]
661 public static void vtypes3 (AStruct s) {
662 AStruct.static_foo (5);
665 [MethodImplAttribute (MethodImplOptions.NoInlining)]
666 public static void vtypes4_2 (IRecStruct o) {
669 [MethodImplAttribute (MethodImplOptions.NoInlining)]
670 public static void vtypes4 () {
671 IRecStruct s = new RecStruct ();
676 [MethodImplAttribute (MethodImplOptions.NoInlining)]
677 public static void locals () {
679 var astruct = new AStruct () { i = 42 };
681 locals2<string> (null, 5, "ABC", ref s, ref astruct);
687 [MethodImplAttribute (MethodImplOptions.NoInlining)]
688 static void locals11 (double a, ref double b) {
691 [MethodImplAttribute (MethodImplOptions.NoInlining)]
692 public static void locals1 (string[] args) {
696 locals11 (b: ref ri, a: ri);
698 for (int j = 0; j < 10; ++j) {
703 [MethodImplAttribute (MethodImplOptions.NoInlining)]
705 [StateMachine (typeof (int))]
707 public static void locals2<T> (string[] args, int arg, T t, ref string rs, ref AStruct astruct) {
711 for (int j = 0; j < 10; ++j) {
716 astruct = new AStruct ();
722 [MethodImplAttribute (MethodImplOptions.NoInlining)]
723 public static void locals3 () {
743 [MethodImplAttribute (MethodImplOptions.NoInlining)]
744 public static void locals4 () {
747 [MethodImplAttribute (MethodImplOptions.NoInlining)]
748 public static void locals5 () {
751 [MethodImplAttribute (MethodImplOptions.NoInlining)]
752 public static void locals6 () {
755 for (i = 0; i < 10; ++i)
758 for (i = 0; i < 10; ++i)
768 [MethodImplAttribute (MethodImplOptions.NoInlining)]
769 public static void locals6_1 () {
772 [MethodImplAttribute (MethodImplOptions.NoInlining)]
773 public static void locals6_2 (int arg) {
776 [MethodImplAttribute (MethodImplOptions.NoInlining)]
777 public static void locals6_3 () {
778 // Clobber all registers
779 int sum = 0, i, j, k, l, m;
780 for (i = 0; i < 100; ++i)
782 for (j = 0; j < 100; ++j)
784 for (k = 0; k < 100; ++k)
786 for (l = 0; l < 100; ++l)
788 for (m = 0; m < 100; ++m)
792 [MethodImplAttribute (MethodImplOptions.NoInlining)]
793 public static void locals6_4 (int arg) {
796 [MethodImplAttribute (MethodImplOptions.NoInlining)]
797 public static void locals6_5 () {
800 [MethodImplAttribute (MethodImplOptions.NoInlining)]
801 public static void locals6_6 (int arg) {
804 [MethodImplAttribute (MethodImplOptions.NoInlining)]
805 public static void locals7<T> (T arg) {
810 [MethodImplAttribute (MethodImplOptions.NoInlining)]
811 public static void line_numbers () {
815 [MethodImplAttribute (MethodImplOptions.NoInlining)]
816 public static void suspend () {
824 struct TypedRefTest {
828 [MethodImplAttribute (MethodImplOptions.NoInlining)]
829 public static void type_info () {
830 Tests t = new Tests () { field_i = 42, field_s = "S", base_field_i = 43, base_field_s = "T", field_enum = AnEnum.B };
831 t.ti1 (new Tests2 () { field_j = 43 }, new GClass <int> { field = 42 }, new GClass <string> { field = "FOO" });
834 AStruct s = new AStruct () { i = 42, s = "S", k = 43 };
835 TypedRefTest reftest = new TypedRefTest () { MaxValue = 12 };
836 TypedReference typedref = __makeref (reftest);
837 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);
841 [MethodImplAttribute (MethodImplOptions.NoInlining)]
842 public object ti1 (Tests2 t, GClass <int> gc1, GClass <string> gc2) {
843 if (t == null || gc1 == null || gc2 == null)
849 [MethodImplAttribute (MethodImplOptions.NoInlining)]
850 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) {
851 return s2 [0] + s3 [0] + s4 [0, 0];
854 [MethodImplAttribute (MethodImplOptions.NoInlining)]
855 public static void assembly_load () {
859 [MethodImplAttribute (MethodImplOptions.NoInlining)]
860 public static void assembly_load_2 () {
861 // This will load System.dll while holding the loader lock
865 [MethodImplAttribute (MethodImplOptions.NoInlining)]
866 public static void invoke () {
867 new Tests ().invoke1 (new Tests2 (), new AStruct () { i = 42, j = (IntPtr)43 }, new GStruct<int> { j = 42 });
868 new Tests ().invoke_ex ();
871 [MethodImplAttribute (MethodImplOptions.NoInlining)]
872 public void invoke1 (Tests2 t, AStruct s, GStruct<int> g) {
876 [MethodImplAttribute (MethodImplOptions.NoInlining)]
877 public void invoke2 () {
880 [MethodImplAttribute (MethodImplOptions.NoInlining)]
881 public void invoke_ex () {
885 [MethodImplAttribute (MethodImplOptions.NoInlining)]
886 public void invoke_ex_inner () {
888 throw new Exception ();
895 [MethodImplAttribute (MethodImplOptions.NoInlining)]
896 public void invoke_single_threaded () {
897 // Spawn a thread incrementing a counter
898 bool finished = false;
900 new Thread (delegate () {
907 invoke_single_threaded_2 ();
912 [MethodImplAttribute (MethodImplOptions.NoInlining)]
913 public void invoke_single_threaded_2 () {
916 public void invoke_return_void () {
919 public string invoke_return_ref () {
923 public object invoke_return_null () {
927 public int invoke_return_primitive () {
931 public int? invoke_return_nullable () {
935 public int? invoke_return_nullable_null () {
939 public void invoke_type_load () {
946 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) {
947 return ub + sb + ss + us + i + ui + l + (long)ul + (int)c + (b ? 1 : 0) + (int)f + (int)d;
950 public int invoke_pass_primitive2 (bool b) {
954 public string invoke_pass_ref (string s) {
958 public static string invoke_static_pass_ref (string s) {
962 public static void invoke_static_return_void () {
965 public static void invoke_throws () {
966 throw new Exception ();
969 public int invoke_iface () {
973 public void invoke_out (out int foo, out int[] arr) {
978 [MethodImplAttribute (MethodImplOptions.NoInlining)]
979 public static void exceptions () {
981 throw new OverflowException ();
982 } catch (Exception) {
985 throw new OverflowException ();
986 } catch (Exception) {
989 throw new ArgumentException ();
990 } catch (Exception) {
993 throw new OverflowException ();
994 } catch (Exception) {
998 throw new OverflowException ();
999 } catch (Exception) {
1002 throw new Exception ();
1003 } catch (Exception) {
1009 } catch (Exception) {
1014 } catch (Exception) {
1018 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1019 public static void unhandled_exception () {
1020 ThreadPool.QueueUserWorkItem (delegate {
1021 throw new InvalidOperationException ();
1023 Thread.Sleep (10000);
1026 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1027 public static void unhandled_exception_endinvoke_2 () {
1030 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1031 public static void unhandled_exception_endinvoke () {
1032 Action action = new Action (() =>
1034 throw new Exception ("thrown");
1036 action.BeginInvoke ((ar) => {
1038 action.EndInvoke (ar);
1039 } catch (Exception ex) {
1040 //Console.WriteLine (ex);
1043 Thread.Sleep (1000);
1044 unhandled_exception_endinvoke_2 ();
1047 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1048 public static void unhandled_exception_user () {
1050 System.Threading.Tasks.Task.Factory.StartNew (() => {
1053 Thread.Sleep (10000);
1057 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1058 public static void Throw () {
1059 throw new Exception ();
1062 internal static Delegate create_filter_delegate (Delegate dlg, MethodInfo filter_method)
1065 throw new ArgumentNullException ();
1066 if (dlg.Target != null)
1067 throw new ArgumentException ();
1068 if (dlg.Method == null)
1069 throw new ArgumentException ();
1071 var ret_type = dlg.Method.ReturnType;
1072 var param_types = dlg.Method.GetParameters ().Select (x => x.ParameterType).ToArray ();
1074 var dynamic = new DynamicMethod (Guid.NewGuid ().ToString (), ret_type, param_types, typeof (object), true);
1075 var ig = dynamic.GetILGenerator ();
1077 LocalBuilder retval = null;
1078 if (ret_type != typeof (void))
1079 retval = ig.DeclareLocal (ret_type);
1081 var label = ig.BeginExceptionBlock ();
1083 for (int i = 0; i < param_types.Length; i++)
1084 ig.Emit (OpCodes.Ldarg, i);
1085 ig.Emit (OpCodes.Call, dlg.Method);
1088 ig.Emit (OpCodes.Stloc, retval);
1090 ig.Emit (OpCodes.Leave, label);
1092 ig.BeginExceptFilterBlock ();
1094 ig.Emit (OpCodes.Call, filter_method);
1096 ig.BeginCatchBlock (null);
1098 ig.Emit (OpCodes.Pop);
1100 ig.EndExceptionBlock ();
1103 ig.Emit (OpCodes.Ldloc, retval);
1105 ig.Emit (OpCodes.Ret);
1107 return dynamic.CreateDelegate (dlg.GetType ());
1110 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1111 static void exception_filter_method () {
1112 throw new InvalidOperationException ();
1115 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1116 static int exception_filter_filter (Exception exc) {
1120 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1121 public static void exception_filter () {
1122 var method = typeof (Tests).GetMethod (
1123 "exception_filter_method", BindingFlags.NonPublic | BindingFlags.Static);
1124 var filter_method = typeof (Tests).GetMethod (
1125 "exception_filter_filter", BindingFlags.NonPublic | BindingFlags.Static);
1127 var dlg = Delegate.CreateDelegate (typeof (Action), method);
1129 var wrapper = (Action) create_filter_delegate (dlg, filter_method);
1134 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1135 public static bool return_true () {
1139 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1140 public static void exceptions2 () {
1142 throw new Exception ();
1143 Console.WriteLine ();
1146 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1147 public static void threads () {
1148 Thread t = new Thread (delegate () {});
1154 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1155 public static void domains () {
1156 AppDomain domain = AppDomain.CreateDomain ("domain");
1158 CrossDomain o = (CrossDomain)domain.CreateInstanceAndUnwrap (
1159 typeof (CrossDomain).Assembly.FullName, "CrossDomain");
1161 domains_2 (o, new CrossDomain ());
1169 AppDomain.Unload (domain);
1173 typeof (Tests).GetMethod ("called_from_invoke").Invoke (null, null);
1176 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1177 public static void called_from_invoke () {
1180 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1181 public static void domains_2 (object o, object o2) {
1184 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1185 public static void domains_3 () {
1188 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1189 public static void invoke_in_domain () {
1192 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1193 public static void invoke_in_domain_2 () {
1196 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1197 public static void dynamic_methods () {
1198 var m = new DynamicMethod ("dyn_method", typeof (void), new Type [] { typeof (int) }, typeof (object).Module);
1199 var ig = m.GetILGenerator ();
1201 ig.Emit (OpCodes.Ldstr, "FOO");
1202 ig.Emit (OpCodes.Call, typeof (Tests).GetMethod ("dyn_call"));
1203 ig.Emit (OpCodes.Ret);
1205 var del = (Action<int>)m.CreateDelegate (typeof (Action<int>));
1210 public static void dyn_call (string s) {
1213 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1214 public static void ref_emit () {
1215 AssemblyName assemblyName = new AssemblyName ();
1216 assemblyName.Name = "foo";
1218 AssemblyBuilder assembly =
1219 Thread.GetDomain ().DefineDynamicAssembly (
1220 assemblyName, AssemblyBuilderAccess.RunAndSave);
1222 ModuleBuilder module = assembly.DefineDynamicModule ("foo.dll");
1224 TypeBuilder tb = module.DefineType ("foo", TypeAttributes.Public, typeof (object));
1225 MethodBuilder mb = tb.DefineMethod ("ref_emit_method", MethodAttributes.Public|MethodAttributes.Static, CallingConventions.Standard, typeof (void), new Type [] { });
1226 ILGenerator ig = mb.GetILGenerator ();
1227 ig.Emit (OpCodes.Ldstr, "FOO");
1228 ig.Emit (OpCodes.Call, typeof (Tests).GetMethod ("ref_emit_call"));
1229 ig.Emit (OpCodes.Ret);
1231 Type t = tb.CreateType ();
1233 t.GetMethod ("ref_emit_method").Invoke (null, null);
1236 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1237 public static void ref_emit_call (string s) {
1240 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1241 public static void frames_in_native () {
1243 var evt = new ManualResetEvent (false);
1245 object mon = new object ();
1246 ThreadPool.QueueUserWorkItem (delegate {
1247 frames_in_native_2 ();
1253 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1254 static void frames_in_native_2 () {
1255 frames_in_native_3 ();
1258 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1259 static void frames_in_native_3 () {
1262 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1263 public static void string_call (string s) {
1266 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1267 public static void ss_regress_654694 () {
1274 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1275 public static void user () {
1278 Debugger.Log (5, Debugger.IsLogging () ? "A" : "", "B");
1281 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1282 public static void type_load () {
1286 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1287 static void type_load_2 () {
1288 var c1 = new Dictionary<int, int> ();
1290 var c = new TypeLoadClass ();
1292 var c2 = new TypeLoadClass2 ();
1296 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1297 public static void regress () {
1298 regress_2755 (DateTime.Now);
1301 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1302 public static unsafe void regress_2755 (DateTime d) {
1303 int* buffer = stackalloc int [128];
1308 for (int i = 0; i < 128; ++i)
1311 regress_2755_3 (sum);
1314 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1315 public static void regress_2755_2 () {
1318 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1319 public static void regress_2755_3 (int sum) {
1322 static object gc_suspend_field;
1324 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1325 static unsafe void set_gc_suspend_field () {
1326 set_gc_suspend_field_2 ();
1328 int* buffer = stackalloc int [4096];
1331 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1332 static void set_gc_suspend_field_2 () {
1333 gc_suspend_field = new object ();
1336 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1337 static void gc_suspend_1 () {
1340 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1341 public static void gc_suspend_invoke () {
1342 gc_suspend_field = null;
1344 GC.WaitForPendingFinalizers ();
1347 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1348 public static void gc_suspend () {
1349 set_gc_suspend_field ();
1353 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1354 public static void generic_method<T> () where T : class {
1357 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1358 public void evaluate_method_2 () {
1361 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1362 public void evaluate_method () {
1364 evaluate_method_2 ();
1367 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1368 static void set_ip_1 () {
1371 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1372 static void set_ip_2 () {
1375 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1376 public static void set_ip () {
1387 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1388 public static void step_filters () {
1389 ClassWithCctor.cctor_filter ();
1392 class ClassWithCctor {
1393 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1394 static ClassWithCctor () {
1399 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1400 public static void cctor_filter () {
1404 public override string virtual_method () {
1409 class TypeLoadClass {
1412 class TypeLoadClass2 {
1415 public class CrossDomain : MarshalByRefObject
1417 public void invoke () {
1418 Tests.invoke_in_domain ();
1421 public void invoke_2 () {
1422 Tests.invoke_in_domain_2 ();
1425 public int invoke_3 () {
1432 public ProcessStartInfo info;
1435 // Class used for line number info testing, don't change its layout
1436 public class LineNumbers
1438 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1439 public static void ln1 () {
1445 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1446 public static void ln2 () {
1449 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1450 public static void ln3 () {
1451 #pragma warning disable 0219
1453 #pragma warning restore 0219