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 ();
365 [MethodImplAttribute (MethodImplOptions.NoInlining)]
366 public static void ss1 () {
369 [MethodImplAttribute (MethodImplOptions.NoInlining)]
370 public static void ss2 () {
373 [MethodImplAttribute (MethodImplOptions.NoInlining)]
374 public static int ss3 () {
377 for (int i = 0; i < 10; ++i)
383 [MethodImplAttribute (MethodImplOptions.NoInlining)]
384 public static void ss3_2 () {
388 [MethodImplAttribute (MethodImplOptions.NoInlining)]
389 public static void ss3_2_2 () {
392 [MethodImplAttribute (MethodImplOptions.NoInlining)]
393 public static int ss4 () {
399 [MethodImplAttribute (MethodImplOptions.NoInlining)]
400 public static void ss5 (int[] arr, Func<int, bool> selector) {
401 // Call into linq which calls back into this assembly
402 arr.Count (selector);
405 [MethodImplAttribute (MethodImplOptions.NoInlining)]
406 public static void ss6 (bool b) {
409 throw new Exception ();
413 [MethodImplAttribute (MethodImplOptions.NoInlining)]
414 public static void ss6_2 () {
417 [MethodImplAttribute (MethodImplOptions.NoInlining)]
418 public static void ss7 () {
427 [MethodImplAttribute (MethodImplOptions.NoInlining)]
428 public static void ss7_2 () {
431 [MethodImplAttribute (MethodImplOptions.NoInlining)]
432 public static void ss7_3 () {
433 throw new Exception ();
436 [MethodImplAttribute (MethodImplOptions.NoInlining)]
437 public static void ss_nested () {
438 ss_nested_1 (ss_nested_2 ());
439 ss_nested_1 (ss_nested_2 ());
443 [MethodImplAttribute (MethodImplOptions.NoInlining)]
444 public static void ss_nested_1 (int i) {
447 [MethodImplAttribute (MethodImplOptions.NoInlining)]
448 public static int ss_nested_2 () {
452 [MethodImplAttribute (MethodImplOptions.NoInlining)]
453 public static void ss_nested_3 () {
456 [MethodImplAttribute (MethodImplOptions.NoInlining)]
457 public static void ss_step_through () {
459 StepThroughClass.step_through_2 ();
463 [DebuggerStepThrough]
464 [MethodImplAttribute (MethodImplOptions.NoInlining)]
465 public static void step_through_1 () {
468 [DebuggerStepThrough]
469 class StepThroughClass {
470 [MethodImplAttribute (MethodImplOptions.NoInlining)]
471 public static void step_through_2 () {
475 [DebuggerStepThrough]
476 [MethodImplAttribute (MethodImplOptions.NoInlining)]
477 public static void step_through_3 () {
480 [MethodImplAttribute (MethodImplOptions.NoInlining)]
481 public static bool is_even (int i) {
487 Console.WriteLine ("HIT!");
493 [MethodImplAttribute (MethodImplOptions.NoInlining)]
494 public static void arguments () {
495 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));
497 arg2 ("FOO", null, "BLA", ref i, new GClass <int> { field = 42 }, new object ());
498 Tests t = new Tests () { field_i = 42, field_s = "S" };
502 [MethodImplAttribute (MethodImplOptions.NoInlining)]
503 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) {
504 return (int)(sb + b + (bl ? 0 : 1) + s + us + (int)c + i + ui + l + (long)ul + f + d + (int)ip + (int)uip);
507 [MethodImplAttribute (MethodImplOptions.NoInlining)]
508 public static string arg2 (string s, string s3, object o, ref int i, GClass <int> gc, object o2) {
509 return s + (s3 != null ? "" : "") + o + i + gc.field + o2;
512 [MethodImplAttribute (MethodImplOptions.NoInlining)]
513 public object arg3 (string s) {
514 return s + s + s + s + this;
517 [MethodImplAttribute (MethodImplOptions.NoInlining)]
518 public static void objects () {
519 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 };
520 t.o1 (new Tests2 () { field_j = 43 }, new GClass <int> { field = 42 }, new GClass <string> { field = "FOO" });
521 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 });
524 [MethodImplAttribute (MethodImplOptions.NoInlining)]
525 public object o1 (Tests2 t, GClass <int> gc1, GClass <string> gc2) {
526 if (t == null || gc1 == null || gc2 == null)
532 [MethodImplAttribute (MethodImplOptions.NoInlining)]
533 public static string o2 (string[] s2, int[] s3, int[,] s4, int[,] s5, IList<int> s6) {
534 return s2 [0] + s3 [0] + s4 [0, 0] + s6 [0];
537 [MethodImplAttribute (MethodImplOptions.NoInlining)]
538 public static void objrefs () {
539 Tests t = new Tests () {};
547 [MethodImplAttribute (MethodImplOptions.NoInlining)]
548 public static void set_child (Tests t) {
549 t.child = new Tests ();
552 [MethodImplAttribute (MethodImplOptions.NoInlining)]
553 public void objrefs1 () {
556 [MethodImplAttribute (MethodImplOptions.NoInlining)]
557 public static void objrefs2 () {
560 public static void vtypes () {
561 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 ) };
562 AStruct s = new AStruct { i = 44, s = "T", k = 45 };
563 AStruct[] arr = new AStruct[] {
564 new AStruct () { i = 1, s = "S1" },
565 new AStruct () { i = 2, s = "S2" } };
571 [MethodImplAttribute (MethodImplOptions.NoInlining)]
572 public object vtypes1 (AStruct s, AStruct[] arr) {
579 [MethodImplAttribute (MethodImplOptions.NoInlining)]
580 public static void vtypes2 (AStruct s) {
584 [MethodImplAttribute (MethodImplOptions.NoInlining)]
585 public static void vtypes3 (AStruct s) {
586 AStruct.static_foo (5);
589 [MethodImplAttribute (MethodImplOptions.NoInlining)]
590 public static void locals () {
593 locals2<string> (null, 5, "ABC", ref s);
599 [MethodImplAttribute (MethodImplOptions.NoInlining)]
600 static void locals11 (double a, ref double b) {
603 [MethodImplAttribute (MethodImplOptions.NoInlining)]
604 public static void locals1 (string[] args) {
608 locals11 (b: ref ri, a: ri);
610 for (int j = 0; j < 10; ++j) {
615 [MethodImplAttribute (MethodImplOptions.NoInlining)]
617 [StateMachine (typeof (int))]
619 public static void locals2<T> (string[] args, int arg, T t, ref string rs) {
623 for (int j = 0; j < 10; ++j) {
633 [MethodImplAttribute (MethodImplOptions.NoInlining)]
634 public static void locals3 () {
654 [MethodImplAttribute (MethodImplOptions.NoInlining)]
655 public static void locals4 () {
658 [MethodImplAttribute (MethodImplOptions.NoInlining)]
659 public static void locals5 () {
662 [MethodImplAttribute (MethodImplOptions.NoInlining)]
663 public static void locals6 () {
666 for (i = 0; i < 10; ++i)
669 for (i = 0; i < 10; ++i)
679 [MethodImplAttribute (MethodImplOptions.NoInlining)]
680 public static void locals6_1 () {
683 [MethodImplAttribute (MethodImplOptions.NoInlining)]
684 public static void locals6_2 (int arg) {
687 [MethodImplAttribute (MethodImplOptions.NoInlining)]
688 public static void locals6_3 () {
689 // Clobber all registers
690 int sum = 0, i, j, k, l, m;
691 for (i = 0; i < 100; ++i)
693 for (j = 0; j < 100; ++j)
695 for (k = 0; k < 100; ++k)
697 for (l = 0; l < 100; ++l)
699 for (m = 0; m < 100; ++m)
703 [MethodImplAttribute (MethodImplOptions.NoInlining)]
704 public static void locals6_4 (int arg) {
707 [MethodImplAttribute (MethodImplOptions.NoInlining)]
708 public static void locals6_5 () {
711 [MethodImplAttribute (MethodImplOptions.NoInlining)]
712 public static void locals6_6 (int arg) {
715 [MethodImplAttribute (MethodImplOptions.NoInlining)]
716 public static void locals7<T> (T arg) {
721 [MethodImplAttribute (MethodImplOptions.NoInlining)]
722 public static void line_numbers () {
726 [MethodImplAttribute (MethodImplOptions.NoInlining)]
727 public static void suspend () {
735 [MethodImplAttribute (MethodImplOptions.NoInlining)]
736 public static void type_info () {
737 Tests t = new Tests () { field_i = 42, field_s = "S", base_field_i = 43, base_field_s = "T", field_enum = AnEnum.B };
738 t.ti1 (new Tests2 () { field_j = 43 }, new GClass <int> { field = 42 }, new GClass <string> { field = "FOO" });
741 AStruct s = new AStruct () { i = 42, s = "S", k = 43 };
743 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);
747 [MethodImplAttribute (MethodImplOptions.NoInlining)]
748 public object ti1 (Tests2 t, GClass <int> gc1, GClass <string> gc2) {
749 if (t == null || gc1 == null || gc2 == null)
755 [MethodImplAttribute (MethodImplOptions.NoInlining)]
756 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) {
757 return s2 [0] + s3 [0] + s4 [0, 0];
760 [MethodImplAttribute (MethodImplOptions.NoInlining)]
761 public static void assembly_load () {
765 [MethodImplAttribute (MethodImplOptions.NoInlining)]
766 public static void assembly_load_2 () {
767 // This will load System.dll while holding the loader lock
771 [MethodImplAttribute (MethodImplOptions.NoInlining)]
772 public static void invoke () {
773 new Tests ().invoke1 (new Tests2 (), new AStruct () { i = 42, j = (IntPtr)43 }, new GStruct<int> { j = 42 });
774 new Tests ().invoke_ex ();
777 [MethodImplAttribute (MethodImplOptions.NoInlining)]
778 public void invoke1 (Tests2 t, AStruct s, GStruct<int> g) {
782 [MethodImplAttribute (MethodImplOptions.NoInlining)]
783 public void invoke2 () {
786 [MethodImplAttribute (MethodImplOptions.NoInlining)]
787 public void invoke_ex () {
791 [MethodImplAttribute (MethodImplOptions.NoInlining)]
792 public void invoke_ex_inner () {
794 throw new Exception ();
801 [MethodImplAttribute (MethodImplOptions.NoInlining)]
802 public void invoke_single_threaded () {
803 // Spawn a thread incrementing a counter
804 bool finished = false;
806 new Thread (delegate () {
813 invoke_single_threaded_2 ();
818 [MethodImplAttribute (MethodImplOptions.NoInlining)]
819 public void invoke_single_threaded_2 () {
822 public void invoke_return_void () {
825 public string invoke_return_ref () {
829 public object invoke_return_null () {
833 public int invoke_return_primitive () {
837 public int? invoke_return_nullable () {
841 public int? invoke_return_nullable_null () {
845 public void invoke_type_load () {
852 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) {
853 return ub + sb + ss + us + i + ui + l + (long)ul + (int)c + (b ? 1 : 0) + (int)f + (int)d;
856 public int invoke_pass_primitive2 (bool b) {
860 public string invoke_pass_ref (string s) {
864 public static string invoke_static_pass_ref (string s) {
868 public static void invoke_static_return_void () {
871 public static void invoke_throws () {
872 throw new Exception ();
875 public int invoke_iface () {
879 [MethodImplAttribute (MethodImplOptions.NoInlining)]
880 public static void exceptions () {
882 throw new OverflowException ();
883 } catch (Exception) {
886 throw new OverflowException ();
887 } catch (Exception) {
890 throw new ArgumentException ();
891 } catch (Exception) {
894 throw new OverflowException ();
895 } catch (Exception) {
899 throw new OverflowException ();
900 } catch (Exception) {
903 throw new Exception ();
904 } catch (Exception) {
910 } catch (Exception) {
915 } catch (Exception) {
919 [MethodImplAttribute (MethodImplOptions.NoInlining)]
920 public static void unhandled_exception () {
921 ThreadPool.QueueUserWorkItem (delegate {
922 throw new InvalidOperationException ();
924 Thread.Sleep (10000);
927 [MethodImplAttribute (MethodImplOptions.NoInlining)]
928 public static void unhandled_exception_endinvoke_2 () {
931 [MethodImplAttribute (MethodImplOptions.NoInlining)]
932 public static void unhandled_exception_endinvoke () {
933 Action action = new Action (() =>
935 throw new Exception ("thrown");
937 action.BeginInvoke ((ar) => {
939 action.EndInvoke (ar);
940 } catch (Exception ex) {
941 //Console.WriteLine (ex);
945 unhandled_exception_endinvoke_2 ();
948 [MethodImplAttribute (MethodImplOptions.NoInlining)]
949 public static void unhandled_exception_user () {
951 System.Threading.Tasks.Task.Factory.StartNew (() => {
954 Thread.Sleep (10000);
958 [MethodImplAttribute (MethodImplOptions.NoInlining)]
959 public static void Throw () {
960 throw new Exception ();
963 internal static Delegate create_filter_delegate (Delegate dlg, MethodInfo filter_method)
966 throw new ArgumentNullException ();
967 if (dlg.Target != null)
968 throw new ArgumentException ();
969 if (dlg.Method == null)
970 throw new ArgumentException ();
972 var ret_type = dlg.Method.ReturnType;
973 var param_types = dlg.Method.GetParameters ().Select (x => x.ParameterType).ToArray ();
975 var dynamic = new DynamicMethod (Guid.NewGuid ().ToString (), ret_type, param_types, typeof (object), true);
976 var ig = dynamic.GetILGenerator ();
978 LocalBuilder retval = null;
979 if (ret_type != typeof (void))
980 retval = ig.DeclareLocal (ret_type);
982 var label = ig.BeginExceptionBlock ();
984 for (int i = 0; i < param_types.Length; i++)
985 ig.Emit (OpCodes.Ldarg, i);
986 ig.Emit (OpCodes.Call, dlg.Method);
989 ig.Emit (OpCodes.Stloc, retval);
991 ig.Emit (OpCodes.Leave, label);
993 ig.BeginExceptFilterBlock ();
995 ig.Emit (OpCodes.Call, filter_method);
997 ig.BeginCatchBlock (null);
999 ig.Emit (OpCodes.Pop);
1001 ig.EndExceptionBlock ();
1004 ig.Emit (OpCodes.Ldloc, retval);
1006 ig.Emit (OpCodes.Ret);
1008 return dynamic.CreateDelegate (dlg.GetType ());
1011 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1012 static void exception_filter_method () {
1013 throw new InvalidOperationException ();
1016 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1017 static int exception_filter_filter (Exception exc) {
1021 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1022 public static void exception_filter () {
1023 var method = typeof (Tests).GetMethod (
1024 "exception_filter_method", BindingFlags.NonPublic | BindingFlags.Static);
1025 var filter_method = typeof (Tests).GetMethod (
1026 "exception_filter_filter", BindingFlags.NonPublic | BindingFlags.Static);
1028 var dlg = Delegate.CreateDelegate (typeof (Action), method);
1030 var wrapper = (Action) create_filter_delegate (dlg, filter_method);
1035 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1036 public static bool return_true () {
1040 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1041 public static void exceptions2 () {
1043 throw new Exception ();
1044 Console.WriteLine ();
1047 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1048 public static void threads () {
1049 Thread t = new Thread (delegate () {});
1055 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1056 public static void domains () {
1057 AppDomain domain = AppDomain.CreateDomain ("domain");
1059 CrossDomain o = (CrossDomain)domain.CreateInstanceAndUnwrap (
1060 typeof (CrossDomain).Assembly.FullName, "CrossDomain");
1062 domains_2 (o, new CrossDomain ());
1070 AppDomain.Unload (domain);
1075 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1076 public static void domains_2 (object o, object o2) {
1079 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1080 public static void domains_3 () {
1083 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1084 public static void invoke_in_domain () {
1087 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1088 public static void invoke_in_domain_2 () {
1091 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1092 public static void dynamic_methods () {
1093 var m = new DynamicMethod ("dyn_method", typeof (void), new Type [] { typeof (int) }, typeof (object).Module);
1094 var ig = m.GetILGenerator ();
1096 ig.Emit (OpCodes.Ldstr, "FOO");
1097 ig.Emit (OpCodes.Call, typeof (Tests).GetMethod ("dyn_call"));
1098 ig.Emit (OpCodes.Ret);
1100 var del = (Action<int>)m.CreateDelegate (typeof (Action<int>));
1105 public static void dyn_call (string s) {
1108 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1109 public static void ref_emit () {
1110 AssemblyName assemblyName = new AssemblyName ();
1111 assemblyName.Name = "foo";
1113 AssemblyBuilder assembly =
1114 Thread.GetDomain ().DefineDynamicAssembly (
1115 assemblyName, AssemblyBuilderAccess.RunAndSave);
1117 ModuleBuilder module = assembly.DefineDynamicModule ("foo.dll");
1119 TypeBuilder tb = module.DefineType ("foo", TypeAttributes.Public, typeof (object));
1120 MethodBuilder mb = tb.DefineMethod ("ref_emit_method", MethodAttributes.Public|MethodAttributes.Static, CallingConventions.Standard, typeof (void), new Type [] { });
1121 ILGenerator ig = mb.GetILGenerator ();
1122 ig.Emit (OpCodes.Ldstr, "FOO");
1123 ig.Emit (OpCodes.Call, typeof (Tests).GetMethod ("ref_emit_call"));
1124 ig.Emit (OpCodes.Ret);
1126 Type t = tb.CreateType ();
1128 t.GetMethod ("ref_emit_method").Invoke (null, null);
1131 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1132 public static void ref_emit_call (string s) {
1135 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1136 public static void frames_in_native () {
1138 var evt = new ManualResetEvent (false);
1140 object mon = new object ();
1141 ThreadPool.QueueUserWorkItem (delegate {
1142 frames_in_native_2 ();
1148 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1149 static void frames_in_native_2 () {
1150 frames_in_native_3 ();
1153 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1154 static void frames_in_native_3 () {
1157 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1158 public static void string_call (string s) {
1161 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1162 public static void ss_regress_654694 () {
1169 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1170 public static void user () {
1173 Debugger.Log (5, Debugger.IsLogging () ? "A" : "", "B");
1176 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1177 public static void type_load () {
1181 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1182 static void type_load_2 () {
1183 var c1 = new Dictionary<int, int> ();
1185 var c = new TypeLoadClass ();
1187 var c2 = new TypeLoadClass2 ();
1191 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1192 public static void regress () {
1193 regress_2755 (DateTime.Now);
1196 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1197 public static unsafe void regress_2755 (DateTime d) {
1198 int* buffer = stackalloc int [128];
1203 for (int i = 0; i < 128; ++i)
1206 regress_2755_3 (sum);
1209 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1210 public static void regress_2755_2 () {
1213 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1214 public static void regress_2755_3 (int sum) {
1217 static object gc_suspend_field;
1219 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1220 static unsafe void set_gc_suspend_field () {
1221 set_gc_suspend_field_2 ();
1223 int* buffer = stackalloc int [4096];
1226 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1227 static void set_gc_suspend_field_2 () {
1228 gc_suspend_field = new object ();
1231 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1232 static void gc_suspend_1 () {
1235 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1236 public static void gc_suspend_invoke () {
1237 gc_suspend_field = null;
1239 GC.WaitForPendingFinalizers ();
1242 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1243 public static void gc_suspend () {
1244 set_gc_suspend_field ();
1248 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1249 public static void generic_method<T> () where T : class {
1253 class TypeLoadClass {
1256 class TypeLoadClass2 {
1259 public class CrossDomain : MarshalByRefObject
1261 public void invoke () {
1262 Tests.invoke_in_domain ();
1265 public void invoke_2 () {
1266 Tests.invoke_in_domain_2 ();
1269 public int invoke_3 () {
1276 public ProcessStartInfo info;
1279 // Class used for line number info testing, don't change its layout
1280 public class LineNumbers
1282 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1283 public static void ln1 () {
1289 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1290 public static void ln2 () {
1293 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1294 public static void ln3 () {
1295 #pragma warning disable 0219
1297 #pragma warning restore 0219