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 new Tests ().evaluate_method ();
349 public static void local_reflect () {
350 //Breakpoint line below, and reflect someField via ObjectMirror;
351 LocalReflectClass.RunMe ();
354 public static void breakpoints () {
355 /* Call these early so it is JITted by the time a breakpoint is placed on it */
367 bp6<string> (new GClass <int> ());
372 [MethodImplAttribute (MethodImplOptions.NoInlining)]
373 public static void bp1 () {
376 [MethodImplAttribute (MethodImplOptions.NoInlining)]
377 public static void bp2 () {
380 [MethodImplAttribute (MethodImplOptions.NoInlining)]
381 public static void bp3 () {
384 [MethodImplAttribute (MethodImplOptions.NoInlining)]
385 public static void bp4 () {
388 [MethodImplAttribute (MethodImplOptions.NoInlining)]
389 public static void bp5 () {
392 [MethodImplAttribute (MethodImplOptions.NoInlining)]
393 public static void bp6<T> (GClass<int> gc) {
397 [MethodImplAttribute (MethodImplOptions.NoInlining)]
398 public static void bp7<T> () {
401 [MethodImplAttribute (MethodImplOptions.NoInlining)]
402 public static void single_stepping () {
409 ss5 (new int [] { 1, 2, 3 }, new Func<int, bool> (is_even));
416 ss_regress_654694 ();
423 [MethodImplAttribute (MethodImplOptions.NoInlining)]
424 public static void ss1 () {
427 [MethodImplAttribute (MethodImplOptions.NoInlining)]
428 public static void ss2 () {
431 [MethodImplAttribute (MethodImplOptions.NoInlining)]
432 public static int ss3 () {
435 for (int i = 0; i < 10; ++i)
441 [MethodImplAttribute (MethodImplOptions.NoInlining)]
442 public static void ss3_2 () {
446 [MethodImplAttribute (MethodImplOptions.NoInlining)]
447 public static void ss3_2_2 () {
450 [MethodImplAttribute (MethodImplOptions.NoInlining)]
451 public static int ss4 () {
457 [MethodImplAttribute (MethodImplOptions.NoInlining)]
458 public static void ss5 (int[] arr, Func<int, bool> selector) {
459 // Call into linq which calls back into this assembly
460 arr.Count (selector);
463 [MethodImplAttribute (MethodImplOptions.NoInlining)]
464 public static void ss6 (bool b) {
467 throw new Exception ();
471 [MethodImplAttribute (MethodImplOptions.NoInlining)]
472 public static void ss6_2 () {
475 [MethodImplAttribute (MethodImplOptions.NoInlining)]
476 public static void ss7 () {
485 [MethodImplAttribute (MethodImplOptions.NoInlining)]
486 public static void ss7_2 () {
489 [MethodImplAttribute (MethodImplOptions.NoInlining)]
490 public static void ss7_3 () {
491 throw new Exception ();
494 [MethodImplAttribute (MethodImplOptions.NoInlining)]
495 public static void ss_nested () {
496 ss_nested_1 (ss_nested_2 ());
497 ss_nested_1 (ss_nested_2 ());
501 [MethodImplAttribute (MethodImplOptions.NoInlining)]
502 public static void ss_nested_1 (int i) {
505 [MethodImplAttribute (MethodImplOptions.NoInlining)]
506 public static int ss_nested_2 () {
510 [MethodImplAttribute (MethodImplOptions.NoInlining)]
511 public static void ss_nested_3 () {
514 [MethodImplAttribute (MethodImplOptions.NoInlining)]
515 public static void ss_step_through () {
517 StepThroughClass.step_through_2 ();
521 [DebuggerStepThrough]
522 [MethodImplAttribute (MethodImplOptions.NoInlining)]
523 public static void step_through_1 () {
526 [DebuggerStepThrough]
527 class StepThroughClass {
528 [MethodImplAttribute (MethodImplOptions.NoInlining)]
529 public static void step_through_2 () {
533 [DebuggerStepThrough]
534 [MethodImplAttribute (MethodImplOptions.NoInlining)]
535 public static void step_through_3 () {
538 [MethodImplAttribute (MethodImplOptions.NoInlining)]
539 public static void ss_non_user_code () {
541 StepNonUserCodeClass.non_user_code_2 ();
545 [DebuggerNonUserCode]
546 [MethodImplAttribute (MethodImplOptions.NoInlining)]
547 public static void non_user_code_1 () {
550 [DebuggerNonUserCode]
551 class StepNonUserCodeClass {
552 [MethodImplAttribute (MethodImplOptions.NoInlining)]
553 public static void non_user_code_2 () {
557 [DebuggerNonUserCode]
558 [MethodImplAttribute (MethodImplOptions.NoInlining)]
559 public static void non_user_code_3 () {
562 [MethodImplAttribute (MethodImplOptions.NoInlining)]
563 public static void ss_recursive (int n) {
566 ss_recursive (n + 1);
569 [MethodImplAttribute (MethodImplOptions.NoInlining)]
570 public static void ss_fp_clobber () {
571 double v = ss_fp_clobber_1 (5.0);
575 [MethodImplAttribute (MethodImplOptions.NoInlining)]
576 public static double ss_fp_clobber_1 (double d) {
580 [MethodImplAttribute (MethodImplOptions.NoInlining)]
581 public static void ss_fp_clobber_2 (double d) {
584 [MethodImplAttribute (MethodImplOptions.NoInlining)]
585 public static bool is_even (int i) {
591 Console.WriteLine ("HIT!");
597 [MethodImplAttribute (MethodImplOptions.NoInlining)]
598 public static void arguments () {
599 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));
601 arg2 ("FOO", null, "BLA", ref i, new GClass <int> { field = 42 }, new object (), '\0'.ToString () + "A");
602 Tests t = new Tests () { field_i = 42, field_s = "S" };
606 [MethodImplAttribute (MethodImplOptions.NoInlining)]
607 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) {
608 return (int)(sb + b + (bl ? 0 : 1) + s + us + (int)c + i + ui + l + (long)ul + f + d + (int)ip + (int)uip);
611 [MethodImplAttribute (MethodImplOptions.NoInlining)]
612 public static string arg2 (string s, string s3, object o, ref int i, GClass <int> gc, object o2, string s4) {
613 return s + (s3 != null ? "" : "") + o + i + gc.field + o2;
616 [MethodImplAttribute (MethodImplOptions.NoInlining)]
617 public object arg3 (string s) {
618 return s + s + s + s + this;
621 [MethodImplAttribute (MethodImplOptions.NoInlining)]
622 public static void objects () {
623 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 };
624 t.o1 (new Tests2 () { field_j = 43 }, new GClass <int> { field = 42 }, new GClass <string> { field = "FOO" });
625 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 });
628 [MethodImplAttribute (MethodImplOptions.NoInlining)]
629 public object o1 (Tests2 t, GClass <int> gc1, GClass <string> gc2) {
630 if (t == null || gc1 == null || gc2 == null)
636 [MethodImplAttribute (MethodImplOptions.NoInlining)]
637 public static string o2 (string[] s2, int[] s3, int[,] s4, int[,] s5, IList<int> s6) {
638 return s2 [0] + s3 [0] + s4 [0, 0] + s6 [0];
641 [MethodImplAttribute (MethodImplOptions.NoInlining)]
642 public static void objrefs () {
643 Tests t = new Tests () {};
651 [MethodImplAttribute (MethodImplOptions.NoInlining)]
652 public static void set_child (Tests t) {
653 t.child = new Tests ();
656 [MethodImplAttribute (MethodImplOptions.NoInlining)]
657 public void objrefs1 () {
660 [MethodImplAttribute (MethodImplOptions.NoInlining)]
661 public static void objrefs2 () {
664 public static void vtypes () {
665 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 ) };
666 AStruct s = new AStruct { i = 44, s = "T", k = 45 };
667 AStruct[] arr = new AStruct[] {
668 new AStruct () { i = 1, s = "S1" },
669 new AStruct () { i = 2, s = "S2" } };
670 TypedReference typedref = __makeref (s);
671 t.vtypes1 (s, arr, typedref);
677 [MethodImplAttribute (MethodImplOptions.NoInlining)]
678 public object vtypes1 (AStruct s, AStruct[] arr, TypedReference typedref) {
685 [MethodImplAttribute (MethodImplOptions.NoInlining)]
686 public static void vtypes2 (AStruct s) {
690 [MethodImplAttribute (MethodImplOptions.NoInlining)]
691 public static void vtypes3 (AStruct s) {
692 AStruct.static_foo (5);
695 [MethodImplAttribute (MethodImplOptions.NoInlining)]
696 public static void vtypes4_2 (IRecStruct o) {
699 [MethodImplAttribute (MethodImplOptions.NoInlining)]
700 public static void vtypes4 () {
701 IRecStruct s = new RecStruct ();
706 [MethodImplAttribute (MethodImplOptions.NoInlining)]
707 public static void locals () {
709 var astruct = new AStruct () { i = 42 };
711 locals2<string> (null, 5, "ABC", ref s, ref astruct);
717 [MethodImplAttribute (MethodImplOptions.NoInlining)]
718 static void locals11 (double a, ref double b) {
721 [MethodImplAttribute (MethodImplOptions.NoInlining)]
722 public static void locals1 (string[] args) {
726 locals11 (b: ref ri, a: ri);
728 for (int j = 0; j < 10; ++j) {
733 [MethodImplAttribute (MethodImplOptions.NoInlining)]
735 [StateMachine (typeof (int))]
737 public static void locals2<T> (string[] args, int arg, T t, ref string rs, ref AStruct astruct) {
741 for (int j = 0; j < 10; ++j) {
746 astruct = new AStruct ();
749 List<int> alist = new List<int> () { 12 };
753 [MethodImplAttribute (MethodImplOptions.NoInlining)]
754 public static void locals3 () {
774 [MethodImplAttribute (MethodImplOptions.NoInlining)]
775 public static void locals4 () {
778 [MethodImplAttribute (MethodImplOptions.NoInlining)]
779 public static void locals5 () {
782 [MethodImplAttribute (MethodImplOptions.NoInlining)]
783 public static void locals6 () {
786 for (i = 0; i < 10; ++i)
789 for (i = 0; i < 10; ++i)
799 [MethodImplAttribute (MethodImplOptions.NoInlining)]
800 public static void locals6_1 () {
803 [MethodImplAttribute (MethodImplOptions.NoInlining)]
804 public static void locals6_2 (int arg) {
807 [MethodImplAttribute (MethodImplOptions.NoInlining)]
808 public static void locals6_3 () {
809 // Clobber all registers
810 int sum = 0, i, j, k, l, m;
811 for (i = 0; i < 100; ++i)
813 for (j = 0; j < 100; ++j)
815 for (k = 0; k < 100; ++k)
817 for (l = 0; l < 100; ++l)
819 for (m = 0; m < 100; ++m)
823 [MethodImplAttribute (MethodImplOptions.NoInlining)]
824 public static void locals6_4 (int arg) {
827 [MethodImplAttribute (MethodImplOptions.NoInlining)]
828 public static void locals6_5 () {
831 [MethodImplAttribute (MethodImplOptions.NoInlining)]
832 public static void locals6_6 (int arg) {
835 [MethodImplAttribute (MethodImplOptions.NoInlining)]
836 public static void locals7<T> (T arg) {
841 [MethodImplAttribute (MethodImplOptions.NoInlining)]
842 public static void line_numbers () {
846 [MethodImplAttribute (MethodImplOptions.NoInlining)]
847 public static void suspend () {
855 struct TypedRefTest {
859 [MethodImplAttribute (MethodImplOptions.NoInlining)]
860 public static void type_info () {
861 Tests t = new Tests () { field_i = 42, field_s = "S", base_field_i = 43, base_field_s = "T", field_enum = AnEnum.B };
862 t.ti1 (new Tests2 () { field_j = 43 }, new GClass <int> { field = 42 }, new GClass <string> { field = "FOO" });
865 AStruct s = new AStruct () { i = 42, s = "S", k = 43 };
866 TypedRefTest reftest = new TypedRefTest () { MaxValue = 12 };
867 TypedReference typedref = __makeref (reftest);
868 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);
872 [MethodImplAttribute (MethodImplOptions.NoInlining)]
873 public object ti1 (Tests2 t, GClass <int> gc1, GClass <string> gc2) {
874 if (t == null || gc1 == null || gc2 == null)
880 [MethodImplAttribute (MethodImplOptions.NoInlining)]
881 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) {
882 return s2 [0] + s3 [0] + s4 [0, 0];
885 [MethodImplAttribute (MethodImplOptions.NoInlining)]
886 public static void assembly_load () {
890 [MethodImplAttribute (MethodImplOptions.NoInlining)]
891 public static void assembly_load_2 () {
892 // This will load System.dll while holding the loader lock
896 [MethodImplAttribute (MethodImplOptions.NoInlining)]
897 public static void invoke () {
898 new Tests ().invoke1 (new Tests2 (), new AStruct () { i = 42, j = (IntPtr)43 }, new GStruct<int> { j = 42 });
899 new Tests ().invoke_ex ();
902 [MethodImplAttribute (MethodImplOptions.NoInlining)]
903 public void invoke1 (Tests2 t, AStruct s, GStruct<int> g) {
907 [MethodImplAttribute (MethodImplOptions.NoInlining)]
908 public void invoke2 () {
911 [MethodImplAttribute (MethodImplOptions.NoInlining)]
912 public void invoke3 () {
915 [MethodImplAttribute (MethodImplOptions.NoInlining)]
916 public void invoke_ex () {
920 [MethodImplAttribute (MethodImplOptions.NoInlining)]
921 public void invoke_ex_inner () {
923 throw new Exception ();
930 [MethodImplAttribute (MethodImplOptions.NoInlining)]
931 public void invoke_single_threaded () {
932 // Spawn a thread incrementing a counter
933 bool finished = false;
935 new Thread (delegate () {
942 invoke_single_threaded_2 ();
947 [MethodImplAttribute (MethodImplOptions.NoInlining)]
948 public void invoke_single_threaded_2 () {
951 public void invoke_return_void () {
954 public string invoke_return_ref () {
958 public object invoke_return_null () {
962 public int invoke_return_primitive () {
966 public int? invoke_return_nullable () {
970 public int? invoke_return_nullable_null () {
974 public void invoke_type_load () {
981 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) {
982 return ub + sb + ss + us + i + ui + l + (long)ul + (int)c + (b ? 1 : 0) + (int)f + (int)d;
985 public int invoke_pass_primitive2 (bool b) {
989 public string invoke_pass_ref (string s) {
993 public static string invoke_static_pass_ref (string s) {
997 public static void invoke_static_return_void () {
1000 public static void invoke_throws () {
1001 throw new Exception ();
1004 public int invoke_iface () {
1008 public void invoke_out (out int foo, out int[] arr) {
1013 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1014 public static void exceptions () {
1016 throw new OverflowException ();
1017 } catch (Exception) {
1020 throw new OverflowException ();
1021 } catch (Exception) {
1024 throw new ArgumentException ();
1025 } catch (Exception) {
1028 throw new OverflowException ();
1029 } catch (Exception) {
1033 throw new OverflowException ();
1034 } catch (Exception) {
1037 throw new Exception ();
1038 } catch (Exception) {
1044 } catch (Exception) {
1049 } catch (Exception) {
1053 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1054 public static void unhandled_exception () {
1055 ThreadPool.QueueUserWorkItem (delegate {
1056 throw new InvalidOperationException ();
1058 Thread.Sleep (10000);
1061 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1062 public static void unhandled_exception_endinvoke_2 () {
1065 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1066 public static void unhandled_exception_endinvoke () {
1067 Action action = new Action (() =>
1069 throw new Exception ("thrown");
1071 action.BeginInvoke ((ar) => {
1073 action.EndInvoke (ar);
1074 } catch (Exception ex) {
1075 //Console.WriteLine (ex);
1078 Thread.Sleep (1000);
1079 unhandled_exception_endinvoke_2 ();
1082 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1083 public static void unhandled_exception_user () {
1085 System.Threading.Tasks.Task.Factory.StartNew (() => {
1088 Thread.Sleep (10000);
1092 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1093 public static void Throw () {
1094 throw new Exception ();
1097 internal static Delegate create_filter_delegate (Delegate dlg, MethodInfo filter_method)
1100 throw new ArgumentNullException ();
1101 if (dlg.Target != null)
1102 throw new ArgumentException ();
1103 if (dlg.Method == null)
1104 throw new ArgumentException ();
1106 var ret_type = dlg.Method.ReturnType;
1107 var param_types = dlg.Method.GetParameters ().Select (x => x.ParameterType).ToArray ();
1109 var dynamic = new DynamicMethod (Guid.NewGuid ().ToString (), ret_type, param_types, typeof (object), true);
1110 var ig = dynamic.GetILGenerator ();
1112 LocalBuilder retval = null;
1113 if (ret_type != typeof (void))
1114 retval = ig.DeclareLocal (ret_type);
1116 var label = ig.BeginExceptionBlock ();
1118 for (int i = 0; i < param_types.Length; i++)
1119 ig.Emit (OpCodes.Ldarg, i);
1120 ig.Emit (OpCodes.Call, dlg.Method);
1123 ig.Emit (OpCodes.Stloc, retval);
1125 ig.Emit (OpCodes.Leave, label);
1127 ig.BeginExceptFilterBlock ();
1129 ig.Emit (OpCodes.Call, filter_method);
1131 ig.BeginCatchBlock (null);
1133 ig.Emit (OpCodes.Pop);
1135 ig.EndExceptionBlock ();
1138 ig.Emit (OpCodes.Ldloc, retval);
1140 ig.Emit (OpCodes.Ret);
1142 return dynamic.CreateDelegate (dlg.GetType ());
1145 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1146 static void exception_filter_method () {
1147 throw new InvalidOperationException ();
1150 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1151 static int exception_filter_filter (Exception exc) {
1155 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1156 public static void exception_filter () {
1157 var method = typeof (Tests).GetMethod (
1158 "exception_filter_method", BindingFlags.NonPublic | BindingFlags.Static);
1159 var filter_method = typeof (Tests).GetMethod (
1160 "exception_filter_filter", BindingFlags.NonPublic | BindingFlags.Static);
1162 var dlg = Delegate.CreateDelegate (typeof (Action), method);
1164 var wrapper = (Action) create_filter_delegate (dlg, filter_method);
1169 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1170 public static bool return_true () {
1174 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1175 public static void exceptions2 () {
1177 throw new Exception ();
1178 Console.WriteLine ();
1181 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1182 public static void threads () {
1183 Thread t = new Thread (delegate () {});
1189 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1190 public static void domains () {
1191 AppDomain domain = AppDomain.CreateDomain ("domain");
1193 CrossDomain o = (CrossDomain)domain.CreateInstanceAndUnwrap (
1194 typeof (CrossDomain).Assembly.FullName, "CrossDomain");
1196 domains_2 (o, new CrossDomain ());
1204 AppDomain.Unload (domain);
1208 typeof (Tests).GetMethod ("called_from_invoke").Invoke (null, null);
1211 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1212 public static void called_from_invoke () {
1215 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1216 public static void domains_2 (object o, object o2) {
1219 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1220 public static void domains_3 () {
1223 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1224 public static void invoke_in_domain () {
1227 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1228 public static void invoke_in_domain_2 () {
1231 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1232 public static void dynamic_methods () {
1233 var m = new DynamicMethod ("dyn_method", typeof (void), new Type [] { typeof (int) }, typeof (object).Module);
1234 var ig = m.GetILGenerator ();
1236 ig.Emit (OpCodes.Ldstr, "FOO");
1237 ig.Emit (OpCodes.Call, typeof (Tests).GetMethod ("dyn_call"));
1238 ig.Emit (OpCodes.Ret);
1240 var del = (Action<int>)m.CreateDelegate (typeof (Action<int>));
1245 public static void dyn_call (string s) {
1248 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1249 public static void ref_emit () {
1250 AssemblyName assemblyName = new AssemblyName ();
1251 assemblyName.Name = "foo";
1253 AssemblyBuilder assembly =
1254 Thread.GetDomain ().DefineDynamicAssembly (
1255 assemblyName, AssemblyBuilderAccess.RunAndSave);
1257 ModuleBuilder module = assembly.DefineDynamicModule ("foo.dll");
1259 TypeBuilder tb = module.DefineType ("foo", TypeAttributes.Public, typeof (object));
1260 MethodBuilder mb = tb.DefineMethod ("ref_emit_method", MethodAttributes.Public|MethodAttributes.Static, CallingConventions.Standard, typeof (void), new Type [] { });
1261 ILGenerator ig = mb.GetILGenerator ();
1262 ig.Emit (OpCodes.Ldstr, "FOO");
1263 ig.Emit (OpCodes.Call, typeof (Tests).GetMethod ("ref_emit_call"));
1264 ig.Emit (OpCodes.Ret);
1266 Type t = tb.CreateType ();
1268 t.GetMethod ("ref_emit_method").Invoke (null, null);
1271 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1272 public static void ref_emit_call (string s) {
1275 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1276 public static void frames_in_native () {
1278 var evt = new ManualResetEvent (false);
1280 object mon = new object ();
1281 ThreadPool.QueueUserWorkItem (delegate {
1282 frames_in_native_2 ();
1288 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1289 static void frames_in_native_2 () {
1290 frames_in_native_3 ();
1293 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1294 static void frames_in_native_3 () {
1297 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1298 public static void string_call (string s) {
1301 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1302 public static void ss_regress_654694 () {
1309 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1310 public static void user () {
1313 Debugger.Log (5, Debugger.IsLogging () ? "A" : "", "B");
1316 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1317 public static void type_load () {
1321 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1322 static void type_load_2 () {
1323 var c1 = new Dictionary<int, int> ();
1325 var c = new TypeLoadClass ();
1327 var c2 = new TypeLoadClass2 ();
1331 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1332 public static void regress () {
1333 regress_2755 (DateTime.Now);
1336 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1337 public static unsafe void regress_2755 (DateTime d) {
1338 int* buffer = stackalloc int [128];
1343 for (int i = 0; i < 128; ++i)
1346 regress_2755_3 (sum);
1349 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1350 public static void regress_2755_2 () {
1353 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1354 public static void regress_2755_3 (int sum) {
1357 static object gc_suspend_field;
1359 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1360 static unsafe void set_gc_suspend_field () {
1361 set_gc_suspend_field_2 ();
1363 int* buffer = stackalloc int [4096];
1366 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1367 static void set_gc_suspend_field_2 () {
1368 gc_suspend_field = new object ();
1371 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1372 static void gc_suspend_1 () {
1375 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1376 public static void gc_suspend_invoke () {
1377 gc_suspend_field = null;
1379 GC.WaitForPendingFinalizers ();
1382 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1383 public static void gc_suspend () {
1384 set_gc_suspend_field ();
1388 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1389 public static void generic_method<T> () where T : class {
1392 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1393 public void evaluate_method_2 () {
1396 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1397 public void evaluate_method () {
1399 evaluate_method_2 ();
1402 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1403 static void set_ip_1 () {
1406 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1407 static void set_ip_2 () {
1410 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1411 public static void set_ip () {
1422 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1423 public static void step_filters () {
1424 ClassWithCctor.cctor_filter ();
1427 class ClassWithCctor {
1428 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1429 static ClassWithCctor () {
1434 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1435 public static void cctor_filter () {
1439 public override string virtual_method () {
1444 class TypeLoadClass {
1447 class TypeLoadClass2 {
1450 public class CrossDomain : MarshalByRefObject
1452 public void invoke () {
1453 Tests.invoke_in_domain ();
1456 public void invoke_2 () {
1457 Tests.invoke_in_domain_2 ();
1460 public int invoke_3 () {
1467 public ProcessStartInfo info;
1470 // Class used for line number info testing, don't change its layout
1471 public class LineNumbers
1473 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1474 public static void ln1 () {
1480 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1481 public static void ln2 () {
1484 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1485 public static void ln3 () {
1486 #pragma warning disable 0219
1488 #pragma warning restore 0219
1493 class LocalReflectClass
1495 public static void RunMe ()
1497 var reflectMe = new someClass ();
1498 reflectMe.someMethod ();
1501 class someClass : ContextBoundObject
1503 public object someField;
1505 public void someMethod ()