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 ());
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) {
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 invoke_ex () {
916 [MethodImplAttribute (MethodImplOptions.NoInlining)]
917 public void invoke_ex_inner () {
919 throw new Exception ();
926 [MethodImplAttribute (MethodImplOptions.NoInlining)]
927 public void invoke_single_threaded () {
928 // Spawn a thread incrementing a counter
929 bool finished = false;
931 new Thread (delegate () {
938 invoke_single_threaded_2 ();
943 [MethodImplAttribute (MethodImplOptions.NoInlining)]
944 public void invoke_single_threaded_2 () {
947 public void invoke_return_void () {
950 public string invoke_return_ref () {
954 public object invoke_return_null () {
958 public int invoke_return_primitive () {
962 public int? invoke_return_nullable () {
966 public int? invoke_return_nullable_null () {
970 public void invoke_type_load () {
977 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) {
978 return ub + sb + ss + us + i + ui + l + (long)ul + (int)c + (b ? 1 : 0) + (int)f + (int)d;
981 public int invoke_pass_primitive2 (bool b) {
985 public string invoke_pass_ref (string s) {
989 public static string invoke_static_pass_ref (string s) {
993 public static void invoke_static_return_void () {
996 public static void invoke_throws () {
997 throw new Exception ();
1000 public int invoke_iface () {
1004 public void invoke_out (out int foo, out int[] arr) {
1009 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1010 public static void exceptions () {
1012 throw new OverflowException ();
1013 } catch (Exception) {
1016 throw new OverflowException ();
1017 } catch (Exception) {
1020 throw new ArgumentException ();
1021 } catch (Exception) {
1024 throw new OverflowException ();
1025 } catch (Exception) {
1029 throw new OverflowException ();
1030 } catch (Exception) {
1033 throw new Exception ();
1034 } catch (Exception) {
1040 } catch (Exception) {
1045 } catch (Exception) {
1049 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1050 public static void unhandled_exception () {
1051 ThreadPool.QueueUserWorkItem (delegate {
1052 throw new InvalidOperationException ();
1054 Thread.Sleep (10000);
1057 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1058 public static void unhandled_exception_endinvoke_2 () {
1061 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1062 public static void unhandled_exception_endinvoke () {
1063 Action action = new Action (() =>
1065 throw new Exception ("thrown");
1067 action.BeginInvoke ((ar) => {
1069 action.EndInvoke (ar);
1070 } catch (Exception ex) {
1071 //Console.WriteLine (ex);
1074 Thread.Sleep (1000);
1075 unhandled_exception_endinvoke_2 ();
1078 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1079 public static void unhandled_exception_user () {
1081 System.Threading.Tasks.Task.Factory.StartNew (() => {
1084 Thread.Sleep (10000);
1088 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1089 public static void Throw () {
1090 throw new Exception ();
1093 internal static Delegate create_filter_delegate (Delegate dlg, MethodInfo filter_method)
1096 throw new ArgumentNullException ();
1097 if (dlg.Target != null)
1098 throw new ArgumentException ();
1099 if (dlg.Method == null)
1100 throw new ArgumentException ();
1102 var ret_type = dlg.Method.ReturnType;
1103 var param_types = dlg.Method.GetParameters ().Select (x => x.ParameterType).ToArray ();
1105 var dynamic = new DynamicMethod (Guid.NewGuid ().ToString (), ret_type, param_types, typeof (object), true);
1106 var ig = dynamic.GetILGenerator ();
1108 LocalBuilder retval = null;
1109 if (ret_type != typeof (void))
1110 retval = ig.DeclareLocal (ret_type);
1112 var label = ig.BeginExceptionBlock ();
1114 for (int i = 0; i < param_types.Length; i++)
1115 ig.Emit (OpCodes.Ldarg, i);
1116 ig.Emit (OpCodes.Call, dlg.Method);
1119 ig.Emit (OpCodes.Stloc, retval);
1121 ig.Emit (OpCodes.Leave, label);
1123 ig.BeginExceptFilterBlock ();
1125 ig.Emit (OpCodes.Call, filter_method);
1127 ig.BeginCatchBlock (null);
1129 ig.Emit (OpCodes.Pop);
1131 ig.EndExceptionBlock ();
1134 ig.Emit (OpCodes.Ldloc, retval);
1136 ig.Emit (OpCodes.Ret);
1138 return dynamic.CreateDelegate (dlg.GetType ());
1141 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1142 static void exception_filter_method () {
1143 throw new InvalidOperationException ();
1146 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1147 static int exception_filter_filter (Exception exc) {
1151 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1152 public static void exception_filter () {
1153 var method = typeof (Tests).GetMethod (
1154 "exception_filter_method", BindingFlags.NonPublic | BindingFlags.Static);
1155 var filter_method = typeof (Tests).GetMethod (
1156 "exception_filter_filter", BindingFlags.NonPublic | BindingFlags.Static);
1158 var dlg = Delegate.CreateDelegate (typeof (Action), method);
1160 var wrapper = (Action) create_filter_delegate (dlg, filter_method);
1165 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1166 public static bool return_true () {
1170 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1171 public static void exceptions2 () {
1173 throw new Exception ();
1174 Console.WriteLine ();
1177 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1178 public static void threads () {
1179 Thread t = new Thread (delegate () {});
1185 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1186 public static void domains () {
1187 AppDomain domain = AppDomain.CreateDomain ("domain");
1189 CrossDomain o = (CrossDomain)domain.CreateInstanceAndUnwrap (
1190 typeof (CrossDomain).Assembly.FullName, "CrossDomain");
1192 domains_2 (o, new CrossDomain ());
1200 AppDomain.Unload (domain);
1204 typeof (Tests).GetMethod ("called_from_invoke").Invoke (null, null);
1207 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1208 public static void called_from_invoke () {
1211 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1212 public static void domains_2 (object o, object o2) {
1215 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1216 public static void domains_3 () {
1219 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1220 public static void invoke_in_domain () {
1223 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1224 public static void invoke_in_domain_2 () {
1227 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1228 public static void dynamic_methods () {
1229 var m = new DynamicMethod ("dyn_method", typeof (void), new Type [] { typeof (int) }, typeof (object).Module);
1230 var ig = m.GetILGenerator ();
1232 ig.Emit (OpCodes.Ldstr, "FOO");
1233 ig.Emit (OpCodes.Call, typeof (Tests).GetMethod ("dyn_call"));
1234 ig.Emit (OpCodes.Ret);
1236 var del = (Action<int>)m.CreateDelegate (typeof (Action<int>));
1241 public static void dyn_call (string s) {
1244 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1245 public static void ref_emit () {
1246 AssemblyName assemblyName = new AssemblyName ();
1247 assemblyName.Name = "foo";
1249 AssemblyBuilder assembly =
1250 Thread.GetDomain ().DefineDynamicAssembly (
1251 assemblyName, AssemblyBuilderAccess.RunAndSave);
1253 ModuleBuilder module = assembly.DefineDynamicModule ("foo.dll");
1255 TypeBuilder tb = module.DefineType ("foo", TypeAttributes.Public, typeof (object));
1256 MethodBuilder mb = tb.DefineMethod ("ref_emit_method", MethodAttributes.Public|MethodAttributes.Static, CallingConventions.Standard, typeof (void), new Type [] { });
1257 ILGenerator ig = mb.GetILGenerator ();
1258 ig.Emit (OpCodes.Ldstr, "FOO");
1259 ig.Emit (OpCodes.Call, typeof (Tests).GetMethod ("ref_emit_call"));
1260 ig.Emit (OpCodes.Ret);
1262 Type t = tb.CreateType ();
1264 t.GetMethod ("ref_emit_method").Invoke (null, null);
1267 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1268 public static void ref_emit_call (string s) {
1271 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1272 public static void frames_in_native () {
1274 var evt = new ManualResetEvent (false);
1276 object mon = new object ();
1277 ThreadPool.QueueUserWorkItem (delegate {
1278 frames_in_native_2 ();
1284 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1285 static void frames_in_native_2 () {
1286 frames_in_native_3 ();
1289 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1290 static void frames_in_native_3 () {
1293 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1294 public static void string_call (string s) {
1297 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1298 public static void ss_regress_654694 () {
1305 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1306 public static void user () {
1309 Debugger.Log (5, Debugger.IsLogging () ? "A" : "", "B");
1312 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1313 public static void type_load () {
1317 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1318 static void type_load_2 () {
1319 var c1 = new Dictionary<int, int> ();
1321 var c = new TypeLoadClass ();
1323 var c2 = new TypeLoadClass2 ();
1327 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1328 public static void regress () {
1329 regress_2755 (DateTime.Now);
1332 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1333 public static unsafe void regress_2755 (DateTime d) {
1334 int* buffer = stackalloc int [128];
1339 for (int i = 0; i < 128; ++i)
1342 regress_2755_3 (sum);
1345 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1346 public static void regress_2755_2 () {
1349 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1350 public static void regress_2755_3 (int sum) {
1353 static object gc_suspend_field;
1355 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1356 static unsafe void set_gc_suspend_field () {
1357 set_gc_suspend_field_2 ();
1359 int* buffer = stackalloc int [4096];
1362 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1363 static void set_gc_suspend_field_2 () {
1364 gc_suspend_field = new object ();
1367 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1368 static void gc_suspend_1 () {
1371 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1372 public static void gc_suspend_invoke () {
1373 gc_suspend_field = null;
1375 GC.WaitForPendingFinalizers ();
1378 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1379 public static void gc_suspend () {
1380 set_gc_suspend_field ();
1384 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1385 public static void generic_method<T> () where T : class {
1388 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1389 public void evaluate_method_2 () {
1392 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1393 public void evaluate_method () {
1395 evaluate_method_2 ();
1398 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1399 static void set_ip_1 () {
1402 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1403 static void set_ip_2 () {
1406 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1407 public static void set_ip () {
1418 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1419 public static void step_filters () {
1420 ClassWithCctor.cctor_filter ();
1423 class ClassWithCctor {
1424 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1425 static ClassWithCctor () {
1430 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1431 public static void cctor_filter () {
1435 public override string virtual_method () {
1440 class TypeLoadClass {
1443 class TypeLoadClass2 {
1446 public class CrossDomain : MarshalByRefObject
1448 public void invoke () {
1449 Tests.invoke_in_domain ();
1452 public void invoke_2 () {
1453 Tests.invoke_in_domain_2 ();
1456 public int invoke_3 () {
1463 public ProcessStartInfo info;
1466 // Class used for line number info testing, don't change its layout
1467 public class LineNumbers
1469 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1470 public static void ln1 () {
1476 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1477 public static void ln2 () {
1480 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1481 public static void ln3 () {
1482 #pragma warning disable 0219
1484 #pragma warning restore 0219
1489 class LocalReflectClass
1491 public static void RunMe ()
1493 var reflectMe = new someClass ();
1494 reflectMe.someMethod ();
1497 class someClass : ContextBoundObject
1499 public object someField;
1501 public void someMethod ()