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 () {
147 class TestIfaces
: ITest
155 TestIfaces
<int> Baz () {
160 class TestIfaces
<T
> : ITest
<T
>
162 void ITest
<T
>.Foo () {
165 void ITest
<T
>.Bar () {
169 public class Tests
: TestsBase
171 #pragma warning disable 0414
175 bool field_bool1
, field_bool2
;
188 static int static_i
= 55;
189 static string static_s
= "A";
190 public const int literal_i
= 56;
191 public const string literal_s
= "B";
193 public AStruct field_struct
;
194 public object field_boxed_struct
;
195 public GStruct
<int> generic_field_struct
;
197 public static int tls_i
;
198 public static bool is_attached
= Debugger
.IsAttached
;
200 #pragma warning restore 0414
202 public class NestedClass
{
205 public int IntProperty
{
214 public int ReadOnlyProperty
{
220 public int this [int index
] {
226 public static int Main (String
[] args
) {
229 if (args
.Length
> 0 && args
[0] == "suspend-test")
230 /* This contains an infinite loop, so execute it conditionally */
232 if (args
.Length
>0 && args
[0] == "unhandled-exception") {
233 unhandled_exception ();
236 if (args
.Length
>0 && args
[0] == "unhandled-exception-endinvoke") {
237 unhandled_exception_endinvoke ();
240 if (args
.Length
>0 && args
[0] == "unhandled-exception-user") {
241 unhandled_exception_user ();
263 if (args
.Length
> 0 && args
[0] == "domain-test")
264 /* This takes a lot of time, so execute it conditionally */
266 if (args
.Length
> 0 && args
[0] == "ref-emit-test")
268 if (args
.Length
> 0 && args
[0] == "frames-in-native")
270 if (args
.Length
> 0 && args
[0] == "invoke-single-threaded")
271 new Tests ().invoke_single_threaded ();
275 public static void breakpoints () {
276 /* Call these early so it is JITted by the time a breakpoint is placed on it */
288 bp6
<string> (new GClass
<int> ());
293 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
294 public static void bp1 () {
297 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
298 public static void bp2 () {
301 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
302 public static void bp3 () {
305 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
306 public static void bp4 () {
309 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
310 public static void bp5 () {
313 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
314 public static void bp6
<T
> (GClass
<int> gc
) {
318 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
319 public static void bp7
<T
> () {
322 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
323 public static void single_stepping () {
330 ss5 (new int [] { 1, 2, 3 }
, new Func
<int, bool> (is_even
));
336 ss_regress_654694 ();
339 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
340 public static void ss1 () {
343 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
344 public static void ss2 () {
347 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
348 public static int ss3 () {
351 for (int i
= 0; i
< 10; ++i
)
357 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
358 public static void ss3_2 () {
362 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
363 public static void ss3_2_2 () {
366 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
367 public static int ss4 () {
373 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
374 public static void ss5 (int[] arr
, Func
<int, bool> selector
) {
375 // Call into linq which calls back into this assembly
376 arr
.Count (selector
);
379 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
380 public static void ss6 (bool b
) {
383 throw new Exception ();
387 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
388 public static void ss6_2 () {
391 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
392 public static void ss7 () {
401 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
402 public static void ss7_2 () {
405 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
406 public static void ss7_3 () {
407 throw new Exception ();
410 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
411 public static bool is_even (int i
) {
417 Console.WriteLine ("HIT!");
423 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
424 public static void arguments () {
425 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));
427 arg2 ("FOO", null, "BLA", ref i
, new GClass
<int> { field = 42 }
, new object ());
428 Tests t
= new Tests () { field_i = 42, field_s = "S" }
;
432 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
433 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
) {
434 return (int)(sb
+ b
+ (bl
? 0 : 1) + s
+ us
+ (int)c
+ i
+ ui
+ l
+ (long)ul
+ f
+ d
+ (int)ip
+ (int)uip
);
437 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
438 public static string arg2 (string s
, string s3
, object o
, ref int i
, GClass
<int> gc
, object o2
) {
439 return s
+ (s3
!= null ? "" : "") + o
+ i
+ gc
.field
+ o2
;
442 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
443 public object arg3 (string s
) {
444 return s
+ s
+ s
+ s
+ this;
447 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
448 public static void objects () {
449 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 }
;
450 t
.o1 (new Tests2 () { field_j = 43 }
, new GClass
<int> { field = 42 }
, new GClass
<string> { field = "FOO" }
);
451 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 }
);
454 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
455 public object o1 (Tests2 t
, GClass
<int> gc1
, GClass
<string> gc2
) {
456 if (t
== null || gc1
== null || gc2
== null)
462 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
463 public static string o2 (string[] s2
, int[] s3
, int[,] s4
, int[,] s5
, IList
<int> s6
) {
464 return s2
[0] + s3
[0] + s4
[0, 0] + s6
[0];
467 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
468 public static void objrefs () {
469 Tests t
= new Tests () {};
477 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
478 public static void set_child (Tests t
) {
479 t
.child
= new Tests ();
482 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
483 public void objrefs1 () {
486 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
487 public static void objrefs2 () {
490 public static void vtypes () {
491 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 }}
;
492 AStruct s
= new AStruct { i = 44, s = "T", k = 45 }
;
493 AStruct
[] arr
= new AStruct
[] {
494 new AStruct () { i = 1, s = "S1" }
,
495 new AStruct () { i = 2, s = "S2" }
};
501 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
502 public object vtypes1 (AStruct s
, AStruct
[] arr
) {
509 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
510 public static void vtypes2 (AStruct s
) {
514 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
515 public static void vtypes3 (AStruct s
) {
516 AStruct
.static_foo (5);
519 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
520 public static void locals () {
523 locals2
<string> (null, 5, "ABC", ref s
);
528 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
529 static void locals11 (double a
, ref double b
) {
532 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
533 public static void locals1 (string[] args
) {
537 locals11 (b
: ref ri
, a
: ri
);
539 for (int j
= 0; j
< 10; ++j
) {
544 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
545 [StateMachine (typeof (int))]
546 public static void locals2
<T
> (string[] args
, int arg
, T t
, ref string rs
) {
550 for (int j
= 0; j
< 10; ++j
) {
559 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
560 public static void locals3 () {
580 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
581 public static void locals4 () {
584 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
585 public static void locals5 () {
588 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
589 public static void locals6 () {
592 for (i
= 0; i
< 10; ++i
)
595 for (i
= 0; i
< 10; ++i
)
605 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
606 public static void locals6_1 () {
609 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
610 public static void locals6_2 (int arg
) {
613 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
614 public static void locals6_3 () {
615 // Clobber all registers
616 int sum
= 0, i
, j
, k
, l
, m
;
617 for (i
= 0; i
< 100; ++i
)
619 for (j
= 0; j
< 100; ++j
)
621 for (k
= 0; k
< 100; ++k
)
623 for (l
= 0; l
< 100; ++l
)
625 for (m
= 0; m
< 100; ++m
)
629 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
630 public static void locals6_4 (int arg
) {
633 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
634 public static void locals6_5 () {
637 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
638 public static void locals6_6 (int arg
) {
641 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
642 public static void line_numbers () {
646 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
647 public static void suspend () {
655 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
656 public static void type_info () {
657 Tests t
= new Tests () { field_i = 42, field_s = "S", base_field_i = 43, base_field_s = "T", field_enum = AnEnum.B }
;
658 t
.ti1 (new Tests2 () { field_j = 43 }
, new GClass
<int> { field = 42 }
, new GClass
<string> { field = "FOO" }
);
661 AStruct s
= new AStruct () { i = 42, s = "S", k = 43 }
;
663 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
);
667 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
668 public object ti1 (Tests2 t
, GClass
<int> gc1
, GClass
<string> gc2
) {
669 if (t
== null || gc1
== null || gc2
== null)
675 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
676 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
) {
677 return s2
[0] + s3
[0] + s4
[0, 0];
680 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
681 public static void assembly_load () {
685 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
686 public static void assembly_load_2 () {
687 // This will load System.dll while holding the loader lock
691 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
692 public static void invoke () {
693 new Tests ().invoke1 (new Tests2 (), new AStruct () { i = 42, j = (IntPtr)43 }
, new GStruct
<int> { j = 42 }
);
694 new Tests ().invoke_ex ();
697 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
698 public void invoke1 (Tests2 t
, AStruct s
, GStruct
<int> g
) {
702 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
703 public void invoke2 () {
706 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
707 public void invoke_ex () {
711 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
712 public void invoke_ex_inner () {
714 throw new Exception ();
721 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
722 public void invoke_single_threaded () {
723 // Spawn a thread incrementing a counter
724 bool finished
= false;
726 new Thread (delegate () {
733 invoke_single_threaded_2 ();
738 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
739 public void invoke_single_threaded_2 () {
742 public void invoke_return_void () {
745 public string invoke_return_ref () {
749 public object invoke_return_null () {
753 public int invoke_return_primitive () {
757 public int? invoke_return_nullable () {
761 public int? invoke_return_nullable_null () {
765 public void invoke_type_load () {
772 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
) {
773 return ub
+ sb
+ ss
+ us
+ i
+ ui
+ l
+ (long)ul
+ (int)c
+ (b
? 1 : 0) + (int)f
+ (int)d
;
776 public int invoke_pass_primitive2 (bool b
) {
780 public string invoke_pass_ref (string s
) {
784 public static string invoke_static_pass_ref (string s
) {
788 public static void invoke_static_return_void () {
791 public static void invoke_throws () {
792 throw new Exception ();
795 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
796 public static void exceptions () {
798 throw new OverflowException ();
799 } catch (Exception
) {
802 throw new OverflowException ();
803 } catch (Exception
) {
806 throw new ArgumentException ();
807 } catch (Exception
) {
810 throw new OverflowException ();
811 } catch (Exception
) {
817 } catch (Exception
) {
822 } catch (Exception
) {
826 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
827 public static void unhandled_exception () {
828 ThreadPool
.QueueUserWorkItem (delegate {
829 throw new InvalidOperationException ();
831 Thread
.Sleep (10000);
834 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
835 public static void unhandled_exception_endinvoke_2 () {
838 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
839 public static void unhandled_exception_endinvoke () {
840 Action action
= new Action (() =>
842 throw new Exception ("thrown");
844 action
.BeginInvoke ((ar
) => {
846 action
.EndInvoke (ar
);
847 } catch (Exception ex
) {
848 //Console.WriteLine (ex);
852 unhandled_exception_endinvoke_2 ();
855 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
856 public static void unhandled_exception_user () {
858 System
.Threading
.Tasks
.Task
.Factory
.StartNew (() => {
861 Thread
.Sleep (10000);
865 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
866 public static void Throw () {
867 throw new Exception ();
870 internal static Delegate
create_filter_delegate (Delegate dlg
, MethodInfo filter_method
)
873 throw new ArgumentNullException ();
874 if (dlg
.Target
!= null)
875 throw new ArgumentException ();
876 if (dlg
.Method
== null)
877 throw new ArgumentException ();
879 var ret_type
= dlg
.Method
.ReturnType
;
880 var param_types
= dlg
.Method
.GetParameters ().Select (x
=> x
.ParameterType
).ToArray ();
882 var dynamic = new DynamicMethod (Guid
.NewGuid ().ToString (), ret_type
, param_types
, typeof (object), true);
883 var ig
= dynamic.GetILGenerator ();
885 LocalBuilder retval
= null;
886 if (ret_type
!= typeof (void))
887 retval
= ig
.DeclareLocal (ret_type
);
889 var label
= ig
.BeginExceptionBlock ();
891 for (int i
= 0; i
< param_types
.Length
; i
++)
892 ig
.Emit (OpCodes
.Ldarg
, i
);
893 ig
.Emit (OpCodes
.Call
, dlg
.Method
);
896 ig
.Emit (OpCodes
.Stloc
, retval
);
898 ig
.Emit (OpCodes
.Leave
, label
);
900 ig
.BeginExceptFilterBlock ();
902 ig
.Emit (OpCodes
.Call
, filter_method
);
904 ig
.BeginCatchBlock (null);
906 ig
.Emit (OpCodes
.Pop
);
908 ig
.EndExceptionBlock ();
911 ig
.Emit (OpCodes
.Ldloc
, retval
);
913 ig
.Emit (OpCodes
.Ret
);
915 return dynamic.CreateDelegate (dlg
.GetType ());
918 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
919 static void exception_filter_method () {
920 throw new InvalidOperationException ();
923 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
924 static int exception_filter_filter (Exception exc
) {
928 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
929 public static void exception_filter () {
930 var method
= typeof (Tests
).GetMethod (
931 "exception_filter_method", BindingFlags
.NonPublic
| BindingFlags
.Static
);
932 var filter_method
= typeof (Tests
).GetMethod (
933 "exception_filter_filter", BindingFlags
.NonPublic
| BindingFlags
.Static
);
935 var dlg
= Delegate
.CreateDelegate (typeof (Action
), method
);
937 var wrapper
= (Action
) create_filter_delegate (dlg
, filter_method
);
942 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
943 public static bool return_true () {
947 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
948 public static void exceptions2 () {
950 throw new Exception ();
951 Console
.WriteLine ();
954 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
955 public static void threads () {
956 Thread t
= new Thread (delegate () {});
962 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
963 public static void domains () {
964 AppDomain domain
= AppDomain
.CreateDomain ("domain");
966 CrossDomain o
= (CrossDomain
)domain
.CreateInstanceAndUnwrap (
967 typeof (CrossDomain
).Assembly
.FullName
, "CrossDomain");
969 domains_2 (o
, new CrossDomain ());
977 AppDomain
.Unload (domain
);
982 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
983 public static void domains_2 (object o
, object o2
) {
986 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
987 public static void domains_3 () {
990 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
991 public static void invoke_in_domain () {
994 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
995 public static void invoke_in_domain_2 () {
998 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
999 public static void dynamic_methods () {
1000 var m
= new DynamicMethod ("dyn_method", typeof (void), new Type
[] { typeof (int) }
, typeof (object).Module
);
1001 var ig
= m
.GetILGenerator ();
1003 ig
.Emit (OpCodes
.Ldstr
, "FOO");
1004 ig
.Emit (OpCodes
.Call
, typeof (Tests
).GetMethod ("dyn_call"));
1005 ig
.Emit (OpCodes
.Ret
);
1007 var del
= (Action
<int>)m
.CreateDelegate (typeof (Action
<int>));
1012 public static void dyn_call (string s
) {
1015 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
1016 public static void ref_emit () {
1017 AssemblyName assemblyName
= new AssemblyName ();
1018 assemblyName
.Name
= "foo";
1020 AssemblyBuilder assembly
=
1021 Thread
.GetDomain ().DefineDynamicAssembly (
1022 assemblyName
, AssemblyBuilderAccess
.RunAndSave
);
1024 ModuleBuilder module
= assembly
.DefineDynamicModule ("foo.dll");
1026 TypeBuilder tb
= module
.DefineType ("foo", TypeAttributes
.Public
, typeof (object));
1027 MethodBuilder mb
= tb
.DefineMethod ("ref_emit_method", MethodAttributes
.Public
|MethodAttributes
.Static
, CallingConventions
.Standard
, typeof (void), new Type
[] { }
);
1028 ILGenerator ig
= mb
.GetILGenerator ();
1029 ig
.Emit (OpCodes
.Ldstr
, "FOO");
1030 ig
.Emit (OpCodes
.Call
, typeof (Tests
).GetMethod ("ref_emit_call"));
1031 ig
.Emit (OpCodes
.Ret
);
1033 Type t
= tb
.CreateType ();
1035 t
.GetMethod ("ref_emit_method").Invoke (null, null);
1038 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
1039 public static void ref_emit_call (string s
) {
1042 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
1043 public static void frames_in_native () {
1045 var evt
= new ManualResetEvent (false);
1047 object mon
= new object ();
1048 ThreadPool
.QueueUserWorkItem (delegate {
1049 frames_in_native_2 ();
1055 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
1056 static void frames_in_native_2 () {
1057 frames_in_native_3 ();
1060 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
1061 static void frames_in_native_3 () {
1064 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
1065 public static void string_call (string s
) {
1068 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
1069 public static void ss_regress_654694 () {
1076 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
1077 public static void user () {
1080 Debugger
.Log (5, Debugger
.IsLogging () ? "A" : "", "B");
1083 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
1084 public static void type_load () {
1088 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
1089 static void type_load_2 () {
1090 var c1
= new Dictionary
<int, int> ();
1092 var c
= new TypeLoadClass ();
1094 var c2
= new TypeLoadClass2 ();
1098 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
1099 public static void regress () {
1100 regress_2755 (DateTime
.Now
);
1103 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
1104 public static unsafe void regress_2755 (DateTime d
) {
1105 int* buffer
= stackalloc int [128];
1110 for (int i
= 0; i
< 128; ++i
)
1113 regress_2755_3 (sum
);
1116 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
1117 public static void regress_2755_2 () {
1120 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
1121 public static void regress_2755_3 (int sum
) {
1124 static object gc_suspend_field
;
1126 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
1127 static unsafe void set_gc_suspend_field () {
1128 set_gc_suspend_field_2 ();
1130 int* buffer
= stackalloc int [4096];
1133 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
1134 static void set_gc_suspend_field_2 () {
1135 gc_suspend_field
= new object ();
1138 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
1139 static void gc_suspend_1 () {
1142 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
1143 public static void gc_suspend_invoke () {
1144 gc_suspend_field
= null;
1146 GC
.WaitForPendingFinalizers ();
1149 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
1150 public static void gc_suspend () {
1151 set_gc_suspend_field ();
1156 class TypeLoadClass
{
1159 class TypeLoadClass2
{
1162 public class CrossDomain
: MarshalByRefObject
1164 public void invoke () {
1165 Tests
.invoke_in_domain ();
1168 public void invoke_2 () {
1169 Tests
.invoke_in_domain_2 ();
1172 public int invoke_3 () {
1179 public ProcessStartInfo info
;
1182 // Class used for line number info testing, don't change its layout
1183 public class LineNumbers
1185 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
1186 public static void ln1 () {
1192 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
1193 public static void ln2 () {
1196 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
1197 public static void ln3 () {
1198 #pragma warning disable 0219
1200 #pragma warning restore 0219