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") {
287 if (args.Length > 0 && args [0] == "domain-test")
288 /* This takes a lot of time, so execute it conditionally */
290 if (args.Length > 0 && args [0] == "ref-emit-test")
292 if (args.Length > 0 && args [0] == "frames-in-native")
294 if (args.Length > 0 && args [0] == "invoke-single-threaded")
295 new Tests ().invoke_single_threaded ();
299 public static void breakpoints () {
300 /* Call these early so it is JITted by the time a breakpoint is placed on it */
312 bp6<string> (new GClass <int> ());
317 [MethodImplAttribute (MethodImplOptions.NoInlining)]
318 public static void bp1 () {
321 [MethodImplAttribute (MethodImplOptions.NoInlining)]
322 public static void bp2 () {
325 [MethodImplAttribute (MethodImplOptions.NoInlining)]
326 public static void bp3 () {
329 [MethodImplAttribute (MethodImplOptions.NoInlining)]
330 public static void bp4 () {
333 [MethodImplAttribute (MethodImplOptions.NoInlining)]
334 public static void bp5 () {
337 [MethodImplAttribute (MethodImplOptions.NoInlining)]
338 public static void bp6<T> (GClass<int> gc) {
342 [MethodImplAttribute (MethodImplOptions.NoInlining)]
343 public static void bp7<T> () {
346 [MethodImplAttribute (MethodImplOptions.NoInlining)]
347 public static void single_stepping () {
354 ss5 (new int [] { 1, 2, 3 }, new Func<int, bool> (is_even));
361 ss_regress_654694 ();
366 [MethodImplAttribute (MethodImplOptions.NoInlining)]
367 public static void ss1 () {
370 [MethodImplAttribute (MethodImplOptions.NoInlining)]
371 public static void ss2 () {
374 [MethodImplAttribute (MethodImplOptions.NoInlining)]
375 public static int ss3 () {
378 for (int i = 0; i < 10; ++i)
384 [MethodImplAttribute (MethodImplOptions.NoInlining)]
385 public static void ss3_2 () {
389 [MethodImplAttribute (MethodImplOptions.NoInlining)]
390 public static void ss3_2_2 () {
393 [MethodImplAttribute (MethodImplOptions.NoInlining)]
394 public static int ss4 () {
400 [MethodImplAttribute (MethodImplOptions.NoInlining)]
401 public static void ss5 (int[] arr, Func<int, bool> selector) {
402 // Call into linq which calls back into this assembly
403 arr.Count (selector);
406 [MethodImplAttribute (MethodImplOptions.NoInlining)]
407 public static void ss6 (bool b) {
410 throw new Exception ();
414 [MethodImplAttribute (MethodImplOptions.NoInlining)]
415 public static void ss6_2 () {
418 [MethodImplAttribute (MethodImplOptions.NoInlining)]
419 public static void ss7 () {
428 [MethodImplAttribute (MethodImplOptions.NoInlining)]
429 public static void ss7_2 () {
432 [MethodImplAttribute (MethodImplOptions.NoInlining)]
433 public static void ss7_3 () {
434 throw new Exception ();
437 [MethodImplAttribute (MethodImplOptions.NoInlining)]
438 public static void ss_nested () {
439 ss_nested_1 (ss_nested_2 ());
440 ss_nested_1 (ss_nested_2 ());
444 [MethodImplAttribute (MethodImplOptions.NoInlining)]
445 public static void ss_nested_1 (int i) {
448 [MethodImplAttribute (MethodImplOptions.NoInlining)]
449 public static int ss_nested_2 () {
453 [MethodImplAttribute (MethodImplOptions.NoInlining)]
454 public static void ss_nested_3 () {
457 [MethodImplAttribute (MethodImplOptions.NoInlining)]
458 public static void ss_step_through () {
460 StepThroughClass.step_through_2 ();
464 [DebuggerStepThrough]
465 [MethodImplAttribute (MethodImplOptions.NoInlining)]
466 public static void step_through_1 () {
469 [DebuggerStepThrough]
470 class StepThroughClass {
471 [MethodImplAttribute (MethodImplOptions.NoInlining)]
472 public static void step_through_2 () {
476 [DebuggerStepThrough]
477 [MethodImplAttribute (MethodImplOptions.NoInlining)]
478 public static void step_through_3 () {
481 [MethodImplAttribute (MethodImplOptions.NoInlining)]
482 public static void ss_recursive (int n) {
485 ss_recursive (n + 1);
488 [MethodImplAttribute (MethodImplOptions.NoInlining)]
489 public static bool is_even (int i) {
495 Console.WriteLine ("HIT!");
501 [MethodImplAttribute (MethodImplOptions.NoInlining)]
502 public static void arguments () {
503 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));
505 arg2 ("FOO", null, "BLA", ref i, new GClass <int> { field = 42 }, new object ());
506 Tests t = new Tests () { field_i = 42, field_s = "S" };
510 [MethodImplAttribute (MethodImplOptions.NoInlining)]
511 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) {
512 return (int)(sb + b + (bl ? 0 : 1) + s + us + (int)c + i + ui + l + (long)ul + f + d + (int)ip + (int)uip);
515 [MethodImplAttribute (MethodImplOptions.NoInlining)]
516 public static string arg2 (string s, string s3, object o, ref int i, GClass <int> gc, object o2) {
517 return s + (s3 != null ? "" : "") + o + i + gc.field + o2;
520 [MethodImplAttribute (MethodImplOptions.NoInlining)]
521 public object arg3 (string s) {
522 return s + s + s + s + this;
525 [MethodImplAttribute (MethodImplOptions.NoInlining)]
526 public static void objects () {
527 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 };
528 t.o1 (new Tests2 () { field_j = 43 }, new GClass <int> { field = 42 }, new GClass <string> { field = "FOO" });
529 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 });
532 [MethodImplAttribute (MethodImplOptions.NoInlining)]
533 public object o1 (Tests2 t, GClass <int> gc1, GClass <string> gc2) {
534 if (t == null || gc1 == null || gc2 == null)
540 [MethodImplAttribute (MethodImplOptions.NoInlining)]
541 public static string o2 (string[] s2, int[] s3, int[,] s4, int[,] s5, IList<int> s6) {
542 return s2 [0] + s3 [0] + s4 [0, 0] + s6 [0];
545 [MethodImplAttribute (MethodImplOptions.NoInlining)]
546 public static void objrefs () {
547 Tests t = new Tests () {};
555 [MethodImplAttribute (MethodImplOptions.NoInlining)]
556 public static void set_child (Tests t) {
557 t.child = new Tests ();
560 [MethodImplAttribute (MethodImplOptions.NoInlining)]
561 public void objrefs1 () {
564 [MethodImplAttribute (MethodImplOptions.NoInlining)]
565 public static void objrefs2 () {
568 public static void vtypes () {
569 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 ) };
570 AStruct s = new AStruct { i = 44, s = "T", k = 45 };
571 AStruct[] arr = new AStruct[] {
572 new AStruct () { i = 1, s = "S1" },
573 new AStruct () { i = 2, s = "S2" } };
579 [MethodImplAttribute (MethodImplOptions.NoInlining)]
580 public object vtypes1 (AStruct s, AStruct[] arr) {
587 [MethodImplAttribute (MethodImplOptions.NoInlining)]
588 public static void vtypes2 (AStruct s) {
592 [MethodImplAttribute (MethodImplOptions.NoInlining)]
593 public static void vtypes3 (AStruct s) {
594 AStruct.static_foo (5);
597 [MethodImplAttribute (MethodImplOptions.NoInlining)]
598 public static void locals () {
600 var astruct = new AStruct () { i = 42 };
602 locals2<string> (null, 5, "ABC", ref s, ref astruct);
608 [MethodImplAttribute (MethodImplOptions.NoInlining)]
609 static void locals11 (double a, ref double b) {
612 [MethodImplAttribute (MethodImplOptions.NoInlining)]
613 public static void locals1 (string[] args) {
617 locals11 (b: ref ri, a: ri);
619 for (int j = 0; j < 10; ++j) {
624 [MethodImplAttribute (MethodImplOptions.NoInlining)]
626 [StateMachine (typeof (int))]
628 public static void locals2<T> (string[] args, int arg, T t, ref string rs, ref AStruct astruct) {
632 for (int j = 0; j < 10; ++j) {
637 astruct = new AStruct ();
643 [MethodImplAttribute (MethodImplOptions.NoInlining)]
644 public static void locals3 () {
664 [MethodImplAttribute (MethodImplOptions.NoInlining)]
665 public static void locals4 () {
668 [MethodImplAttribute (MethodImplOptions.NoInlining)]
669 public static void locals5 () {
672 [MethodImplAttribute (MethodImplOptions.NoInlining)]
673 public static void locals6 () {
676 for (i = 0; i < 10; ++i)
679 for (i = 0; i < 10; ++i)
689 [MethodImplAttribute (MethodImplOptions.NoInlining)]
690 public static void locals6_1 () {
693 [MethodImplAttribute (MethodImplOptions.NoInlining)]
694 public static void locals6_2 (int arg) {
697 [MethodImplAttribute (MethodImplOptions.NoInlining)]
698 public static void locals6_3 () {
699 // Clobber all registers
700 int sum = 0, i, j, k, l, m;
701 for (i = 0; i < 100; ++i)
703 for (j = 0; j < 100; ++j)
705 for (k = 0; k < 100; ++k)
707 for (l = 0; l < 100; ++l)
709 for (m = 0; m < 100; ++m)
713 [MethodImplAttribute (MethodImplOptions.NoInlining)]
714 public static void locals6_4 (int arg) {
717 [MethodImplAttribute (MethodImplOptions.NoInlining)]
718 public static void locals6_5 () {
721 [MethodImplAttribute (MethodImplOptions.NoInlining)]
722 public static void locals6_6 (int arg) {
725 [MethodImplAttribute (MethodImplOptions.NoInlining)]
726 public static void locals7<T> (T arg) {
731 [MethodImplAttribute (MethodImplOptions.NoInlining)]
732 public static void line_numbers () {
736 [MethodImplAttribute (MethodImplOptions.NoInlining)]
737 public static void suspend () {
745 [MethodImplAttribute (MethodImplOptions.NoInlining)]
746 public static void type_info () {
747 Tests t = new Tests () { field_i = 42, field_s = "S", base_field_i = 43, base_field_s = "T", field_enum = AnEnum.B };
748 t.ti1 (new Tests2 () { field_j = 43 }, new GClass <int> { field = 42 }, new GClass <string> { field = "FOO" });
751 AStruct s = new AStruct () { i = 42, s = "S", k = 43 };
753 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);
757 [MethodImplAttribute (MethodImplOptions.NoInlining)]
758 public object ti1 (Tests2 t, GClass <int> gc1, GClass <string> gc2) {
759 if (t == null || gc1 == null || gc2 == null)
765 [MethodImplAttribute (MethodImplOptions.NoInlining)]
766 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) {
767 return s2 [0] + s3 [0] + s4 [0, 0];
770 [MethodImplAttribute (MethodImplOptions.NoInlining)]
771 public static void assembly_load () {
775 [MethodImplAttribute (MethodImplOptions.NoInlining)]
776 public static void assembly_load_2 () {
777 // This will load System.dll while holding the loader lock
781 [MethodImplAttribute (MethodImplOptions.NoInlining)]
782 public static void invoke () {
783 new Tests ().invoke1 (new Tests2 (), new AStruct () { i = 42, j = (IntPtr)43 }, new GStruct<int> { j = 42 });
784 new Tests ().invoke_ex ();
787 [MethodImplAttribute (MethodImplOptions.NoInlining)]
788 public void invoke1 (Tests2 t, AStruct s, GStruct<int> g) {
792 [MethodImplAttribute (MethodImplOptions.NoInlining)]
793 public void invoke2 () {
796 [MethodImplAttribute (MethodImplOptions.NoInlining)]
797 public void invoke_ex () {
801 [MethodImplAttribute (MethodImplOptions.NoInlining)]
802 public void invoke_ex_inner () {
804 throw new Exception ();
811 [MethodImplAttribute (MethodImplOptions.NoInlining)]
812 public void invoke_single_threaded () {
813 // Spawn a thread incrementing a counter
814 bool finished = false;
816 new Thread (delegate () {
823 invoke_single_threaded_2 ();
828 [MethodImplAttribute (MethodImplOptions.NoInlining)]
829 public void invoke_single_threaded_2 () {
832 public void invoke_return_void () {
835 public string invoke_return_ref () {
839 public object invoke_return_null () {
843 public int invoke_return_primitive () {
847 public int? invoke_return_nullable () {
851 public int? invoke_return_nullable_null () {
855 public void invoke_type_load () {
862 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) {
863 return ub + sb + ss + us + i + ui + l + (long)ul + (int)c + (b ? 1 : 0) + (int)f + (int)d;
866 public int invoke_pass_primitive2 (bool b) {
870 public string invoke_pass_ref (string s) {
874 public static string invoke_static_pass_ref (string s) {
878 public static void invoke_static_return_void () {
881 public static void invoke_throws () {
882 throw new Exception ();
885 public int invoke_iface () {
889 [MethodImplAttribute (MethodImplOptions.NoInlining)]
890 public static void exceptions () {
892 throw new OverflowException ();
893 } catch (Exception) {
896 throw new OverflowException ();
897 } catch (Exception) {
900 throw new ArgumentException ();
901 } catch (Exception) {
904 throw new OverflowException ();
905 } catch (Exception) {
909 throw new OverflowException ();
910 } catch (Exception) {
913 throw new Exception ();
914 } catch (Exception) {
920 } catch (Exception) {
925 } catch (Exception) {
929 [MethodImplAttribute (MethodImplOptions.NoInlining)]
930 public static void unhandled_exception () {
931 ThreadPool.QueueUserWorkItem (delegate {
932 throw new InvalidOperationException ();
934 Thread.Sleep (10000);
937 [MethodImplAttribute (MethodImplOptions.NoInlining)]
938 public static void unhandled_exception_endinvoke_2 () {
941 [MethodImplAttribute (MethodImplOptions.NoInlining)]
942 public static void unhandled_exception_endinvoke () {
943 Action action = new Action (() =>
945 throw new Exception ("thrown");
947 action.BeginInvoke ((ar) => {
949 action.EndInvoke (ar);
950 } catch (Exception ex) {
951 //Console.WriteLine (ex);
955 unhandled_exception_endinvoke_2 ();
958 [MethodImplAttribute (MethodImplOptions.NoInlining)]
959 public static void unhandled_exception_user () {
961 System.Threading.Tasks.Task.Factory.StartNew (() => {
964 Thread.Sleep (10000);
968 [MethodImplAttribute (MethodImplOptions.NoInlining)]
969 public static void Throw () {
970 throw new Exception ();
973 internal static Delegate create_filter_delegate (Delegate dlg, MethodInfo filter_method)
976 throw new ArgumentNullException ();
977 if (dlg.Target != null)
978 throw new ArgumentException ();
979 if (dlg.Method == null)
980 throw new ArgumentException ();
982 var ret_type = dlg.Method.ReturnType;
983 var param_types = dlg.Method.GetParameters ().Select (x => x.ParameterType).ToArray ();
985 var dynamic = new DynamicMethod (Guid.NewGuid ().ToString (), ret_type, param_types, typeof (object), true);
986 var ig = dynamic.GetILGenerator ();
988 LocalBuilder retval = null;
989 if (ret_type != typeof (void))
990 retval = ig.DeclareLocal (ret_type);
992 var label = ig.BeginExceptionBlock ();
994 for (int i = 0; i < param_types.Length; i++)
995 ig.Emit (OpCodes.Ldarg, i);
996 ig.Emit (OpCodes.Call, dlg.Method);
999 ig.Emit (OpCodes.Stloc, retval);
1001 ig.Emit (OpCodes.Leave, label);
1003 ig.BeginExceptFilterBlock ();
1005 ig.Emit (OpCodes.Call, filter_method);
1007 ig.BeginCatchBlock (null);
1009 ig.Emit (OpCodes.Pop);
1011 ig.EndExceptionBlock ();
1014 ig.Emit (OpCodes.Ldloc, retval);
1016 ig.Emit (OpCodes.Ret);
1018 return dynamic.CreateDelegate (dlg.GetType ());
1021 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1022 static void exception_filter_method () {
1023 throw new InvalidOperationException ();
1026 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1027 static int exception_filter_filter (Exception exc) {
1031 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1032 public static void exception_filter () {
1033 var method = typeof (Tests).GetMethod (
1034 "exception_filter_method", BindingFlags.NonPublic | BindingFlags.Static);
1035 var filter_method = typeof (Tests).GetMethod (
1036 "exception_filter_filter", BindingFlags.NonPublic | BindingFlags.Static);
1038 var dlg = Delegate.CreateDelegate (typeof (Action), method);
1040 var wrapper = (Action) create_filter_delegate (dlg, filter_method);
1045 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1046 public static bool return_true () {
1050 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1051 public static void exceptions2 () {
1053 throw new Exception ();
1054 Console.WriteLine ();
1057 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1058 public static void threads () {
1059 Thread t = new Thread (delegate () {});
1065 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1066 public static void domains () {
1067 AppDomain domain = AppDomain.CreateDomain ("domain");
1069 CrossDomain o = (CrossDomain)domain.CreateInstanceAndUnwrap (
1070 typeof (CrossDomain).Assembly.FullName, "CrossDomain");
1072 domains_2 (o, new CrossDomain ());
1080 AppDomain.Unload (domain);
1085 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1086 public static void domains_2 (object o, object o2) {
1089 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1090 public static void domains_3 () {
1093 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1094 public static void invoke_in_domain () {
1097 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1098 public static void invoke_in_domain_2 () {
1101 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1102 public static void dynamic_methods () {
1103 var m = new DynamicMethod ("dyn_method", typeof (void), new Type [] { typeof (int) }, typeof (object).Module);
1104 var ig = m.GetILGenerator ();
1106 ig.Emit (OpCodes.Ldstr, "FOO");
1107 ig.Emit (OpCodes.Call, typeof (Tests).GetMethod ("dyn_call"));
1108 ig.Emit (OpCodes.Ret);
1110 var del = (Action<int>)m.CreateDelegate (typeof (Action<int>));
1115 public static void dyn_call (string s) {
1118 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1119 public static void ref_emit () {
1120 AssemblyName assemblyName = new AssemblyName ();
1121 assemblyName.Name = "foo";
1123 AssemblyBuilder assembly =
1124 Thread.GetDomain ().DefineDynamicAssembly (
1125 assemblyName, AssemblyBuilderAccess.RunAndSave);
1127 ModuleBuilder module = assembly.DefineDynamicModule ("foo.dll");
1129 TypeBuilder tb = module.DefineType ("foo", TypeAttributes.Public, typeof (object));
1130 MethodBuilder mb = tb.DefineMethod ("ref_emit_method", MethodAttributes.Public|MethodAttributes.Static, CallingConventions.Standard, typeof (void), new Type [] { });
1131 ILGenerator ig = mb.GetILGenerator ();
1132 ig.Emit (OpCodes.Ldstr, "FOO");
1133 ig.Emit (OpCodes.Call, typeof (Tests).GetMethod ("ref_emit_call"));
1134 ig.Emit (OpCodes.Ret);
1136 Type t = tb.CreateType ();
1138 t.GetMethod ("ref_emit_method").Invoke (null, null);
1141 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1142 public static void ref_emit_call (string s) {
1145 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1146 public static void frames_in_native () {
1148 var evt = new ManualResetEvent (false);
1150 object mon = new object ();
1151 ThreadPool.QueueUserWorkItem (delegate {
1152 frames_in_native_2 ();
1158 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1159 static void frames_in_native_2 () {
1160 frames_in_native_3 ();
1163 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1164 static void frames_in_native_3 () {
1167 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1168 public static void string_call (string s) {
1171 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1172 public static void ss_regress_654694 () {
1179 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1180 public static void user () {
1183 Debugger.Log (5, Debugger.IsLogging () ? "A" : "", "B");
1186 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1187 public static void type_load () {
1191 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1192 static void type_load_2 () {
1193 var c1 = new Dictionary<int, int> ();
1195 var c = new TypeLoadClass ();
1197 var c2 = new TypeLoadClass2 ();
1201 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1202 public static void regress () {
1203 regress_2755 (DateTime.Now);
1206 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1207 public static unsafe void regress_2755 (DateTime d) {
1208 int* buffer = stackalloc int [128];
1213 for (int i = 0; i < 128; ++i)
1216 regress_2755_3 (sum);
1219 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1220 public static void regress_2755_2 () {
1223 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1224 public static void regress_2755_3 (int sum) {
1227 static object gc_suspend_field;
1229 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1230 static unsafe void set_gc_suspend_field () {
1231 set_gc_suspend_field_2 ();
1233 int* buffer = stackalloc int [4096];
1236 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1237 static void set_gc_suspend_field_2 () {
1238 gc_suspend_field = new object ();
1241 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1242 static void gc_suspend_1 () {
1245 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1246 public static void gc_suspend_invoke () {
1247 gc_suspend_field = null;
1249 GC.WaitForPendingFinalizers ();
1252 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1253 public static void gc_suspend () {
1254 set_gc_suspend_field ();
1258 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1259 public static void generic_method<T> () where T : class {
1263 class TypeLoadClass {
1266 class TypeLoadClass2 {
1269 public class CrossDomain : MarshalByRefObject
1271 public void invoke () {
1272 Tests.invoke_in_domain ();
1275 public void invoke_2 () {
1276 Tests.invoke_in_domain_2 ();
1279 public int invoke_3 () {
1286 public ProcessStartInfo info;
1289 // Class used for line number info testing, don't change its layout
1290 public class LineNumbers
1292 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1293 public static void ln1 () {
1299 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1300 public static void ln2 () {
1303 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1304 public static void ln3 () {
1305 #pragma warning disable 0219
1307 #pragma warning restore 0219