[sgen] Make sure we don't sweep a block if we're not supposed to
[mono.git] / mcs / class / Mono.Debugger.Soft / Test / dtest-app.cs
1 /*
2  * dtest-app.cs:
3  *
4  *   Application program used by the debugger tests.
5  */
6 using System;
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.Threading.Tasks;
13 using System.Collections.Generic;
14 using System.Linq;
15 using System.Net.Sockets;
16 using MonoTests.Helpers;
17
18 public class TestsBase
19 {
20 #pragma warning disable 0414
21 #pragma warning disable 0169
22         public int base_field_i;
23         public string base_field_s;
24         static int base_static_i = 57;
25         static string base_static_s = "C";
26 #pragma warning restore 0414
27 #pragma warning restore 0169
28
29         public virtual string virtual_method () {
30                 return "V1";
31         }
32 }
33
34 public enum AnEnum {
35         A = 0,
36         B= 1
37 }
38
39 public sealed class Tests3 {
40         public static void M1 () {
41         }
42
43         static void M2 () {
44         }
45
46         public void M3 () {
47         }
48
49         void M4 () {
50         }
51
52 }
53
54 public static class Tests4 {
55         static Tests4 () {
56         }
57 }
58
59 public class AAttribute : Attribute {
60         public int afield;
61 }
62
63 public class BAttribute : AAttribute {
64         public int bfield;
65 }
66
67 [DebuggerDisplay ("Tests", Name="FOO", Target=typeof (int))]
68 [DebuggerTypeProxy (typeof (Tests))]
69 [BAttribute (afield = 1, bfield = 2)]
70 public class Tests2 {
71         [DebuggerBrowsableAttribute (DebuggerBrowsableState.Collapsed)]
72         public int field_j;
73         public static int static_field_j;
74
75         [DebuggerBrowsableAttribute (DebuggerBrowsableState.Collapsed)]
76         public int AProperty {
77                 get {
78                         return 0;
79                 }
80         }
81
82         public void invoke () {
83         }
84 }
85
86 public struct AStruct : ITest2 {
87         public int i;
88         public string s;
89         public byte k;
90         public IntPtr j;
91         public int l;
92 /*
93         public AStruct () {
94                 i = 0;
95                 s = null;
96                 k = 0;
97                 j = IntPtr.Zero;
98                 l = 0;
99         }
100 */
101         public AStruct (int arg) {
102                 i = arg;
103                 s = null;
104                 k = 0;
105                 j = IntPtr.Zero;
106                 l = 0;
107         }
108
109         [MethodImplAttribute (MethodImplOptions.NoInlining)]
110         public int foo (int val) {
111                 return val;
112         }
113
114         [MethodImplAttribute (MethodImplOptions.NoInlining)]
115         public static int static_foo (int val) {
116                 return val;
117         }
118
119         [MethodImplAttribute (MethodImplOptions.NoInlining)]
120         public int invoke_return_int () {
121                 return i;
122         }
123
124         [MethodImplAttribute (MethodImplOptions.NoInlining)]
125         public static int invoke_static () {
126                 return 5;
127         }
128
129         [MethodImplAttribute (MethodImplOptions.NoInlining)]
130         public IntPtr invoke_return_intptr () {
131                 return j;
132         }
133
134         [MethodImplAttribute (MethodImplOptions.NoInlining)]
135         public void invoke_mutate () {
136                 l = 5;
137         }
138
139         public int invoke_iface () {
140                 return i;
141         }
142
143         public override string ToString () {
144                 return i.ToString ();
145         }
146 }
147
148 public class GClass<T> {
149         public T field;
150         public static T static_field;
151
152         [MethodImplAttribute (MethodImplOptions.NoInlining)]
153         public GClass () {
154         }
155
156         [MethodImplAttribute (MethodImplOptions.NoInlining)]
157         public void bp<T2> () {
158         }
159 }
160
161 public struct GStruct<T> {
162         public T i;
163
164         public int j;
165
166         [MethodImplAttribute (MethodImplOptions.NoInlining)]
167         public int invoke_return_int () {
168                 return j;
169         }
170 }
171
172 public struct NestedStruct {
173         NestedInner nested1, nested2;
174 }
175
176 public struct NestedInner {
177 }
178
179 public interface IRecStruct {
180         void foo (object o);
181 }
182
183 struct RecStruct : IRecStruct {
184         public object o;
185
186         public void foo (object o) {
187                 this.o = o;
188         }
189 }
190
191 interface ITest
192 {
193         void Foo ();
194         void Bar ();
195 }
196
197 interface ITest<T>
198 {
199         void Foo ();
200         void Bar ();
201 }
202
203 class TestIfaces : ITest
204 {
205         void ITest.Foo () {
206         }
207
208         void ITest.Bar () {
209         }
210
211         TestIfaces<int> Baz () {
212                 return null;
213         }
214 }
215
216 class TestIfaces<T> : ITest<T>
217 {
218         void ITest<T>.Foo () {
219         }
220
221         void ITest<T>.Bar () {
222         }
223 }
224
225 public interface ITest2
226 {
227         int invoke_iface ();
228 }
229
230 public class Tests : TestsBase, ITest2
231 {
232 #pragma warning disable 0414
233         int field_i;
234         string field_s;
235         AnEnum field_enum;
236         bool field_bool1, field_bool2;
237         char field_char;
238         byte field_byte;
239         sbyte field_sbyte;
240         short field_short;
241         ushort field_ushort;
242         long field_long;
243         ulong field_ulong;
244         float field_float;
245         double field_double;
246         Thread field_class;
247         IntPtr field_intptr;
248         int? field_nullable;
249         static int static_i = 55;
250         static string static_s = "A";
251         public const int literal_i = 56;
252         public const string literal_s = "B";
253         public object child;
254         public AStruct field_struct;
255         public object field_boxed_struct;
256         public GStruct<int> generic_field_struct;
257         public KeyValuePair<int, object> boxed_struct_field;
258         [ThreadStatic]
259         public static int tls_i;
260         public static bool is_attached = Debugger.IsAttached;
261         public NestedStruct nested_struct;
262
263 #pragma warning restore 0414
264
265         public class NestedClass {
266         }
267
268         public int IntProperty {
269                 get {
270                         return field_i;
271                 }
272                 set {
273                         field_i = value;
274                 }
275         }
276
277         public int ReadOnlyProperty {
278                 get {
279                         return field_i;
280                 }
281         }
282
283         public int this [int index] {
284                 get {
285                         return field_i;
286                 }
287         }
288
289         public static void wait_one ()
290         {
291                 ManualResetEvent evt = new ManualResetEvent (false);
292                 evt.WaitOne ();
293         }
294
295         public static int Main (String[] args) {
296                 tls_i = 42;
297
298                 if (args.Length > 0 && args [0] == "suspend-test")
299                         /* This contains an infinite loop, so execute it conditionally */
300                         suspend ();
301                 if (args.Length >0 && args [0] == "unhandled-exception") {
302                         unhandled_exception ();
303                         return 0;
304                 }
305                 if (args.Length >0 && args [0] == "unhandled-exception-endinvoke") {
306                         unhandled_exception_endinvoke ();
307                         return 0;
308                 }
309                 if (args.Length >0 && args [0] == "unhandled-exception-user") {
310                         unhandled_exception_user ();
311                         return 0;
312                 }
313                 if (args.Length >0 && args [0] == "wait-one") {
314                         wait_one ();
315                         return 0;
316                 }
317                 if (args.Length >0 && args [0] == "threadpool-io") {
318                         threadpool_io ();
319                         return 0;
320                 }
321                 breakpoints ();
322                 single_stepping ();
323                 arguments ();
324                 objects ();
325                 objrefs ();
326                 vtypes ();
327                 locals ();
328                 line_numbers ();
329                 type_info ();
330                 assembly_load ();
331                 invoke ();
332                 exceptions ();
333                 exception_filter ();
334                 threads ();
335                 dynamic_methods ();
336                 user ();
337                 type_load ();
338                 regress ();
339                 gc_suspend ();
340                 set_ip ();
341                 step_filters ();
342                 local_reflect ();
343                 if (args.Length > 0 && args [0] == "domain-test")
344                         /* This takes a lot of time, so execute it conditionally */
345                         domains ();
346                 if (args.Length > 0 && args [0] == "ref-emit-test")
347                         ref_emit ();
348                 if (args.Length > 0 && args [0] == "frames-in-native")
349                         frames_in_native ();
350                 if (args.Length > 0 && args [0] == "invoke-single-threaded")
351                         new Tests ().invoke_single_threaded ();
352                 if (args.Length > 0 && args [0] == "invoke-abort")
353                         new Tests ().invoke_abort ();
354                 new Tests ().evaluate_method ();
355                 return 3;
356         }
357
358         public static void local_reflect () {
359                 //Breakpoint line below, and reflect someField via ObjectMirror;
360                 LocalReflectClass.RunMe ();
361         }
362
363         public static void breakpoints () {
364                 /* Call these early so it is JITted by the time a breakpoint is placed on it */
365                 bp3 ();
366                 bp7<int> ();
367                 bp7<string> ();
368
369                 bp1 ();
370                 bp2 ();
371                 bp3 ();
372                 bp4 ();
373                 bp4 ();
374                 bp4 ();
375                 bp5 ();
376                 bp6<string> (new GClass <int> ());
377                 bp7<int> ();
378                 bp7<string> ();
379         }
380
381         [MethodImplAttribute (MethodImplOptions.NoInlining)]
382         public static void bp1 () {
383         }
384
385         [MethodImplAttribute (MethodImplOptions.NoInlining)]
386         public static void bp2 () {
387         }
388
389         [MethodImplAttribute (MethodImplOptions.NoInlining)]
390         public static void bp3 () {
391         }
392
393         [MethodImplAttribute (MethodImplOptions.NoInlining)]
394         public static void bp4 () {
395         }
396
397         [MethodImplAttribute (MethodImplOptions.NoInlining)]
398         public static void bp5 () {
399         }
400
401         [MethodImplAttribute (MethodImplOptions.NoInlining)]
402         public static void bp6<T> (GClass<int> gc) {
403                 gc.bp<int> ();
404         }
405
406         [MethodImplAttribute (MethodImplOptions.NoInlining)]
407         public static void bp7<T> () {
408         }
409
410         [MethodImplAttribute (MethodImplOptions.NoInlining)]
411         public static void single_stepping () {
412                 bool b = true;
413                 ss1 ();
414                 ss2 ();
415                 ss3 ();
416                 ss3_2 ();
417                 ss4 ();
418                 ss5 (new int [] { 1, 2, 3 }, new Func<int, bool> (is_even));
419                 try {
420                         ss6 (b);
421                 } catch {
422                 }
423                 ss7 ();
424                 ss_nested ();
425                 ss_regress_654694 ();
426                 ss_step_through ();
427                 ss_non_user_code ();
428                 ss_recursive (1);
429                 ss_recursive2 (1);
430                 ss_recursive2 (1);
431                 ss_recursive_chaotic ();
432                 ss_fp_clobber ();
433         }
434
435         [MethodImplAttribute (MethodImplOptions.NoInlining)]
436         public static void ss1 () {
437         }
438
439         [MethodImplAttribute (MethodImplOptions.NoInlining)]
440         public static void ss2 () {
441         }
442
443         [MethodImplAttribute (MethodImplOptions.NoInlining)]
444         public static int ss3 () {
445                 int sum = 0;
446
447                 for (int i = 0; i < 10; ++i)
448                         sum += i;
449
450                 return sum;
451         }
452
453         [MethodImplAttribute (MethodImplOptions.NoInlining)]
454         public static void ss3_2 () {
455                 ss3_2_2 ();
456         }
457
458         [MethodImplAttribute (MethodImplOptions.NoInlining)]
459         public static void ss3_2_2 () {
460         }
461
462         [MethodImplAttribute (MethodImplOptions.NoInlining)]
463         public static int ss4 () {
464                 ss1 (); ss1 ();
465                 ss2 ();
466                 return 0;
467         }
468
469         [MethodImplAttribute (MethodImplOptions.NoInlining)]
470         public static void ss5 (int[] arr, Func<int, bool> selector) {
471                 // Call into linq which calls back into this assembly
472                 arr.Count (selector);
473         }
474
475         [MethodImplAttribute (MethodImplOptions.NoInlining)]
476         public static void ss6 (bool b) {
477                 if (b) {
478                         ss6_2 ();
479                         throw new Exception ();
480                 }
481         }
482
483         [MethodImplAttribute (MethodImplOptions.NoInlining)]
484         public static void ss6_2 () {
485         }
486
487         [MethodImplAttribute (MethodImplOptions.NoInlining)]
488         public static void ss7 () {
489                 try {
490                         ss7_2 ();
491                         ss7_3 ();
492                 } catch {
493                 }
494                 ss7_2 ();
495         }
496
497         [MethodImplAttribute (MethodImplOptions.NoInlining)]
498         public static void ss7_2 () {
499         }
500
501         [MethodImplAttribute (MethodImplOptions.NoInlining)]
502         public static void ss7_3 () {
503                 throw new Exception ();
504         }
505
506         [MethodImplAttribute (MethodImplOptions.NoInlining)]
507         public static void ss_nested () {
508                 ss_nested_1 (ss_nested_2 ());
509                 ss_nested_1 (ss_nested_2 ());
510                 ss_nested_3 ();
511         }
512
513         [MethodImplAttribute (MethodImplOptions.NoInlining)]
514         public static void ss_nested_1 (int i) {
515         }
516
517         [MethodImplAttribute (MethodImplOptions.NoInlining)]
518         public static int ss_nested_2 () {
519                 return 0;
520         }
521
522         [MethodImplAttribute (MethodImplOptions.NoInlining)]
523         public static void ss_nested_3 () {
524         }
525
526         [MethodImplAttribute (MethodImplOptions.NoInlining)]
527         public static void ss_step_through () {
528                 step_through_1 ();
529                 StepThroughClass.step_through_2 ();
530                 step_through_3 ();
531         }
532
533         [DebuggerStepThrough]
534         [MethodImplAttribute (MethodImplOptions.NoInlining)]
535         public static void step_through_1 () {
536         }
537
538         [DebuggerStepThrough]
539         class StepThroughClass {
540                 [MethodImplAttribute (MethodImplOptions.NoInlining)]
541                 public static void step_through_2 () {
542                 }
543         }
544
545         [DebuggerStepThrough]
546         [MethodImplAttribute (MethodImplOptions.NoInlining)]
547         public static void step_through_3 () {
548         }
549
550         [MethodImplAttribute (MethodImplOptions.NoInlining)]
551         public static void ss_non_user_code () {
552                 non_user_code_1 ();
553                 StepNonUserCodeClass.non_user_code_2 ();
554                 non_user_code_3 ();
555         }
556
557         [DebuggerNonUserCode]
558         [MethodImplAttribute (MethodImplOptions.NoInlining)]
559         public static void non_user_code_1 () {
560         }
561
562         [DebuggerNonUserCode]
563         class StepNonUserCodeClass {
564                 [MethodImplAttribute (MethodImplOptions.NoInlining)]
565                 public static void non_user_code_2 () {
566                 }
567         }
568
569         [DebuggerNonUserCode]
570         [MethodImplAttribute (MethodImplOptions.NoInlining)]
571         public static void non_user_code_3 () {
572         }
573
574         [MethodImplAttribute (MethodImplOptions.NoInlining)]
575         public static void ss_recursive (int n) {
576                 if (n == 10)
577                         return;
578                 ss_recursive (n + 1);
579         }
580
581         // Breakpoint will be placed here
582         [MethodImplAttribute (MethodImplOptions.NoInlining)]
583         public static void ss_recursive2_trap ()
584         {
585         }
586
587         public static void ss_recursive2_at (string s)
588         {
589                 // Console.WriteLine (s);
590         }
591
592         // This method is used both for a step over and step out test.
593         [MethodImplAttribute (MethodImplOptions.NoInlining)]
594         public static void ss_recursive2 (int x)
595         {
596                 ss_recursive2_at ( "ss_recursive2 in " + x);
597                 if (x < 5) {
598                         int next = x + 1;
599                         ss_recursive2_at ("ss_recursive2 descend " + x);
600                         ss_recursive2_trap ();
601                         ss_recursive2 (next);
602                 }
603                 ss_recursive2_at ("ss_recursive2 out " + x);
604         }
605
606         // Breakpoint will be placed here
607         [MethodImplAttribute (MethodImplOptions.NoInlining)]
608         public static void ss_recursive_chaotic_trap ()
609         {
610         }
611
612         [MethodImplAttribute (MethodImplOptions.NoInlining)]
613         public static void ss_recursive_chaotic_at (bool exiting, string at, int n)
614         {
615 //              string indent = "";
616 //              for (int count = 5 - n; count > 0; count--)
617 //                      indent += "\t";
618 //              Console.WriteLine (indent + (exiting ? "<--" : "-->") + " " + at + " " + n);
619         }
620
621         [MethodImplAttribute (MethodImplOptions.NoInlining)]
622         public static void ss_recursive_chaotic_fizz (int n)
623         {
624                 ss_recursive_chaotic_at (false, "fizz", n);
625                 if (n > 0) {
626                         int next = n - 1;
627                         ss_recursive_chaotic_buzz (next);
628                         ss_recursive_chaotic_fizzbuzz (next);
629                 } else {
630                         ss_recursive_chaotic_trap ();
631                 }
632                 ss_recursive_chaotic_at (true, "fizz", n);
633         }
634
635         [MethodImplAttribute (MethodImplOptions.NoInlining)]
636         public static void ss_recursive_chaotic_buzz (int n)
637         {
638                 ss_recursive_chaotic_at (false, "buzz", n);
639                 if (n > 0) {
640                         int next = n - 1;
641                         ss_recursive_chaotic_fizz (next);
642                         ss_recursive_chaotic_fizzbuzz (next);
643                 }
644                 ss_recursive_chaotic_at (true, "buzz", n);
645         }
646
647         [MethodImplAttribute (MethodImplOptions.NoInlining)]
648         public static void ss_recursive_chaotic_fizzbuzz (int n)
649         {
650                 ss_recursive_chaotic_at (false, "fizzbuzz", n);
651                 if (n > 0) {
652                         int next = n - 1;
653                         ss_recursive_chaotic_fizz (next);
654                         ss_recursive_chaotic_buzz (next);
655                         ss_recursive_chaotic_fizzbuzz (next);
656                 }
657                 ss_recursive_chaotic_at (true, "fizzbuzz", n);
658         }
659
660         // Call a complex tree of recursive calls that has tripped up "step out" in the past.
661         [MethodImplAttribute (MethodImplOptions.NoInlining)]
662         public static void ss_recursive_chaotic ()
663         {
664                 ss_recursive_chaotic_fizz (5);
665         }
666
667         [MethodImplAttribute (MethodImplOptions.NoInlining)]
668         public static void ss_fp_clobber () {
669                 double v = ss_fp_clobber_1 (5.0);
670                 ss_fp_clobber_2 (v);
671         }
672
673         [MethodImplAttribute (MethodImplOptions.NoInlining)]
674         public static double ss_fp_clobber_1 (double d) {
675                 return d + 2.0;
676         }
677
678         [MethodImplAttribute (MethodImplOptions.NoInlining)]
679         public static void ss_fp_clobber_2 (double d) {
680         }
681
682         [MethodImplAttribute (MethodImplOptions.NoInlining)]
683         public static bool is_even (int i) {
684                 return i % 2 == 0;
685         }
686
687         /*
688                 lock (static_s) {
689                         Console.WriteLine ("HIT!");
690                 }
691                 return 0;
692         }
693         */
694
695         [MethodImplAttribute (MethodImplOptions.NoInlining)]
696         public static void arguments () {
697                 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));
698                 int i = 42;
699                 arg2 ("FOO", null, "BLA", ref i, new GClass <int> { field = 42 }, new object (), '\0'.ToString () + "A");
700                 Tests t = new Tests () { field_i = 42, field_s = "S" };
701                 t.arg3 ("BLA");
702         }
703
704         [MethodImplAttribute (MethodImplOptions.NoInlining)]
705         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) {
706                 return (int)(sb + b + (bl ? 0 : 1) + s + us + (int)c + i + ui + l + (long)ul + f + d + (int)ip + (int)uip);
707         }
708
709         [MethodImplAttribute (MethodImplOptions.NoInlining)]
710         public static string arg2 (string s, string s3, object o, ref int i, GClass <int> gc, object o2, string s4) {
711                 return s + (s3 != null ? "" : "") + o + i + gc.field + o2;
712         }
713
714         [MethodImplAttribute (MethodImplOptions.NoInlining)]
715         public object arg3 (string s) {
716                 return s + s + s + s + this;
717         }
718
719         [MethodImplAttribute (MethodImplOptions.NoInlining)]
720         public static void objects () {
721                 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 };
722                 t.o1 (new Tests2 () { field_j = 43 }, new GClass <int> { field = 42 }, new GClass <string> { field = "FOO" });
723                 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 });
724         }
725
726         [MethodImplAttribute (MethodImplOptions.NoInlining)]
727         public object o1 (Tests2 t, GClass <int> gc1, GClass <string> gc2) {
728                 if (t == null || gc1 == null || gc2 == null)
729                         return null;
730                 else
731                         return this;
732         }
733
734         [MethodImplAttribute (MethodImplOptions.NoInlining)]
735         public static string o2 (string[] s2, int[] s3, int[,] s4, int[,] s5, IList<int> s6) {
736                 return s2 [0] + s3 [0] + s4 [0, 0] + s6 [0];
737         }
738
739         [MethodImplAttribute (MethodImplOptions.NoInlining)]
740         public static void objrefs () {
741                 Tests t = new Tests () {};
742                 set_child (t);
743                 t.objrefs1 ();
744                 t.child = null;
745                 GC.Collect ();
746                 objrefs2 ();
747         }
748
749         [MethodImplAttribute (MethodImplOptions.NoInlining)]
750         public static void set_child (Tests t) {
751                 t.child = new Tests ();
752         }
753
754         [MethodImplAttribute (MethodImplOptions.NoInlining)]
755         public void objrefs1 () {
756         }
757
758         [MethodImplAttribute (MethodImplOptions.NoInlining)]
759         public static void objrefs2 () {
760         }
761
762         public static void vtypes () {
763                 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 ) };
764                 AStruct s = new AStruct { i = 44, s = "T", k = 45 };
765                 AStruct[] arr = new AStruct[] { 
766                         new AStruct () { i = 1, s = "S1" },
767                         new AStruct () { i = 2, s = "S2" } };
768                 TypedReference typedref = __makeref (s);
769                 t.vtypes1 (s, arr, typedref);
770                 vtypes2 (s);
771                 vtypes3 (s);
772                 vtypes4 ();
773         }
774
775         [MethodImplAttribute (MethodImplOptions.NoInlining)]
776         public object vtypes1 (AStruct s, AStruct[] arr, TypedReference typedref) {
777                 if (arr != null)
778                         return this;
779                 else
780                         return null;
781         }
782
783         [MethodImplAttribute (MethodImplOptions.NoInlining)]
784         public static void vtypes2 (AStruct s) {
785                 s.foo (5);
786         }
787
788         [MethodImplAttribute (MethodImplOptions.NoInlining)]
789         public static void vtypes3 (AStruct s) {
790                 AStruct.static_foo (5);
791         }
792
793         [MethodImplAttribute (MethodImplOptions.NoInlining)]
794         public static void vtypes4_2 (IRecStruct o) {
795         }
796
797         [MethodImplAttribute (MethodImplOptions.NoInlining)]
798         public static void vtypes4 () {
799                 IRecStruct s = new RecStruct ();
800                 s.foo (s);
801                 vtypes4_2 (s);
802         }
803
804         [MethodImplAttribute (MethodImplOptions.NoInlining)]
805         public static void locals () {
806                 string s = null;
807                 var astruct = new AStruct () { i = 42 };
808                 locals1 (null);
809                 locals2<string> (null, 5, "ABC", ref s, ref astruct);
810                 locals3 ();
811                 locals6 ();
812                 locals7<int> (22);
813         }
814
815         [MethodImplAttribute (MethodImplOptions.NoInlining)]
816         static void locals11 (double a, ref double b) {
817         }
818
819         [MethodImplAttribute (MethodImplOptions.NoInlining)]
820         public static void locals1 (string[] args) {
821                 long foo = 42;
822
823                 double ri = 1;
824                 locals11 (b: ref ri, a: ri);
825
826                 for (int j = 0; j < 10; ++j) {
827                         foo ++;
828                 }
829         }
830
831         [MethodImplAttribute (MethodImplOptions.NoInlining)]
832 #if NET_4_5
833         [StateMachine (typeof (int))]
834 #endif
835         public static void locals2<T> (string[] args, int arg, T t, ref string rs, ref AStruct astruct) {
836                 long i = 42;
837                 string s = "AB";
838
839                 for (int j = 0; j < 10; ++j) {
840                         if (s != null)
841                                 i ++;
842                         if (t != null)
843                                 i ++;
844                         astruct = new AStruct ();
845                 }
846                 rs = "A";
847                 List<int> alist = new List<int> () { 12 };
848         }
849
850
851         [MethodImplAttribute (MethodImplOptions.NoInlining)]
852         public static void locals3 () {
853                 string s = "B";
854                 s.ToString ();
855
856                 {
857                         long i = 42;
858                         i ++;
859                         locals4 ();
860                 }
861                 {
862                         string i = "A";
863                         i.ToString ();
864                         locals5 ();
865                 }
866                 {
867                         long j = 42;
868                         j ++;
869                 }
870         }
871
872         [MethodImplAttribute (MethodImplOptions.NoInlining)]
873         public static void locals4 () {
874         }
875
876         [MethodImplAttribute (MethodImplOptions.NoInlining)]
877         public static void locals5 () {
878         }
879
880         [MethodImplAttribute (MethodImplOptions.NoInlining)]
881         public static void locals6 () {
882                 int i = 0;
883                 int j = 0;
884                 for (i = 0; i < 10; ++i)
885                         j ++;
886                 sbyte sb = 0;
887                 for (i = 0; i < 10; ++i)
888                         sb ++;
889                 locals6_1 ();
890                 locals6_2 (j);
891                 locals6_3 ();
892                 locals6_4 (j);
893                 locals6_5 ();
894                 locals6_6 (sb);
895         }
896
897         [MethodImplAttribute (MethodImplOptions.NoInlining)]
898         public static void locals6_1 () {
899         }
900
901         [MethodImplAttribute (MethodImplOptions.NoInlining)]
902         public static void locals6_2 (int arg) {
903         }
904
905         [MethodImplAttribute (MethodImplOptions.NoInlining)]
906         public static void locals6_3 () {
907                 // Clobber all registers
908                 int sum = 0, i, j, k, l, m;
909                 for (i = 0; i < 100; ++i)
910                         sum ++;
911                 for (j = 0; j < 100; ++j)
912                         sum ++;
913                 for (k = 0; k < 100; ++k)
914                         sum ++;
915                 for (l = 0; l < 100; ++l)
916                         sum ++;
917                 for (m = 0; m < 100; ++m)
918                         sum ++;
919         }
920
921         [MethodImplAttribute (MethodImplOptions.NoInlining)]
922         public static void locals6_4 (int arg) {
923         }
924
925         [MethodImplAttribute (MethodImplOptions.NoInlining)]
926         public static void locals6_5 () {
927         }
928
929         [MethodImplAttribute (MethodImplOptions.NoInlining)]
930         public static void locals6_6 (int arg) {
931         }
932
933         [MethodImplAttribute (MethodImplOptions.NoInlining)]
934         public static void locals7<T> (T arg) {
935                 T t = arg;
936                 T t2 = t;
937         }
938
939         [MethodImplAttribute (MethodImplOptions.NoInlining)]
940         public static void line_numbers () {
941                 LineNumbers.ln1 ();
942         }
943
944         [MethodImplAttribute (MethodImplOptions.NoInlining)]
945         public static void suspend () {
946                 long i = 5;
947
948                 while (true) {
949                         i ++;
950                 }
951         }
952
953         struct TypedRefTest {
954                 public int MaxValue;
955         }
956
957         [MethodImplAttribute (MethodImplOptions.NoInlining)]
958         public static void type_info () {
959                 Tests t = new Tests () { field_i = 42, field_s = "S", base_field_i = 43, base_field_s = "T", field_enum = AnEnum.B };
960                 t.ti1 (new Tests2 () { field_j = 43 }, new GClass <int> { field = 42 }, new GClass <string> { field = "FOO" });
961                 int val = 0;
962                 unsafe {
963                         AStruct s = new AStruct () { i = 42, s = "S", k = 43 };
964                         TypedRefTest reftest = new TypedRefTest () { MaxValue = 12 };
965                         TypedReference typedref = __makeref (reftest);
966                         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, typedref);
967                 }
968         }
969
970         [MethodImplAttribute (MethodImplOptions.NoInlining)]
971         public object ti1 (Tests2 t, GClass <int> gc1, GClass <string> gc2) {
972                 if (t == null || gc1 == null || gc2 == null)
973                         return null;
974                 else
975                         return this;
976         }
977
978         [MethodImplAttribute (MethodImplOptions.NoInlining)]
979         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, TypedReference typedref) {
980                 return s2 [0] + s3 [0] + s4 [0, 0];
981         }
982
983         [MethodImplAttribute (MethodImplOptions.NoInlining)]
984         public static void assembly_load () {
985                 assembly_load_2 ();
986         }
987
988         [MethodImplAttribute (MethodImplOptions.NoInlining)]
989         public static void assembly_load_2 () {
990                 // This will load System.dll while holding the loader lock
991                 new Foo ();
992         }
993
994         [MethodImplAttribute (MethodImplOptions.NoInlining)]
995         public static void invoke () {
996                 new Tests ().invoke1 (new Tests2 (), new AStruct () { i = 42, j = (IntPtr)43 }, new GStruct<int> { j = 42 });
997                 new Tests ().invoke_ex ();
998         }
999
1000         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1001         public void invoke1 (Tests2 t, AStruct s, GStruct<int> g) {
1002                 invoke2 ();
1003         }
1004
1005         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1006         public void invoke2 () {
1007         }
1008
1009         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1010         public void invoke_ex () {
1011                 invoke_ex_inner ();
1012         }
1013
1014         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1015         public void invoke_ex_inner () {
1016                 try {
1017                         throw new Exception ();
1018                 } catch {
1019                 }
1020         }
1021
1022         int counter;
1023
1024         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1025         public void invoke_single_threaded () {
1026                 // Spawn a thread incrementing a counter
1027                 bool finished = false;
1028
1029                 new Thread (delegate () {
1030                                 while (!finished)
1031                                         counter ++;
1032                 }).Start ();
1033
1034                 Thread.Sleep (100);
1035
1036                 invoke_single_threaded_2 ();
1037
1038                 finished = true;
1039         }
1040
1041         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1042         public void invoke_single_threaded_2 () {
1043         }
1044
1045         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1046         public void invoke_abort () {
1047         }
1048
1049         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1050         public void invoke_abort_2 () {
1051                 Thread.Sleep (1000000);
1052         }
1053
1054         public void invoke_return_void () {
1055         }
1056
1057         public string invoke_return_ref () {
1058                 return "ABC";
1059         }
1060
1061         public object invoke_return_null () {
1062                 return null;
1063         }
1064
1065         public int invoke_return_primitive () {
1066                 return 42;
1067         }
1068
1069         public int? invoke_return_nullable () {
1070                 return 42;
1071         }
1072
1073         public int? invoke_return_nullable_null () {
1074                 return null;
1075         }
1076
1077         public void invoke_type_load () {
1078                 new Class3 ();
1079         }
1080
1081         class Class3 {
1082         }
1083
1084         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) {
1085                 return ub + sb + ss + us + i + ui + l + (long)ul + (int)c + (b ? 1 : 0) + (int)f + (int)d;
1086         }
1087
1088         public int invoke_pass_primitive2 (bool b) {
1089                 return b ? 1 : 0;
1090         }
1091
1092         public string invoke_pass_ref (string s) {
1093                 return s;
1094         }
1095
1096         public static string invoke_static_pass_ref (string s) {
1097                 return s;
1098         }
1099
1100         public static void invoke_static_return_void () {
1101         }
1102
1103         public static void invoke_throws () {
1104                 throw new Exception ();
1105         }
1106
1107         public int invoke_iface () {
1108                 return 42;
1109         }
1110
1111         public void invoke_out (out int foo, out int[] arr) {
1112                 foo = 5;
1113                 arr = new int [10];
1114         }
1115
1116         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1117         public static void exceptions () {
1118                 try {
1119                         throw new OverflowException ();
1120                 } catch (Exception) {
1121                 }
1122                 try {
1123                         throw new OverflowException ();
1124                 } catch (Exception) {
1125                 }
1126                 try {
1127                         throw new ArgumentException ();
1128                 } catch (Exception) {
1129                 }
1130                 try {
1131                         throw new OverflowException ();
1132                 } catch (Exception) {
1133                 }
1134                 // no subclasses
1135                 try {
1136                         throw new OverflowException ();
1137                 } catch (Exception) {
1138                 }
1139                 try {
1140                         throw new Exception ();
1141                 } catch (Exception) {
1142                 }
1143
1144                 object o = null;
1145                 try {
1146                         o.GetType ();
1147                 } catch (Exception) {
1148                 }
1149
1150                 try {
1151                         exceptions2 ();
1152                 } catch (Exception) {
1153                 }
1154         }
1155
1156         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1157         public static void unhandled_exception () {
1158                 ThreadPool.QueueUserWorkItem (delegate {
1159                                 throw new InvalidOperationException ();
1160                         });
1161                 Thread.Sleep (10000);
1162         }
1163
1164         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1165         public static void unhandled_exception_endinvoke_2 () {
1166         }
1167
1168         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1169         public static void unhandled_exception_endinvoke () {
1170                         Action action = new Action (() => 
1171                         {
1172                                 throw new Exception ("thrown");
1173                         });
1174                         action.BeginInvoke ((ar) => {
1175                                 try {
1176                                         action.EndInvoke (ar);
1177                                 } catch (Exception ex) {
1178                                         //Console.WriteLine (ex);
1179                                 }
1180                         }, null);
1181                 Thread.Sleep (1000);
1182                 unhandled_exception_endinvoke_2 ();
1183         }
1184
1185         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1186         public static void unhandled_exception_user () {
1187 #if NET_4_5
1188                 System.Threading.Tasks.Task.Factory.StartNew (() => {
1189                                 Throw ();
1190                         });
1191                 Thread.Sleep (10000);
1192 #endif
1193         }
1194
1195         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1196         public static void Throw () {
1197                 throw new Exception ();
1198         }
1199
1200         internal static Delegate create_filter_delegate (Delegate dlg, MethodInfo filter_method)
1201         {
1202                 if (dlg == null)
1203                         throw new ArgumentNullException ();
1204                 if (dlg.Target != null)
1205                         throw new ArgumentException ();
1206                 if (dlg.Method == null)
1207                         throw new ArgumentException ();
1208
1209                 var ret_type = dlg.Method.ReturnType;
1210                 var param_types = dlg.Method.GetParameters ().Select (x => x.ParameterType).ToArray ();
1211
1212                 var dynamic = new DynamicMethod (Guid.NewGuid ().ToString (), ret_type, param_types, typeof (object), true);
1213                 var ig = dynamic.GetILGenerator ();
1214
1215                 LocalBuilder retval = null;
1216                 if (ret_type != typeof (void))
1217                         retval = ig.DeclareLocal (ret_type);
1218
1219                 var label = ig.BeginExceptionBlock ();
1220
1221                 for (int i = 0; i < param_types.Length; i++)
1222                         ig.Emit (OpCodes.Ldarg, i);
1223                 ig.Emit (OpCodes.Call, dlg.Method);
1224
1225                 if (retval != null)
1226                         ig.Emit (OpCodes.Stloc, retval);
1227
1228                 ig.Emit (OpCodes.Leave, label);
1229
1230                 ig.BeginExceptFilterBlock ();
1231
1232                 ig.Emit (OpCodes.Call, filter_method);
1233
1234                 ig.BeginCatchBlock (null);
1235
1236                 ig.Emit (OpCodes.Pop);
1237
1238                 ig.EndExceptionBlock ();
1239
1240                 if (retval != null)
1241                         ig.Emit (OpCodes.Ldloc, retval);
1242
1243                 ig.Emit (OpCodes.Ret);
1244
1245                 return dynamic.CreateDelegate (dlg.GetType ());
1246         }
1247
1248         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1249         static void exception_filter_method () {
1250                 throw new InvalidOperationException ();
1251         }
1252
1253         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1254         static int exception_filter_filter (Exception exc) {
1255                 return 1;
1256         }
1257
1258         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1259         public static void exception_filter () {
1260                 var method = typeof (Tests).GetMethod (
1261                         "exception_filter_method", BindingFlags.NonPublic | BindingFlags.Static);
1262                 var filter_method = typeof (Tests).GetMethod (
1263                         "exception_filter_filter", BindingFlags.NonPublic | BindingFlags.Static);
1264
1265                 var dlg = Delegate.CreateDelegate (typeof (Action), method);
1266
1267                 var wrapper = (Action) create_filter_delegate (dlg, filter_method);
1268
1269                 wrapper ();
1270         }
1271
1272         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1273         public static bool return_true () {
1274                 return true;
1275         }
1276
1277         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1278         public static void exceptions2 () {
1279                 if (return_true ())
1280                         throw new Exception ();
1281                 Console.WriteLine ();
1282         }
1283
1284         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1285         public static void threads () {
1286                 Thread t = new Thread (delegate () {});
1287
1288                 t.Start ();
1289                 t.Join ();
1290         }
1291
1292         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1293         public static void domains () {
1294                 AppDomain domain = AppDomain.CreateDomain ("domain");
1295
1296                 CrossDomain o = (CrossDomain)domain.CreateInstanceAndUnwrap (
1297                                    typeof (CrossDomain).Assembly.FullName, "CrossDomain");
1298
1299                 domains_print_across (o);
1300
1301                 domains_2 (o, new CrossDomain ());
1302
1303                 o.invoke_2 ();
1304
1305                 o.invoke ();
1306
1307                 o.invoke_2 ();
1308
1309                 AppDomain.Unload (domain);
1310
1311                 domains_3 ();
1312
1313                 typeof (Tests).GetMethod ("called_from_invoke").Invoke (null, null);
1314         }
1315
1316         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1317         public static void called_from_invoke () {
1318         }
1319
1320         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1321         public static void domains_2 (object o, object o2) {
1322         }
1323
1324         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1325         public static void domains_print_across (object o) {
1326         }
1327
1328         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1329         public static void domains_3 () {
1330         }
1331
1332         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1333         public static void invoke_in_domain () {
1334         }
1335
1336         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1337         public static void invoke_in_domain_2 () {
1338         }
1339
1340         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1341         public static void dynamic_methods () {
1342                 var m = new DynamicMethod ("dyn_method", typeof (void), new Type []  { typeof (int) }, typeof (object).Module);
1343                 var ig = m.GetILGenerator ();
1344
1345                 ig.Emit (OpCodes.Ldstr, "FOO");
1346                 ig.Emit (OpCodes.Call, typeof (Tests).GetMethod ("dyn_call"));
1347                 ig.Emit (OpCodes.Ret);
1348
1349                 var del = (Action<int>)m.CreateDelegate (typeof (Action<int>));
1350
1351                 del (0);
1352         }
1353
1354         public static void dyn_call (string s) {
1355         }
1356
1357         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1358         public static void ref_emit () {
1359                 AssemblyName assemblyName = new AssemblyName ();
1360                 assemblyName.Name = "foo";
1361
1362                 AssemblyBuilder assembly =
1363                         Thread.GetDomain ().DefineDynamicAssembly (
1364                                                                                                            assemblyName, AssemblyBuilderAccess.RunAndSave);
1365
1366                 ModuleBuilder module = assembly.DefineDynamicModule ("foo.dll");
1367
1368                 TypeBuilder tb = module.DefineType ("foo", TypeAttributes.Public, typeof (object));
1369                 MethodBuilder mb = tb.DefineMethod ("ref_emit_method", MethodAttributes.Public|MethodAttributes.Static, CallingConventions.Standard, typeof (void), new Type [] { });
1370                 ILGenerator ig = mb.GetILGenerator ();
1371                 ig.Emit (OpCodes.Ldstr, "FOO");
1372                 ig.Emit (OpCodes.Call, typeof (Tests).GetMethod ("ref_emit_call"));
1373                 ig.Emit (OpCodes.Ret);
1374
1375                 Type t = tb.CreateType ();
1376
1377                 t.GetMethod ("ref_emit_method").Invoke (null, null);
1378         }
1379
1380         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1381         public static void ref_emit_call (string s) {
1382         }
1383
1384         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1385         public static void frames_in_native () {
1386                 Thread.Sleep (500);
1387                 var evt = new ManualResetEvent (false);
1388                 
1389                 object mon = new object ();
1390                 ThreadPool.QueueUserWorkItem (delegate {
1391                                 frames_in_native_2 ();
1392                                 evt.Set ();
1393                         });
1394                 evt.WaitOne ();
1395         }
1396
1397         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1398         static void frames_in_native_2 () {
1399                 frames_in_native_3 ();
1400         }
1401
1402         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1403         static void frames_in_native_3 () {
1404         }
1405
1406         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1407         public static void string_call (string s) {
1408         }
1409
1410         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1411         public static void ss_regress_654694 () {
1412                 if (true) {
1413                         string h = "hi";
1414                         string_call (h);
1415                 }
1416         }
1417
1418         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1419         public static void user () {
1420                 Debugger.Break ();
1421
1422                 Debugger.Log (5, Debugger.IsLogging () ? "A" : "", "B");
1423         }
1424
1425         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1426         public static void type_load () {
1427                 type_load_2 ();
1428         }
1429
1430         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1431         static void type_load_2 () {
1432                 var c1 = new Dictionary<int, int> ();
1433                 c1.ToString ();
1434                 var c = new TypeLoadClass ();
1435                 c.ToString ();
1436                 var c2 = new TypeLoadClass2 ();
1437                 c2.ToString ();
1438         }
1439
1440         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1441         public static void regress () {
1442                 regress_2755 (DateTime.Now);
1443         }
1444
1445         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1446         public static unsafe void regress_2755 (DateTime d) {
1447                 int* buffer = stackalloc int [128];
1448
1449                 regress_2755_2 ();
1450
1451                 int sum = 0;
1452                 for (int i = 0; i < 128; ++i)
1453                         sum += buffer [i];
1454
1455                 regress_2755_3 (sum);
1456         }
1457
1458         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1459         public static void regress_2755_2 () {
1460         }
1461
1462         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1463         public static void regress_2755_3 (int sum) {
1464         }
1465
1466         static object gc_suspend_field;
1467
1468         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1469         static unsafe void set_gc_suspend_field () {
1470                 set_gc_suspend_field_2 ();
1471                 // Clear stack
1472                 int* buffer = stackalloc int [4096];
1473         }
1474
1475         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1476         static void set_gc_suspend_field_2 () {
1477                 gc_suspend_field = new object ();
1478         }
1479
1480         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1481         static void gc_suspend_1 () {
1482         }
1483
1484         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1485         public static void gc_suspend_invoke () {
1486                 gc_suspend_field = null;
1487                 GC.Collect ();
1488                 GC.WaitForPendingFinalizers ();
1489         }
1490
1491         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1492         public static void gc_suspend () {
1493                 set_gc_suspend_field ();
1494                 gc_suspend_1 ();
1495         }
1496
1497         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1498         public static void generic_method<T> () where T : class {
1499         }
1500
1501         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1502         public void evaluate_method_2 () {
1503         }
1504
1505         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1506         public void evaluate_method () {
1507                 field_i = 42;
1508                 evaluate_method_2 ();
1509         }
1510
1511         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1512         static void set_ip_1 () {
1513         }
1514
1515         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1516         static void set_ip_2 () {
1517         }
1518
1519         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1520         public static void set_ip () {
1521                 int i = 0, j;
1522
1523                 i ++;
1524                 i ++;
1525                 set_ip_1 ();
1526                 i ++;
1527                 j = 5;
1528                 set_ip_2 ();
1529         }
1530
1531         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1532         public static void step_filters () {
1533                 ClassWithCctor.cctor_filter ();
1534         }
1535
1536         class ClassWithCctor {
1537                 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1538                 static ClassWithCctor () {
1539                         int i = 1;
1540                         int j = 2;
1541                 }
1542
1543                 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1544                 public static void cctor_filter () {
1545                 }
1546         }
1547
1548         public override string virtual_method () {
1549                 return "V2";
1550         }
1551
1552         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1553         public static void threadpool_bp () { }
1554
1555         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1556         public static void threadpool_io () {
1557                 // Start a threadpool task that blocks on I/O.
1558                 // Regression test for #42625
1559                 const int nbytes = 16;
1560                 var bsOut = new byte[nbytes];
1561                 for (int i = 0; i < nbytes; i++) {
1562                         bsOut[i] = (byte)i;
1563                 }
1564                 var endPoint = NetworkHelpers.LocalEphemeralEndPoint ();
1565                 var l = new TcpListener (endPoint);
1566                 l.Start ();
1567                 Task<byte[]> t = Task.Run (async () => {
1568                         var c = new TcpClient ();
1569                         await c.ConnectAsync (endPoint.Address, endPoint.Port);
1570                         var streamIn = c.GetStream ();
1571                         var bs = new byte[nbytes];
1572                         int nread = 0;
1573                         int nremain = nbytes;
1574                         while (nread < nbytes) {
1575                                 int r = await streamIn.ReadAsync (bs, nread, nremain);
1576                                 nread += r;
1577                                 nremain -= r;
1578                         }
1579                         streamIn.Close ();
1580                         return bs;
1581                         });
1582                 var s = l.AcceptTcpClient ();
1583                 l.Stop ();
1584                 // write bytes in two groups so that the task blocks on the ReadAsync
1585                 var streamOut = s.GetStream ();
1586                 var nbytesFirst = nbytes / 2;
1587                 var nbytesRest = nbytes - nbytesFirst;
1588                 streamOut.Write (bsOut, 0, nbytesFirst);
1589                 threadpool_bp ();
1590                 streamOut.Write (bsOut, nbytesFirst, nbytesRest);
1591                 streamOut.Close ();
1592                 var bsIn = t.Result;
1593         }
1594 }
1595
1596 class TypeLoadClass {
1597 }
1598
1599 class TypeLoadClass2 {
1600 }
1601
1602 public class SentinelClass : MarshalByRefObject {
1603 }
1604
1605 public class CrossDomain : MarshalByRefObject
1606 {
1607         SentinelClass printMe = new SentinelClass ();
1608
1609         public void invoke () {
1610                 Tests.invoke_in_domain ();
1611         }
1612
1613         public void invoke_2 () {
1614                 Tests.invoke_in_domain_2 ();
1615         }
1616
1617         public int invoke_3 () {
1618                 return 42;
1619         }
1620 }       
1621
1622 public class Foo
1623 {
1624         public ProcessStartInfo info;
1625 }
1626
1627 // Class used for line number info testing, don't change its layout
1628 public class LineNumbers
1629 {
1630         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1631         public static void ln1 () {
1632                 // Column 3
1633                 ln2 ();
1634                 ln3 ();
1635         }
1636
1637         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1638         public static void ln2 () {
1639         }
1640
1641         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1642         public static void ln3 () {
1643 #pragma warning disable 0219
1644                 int i = 5;
1645 #pragma warning restore 0219
1646                 #line 55 "FOO"
1647         }
1648 }
1649
1650 class LocalReflectClass
1651 {
1652         public static void RunMe ()
1653         {
1654                 var reflectMe = new someClass ();
1655                 reflectMe.someMethod ();
1656         }
1657
1658         class someClass : ContextBoundObject
1659         {
1660                 public object someField;
1661
1662                 public void someMethod ()
1663                 {
1664                 }
1665         }
1666 }
1667
1668