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 {
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 () {
120 public int invoke_iface () {
124 public override string ToString () {
125 return i.ToString ();
129 public class GClass<T> {
131 public static T static_field;
133 [MethodImplAttribute (MethodImplOptions.NoInlining)]
137 [MethodImplAttribute (MethodImplOptions.NoInlining)]
138 public void bp<T2> () {
142 public struct GStruct<T> {
147 [MethodImplAttribute (MethodImplOptions.NoInlining)]
148 public int invoke_return_int () {
153 public struct NestedStruct {
154 NestedInner nested1, nested2;
157 public struct NestedInner {
160 public interface IRecStruct {
164 struct RecStruct : IRecStruct {
167 public void foo (object o) {
184 class TestIfaces : ITest
192 TestIfaces<int> Baz () {
197 class TestIfaces<T> : ITest<T>
199 void ITest<T>.Foo () {
202 void ITest<T>.Bar () {
206 public interface ITest2
211 public class Tests : TestsBase, ITest2
213 #pragma warning disable 0414
217 bool field_bool1, field_bool2;
230 static int static_i = 55;
231 static string static_s = "A";
232 public const int literal_i = 56;
233 public const string literal_s = "B";
235 public AStruct field_struct;
236 public object field_boxed_struct;
237 public GStruct<int> generic_field_struct;
238 public KeyValuePair<int, object> boxed_struct_field;
240 public static int tls_i;
241 public static bool is_attached = Debugger.IsAttached;
242 public NestedStruct nested_struct;
244 #pragma warning restore 0414
246 public class NestedClass {
249 public int IntProperty {
258 public int ReadOnlyProperty {
264 public int this [int index] {
270 public static void wait_one ()
272 ManualResetEvent evt = new ManualResetEvent (false);
276 public static int Main (String[] args) {
279 if (args.Length > 0 && args [0] == "suspend-test")
280 /* This contains an infinite loop, so execute it conditionally */
282 if (args.Length >0 && args [0] == "unhandled-exception") {
283 unhandled_exception ();
286 if (args.Length >0 && args [0] == "unhandled-exception-endinvoke") {
287 unhandled_exception_endinvoke ();
290 if (args.Length >0 && args [0] == "unhandled-exception-user") {
291 unhandled_exception_user ();
294 if (args.Length >0 && args [0] == "wait-one") {
319 if (args.Length > 0 && args [0] == "domain-test")
320 /* This takes a lot of time, so execute it conditionally */
322 if (args.Length > 0 && args [0] == "ref-emit-test")
324 if (args.Length > 0 && args [0] == "frames-in-native")
326 if (args.Length > 0 && args [0] == "invoke-single-threaded")
327 new Tests ().invoke_single_threaded ();
328 new Tests ().evaluate_method ();
332 public static void breakpoints () {
333 /* Call these early so it is JITted by the time a breakpoint is placed on it */
345 bp6<string> (new GClass <int> ());
350 [MethodImplAttribute (MethodImplOptions.NoInlining)]
351 public static void bp1 () {
354 [MethodImplAttribute (MethodImplOptions.NoInlining)]
355 public static void bp2 () {
358 [MethodImplAttribute (MethodImplOptions.NoInlining)]
359 public static void bp3 () {
362 [MethodImplAttribute (MethodImplOptions.NoInlining)]
363 public static void bp4 () {
366 [MethodImplAttribute (MethodImplOptions.NoInlining)]
367 public static void bp5 () {
370 [MethodImplAttribute (MethodImplOptions.NoInlining)]
371 public static void bp6<T> (GClass<int> gc) {
375 [MethodImplAttribute (MethodImplOptions.NoInlining)]
376 public static void bp7<T> () {
379 [MethodImplAttribute (MethodImplOptions.NoInlining)]
380 public static void single_stepping () {
387 ss5 (new int [] { 1, 2, 3 }, new Func<int, bool> (is_even));
394 ss_regress_654694 ();
401 [MethodImplAttribute (MethodImplOptions.NoInlining)]
402 public static void ss1 () {
405 [MethodImplAttribute (MethodImplOptions.NoInlining)]
406 public static void ss2 () {
409 [MethodImplAttribute (MethodImplOptions.NoInlining)]
410 public static int ss3 () {
413 for (int i = 0; i < 10; ++i)
419 [MethodImplAttribute (MethodImplOptions.NoInlining)]
420 public static void ss3_2 () {
424 [MethodImplAttribute (MethodImplOptions.NoInlining)]
425 public static void ss3_2_2 () {
428 [MethodImplAttribute (MethodImplOptions.NoInlining)]
429 public static int ss4 () {
435 [MethodImplAttribute (MethodImplOptions.NoInlining)]
436 public static void ss5 (int[] arr, Func<int, bool> selector) {
437 // Call into linq which calls back into this assembly
438 arr.Count (selector);
441 [MethodImplAttribute (MethodImplOptions.NoInlining)]
442 public static void ss6 (bool b) {
445 throw new Exception ();
449 [MethodImplAttribute (MethodImplOptions.NoInlining)]
450 public static void ss6_2 () {
453 [MethodImplAttribute (MethodImplOptions.NoInlining)]
454 public static void ss7 () {
463 [MethodImplAttribute (MethodImplOptions.NoInlining)]
464 public static void ss7_2 () {
467 [MethodImplAttribute (MethodImplOptions.NoInlining)]
468 public static void ss7_3 () {
469 throw new Exception ();
472 [MethodImplAttribute (MethodImplOptions.NoInlining)]
473 public static void ss_nested () {
474 ss_nested_1 (ss_nested_2 ());
475 ss_nested_1 (ss_nested_2 ());
479 [MethodImplAttribute (MethodImplOptions.NoInlining)]
480 public static void ss_nested_1 (int i) {
483 [MethodImplAttribute (MethodImplOptions.NoInlining)]
484 public static int ss_nested_2 () {
488 [MethodImplAttribute (MethodImplOptions.NoInlining)]
489 public static void ss_nested_3 () {
492 [MethodImplAttribute (MethodImplOptions.NoInlining)]
493 public static void ss_step_through () {
495 StepThroughClass.step_through_2 ();
499 [DebuggerStepThrough]
500 [MethodImplAttribute (MethodImplOptions.NoInlining)]
501 public static void step_through_1 () {
504 [DebuggerStepThrough]
505 class StepThroughClass {
506 [MethodImplAttribute (MethodImplOptions.NoInlining)]
507 public static void step_through_2 () {
511 [DebuggerStepThrough]
512 [MethodImplAttribute (MethodImplOptions.NoInlining)]
513 public static void step_through_3 () {
516 [MethodImplAttribute (MethodImplOptions.NoInlining)]
517 public static void ss_non_user_code () {
519 StepNonUserCodeClass.non_user_code_2 ();
523 [DebuggerNonUserCode]
524 [MethodImplAttribute (MethodImplOptions.NoInlining)]
525 public static void non_user_code_1 () {
528 [DebuggerNonUserCode]
529 class StepNonUserCodeClass {
530 [MethodImplAttribute (MethodImplOptions.NoInlining)]
531 public static void non_user_code_2 () {
535 [DebuggerNonUserCode]
536 [MethodImplAttribute (MethodImplOptions.NoInlining)]
537 public static void non_user_code_3 () {
540 [MethodImplAttribute (MethodImplOptions.NoInlining)]
541 public static void ss_recursive (int n) {
544 ss_recursive (n + 1);
547 [MethodImplAttribute (MethodImplOptions.NoInlining)]
548 public static void ss_fp_clobber () {
549 double v = ss_fp_clobber_1 (5.0);
553 [MethodImplAttribute (MethodImplOptions.NoInlining)]
554 public static double ss_fp_clobber_1 (double d) {
558 [MethodImplAttribute (MethodImplOptions.NoInlining)]
559 public static void ss_fp_clobber_2 (double d) {
562 [MethodImplAttribute (MethodImplOptions.NoInlining)]
563 public static bool is_even (int i) {
569 Console.WriteLine ("HIT!");
575 [MethodImplAttribute (MethodImplOptions.NoInlining)]
576 public static void arguments () {
577 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));
579 arg2 ("FOO", null, "BLA", ref i, new GClass <int> { field = 42 }, new object ());
580 Tests t = new Tests () { field_i = 42, field_s = "S" };
584 [MethodImplAttribute (MethodImplOptions.NoInlining)]
585 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) {
586 return (int)(sb + b + (bl ? 0 : 1) + s + us + (int)c + i + ui + l + (long)ul + f + d + (int)ip + (int)uip);
589 [MethodImplAttribute (MethodImplOptions.NoInlining)]
590 public static string arg2 (string s, string s3, object o, ref int i, GClass <int> gc, object o2) {
591 return s + (s3 != null ? "" : "") + o + i + gc.field + o2;
594 [MethodImplAttribute (MethodImplOptions.NoInlining)]
595 public object arg3 (string s) {
596 return s + s + s + s + this;
599 [MethodImplAttribute (MethodImplOptions.NoInlining)]
600 public static void objects () {
601 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 };
602 t.o1 (new Tests2 () { field_j = 43 }, new GClass <int> { field = 42 }, new GClass <string> { field = "FOO" });
603 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 });
606 [MethodImplAttribute (MethodImplOptions.NoInlining)]
607 public object o1 (Tests2 t, GClass <int> gc1, GClass <string> gc2) {
608 if (t == null || gc1 == null || gc2 == null)
614 [MethodImplAttribute (MethodImplOptions.NoInlining)]
615 public static string o2 (string[] s2, int[] s3, int[,] s4, int[,] s5, IList<int> s6) {
616 return s2 [0] + s3 [0] + s4 [0, 0] + s6 [0];
619 [MethodImplAttribute (MethodImplOptions.NoInlining)]
620 public static void objrefs () {
621 Tests t = new Tests () {};
629 [MethodImplAttribute (MethodImplOptions.NoInlining)]
630 public static void set_child (Tests t) {
631 t.child = new Tests ();
634 [MethodImplAttribute (MethodImplOptions.NoInlining)]
635 public void objrefs1 () {
638 [MethodImplAttribute (MethodImplOptions.NoInlining)]
639 public static void objrefs2 () {
642 public static void vtypes () {
643 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 ) };
644 AStruct s = new AStruct { i = 44, s = "T", k = 45 };
645 AStruct[] arr = new AStruct[] {
646 new AStruct () { i = 1, s = "S1" },
647 new AStruct () { i = 2, s = "S2" } };
648 TypedReference typedref = __makeref (s);
649 t.vtypes1 (s, arr, typedref);
655 [MethodImplAttribute (MethodImplOptions.NoInlining)]
656 public object vtypes1 (AStruct s, AStruct[] arr, TypedReference typedref) {
663 [MethodImplAttribute (MethodImplOptions.NoInlining)]
664 public static void vtypes2 (AStruct s) {
668 [MethodImplAttribute (MethodImplOptions.NoInlining)]
669 public static void vtypes3 (AStruct s) {
670 AStruct.static_foo (5);
673 [MethodImplAttribute (MethodImplOptions.NoInlining)]
674 public static void vtypes4_2 (IRecStruct o) {
677 [MethodImplAttribute (MethodImplOptions.NoInlining)]
678 public static void vtypes4 () {
679 IRecStruct s = new RecStruct ();
684 [MethodImplAttribute (MethodImplOptions.NoInlining)]
685 public static void locals () {
687 var astruct = new AStruct () { i = 42 };
689 locals2<string> (null, 5, "ABC", ref s, ref astruct);
695 [MethodImplAttribute (MethodImplOptions.NoInlining)]
696 static void locals11 (double a, ref double b) {
699 [MethodImplAttribute (MethodImplOptions.NoInlining)]
700 public static void locals1 (string[] args) {
704 locals11 (b: ref ri, a: ri);
706 for (int j = 0; j < 10; ++j) {
711 [MethodImplAttribute (MethodImplOptions.NoInlining)]
713 [StateMachine (typeof (int))]
715 public static void locals2<T> (string[] args, int arg, T t, ref string rs, ref AStruct astruct) {
719 for (int j = 0; j < 10; ++j) {
724 astruct = new AStruct ();
727 List<int> alist = new List<int> () { 12 };
731 [MethodImplAttribute (MethodImplOptions.NoInlining)]
732 public static void locals3 () {
752 [MethodImplAttribute (MethodImplOptions.NoInlining)]
753 public static void locals4 () {
756 [MethodImplAttribute (MethodImplOptions.NoInlining)]
757 public static void locals5 () {
760 [MethodImplAttribute (MethodImplOptions.NoInlining)]
761 public static void locals6 () {
764 for (i = 0; i < 10; ++i)
767 for (i = 0; i < 10; ++i)
777 [MethodImplAttribute (MethodImplOptions.NoInlining)]
778 public static void locals6_1 () {
781 [MethodImplAttribute (MethodImplOptions.NoInlining)]
782 public static void locals6_2 (int arg) {
785 [MethodImplAttribute (MethodImplOptions.NoInlining)]
786 public static void locals6_3 () {
787 // Clobber all registers
788 int sum = 0, i, j, k, l, m;
789 for (i = 0; i < 100; ++i)
791 for (j = 0; j < 100; ++j)
793 for (k = 0; k < 100; ++k)
795 for (l = 0; l < 100; ++l)
797 for (m = 0; m < 100; ++m)
801 [MethodImplAttribute (MethodImplOptions.NoInlining)]
802 public static void locals6_4 (int arg) {
805 [MethodImplAttribute (MethodImplOptions.NoInlining)]
806 public static void locals6_5 () {
809 [MethodImplAttribute (MethodImplOptions.NoInlining)]
810 public static void locals6_6 (int arg) {
813 [MethodImplAttribute (MethodImplOptions.NoInlining)]
814 public static void locals7<T> (T arg) {
819 [MethodImplAttribute (MethodImplOptions.NoInlining)]
820 public static void line_numbers () {
824 [MethodImplAttribute (MethodImplOptions.NoInlining)]
825 public static void suspend () {
833 struct TypedRefTest {
837 [MethodImplAttribute (MethodImplOptions.NoInlining)]
838 public static void type_info () {
839 Tests t = new Tests () { field_i = 42, field_s = "S", base_field_i = 43, base_field_s = "T", field_enum = AnEnum.B };
840 t.ti1 (new Tests2 () { field_j = 43 }, new GClass <int> { field = 42 }, new GClass <string> { field = "FOO" });
843 AStruct s = new AStruct () { i = 42, s = "S", k = 43 };
844 TypedRefTest reftest = new TypedRefTest () { MaxValue = 12 };
845 TypedReference typedref = __makeref (reftest);
846 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);
850 [MethodImplAttribute (MethodImplOptions.NoInlining)]
851 public object ti1 (Tests2 t, GClass <int> gc1, GClass <string> gc2) {
852 if (t == null || gc1 == null || gc2 == null)
858 [MethodImplAttribute (MethodImplOptions.NoInlining)]
859 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) {
860 return s2 [0] + s3 [0] + s4 [0, 0];
863 [MethodImplAttribute (MethodImplOptions.NoInlining)]
864 public static void assembly_load () {
868 [MethodImplAttribute (MethodImplOptions.NoInlining)]
869 public static void assembly_load_2 () {
870 // This will load System.dll while holding the loader lock
874 [MethodImplAttribute (MethodImplOptions.NoInlining)]
875 public static void invoke () {
876 new Tests ().invoke1 (new Tests2 (), new AStruct () { i = 42, j = (IntPtr)43 }, new GStruct<int> { j = 42 });
877 new Tests ().invoke_ex ();
880 [MethodImplAttribute (MethodImplOptions.NoInlining)]
881 public void invoke1 (Tests2 t, AStruct s, GStruct<int> g) {
885 [MethodImplAttribute (MethodImplOptions.NoInlining)]
886 public void invoke2 () {
889 [MethodImplAttribute (MethodImplOptions.NoInlining)]
890 public void invoke_ex () {
894 [MethodImplAttribute (MethodImplOptions.NoInlining)]
895 public void invoke_ex_inner () {
897 throw new Exception ();
904 [MethodImplAttribute (MethodImplOptions.NoInlining)]
905 public void invoke_single_threaded () {
906 // Spawn a thread incrementing a counter
907 bool finished = false;
909 new Thread (delegate () {
916 invoke_single_threaded_2 ();
921 [MethodImplAttribute (MethodImplOptions.NoInlining)]
922 public void invoke_single_threaded_2 () {
925 public void invoke_return_void () {
928 public string invoke_return_ref () {
932 public object invoke_return_null () {
936 public int invoke_return_primitive () {
940 public int? invoke_return_nullable () {
944 public int? invoke_return_nullable_null () {
948 public void invoke_type_load () {
955 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) {
956 return ub + sb + ss + us + i + ui + l + (long)ul + (int)c + (b ? 1 : 0) + (int)f + (int)d;
959 public int invoke_pass_primitive2 (bool b) {
963 public string invoke_pass_ref (string s) {
967 public static string invoke_static_pass_ref (string s) {
971 public static void invoke_static_return_void () {
974 public static void invoke_throws () {
975 throw new Exception ();
978 public int invoke_iface () {
982 public void invoke_out (out int foo, out int[] arr) {
987 [MethodImplAttribute (MethodImplOptions.NoInlining)]
988 public static void exceptions () {
990 throw new OverflowException ();
991 } catch (Exception) {
994 throw new OverflowException ();
995 } catch (Exception) {
998 throw new ArgumentException ();
999 } catch (Exception) {
1002 throw new OverflowException ();
1003 } catch (Exception) {
1007 throw new OverflowException ();
1008 } catch (Exception) {
1011 throw new Exception ();
1012 } catch (Exception) {
1018 } catch (Exception) {
1023 } catch (Exception) {
1027 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1028 public static void unhandled_exception () {
1029 ThreadPool.QueueUserWorkItem (delegate {
1030 throw new InvalidOperationException ();
1032 Thread.Sleep (10000);
1035 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1036 public static void unhandled_exception_endinvoke_2 () {
1039 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1040 public static void unhandled_exception_endinvoke () {
1041 Action action = new Action (() =>
1043 throw new Exception ("thrown");
1045 action.BeginInvoke ((ar) => {
1047 action.EndInvoke (ar);
1048 } catch (Exception ex) {
1049 //Console.WriteLine (ex);
1052 Thread.Sleep (1000);
1053 unhandled_exception_endinvoke_2 ();
1056 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1057 public static void unhandled_exception_user () {
1059 System.Threading.Tasks.Task.Factory.StartNew (() => {
1062 Thread.Sleep (10000);
1066 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1067 public static void Throw () {
1068 throw new Exception ();
1071 internal static Delegate create_filter_delegate (Delegate dlg, MethodInfo filter_method)
1074 throw new ArgumentNullException ();
1075 if (dlg.Target != null)
1076 throw new ArgumentException ();
1077 if (dlg.Method == null)
1078 throw new ArgumentException ();
1080 var ret_type = dlg.Method.ReturnType;
1081 var param_types = dlg.Method.GetParameters ().Select (x => x.ParameterType).ToArray ();
1083 var dynamic = new DynamicMethod (Guid.NewGuid ().ToString (), ret_type, param_types, typeof (object), true);
1084 var ig = dynamic.GetILGenerator ();
1086 LocalBuilder retval = null;
1087 if (ret_type != typeof (void))
1088 retval = ig.DeclareLocal (ret_type);
1090 var label = ig.BeginExceptionBlock ();
1092 for (int i = 0; i < param_types.Length; i++)
1093 ig.Emit (OpCodes.Ldarg, i);
1094 ig.Emit (OpCodes.Call, dlg.Method);
1097 ig.Emit (OpCodes.Stloc, retval);
1099 ig.Emit (OpCodes.Leave, label);
1101 ig.BeginExceptFilterBlock ();
1103 ig.Emit (OpCodes.Call, filter_method);
1105 ig.BeginCatchBlock (null);
1107 ig.Emit (OpCodes.Pop);
1109 ig.EndExceptionBlock ();
1112 ig.Emit (OpCodes.Ldloc, retval);
1114 ig.Emit (OpCodes.Ret);
1116 return dynamic.CreateDelegate (dlg.GetType ());
1119 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1120 static void exception_filter_method () {
1121 throw new InvalidOperationException ();
1124 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1125 static int exception_filter_filter (Exception exc) {
1129 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1130 public static void exception_filter () {
1131 var method = typeof (Tests).GetMethod (
1132 "exception_filter_method", BindingFlags.NonPublic | BindingFlags.Static);
1133 var filter_method = typeof (Tests).GetMethod (
1134 "exception_filter_filter", BindingFlags.NonPublic | BindingFlags.Static);
1136 var dlg = Delegate.CreateDelegate (typeof (Action), method);
1138 var wrapper = (Action) create_filter_delegate (dlg, filter_method);
1143 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1144 public static bool return_true () {
1148 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1149 public static void exceptions2 () {
1151 throw new Exception ();
1152 Console.WriteLine ();
1155 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1156 public static void threads () {
1157 Thread t = new Thread (delegate () {});
1163 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1164 public static void domains () {
1165 AppDomain domain = AppDomain.CreateDomain ("domain");
1167 CrossDomain o = (CrossDomain)domain.CreateInstanceAndUnwrap (
1168 typeof (CrossDomain).Assembly.FullName, "CrossDomain");
1170 domains_2 (o, new CrossDomain ());
1178 AppDomain.Unload (domain);
1182 typeof (Tests).GetMethod ("called_from_invoke").Invoke (null, null);
1185 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1186 public static void called_from_invoke () {
1189 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1190 public static void domains_2 (object o, object o2) {
1193 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1194 public static void domains_3 () {
1197 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1198 public static void invoke_in_domain () {
1201 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1202 public static void invoke_in_domain_2 () {
1205 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1206 public static void dynamic_methods () {
1207 var m = new DynamicMethod ("dyn_method", typeof (void), new Type [] { typeof (int) }, typeof (object).Module);
1208 var ig = m.GetILGenerator ();
1210 ig.Emit (OpCodes.Ldstr, "FOO");
1211 ig.Emit (OpCodes.Call, typeof (Tests).GetMethod ("dyn_call"));
1212 ig.Emit (OpCodes.Ret);
1214 var del = (Action<int>)m.CreateDelegate (typeof (Action<int>));
1219 public static void dyn_call (string s) {
1222 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1223 public static void ref_emit () {
1224 AssemblyName assemblyName = new AssemblyName ();
1225 assemblyName.Name = "foo";
1227 AssemblyBuilder assembly =
1228 Thread.GetDomain ().DefineDynamicAssembly (
1229 assemblyName, AssemblyBuilderAccess.RunAndSave);
1231 ModuleBuilder module = assembly.DefineDynamicModule ("foo.dll");
1233 TypeBuilder tb = module.DefineType ("foo", TypeAttributes.Public, typeof (object));
1234 MethodBuilder mb = tb.DefineMethod ("ref_emit_method", MethodAttributes.Public|MethodAttributes.Static, CallingConventions.Standard, typeof (void), new Type [] { });
1235 ILGenerator ig = mb.GetILGenerator ();
1236 ig.Emit (OpCodes.Ldstr, "FOO");
1237 ig.Emit (OpCodes.Call, typeof (Tests).GetMethod ("ref_emit_call"));
1238 ig.Emit (OpCodes.Ret);
1240 Type t = tb.CreateType ();
1242 t.GetMethod ("ref_emit_method").Invoke (null, null);
1245 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1246 public static void ref_emit_call (string s) {
1249 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1250 public static void frames_in_native () {
1252 var evt = new ManualResetEvent (false);
1254 object mon = new object ();
1255 ThreadPool.QueueUserWorkItem (delegate {
1256 frames_in_native_2 ();
1262 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1263 static void frames_in_native_2 () {
1264 frames_in_native_3 ();
1267 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1268 static void frames_in_native_3 () {
1271 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1272 public static void string_call (string s) {
1275 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1276 public static void ss_regress_654694 () {
1283 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1284 public static void user () {
1287 Debugger.Log (5, Debugger.IsLogging () ? "A" : "", "B");
1290 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1291 public static void type_load () {
1295 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1296 static void type_load_2 () {
1297 var c1 = new Dictionary<int, int> ();
1299 var c = new TypeLoadClass ();
1301 var c2 = new TypeLoadClass2 ();
1305 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1306 public static void regress () {
1307 regress_2755 (DateTime.Now);
1310 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1311 public static unsafe void regress_2755 (DateTime d) {
1312 int* buffer = stackalloc int [128];
1317 for (int i = 0; i < 128; ++i)
1320 regress_2755_3 (sum);
1323 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1324 public static void regress_2755_2 () {
1327 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1328 public static void regress_2755_3 (int sum) {
1331 static object gc_suspend_field;
1333 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1334 static unsafe void set_gc_suspend_field () {
1335 set_gc_suspend_field_2 ();
1337 int* buffer = stackalloc int [4096];
1340 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1341 static void set_gc_suspend_field_2 () {
1342 gc_suspend_field = new object ();
1345 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1346 static void gc_suspend_1 () {
1349 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1350 public static void gc_suspend_invoke () {
1351 gc_suspend_field = null;
1353 GC.WaitForPendingFinalizers ();
1356 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1357 public static void gc_suspend () {
1358 set_gc_suspend_field ();
1362 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1363 public static void generic_method<T> () where T : class {
1366 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1367 public void evaluate_method_2 () {
1370 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1371 public void evaluate_method () {
1373 evaluate_method_2 ();
1376 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1377 static void set_ip_1 () {
1380 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1381 static void set_ip_2 () {
1384 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1385 public static void set_ip () {
1396 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1397 public static void step_filters () {
1398 ClassWithCctor.cctor_filter ();
1401 class ClassWithCctor {
1402 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1403 static ClassWithCctor () {
1408 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1409 public static void cctor_filter () {
1413 public override string virtual_method () {
1418 class TypeLoadClass {
1421 class TypeLoadClass2 {
1424 public class CrossDomain : MarshalByRefObject
1426 public void invoke () {
1427 Tests.invoke_in_domain ();
1430 public void invoke_2 () {
1431 Tests.invoke_in_domain_2 ();
1434 public int invoke_3 () {
1441 public ProcessStartInfo info;
1444 // Class used for line number info testing, don't change its layout
1445 public class LineNumbers
1447 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1448 public static void ln1 () {
1454 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1455 public static void ln2 () {
1458 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1459 public static void ln3 () {
1460 #pragma warning disable 0219
1462 #pragma warning restore 0219