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 () {
601 locals2<string> (null, 5, "ABC", ref s);
607 [MethodImplAttribute (MethodImplOptions.NoInlining)]
608 static void locals11 (double a, ref double b) {
611 [MethodImplAttribute (MethodImplOptions.NoInlining)]
612 public static void locals1 (string[] args) {
616 locals11 (b: ref ri, a: ri);
618 for (int j = 0; j < 10; ++j) {
623 [MethodImplAttribute (MethodImplOptions.NoInlining)]
625 [StateMachine (typeof (int))]
627 public static void locals2<T> (string[] args, int arg, T t, ref string rs) {
631 for (int j = 0; j < 10; ++j) {
641 [MethodImplAttribute (MethodImplOptions.NoInlining)]
642 public static void locals3 () {
662 [MethodImplAttribute (MethodImplOptions.NoInlining)]
663 public static void locals4 () {
666 [MethodImplAttribute (MethodImplOptions.NoInlining)]
667 public static void locals5 () {
670 [MethodImplAttribute (MethodImplOptions.NoInlining)]
671 public static void locals6 () {
674 for (i = 0; i < 10; ++i)
677 for (i = 0; i < 10; ++i)
687 [MethodImplAttribute (MethodImplOptions.NoInlining)]
688 public static void locals6_1 () {
691 [MethodImplAttribute (MethodImplOptions.NoInlining)]
692 public static void locals6_2 (int arg) {
695 [MethodImplAttribute (MethodImplOptions.NoInlining)]
696 public static void locals6_3 () {
697 // Clobber all registers
698 int sum = 0, i, j, k, l, m;
699 for (i = 0; i < 100; ++i)
701 for (j = 0; j < 100; ++j)
703 for (k = 0; k < 100; ++k)
705 for (l = 0; l < 100; ++l)
707 for (m = 0; m < 100; ++m)
711 [MethodImplAttribute (MethodImplOptions.NoInlining)]
712 public static void locals6_4 (int arg) {
715 [MethodImplAttribute (MethodImplOptions.NoInlining)]
716 public static void locals6_5 () {
719 [MethodImplAttribute (MethodImplOptions.NoInlining)]
720 public static void locals6_6 (int arg) {
723 [MethodImplAttribute (MethodImplOptions.NoInlining)]
724 public static void locals7<T> (T arg) {
729 [MethodImplAttribute (MethodImplOptions.NoInlining)]
730 public static void line_numbers () {
734 [MethodImplAttribute (MethodImplOptions.NoInlining)]
735 public static void suspend () {
743 [MethodImplAttribute (MethodImplOptions.NoInlining)]
744 public static void type_info () {
745 Tests t = new Tests () { field_i = 42, field_s = "S", base_field_i = 43, base_field_s = "T", field_enum = AnEnum.B };
746 t.ti1 (new Tests2 () { field_j = 43 }, new GClass <int> { field = 42 }, new GClass <string> { field = "FOO" });
749 AStruct s = new AStruct () { i = 42, s = "S", k = 43 };
751 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);
755 [MethodImplAttribute (MethodImplOptions.NoInlining)]
756 public object ti1 (Tests2 t, GClass <int> gc1, GClass <string> gc2) {
757 if (t == null || gc1 == null || gc2 == null)
763 [MethodImplAttribute (MethodImplOptions.NoInlining)]
764 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) {
765 return s2 [0] + s3 [0] + s4 [0, 0];
768 [MethodImplAttribute (MethodImplOptions.NoInlining)]
769 public static void assembly_load () {
773 [MethodImplAttribute (MethodImplOptions.NoInlining)]
774 public static void assembly_load_2 () {
775 // This will load System.dll while holding the loader lock
779 [MethodImplAttribute (MethodImplOptions.NoInlining)]
780 public static void invoke () {
781 new Tests ().invoke1 (new Tests2 (), new AStruct () { i = 42, j = (IntPtr)43 }, new GStruct<int> { j = 42 });
782 new Tests ().invoke_ex ();
785 [MethodImplAttribute (MethodImplOptions.NoInlining)]
786 public void invoke1 (Tests2 t, AStruct s, GStruct<int> g) {
790 [MethodImplAttribute (MethodImplOptions.NoInlining)]
791 public void invoke2 () {
794 [MethodImplAttribute (MethodImplOptions.NoInlining)]
795 public void invoke_ex () {
799 [MethodImplAttribute (MethodImplOptions.NoInlining)]
800 public void invoke_ex_inner () {
802 throw new Exception ();
809 [MethodImplAttribute (MethodImplOptions.NoInlining)]
810 public void invoke_single_threaded () {
811 // Spawn a thread incrementing a counter
812 bool finished = false;
814 new Thread (delegate () {
821 invoke_single_threaded_2 ();
826 [MethodImplAttribute (MethodImplOptions.NoInlining)]
827 public void invoke_single_threaded_2 () {
830 public void invoke_return_void () {
833 public string invoke_return_ref () {
837 public object invoke_return_null () {
841 public int invoke_return_primitive () {
845 public int? invoke_return_nullable () {
849 public int? invoke_return_nullable_null () {
853 public void invoke_type_load () {
860 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) {
861 return ub + sb + ss + us + i + ui + l + (long)ul + (int)c + (b ? 1 : 0) + (int)f + (int)d;
864 public int invoke_pass_primitive2 (bool b) {
868 public string invoke_pass_ref (string s) {
872 public static string invoke_static_pass_ref (string s) {
876 public static void invoke_static_return_void () {
879 public static void invoke_throws () {
880 throw new Exception ();
883 public int invoke_iface () {
887 [MethodImplAttribute (MethodImplOptions.NoInlining)]
888 public static void exceptions () {
890 throw new OverflowException ();
891 } catch (Exception) {
894 throw new OverflowException ();
895 } catch (Exception) {
898 throw new ArgumentException ();
899 } catch (Exception) {
902 throw new OverflowException ();
903 } catch (Exception) {
907 throw new OverflowException ();
908 } catch (Exception) {
911 throw new Exception ();
912 } catch (Exception) {
918 } catch (Exception) {
923 } catch (Exception) {
927 [MethodImplAttribute (MethodImplOptions.NoInlining)]
928 public static void unhandled_exception () {
929 ThreadPool.QueueUserWorkItem (delegate {
930 throw new InvalidOperationException ();
932 Thread.Sleep (10000);
935 [MethodImplAttribute (MethodImplOptions.NoInlining)]
936 public static void unhandled_exception_endinvoke_2 () {
939 [MethodImplAttribute (MethodImplOptions.NoInlining)]
940 public static void unhandled_exception_endinvoke () {
941 Action action = new Action (() =>
943 throw new Exception ("thrown");
945 action.BeginInvoke ((ar) => {
947 action.EndInvoke (ar);
948 } catch (Exception ex) {
949 //Console.WriteLine (ex);
953 unhandled_exception_endinvoke_2 ();
956 [MethodImplAttribute (MethodImplOptions.NoInlining)]
957 public static void unhandled_exception_user () {
959 System.Threading.Tasks.Task.Factory.StartNew (() => {
962 Thread.Sleep (10000);
966 [MethodImplAttribute (MethodImplOptions.NoInlining)]
967 public static void Throw () {
968 throw new Exception ();
971 internal static Delegate create_filter_delegate (Delegate dlg, MethodInfo filter_method)
974 throw new ArgumentNullException ();
975 if (dlg.Target != null)
976 throw new ArgumentException ();
977 if (dlg.Method == null)
978 throw new ArgumentException ();
980 var ret_type = dlg.Method.ReturnType;
981 var param_types = dlg.Method.GetParameters ().Select (x => x.ParameterType).ToArray ();
983 var dynamic = new DynamicMethod (Guid.NewGuid ().ToString (), ret_type, param_types, typeof (object), true);
984 var ig = dynamic.GetILGenerator ();
986 LocalBuilder retval = null;
987 if (ret_type != typeof (void))
988 retval = ig.DeclareLocal (ret_type);
990 var label = ig.BeginExceptionBlock ();
992 for (int i = 0; i < param_types.Length; i++)
993 ig.Emit (OpCodes.Ldarg, i);
994 ig.Emit (OpCodes.Call, dlg.Method);
997 ig.Emit (OpCodes.Stloc, retval);
999 ig.Emit (OpCodes.Leave, label);
1001 ig.BeginExceptFilterBlock ();
1003 ig.Emit (OpCodes.Call, filter_method);
1005 ig.BeginCatchBlock (null);
1007 ig.Emit (OpCodes.Pop);
1009 ig.EndExceptionBlock ();
1012 ig.Emit (OpCodes.Ldloc, retval);
1014 ig.Emit (OpCodes.Ret);
1016 return dynamic.CreateDelegate (dlg.GetType ());
1019 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1020 static void exception_filter_method () {
1021 throw new InvalidOperationException ();
1024 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1025 static int exception_filter_filter (Exception exc) {
1029 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1030 public static void exception_filter () {
1031 var method = typeof (Tests).GetMethod (
1032 "exception_filter_method", BindingFlags.NonPublic | BindingFlags.Static);
1033 var filter_method = typeof (Tests).GetMethod (
1034 "exception_filter_filter", BindingFlags.NonPublic | BindingFlags.Static);
1036 var dlg = Delegate.CreateDelegate (typeof (Action), method);
1038 var wrapper = (Action) create_filter_delegate (dlg, filter_method);
1043 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1044 public static bool return_true () {
1048 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1049 public static void exceptions2 () {
1051 throw new Exception ();
1052 Console.WriteLine ();
1055 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1056 public static void threads () {
1057 Thread t = new Thread (delegate () {});
1063 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1064 public static void domains () {
1065 AppDomain domain = AppDomain.CreateDomain ("domain");
1067 CrossDomain o = (CrossDomain)domain.CreateInstanceAndUnwrap (
1068 typeof (CrossDomain).Assembly.FullName, "CrossDomain");
1070 domains_2 (o, new CrossDomain ());
1078 AppDomain.Unload (domain);
1083 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1084 public static void domains_2 (object o, object o2) {
1087 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1088 public static void domains_3 () {
1091 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1092 public static void invoke_in_domain () {
1095 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1096 public static void invoke_in_domain_2 () {
1099 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1100 public static void dynamic_methods () {
1101 var m = new DynamicMethod ("dyn_method", typeof (void), new Type [] { typeof (int) }, typeof (object).Module);
1102 var ig = m.GetILGenerator ();
1104 ig.Emit (OpCodes.Ldstr, "FOO");
1105 ig.Emit (OpCodes.Call, typeof (Tests).GetMethod ("dyn_call"));
1106 ig.Emit (OpCodes.Ret);
1108 var del = (Action<int>)m.CreateDelegate (typeof (Action<int>));
1113 public static void dyn_call (string s) {
1116 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1117 public static void ref_emit () {
1118 AssemblyName assemblyName = new AssemblyName ();
1119 assemblyName.Name = "foo";
1121 AssemblyBuilder assembly =
1122 Thread.GetDomain ().DefineDynamicAssembly (
1123 assemblyName, AssemblyBuilderAccess.RunAndSave);
1125 ModuleBuilder module = assembly.DefineDynamicModule ("foo.dll");
1127 TypeBuilder tb = module.DefineType ("foo", TypeAttributes.Public, typeof (object));
1128 MethodBuilder mb = tb.DefineMethod ("ref_emit_method", MethodAttributes.Public|MethodAttributes.Static, CallingConventions.Standard, typeof (void), new Type [] { });
1129 ILGenerator ig = mb.GetILGenerator ();
1130 ig.Emit (OpCodes.Ldstr, "FOO");
1131 ig.Emit (OpCodes.Call, typeof (Tests).GetMethod ("ref_emit_call"));
1132 ig.Emit (OpCodes.Ret);
1134 Type t = tb.CreateType ();
1136 t.GetMethod ("ref_emit_method").Invoke (null, null);
1139 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1140 public static void ref_emit_call (string s) {
1143 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1144 public static void frames_in_native () {
1146 var evt = new ManualResetEvent (false);
1148 object mon = new object ();
1149 ThreadPool.QueueUserWorkItem (delegate {
1150 frames_in_native_2 ();
1156 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1157 static void frames_in_native_2 () {
1158 frames_in_native_3 ();
1161 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1162 static void frames_in_native_3 () {
1165 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1166 public static void string_call (string s) {
1169 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1170 public static void ss_regress_654694 () {
1177 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1178 public static void user () {
1181 Debugger.Log (5, Debugger.IsLogging () ? "A" : "", "B");
1184 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1185 public static void type_load () {
1189 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1190 static void type_load_2 () {
1191 var c1 = new Dictionary<int, int> ();
1193 var c = new TypeLoadClass ();
1195 var c2 = new TypeLoadClass2 ();
1199 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1200 public static void regress () {
1201 regress_2755 (DateTime.Now);
1204 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1205 public static unsafe void regress_2755 (DateTime d) {
1206 int* buffer = stackalloc int [128];
1211 for (int i = 0; i < 128; ++i)
1214 regress_2755_3 (sum);
1217 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1218 public static void regress_2755_2 () {
1221 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1222 public static void regress_2755_3 (int sum) {
1225 static object gc_suspend_field;
1227 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1228 static unsafe void set_gc_suspend_field () {
1229 set_gc_suspend_field_2 ();
1231 int* buffer = stackalloc int [4096];
1234 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1235 static void set_gc_suspend_field_2 () {
1236 gc_suspend_field = new object ();
1239 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1240 static void gc_suspend_1 () {
1243 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1244 public static void gc_suspend_invoke () {
1245 gc_suspend_field = null;
1247 GC.WaitForPendingFinalizers ();
1250 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1251 public static void gc_suspend () {
1252 set_gc_suspend_field ();
1256 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1257 public static void generic_method<T> () where T : class {
1261 class TypeLoadClass {
1264 class TypeLoadClass2 {
1267 public class CrossDomain : MarshalByRefObject
1269 public void invoke () {
1270 Tests.invoke_in_domain ();
1273 public void invoke_2 () {
1274 Tests.invoke_in_domain_2 ();
1277 public int invoke_3 () {
1284 public ProcessStartInfo info;
1287 // Class used for line number info testing, don't change its layout
1288 public class LineNumbers
1290 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1291 public static void ln1 () {
1297 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1298 public static void ln2 () {
1301 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1302 public static void ln3 () {
1303 #pragma warning disable 0219
1305 #pragma warning restore 0219