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
32 public sealed class Tests3 {
33 public static void M1 () {
47 public static class Tests4 {
52 public class AAttribute : Attribute {
56 public class BAttribute : AAttribute {
60 [DebuggerDisplay ("Tests", Name="FOO", Target=typeof (int))]
61 [DebuggerTypeProxy (typeof (Tests))]
62 [BAttribute (afield = 1, bfield = 2)]
64 [DebuggerBrowsableAttribute (DebuggerBrowsableState.Collapsed)]
66 public static int static_field_j;
68 [DebuggerBrowsableAttribute (DebuggerBrowsableState.Collapsed)]
69 public int AProperty {
75 public void invoke () {
79 public struct AStruct {
85 [MethodImplAttribute (MethodImplOptions.NoInlining)]
86 public int foo (int val) {
90 [MethodImplAttribute (MethodImplOptions.NoInlining)]
91 public static int static_foo (int val) {
95 [MethodImplAttribute (MethodImplOptions.NoInlining)]
96 public int invoke_return_int () {
100 [MethodImplAttribute (MethodImplOptions.NoInlining)]
101 public static int invoke_static () {
105 [MethodImplAttribute (MethodImplOptions.NoInlining)]
106 public IntPtr invoke_return_intptr () {
111 public class GClass<T> {
113 public static T static_field;
115 [MethodImplAttribute (MethodImplOptions.NoInlining)]
119 [MethodImplAttribute (MethodImplOptions.NoInlining)]
120 public void bp<T2> () {
124 public struct GStruct<T> {
129 [MethodImplAttribute (MethodImplOptions.NoInlining)]
130 public int invoke_return_int () {
135 public struct NestedStruct {
136 NestedInner nested1, nested2;
139 public struct NestedInner {
154 class TestIfaces : ITest
162 TestIfaces<int> Baz () {
167 class TestIfaces<T> : ITest<T>
169 void ITest<T>.Foo () {
172 void ITest<T>.Bar () {
176 public interface ITest2
181 public class Tests : TestsBase, ITest2
183 #pragma warning disable 0414
187 bool field_bool1, field_bool2;
200 static int static_i = 55;
201 static string static_s = "A";
202 public const int literal_i = 56;
203 public const string literal_s = "B";
205 public AStruct field_struct;
206 public object field_boxed_struct;
207 public GStruct<int> generic_field_struct;
208 public KeyValuePair<int, object> boxed_struct_field;
210 public static int tls_i;
211 public static bool is_attached = Debugger.IsAttached;
212 public NestedStruct nested_struct;
214 #pragma warning restore 0414
216 public class NestedClass {
219 public int IntProperty {
228 public int ReadOnlyProperty {
234 public int this [int index] {
240 public static void wait_one ()
242 ManualResetEvent evt = new ManualResetEvent (false);
246 public static int Main (String[] args) {
249 if (args.Length > 0 && args [0] == "suspend-test")
250 /* This contains an infinite loop, so execute it conditionally */
252 if (args.Length >0 && args [0] == "unhandled-exception") {
253 unhandled_exception ();
256 if (args.Length >0 && args [0] == "unhandled-exception-endinvoke") {
257 unhandled_exception_endinvoke ();
260 if (args.Length >0 && args [0] == "unhandled-exception-user") {
261 unhandled_exception_user ();
264 if (args.Length >0 && args [0] == "wait-one") {
288 if (args.Length > 0 && args [0] == "domain-test")
289 /* This takes a lot of time, so execute it conditionally */
291 if (args.Length > 0 && args [0] == "ref-emit-test")
293 if (args.Length > 0 && args [0] == "frames-in-native")
295 if (args.Length > 0 && args [0] == "invoke-single-threaded")
296 new Tests ().invoke_single_threaded ();
297 new Tests ().evaluate_method ();
301 public static void breakpoints () {
302 /* Call these early so it is JITted by the time a breakpoint is placed on it */
314 bp6<string> (new GClass <int> ());
319 [MethodImplAttribute (MethodImplOptions.NoInlining)]
320 public static void bp1 () {
323 [MethodImplAttribute (MethodImplOptions.NoInlining)]
324 public static void bp2 () {
327 [MethodImplAttribute (MethodImplOptions.NoInlining)]
328 public static void bp3 () {
331 [MethodImplAttribute (MethodImplOptions.NoInlining)]
332 public static void bp4 () {
335 [MethodImplAttribute (MethodImplOptions.NoInlining)]
336 public static void bp5 () {
339 [MethodImplAttribute (MethodImplOptions.NoInlining)]
340 public static void bp6<T> (GClass<int> gc) {
344 [MethodImplAttribute (MethodImplOptions.NoInlining)]
345 public static void bp7<T> () {
348 [MethodImplAttribute (MethodImplOptions.NoInlining)]
349 public static void single_stepping () {
356 ss5 (new int [] { 1, 2, 3 }, new Func<int, bool> (is_even));
363 ss_regress_654694 ();
370 [MethodImplAttribute (MethodImplOptions.NoInlining)]
371 public static void ss1 () {
374 [MethodImplAttribute (MethodImplOptions.NoInlining)]
375 public static void ss2 () {
378 [MethodImplAttribute (MethodImplOptions.NoInlining)]
379 public static int ss3 () {
382 for (int i = 0; i < 10; ++i)
388 [MethodImplAttribute (MethodImplOptions.NoInlining)]
389 public static void ss3_2 () {
393 [MethodImplAttribute (MethodImplOptions.NoInlining)]
394 public static void ss3_2_2 () {
397 [MethodImplAttribute (MethodImplOptions.NoInlining)]
398 public static int ss4 () {
404 [MethodImplAttribute (MethodImplOptions.NoInlining)]
405 public static void ss5 (int[] arr, Func<int, bool> selector) {
406 // Call into linq which calls back into this assembly
407 arr.Count (selector);
410 [MethodImplAttribute (MethodImplOptions.NoInlining)]
411 public static void ss6 (bool b) {
414 throw new Exception ();
418 [MethodImplAttribute (MethodImplOptions.NoInlining)]
419 public static void ss6_2 () {
422 [MethodImplAttribute (MethodImplOptions.NoInlining)]
423 public static void ss7 () {
432 [MethodImplAttribute (MethodImplOptions.NoInlining)]
433 public static void ss7_2 () {
436 [MethodImplAttribute (MethodImplOptions.NoInlining)]
437 public static void ss7_3 () {
438 throw new Exception ();
441 [MethodImplAttribute (MethodImplOptions.NoInlining)]
442 public static void ss_nested () {
443 ss_nested_1 (ss_nested_2 ());
444 ss_nested_1 (ss_nested_2 ());
448 [MethodImplAttribute (MethodImplOptions.NoInlining)]
449 public static void ss_nested_1 (int i) {
452 [MethodImplAttribute (MethodImplOptions.NoInlining)]
453 public static int ss_nested_2 () {
457 [MethodImplAttribute (MethodImplOptions.NoInlining)]
458 public static void ss_nested_3 () {
461 [MethodImplAttribute (MethodImplOptions.NoInlining)]
462 public static void ss_step_through () {
464 StepThroughClass.step_through_2 ();
468 [DebuggerStepThrough]
469 [MethodImplAttribute (MethodImplOptions.NoInlining)]
470 public static void step_through_1 () {
473 [DebuggerStepThrough]
474 class StepThroughClass {
475 [MethodImplAttribute (MethodImplOptions.NoInlining)]
476 public static void step_through_2 () {
480 [DebuggerStepThrough]
481 [MethodImplAttribute (MethodImplOptions.NoInlining)]
482 public static void step_through_3 () {
485 [MethodImplAttribute (MethodImplOptions.NoInlining)]
486 public static void ss_non_user_code () {
488 StepNonUserCodeClass.non_user_code_2 ();
492 [DebuggerNonUserCode]
493 [MethodImplAttribute (MethodImplOptions.NoInlining)]
494 public static void non_user_code_1 () {
497 [DebuggerNonUserCode]
498 class StepNonUserCodeClass {
499 [MethodImplAttribute (MethodImplOptions.NoInlining)]
500 public static void non_user_code_2 () {
504 [DebuggerNonUserCode]
505 [MethodImplAttribute (MethodImplOptions.NoInlining)]
506 public static void non_user_code_3 () {
509 [MethodImplAttribute (MethodImplOptions.NoInlining)]
510 public static void ss_recursive (int n) {
513 ss_recursive (n + 1);
516 [MethodImplAttribute (MethodImplOptions.NoInlining)]
517 public static void ss_fp_clobber () {
518 double v = ss_fp_clobber_1 (5.0);
522 [MethodImplAttribute (MethodImplOptions.NoInlining)]
523 public static double ss_fp_clobber_1 (double d) {
527 [MethodImplAttribute (MethodImplOptions.NoInlining)]
528 public static void ss_fp_clobber_2 (double d) {
531 [MethodImplAttribute (MethodImplOptions.NoInlining)]
532 public static bool is_even (int i) {
538 Console.WriteLine ("HIT!");
544 [MethodImplAttribute (MethodImplOptions.NoInlining)]
545 public static void arguments () {
546 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));
548 arg2 ("FOO", null, "BLA", ref i, new GClass <int> { field = 42 }, new object ());
549 Tests t = new Tests () { field_i = 42, field_s = "S" };
553 [MethodImplAttribute (MethodImplOptions.NoInlining)]
554 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) {
555 return (int)(sb + b + (bl ? 0 : 1) + s + us + (int)c + i + ui + l + (long)ul + f + d + (int)ip + (int)uip);
558 [MethodImplAttribute (MethodImplOptions.NoInlining)]
559 public static string arg2 (string s, string s3, object o, ref int i, GClass <int> gc, object o2) {
560 return s + (s3 != null ? "" : "") + o + i + gc.field + o2;
563 [MethodImplAttribute (MethodImplOptions.NoInlining)]
564 public object arg3 (string s) {
565 return s + s + s + s + this;
568 [MethodImplAttribute (MethodImplOptions.NoInlining)]
569 public static void objects () {
570 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 };
571 t.o1 (new Tests2 () { field_j = 43 }, new GClass <int> { field = 42 }, new GClass <string> { field = "FOO" });
572 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 });
575 [MethodImplAttribute (MethodImplOptions.NoInlining)]
576 public object o1 (Tests2 t, GClass <int> gc1, GClass <string> gc2) {
577 if (t == null || gc1 == null || gc2 == null)
583 [MethodImplAttribute (MethodImplOptions.NoInlining)]
584 public static string o2 (string[] s2, int[] s3, int[,] s4, int[,] s5, IList<int> s6) {
585 return s2 [0] + s3 [0] + s4 [0, 0] + s6 [0];
588 [MethodImplAttribute (MethodImplOptions.NoInlining)]
589 public static void objrefs () {
590 Tests t = new Tests () {};
598 [MethodImplAttribute (MethodImplOptions.NoInlining)]
599 public static void set_child (Tests t) {
600 t.child = new Tests ();
603 [MethodImplAttribute (MethodImplOptions.NoInlining)]
604 public void objrefs1 () {
607 [MethodImplAttribute (MethodImplOptions.NoInlining)]
608 public static void objrefs2 () {
611 public static void vtypes () {
612 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 ) };
613 AStruct s = new AStruct { i = 44, s = "T", k = 45 };
614 AStruct[] arr = new AStruct[] {
615 new AStruct () { i = 1, s = "S1" },
616 new AStruct () { i = 2, s = "S2" } };
622 [MethodImplAttribute (MethodImplOptions.NoInlining)]
623 public object vtypes1 (AStruct s, AStruct[] arr) {
630 [MethodImplAttribute (MethodImplOptions.NoInlining)]
631 public static void vtypes2 (AStruct s) {
635 [MethodImplAttribute (MethodImplOptions.NoInlining)]
636 public static void vtypes3 (AStruct s) {
637 AStruct.static_foo (5);
640 [MethodImplAttribute (MethodImplOptions.NoInlining)]
641 public static void locals () {
643 var astruct = new AStruct () { i = 42 };
645 locals2<string> (null, 5, "ABC", ref s, ref astruct);
651 [MethodImplAttribute (MethodImplOptions.NoInlining)]
652 static void locals11 (double a, ref double b) {
655 [MethodImplAttribute (MethodImplOptions.NoInlining)]
656 public static void locals1 (string[] args) {
660 locals11 (b: ref ri, a: ri);
662 for (int j = 0; j < 10; ++j) {
667 [MethodImplAttribute (MethodImplOptions.NoInlining)]
669 [StateMachine (typeof (int))]
671 public static void locals2<T> (string[] args, int arg, T t, ref string rs, ref AStruct astruct) {
675 for (int j = 0; j < 10; ++j) {
680 astruct = new AStruct ();
686 [MethodImplAttribute (MethodImplOptions.NoInlining)]
687 public static void locals3 () {
707 [MethodImplAttribute (MethodImplOptions.NoInlining)]
708 public static void locals4 () {
711 [MethodImplAttribute (MethodImplOptions.NoInlining)]
712 public static void locals5 () {
715 [MethodImplAttribute (MethodImplOptions.NoInlining)]
716 public static void locals6 () {
719 for (i = 0; i < 10; ++i)
722 for (i = 0; i < 10; ++i)
732 [MethodImplAttribute (MethodImplOptions.NoInlining)]
733 public static void locals6_1 () {
736 [MethodImplAttribute (MethodImplOptions.NoInlining)]
737 public static void locals6_2 (int arg) {
740 [MethodImplAttribute (MethodImplOptions.NoInlining)]
741 public static void locals6_3 () {
742 // Clobber all registers
743 int sum = 0, i, j, k, l, m;
744 for (i = 0; i < 100; ++i)
746 for (j = 0; j < 100; ++j)
748 for (k = 0; k < 100; ++k)
750 for (l = 0; l < 100; ++l)
752 for (m = 0; m < 100; ++m)
756 [MethodImplAttribute (MethodImplOptions.NoInlining)]
757 public static void locals6_4 (int arg) {
760 [MethodImplAttribute (MethodImplOptions.NoInlining)]
761 public static void locals6_5 () {
764 [MethodImplAttribute (MethodImplOptions.NoInlining)]
765 public static void locals6_6 (int arg) {
768 [MethodImplAttribute (MethodImplOptions.NoInlining)]
769 public static void locals7<T> (T arg) {
774 [MethodImplAttribute (MethodImplOptions.NoInlining)]
775 public static void line_numbers () {
779 [MethodImplAttribute (MethodImplOptions.NoInlining)]
780 public static void suspend () {
788 [MethodImplAttribute (MethodImplOptions.NoInlining)]
789 public static void type_info () {
790 Tests t = new Tests () { field_i = 42, field_s = "S", base_field_i = 43, base_field_s = "T", field_enum = AnEnum.B };
791 t.ti1 (new Tests2 () { field_j = 43 }, new GClass <int> { field = 42 }, new GClass <string> { field = "FOO" });
794 AStruct s = new AStruct () { i = 42, s = "S", k = 43 };
796 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);
800 [MethodImplAttribute (MethodImplOptions.NoInlining)]
801 public object ti1 (Tests2 t, GClass <int> gc1, GClass <string> gc2) {
802 if (t == null || gc1 == null || gc2 == null)
808 [MethodImplAttribute (MethodImplOptions.NoInlining)]
809 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) {
810 return s2 [0] + s3 [0] + s4 [0, 0];
813 [MethodImplAttribute (MethodImplOptions.NoInlining)]
814 public static void assembly_load () {
818 [MethodImplAttribute (MethodImplOptions.NoInlining)]
819 public static void assembly_load_2 () {
820 // This will load System.dll while holding the loader lock
824 [MethodImplAttribute (MethodImplOptions.NoInlining)]
825 public static void invoke () {
826 new Tests ().invoke1 (new Tests2 (), new AStruct () { i = 42, j = (IntPtr)43 }, new GStruct<int> { j = 42 });
827 new Tests ().invoke_ex ();
830 [MethodImplAttribute (MethodImplOptions.NoInlining)]
831 public void invoke1 (Tests2 t, AStruct s, GStruct<int> g) {
835 [MethodImplAttribute (MethodImplOptions.NoInlining)]
836 public void invoke2 () {
839 [MethodImplAttribute (MethodImplOptions.NoInlining)]
840 public void invoke_ex () {
844 [MethodImplAttribute (MethodImplOptions.NoInlining)]
845 public void invoke_ex_inner () {
847 throw new Exception ();
854 [MethodImplAttribute (MethodImplOptions.NoInlining)]
855 public void invoke_single_threaded () {
856 // Spawn a thread incrementing a counter
857 bool finished = false;
859 new Thread (delegate () {
866 invoke_single_threaded_2 ();
871 [MethodImplAttribute (MethodImplOptions.NoInlining)]
872 public void invoke_single_threaded_2 () {
875 public void invoke_return_void () {
878 public string invoke_return_ref () {
882 public object invoke_return_null () {
886 public int invoke_return_primitive () {
890 public int? invoke_return_nullable () {
894 public int? invoke_return_nullable_null () {
898 public void invoke_type_load () {
905 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) {
906 return ub + sb + ss + us + i + ui + l + (long)ul + (int)c + (b ? 1 : 0) + (int)f + (int)d;
909 public int invoke_pass_primitive2 (bool b) {
913 public string invoke_pass_ref (string s) {
917 public static string invoke_static_pass_ref (string s) {
921 public static void invoke_static_return_void () {
924 public static void invoke_throws () {
925 throw new Exception ();
928 public int invoke_iface () {
932 [MethodImplAttribute (MethodImplOptions.NoInlining)]
933 public static void exceptions () {
935 throw new OverflowException ();
936 } catch (Exception) {
939 throw new OverflowException ();
940 } catch (Exception) {
943 throw new ArgumentException ();
944 } catch (Exception) {
947 throw new OverflowException ();
948 } catch (Exception) {
952 throw new OverflowException ();
953 } catch (Exception) {
956 throw new Exception ();
957 } catch (Exception) {
963 } catch (Exception) {
968 } catch (Exception) {
972 [MethodImplAttribute (MethodImplOptions.NoInlining)]
973 public static void unhandled_exception () {
974 ThreadPool.QueueUserWorkItem (delegate {
975 throw new InvalidOperationException ();
977 Thread.Sleep (10000);
980 [MethodImplAttribute (MethodImplOptions.NoInlining)]
981 public static void unhandled_exception_endinvoke_2 () {
984 [MethodImplAttribute (MethodImplOptions.NoInlining)]
985 public static void unhandled_exception_endinvoke () {
986 Action action = new Action (() =>
988 throw new Exception ("thrown");
990 action.BeginInvoke ((ar) => {
992 action.EndInvoke (ar);
993 } catch (Exception ex) {
994 //Console.WriteLine (ex);
998 unhandled_exception_endinvoke_2 ();
1001 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1002 public static void unhandled_exception_user () {
1004 System.Threading.Tasks.Task.Factory.StartNew (() => {
1007 Thread.Sleep (10000);
1011 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1012 public static void Throw () {
1013 throw new Exception ();
1016 internal static Delegate create_filter_delegate (Delegate dlg, MethodInfo filter_method)
1019 throw new ArgumentNullException ();
1020 if (dlg.Target != null)
1021 throw new ArgumentException ();
1022 if (dlg.Method == null)
1023 throw new ArgumentException ();
1025 var ret_type = dlg.Method.ReturnType;
1026 var param_types = dlg.Method.GetParameters ().Select (x => x.ParameterType).ToArray ();
1028 var dynamic = new DynamicMethod (Guid.NewGuid ().ToString (), ret_type, param_types, typeof (object), true);
1029 var ig = dynamic.GetILGenerator ();
1031 LocalBuilder retval = null;
1032 if (ret_type != typeof (void))
1033 retval = ig.DeclareLocal (ret_type);
1035 var label = ig.BeginExceptionBlock ();
1037 for (int i = 0; i < param_types.Length; i++)
1038 ig.Emit (OpCodes.Ldarg, i);
1039 ig.Emit (OpCodes.Call, dlg.Method);
1042 ig.Emit (OpCodes.Stloc, retval);
1044 ig.Emit (OpCodes.Leave, label);
1046 ig.BeginExceptFilterBlock ();
1048 ig.Emit (OpCodes.Call, filter_method);
1050 ig.BeginCatchBlock (null);
1052 ig.Emit (OpCodes.Pop);
1054 ig.EndExceptionBlock ();
1057 ig.Emit (OpCodes.Ldloc, retval);
1059 ig.Emit (OpCodes.Ret);
1061 return dynamic.CreateDelegate (dlg.GetType ());
1064 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1065 static void exception_filter_method () {
1066 throw new InvalidOperationException ();
1069 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1070 static int exception_filter_filter (Exception exc) {
1074 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1075 public static void exception_filter () {
1076 var method = typeof (Tests).GetMethod (
1077 "exception_filter_method", BindingFlags.NonPublic | BindingFlags.Static);
1078 var filter_method = typeof (Tests).GetMethod (
1079 "exception_filter_filter", BindingFlags.NonPublic | BindingFlags.Static);
1081 var dlg = Delegate.CreateDelegate (typeof (Action), method);
1083 var wrapper = (Action) create_filter_delegate (dlg, filter_method);
1088 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1089 public static bool return_true () {
1093 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1094 public static void exceptions2 () {
1096 throw new Exception ();
1097 Console.WriteLine ();
1100 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1101 public static void threads () {
1102 Thread t = new Thread (delegate () {});
1108 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1109 public static void domains () {
1110 AppDomain domain = AppDomain.CreateDomain ("domain");
1112 CrossDomain o = (CrossDomain)domain.CreateInstanceAndUnwrap (
1113 typeof (CrossDomain).Assembly.FullName, "CrossDomain");
1115 domains_2 (o, new CrossDomain ());
1123 AppDomain.Unload (domain);
1128 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1129 public static void domains_2 (object o, object o2) {
1132 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1133 public static void domains_3 () {
1136 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1137 public static void invoke_in_domain () {
1140 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1141 public static void invoke_in_domain_2 () {
1144 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1145 public static void dynamic_methods () {
1146 var m = new DynamicMethod ("dyn_method", typeof (void), new Type [] { typeof (int) }, typeof (object).Module);
1147 var ig = m.GetILGenerator ();
1149 ig.Emit (OpCodes.Ldstr, "FOO");
1150 ig.Emit (OpCodes.Call, typeof (Tests).GetMethod ("dyn_call"));
1151 ig.Emit (OpCodes.Ret);
1153 var del = (Action<int>)m.CreateDelegate (typeof (Action<int>));
1158 public static void dyn_call (string s) {
1161 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1162 public static void ref_emit () {
1163 AssemblyName assemblyName = new AssemblyName ();
1164 assemblyName.Name = "foo";
1166 AssemblyBuilder assembly =
1167 Thread.GetDomain ().DefineDynamicAssembly (
1168 assemblyName, AssemblyBuilderAccess.RunAndSave);
1170 ModuleBuilder module = assembly.DefineDynamicModule ("foo.dll");
1172 TypeBuilder tb = module.DefineType ("foo", TypeAttributes.Public, typeof (object));
1173 MethodBuilder mb = tb.DefineMethod ("ref_emit_method", MethodAttributes.Public|MethodAttributes.Static, CallingConventions.Standard, typeof (void), new Type [] { });
1174 ILGenerator ig = mb.GetILGenerator ();
1175 ig.Emit (OpCodes.Ldstr, "FOO");
1176 ig.Emit (OpCodes.Call, typeof (Tests).GetMethod ("ref_emit_call"));
1177 ig.Emit (OpCodes.Ret);
1179 Type t = tb.CreateType ();
1181 t.GetMethod ("ref_emit_method").Invoke (null, null);
1184 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1185 public static void ref_emit_call (string s) {
1188 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1189 public static void frames_in_native () {
1191 var evt = new ManualResetEvent (false);
1193 object mon = new object ();
1194 ThreadPool.QueueUserWorkItem (delegate {
1195 frames_in_native_2 ();
1201 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1202 static void frames_in_native_2 () {
1203 frames_in_native_3 ();
1206 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1207 static void frames_in_native_3 () {
1210 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1211 public static void string_call (string s) {
1214 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1215 public static void ss_regress_654694 () {
1222 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1223 public static void user () {
1226 Debugger.Log (5, Debugger.IsLogging () ? "A" : "", "B");
1229 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1230 public static void type_load () {
1234 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1235 static void type_load_2 () {
1236 var c1 = new Dictionary<int, int> ();
1238 var c = new TypeLoadClass ();
1240 var c2 = new TypeLoadClass2 ();
1244 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1245 public static void regress () {
1246 regress_2755 (DateTime.Now);
1249 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1250 public static unsafe void regress_2755 (DateTime d) {
1251 int* buffer = stackalloc int [128];
1256 for (int i = 0; i < 128; ++i)
1259 regress_2755_3 (sum);
1262 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1263 public static void regress_2755_2 () {
1266 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1267 public static void regress_2755_3 (int sum) {
1270 static object gc_suspend_field;
1272 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1273 static unsafe void set_gc_suspend_field () {
1274 set_gc_suspend_field_2 ();
1276 int* buffer = stackalloc int [4096];
1279 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1280 static void set_gc_suspend_field_2 () {
1281 gc_suspend_field = new object ();
1284 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1285 static void gc_suspend_1 () {
1288 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1289 public static void gc_suspend_invoke () {
1290 gc_suspend_field = null;
1292 GC.WaitForPendingFinalizers ();
1295 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1296 public static void gc_suspend () {
1297 set_gc_suspend_field ();
1301 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1302 public static void generic_method<T> () where T : class {
1305 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1306 public void evaluate_method_2 () {
1309 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1310 public void evaluate_method () {
1312 evaluate_method_2 ();
1315 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1316 static void set_ip_1 () {
1319 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1320 static void set_ip_2 () {
1323 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1324 public static void set_ip () {
1335 class TypeLoadClass {
1338 class TypeLoadClass2 {
1341 public class CrossDomain : MarshalByRefObject
1343 public void invoke () {
1344 Tests.invoke_in_domain ();
1347 public void invoke_2 () {
1348 Tests.invoke_in_domain_2 ();
1351 public int invoke_3 () {
1358 public ProcessStartInfo info;
1361 // Class used for line number info testing, don't change its layout
1362 public class LineNumbers
1364 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1365 public static void ln1 () {
1371 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1372 public static void ln2 () {
1375 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1376 public static void ln3 () {
1377 #pragma warning disable 0219
1379 #pragma warning restore 0219