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