Merge pull request #4063 from ntherning/fix-culture-info-problem-in-RepeatInfoTest
[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                 assembly_load ();
322                 breakpoints ();
323                 single_stepping ();
324                 arguments ();
325                 objects ();
326                 objrefs ();
327                 vtypes ();
328                 locals ();
329                 line_numbers ();
330                 type_info ();
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                 ss_no_frames ();
434         }
435
436         [MethodImplAttribute (MethodImplOptions.NoInlining)]
437         public static void ss1 () {
438         }
439
440         [MethodImplAttribute (MethodImplOptions.NoInlining)]
441         public static void ss2 () {
442         }
443
444         [MethodImplAttribute (MethodImplOptions.NoInlining)]
445         public static int ss3 () {
446                 int sum = 0;
447
448                 for (int i = 0; i < 10; ++i)
449                         sum += i;
450
451                 return sum;
452         }
453
454         [MethodImplAttribute (MethodImplOptions.NoInlining)]
455         public static void ss3_2 () {
456                 ss3_2_2 ();
457         }
458
459         [MethodImplAttribute (MethodImplOptions.NoInlining)]
460         public static void ss3_2_2 () {
461         }
462
463         [MethodImplAttribute (MethodImplOptions.NoInlining)]
464         public static int ss4 () {
465                 ss1 (); ss1 ();
466                 ss2 ();
467                 return 0;
468         }
469
470         [MethodImplAttribute (MethodImplOptions.NoInlining)]
471         public static void ss5 (int[] arr, Func<int, bool> selector) {
472                 // Call into linq which calls back into this assembly
473                 arr.Count (selector);
474         }
475
476         [MethodImplAttribute (MethodImplOptions.NoInlining)]
477         public static void ss6 (bool b) {
478                 if (b) {
479                         ss6_2 ();
480                         throw new Exception ();
481                 }
482         }
483
484         [MethodImplAttribute (MethodImplOptions.NoInlining)]
485         public static void ss6_2 () {
486         }
487
488         [MethodImplAttribute (MethodImplOptions.NoInlining)]
489         public static void ss7 () {
490                 try {
491                         ss7_2 ();
492                         ss7_3 ();
493                 } catch {
494                 }
495                 ss7_2 ();
496         }
497
498         [MethodImplAttribute (MethodImplOptions.NoInlining)]
499         public static void ss7_2 () {
500         }
501
502         [MethodImplAttribute (MethodImplOptions.NoInlining)]
503         public static void ss7_3 () {
504                 throw new Exception ();
505         }
506
507         [MethodImplAttribute (MethodImplOptions.NoInlining)]
508         public static void ss_nested () {
509                 ss_nested_1 (ss_nested_2 ());
510                 ss_nested_1 (ss_nested_2 ());
511                 ss_nested_3 ();
512         }
513
514         [MethodImplAttribute (MethodImplOptions.NoInlining)]
515         public static void ss_nested_1 (int i) {
516         }
517
518         [MethodImplAttribute (MethodImplOptions.NoInlining)]
519         public static int ss_nested_2 () {
520                 return 0;
521         }
522
523         [MethodImplAttribute (MethodImplOptions.NoInlining)]
524         public static void ss_nested_3 () {
525         }
526
527         [MethodImplAttribute (MethodImplOptions.NoInlining)]
528         public static void ss_step_through () {
529                 step_through_1 ();
530                 StepThroughClass.step_through_2 ();
531                 step_through_3 ();
532         }
533
534         [DebuggerStepThrough]
535         [MethodImplAttribute (MethodImplOptions.NoInlining)]
536         public static void step_through_1 () {
537         }
538
539         [DebuggerStepThrough]
540         class StepThroughClass {
541                 [MethodImplAttribute (MethodImplOptions.NoInlining)]
542                 public static void step_through_2 () {
543                 }
544         }
545
546         [DebuggerStepThrough]
547         [MethodImplAttribute (MethodImplOptions.NoInlining)]
548         public static void step_through_3 () {
549         }
550
551         [MethodImplAttribute (MethodImplOptions.NoInlining)]
552         public static void ss_non_user_code () {
553                 non_user_code_1 ();
554                 StepNonUserCodeClass.non_user_code_2 ();
555                 non_user_code_3 ();
556         }
557
558         [DebuggerNonUserCode]
559         [MethodImplAttribute (MethodImplOptions.NoInlining)]
560         public static void non_user_code_1 () {
561         }
562
563         [DebuggerNonUserCode]
564         class StepNonUserCodeClass {
565                 [MethodImplAttribute (MethodImplOptions.NoInlining)]
566                 public static void non_user_code_2 () {
567                 }
568         }
569
570         [DebuggerNonUserCode]
571         [MethodImplAttribute (MethodImplOptions.NoInlining)]
572         public static void non_user_code_3 () {
573         }
574
575         [MethodImplAttribute (MethodImplOptions.NoInlining)]
576         public static void ss_recursive (int n) {
577                 if (n == 10)
578                         return;
579                 ss_recursive (n + 1);
580         }
581
582         // Breakpoint will be placed here
583         [MethodImplAttribute (MethodImplOptions.NoInlining)]
584         public static void ss_recursive2_trap ()
585         {
586         }
587
588         public static void ss_recursive2_at (string s)
589         {
590                 // Console.WriteLine (s);
591         }
592
593         // This method is used both for a step over and step out test.
594         [MethodImplAttribute (MethodImplOptions.NoInlining)]
595         public static void ss_recursive2 (int x)
596         {
597                 ss_recursive2_at ( "ss_recursive2 in " + x);
598                 if (x < 5) {
599                         int next = x + 1;
600                         ss_recursive2_at ("ss_recursive2 descend " + x);
601                         ss_recursive2_trap ();
602                         ss_recursive2 (next);
603                 }
604                 ss_recursive2_at ("ss_recursive2 out " + x);
605         }
606
607         // Breakpoint will be placed here
608         [MethodImplAttribute (MethodImplOptions.NoInlining)]
609         public static void ss_recursive_chaotic_trap ()
610         {
611         }
612
613         [MethodImplAttribute (MethodImplOptions.NoInlining)]
614         public static void ss_recursive_chaotic_at (bool exiting, string at, int n)
615         {
616 //              string indent = "";
617 //              for (int count = 5 - n; count > 0; count--)
618 //                      indent += "\t";
619 //              Console.WriteLine (indent + (exiting ? "<--" : "-->") + " " + at + " " + n);
620         }
621
622         [MethodImplAttribute (MethodImplOptions.NoInlining)]
623         public static void ss_recursive_chaotic_fizz (int n)
624         {
625                 ss_recursive_chaotic_at (false, "fizz", n);
626                 if (n > 0) {
627                         int next = n - 1;
628                         ss_recursive_chaotic_buzz (next);
629                         ss_recursive_chaotic_fizzbuzz (next);
630                 } else {
631                         ss_recursive_chaotic_trap ();
632                 }
633                 ss_recursive_chaotic_at (true, "fizz", n);
634         }
635
636         [MethodImplAttribute (MethodImplOptions.NoInlining)]
637         public static void ss_recursive_chaotic_buzz (int n)
638         {
639                 ss_recursive_chaotic_at (false, "buzz", n);
640                 if (n > 0) {
641                         int next = n - 1;
642                         ss_recursive_chaotic_fizz (next);
643                         ss_recursive_chaotic_fizzbuzz (next);
644                 }
645                 ss_recursive_chaotic_at (true, "buzz", n);
646         }
647
648         [MethodImplAttribute (MethodImplOptions.NoInlining)]
649         public static void ss_recursive_chaotic_fizzbuzz (int n)
650         {
651                 ss_recursive_chaotic_at (false, "fizzbuzz", n);
652                 if (n > 0) {
653                         int next = n - 1;
654                         ss_recursive_chaotic_fizz (next);
655                         ss_recursive_chaotic_buzz (next);
656                         ss_recursive_chaotic_fizzbuzz (next);
657                 }
658                 ss_recursive_chaotic_at (true, "fizzbuzz", n);
659         }
660
661         // Call a complex tree of recursive calls that has tripped up "step out" in the past.
662         [MethodImplAttribute (MethodImplOptions.NoInlining)]
663         public static void ss_recursive_chaotic ()
664         {
665                 ss_recursive_chaotic_fizz (5);
666         }
667
668         [MethodImplAttribute (MethodImplOptions.NoInlining)]
669         public static void ss_fp_clobber () {
670                 double v = ss_fp_clobber_1 (5.0);
671                 ss_fp_clobber_2 (v);
672         }
673
674         [MethodImplAttribute (MethodImplOptions.NoInlining)]
675         public static double ss_fp_clobber_1 (double d) {
676                 return d + 2.0;
677         }
678
679         [MethodImplAttribute (MethodImplOptions.NoInlining)]
680         public static void ss_fp_clobber_2 (double d) {
681         }
682
683         [MethodImplAttribute (MethodImplOptions.NoInlining)]
684         public static void ss_no_frames () {
685                 Action a = ss_no_frames_2;
686                 var ar = a.BeginInvoke (null, null);
687                 ar.AsyncWaitHandle.WaitOne ();
688                 // Avoid waiting every time this runs
689                 if (static_i == 56)
690                         Thread.Sleep (200);
691                 ss_no_frames_3 ();
692         }
693
694         [MethodImplAttribute (MethodImplOptions.NoInlining)]
695         public static void ss_no_frames_2 () {
696         }
697
698         [MethodImplAttribute (MethodImplOptions.NoInlining)]
699         public static void ss_no_frames_3 () {
700         }
701
702         [MethodImplAttribute (MethodImplOptions.NoInlining)]
703         public static bool is_even (int i) {
704                 return i % 2 == 0;
705         }
706
707         /*
708                 lock (static_s) {
709                         Console.WriteLine ("HIT!");
710                 }
711                 return 0;
712         }
713         */
714
715         [MethodImplAttribute (MethodImplOptions.NoInlining)]
716         public static void arguments () {
717                 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));
718                 int i = 42;
719                 arg2 ("FOO", null, "BLA", ref i, new GClass <int> { field = 42 }, new object (), '\0'.ToString () + "A");
720                 Tests t = new Tests () { field_i = 42, field_s = "S" };
721                 t.arg3 ("BLA");
722         }
723
724         [MethodImplAttribute (MethodImplOptions.NoInlining)]
725         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) {
726                 return (int)(sb + b + (bl ? 0 : 1) + s + us + (int)c + i + ui + l + (long)ul + f + d + (int)ip + (int)uip);
727         }
728
729         [MethodImplAttribute (MethodImplOptions.NoInlining)]
730         public static string arg2 (string s, string s3, object o, ref int i, GClass <int> gc, object o2, string s4) {
731                 return s + (s3 != null ? "" : "") + o + i + gc.field + o2;
732         }
733
734         [MethodImplAttribute (MethodImplOptions.NoInlining)]
735         public object arg3 (string s) {
736                 return s + s + s + s + this;
737         }
738
739         [MethodImplAttribute (MethodImplOptions.NoInlining)]
740         public static void objects () {
741                 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 };
742                 t.o1 (new Tests2 () { field_j = 43 }, new GClass <int> { field = 42 }, new GClass <string> { field = "FOO" });
743                 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 });
744         }
745
746         [MethodImplAttribute (MethodImplOptions.NoInlining)]
747         public object o1 (Tests2 t, GClass <int> gc1, GClass <string> gc2) {
748                 if (t == null || gc1 == null || gc2 == null)
749                         return null;
750                 else
751                         return this;
752         }
753
754         [MethodImplAttribute (MethodImplOptions.NoInlining)]
755         public static string o2 (string[] s2, int[] s3, int[,] s4, int[,] s5, IList<int> s6) {
756                 return s2 [0] + s3 [0] + s4 [0, 0] + s6 [0];
757         }
758
759         [MethodImplAttribute (MethodImplOptions.NoInlining)]
760         public static void objrefs () {
761                 Tests t = new Tests () {};
762                 set_child (t);
763                 t.objrefs1 ();
764                 t.child = null;
765                 GC.Collect ();
766                 objrefs2 ();
767         }
768
769         [MethodImplAttribute (MethodImplOptions.NoInlining)]
770         public static void set_child (Tests t) {
771                 t.child = new Tests ();
772         }
773
774         [MethodImplAttribute (MethodImplOptions.NoInlining)]
775         public void objrefs1 () {
776         }
777
778         [MethodImplAttribute (MethodImplOptions.NoInlining)]
779         public static void objrefs2 () {
780         }
781
782         public static void vtypes () {
783                 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 ) };
784                 AStruct s = new AStruct { i = 44, s = "T", k = 45 };
785                 AStruct[] arr = new AStruct[] { 
786                         new AStruct () { i = 1, s = "S1" },
787                         new AStruct () { i = 2, s = "S2" } };
788                 TypedReference typedref = __makeref (s);
789                 t.vtypes1 (s, arr, typedref);
790                 vtypes2 (s);
791                 vtypes3 (s);
792                 vtypes4 ();
793         }
794
795         [MethodImplAttribute (MethodImplOptions.NoInlining)]
796         public object vtypes1 (AStruct s, AStruct[] arr, TypedReference typedref) {
797                 if (arr != null)
798                         return this;
799                 else
800                         return null;
801         }
802
803         [MethodImplAttribute (MethodImplOptions.NoInlining)]
804         public static void vtypes2 (AStruct s) {
805                 s.foo (5);
806         }
807
808         [MethodImplAttribute (MethodImplOptions.NoInlining)]
809         public static void vtypes3 (AStruct s) {
810                 AStruct.static_foo (5);
811         }
812
813         [MethodImplAttribute (MethodImplOptions.NoInlining)]
814         public static void vtypes4_2 (IRecStruct o) {
815         }
816
817         [MethodImplAttribute (MethodImplOptions.NoInlining)]
818         public static void vtypes4 () {
819                 IRecStruct s = new RecStruct ();
820                 s.foo (s);
821                 vtypes4_2 (s);
822         }
823
824         [MethodImplAttribute (MethodImplOptions.NoInlining)]
825         public static void locals () {
826                 string s = null;
827                 var astruct = new AStruct () { i = 42 };
828                 locals1 (null);
829                 locals2<string> (null, 5, "ABC", ref s, ref astruct);
830                 locals3 ();
831                 locals6 ();
832                 locals7<int> (22);
833         }
834
835         [MethodImplAttribute (MethodImplOptions.NoInlining)]
836         static void locals11 (double a, ref double b) {
837         }
838
839         [MethodImplAttribute (MethodImplOptions.NoInlining)]
840         public static void locals1 (string[] args) {
841                 long foo = 42;
842
843                 double ri = 1;
844                 locals11 (b: ref ri, a: ri);
845
846                 for (int j = 0; j < 10; ++j) {
847                         foo ++;
848                 }
849         }
850
851         [MethodImplAttribute (MethodImplOptions.NoInlining)]
852         [StateMachine (typeof (int))]
853         public static void locals2<T> (string[] args, int arg, T t, ref string rs, ref AStruct astruct) {
854                 long i = 42;
855                 string s = "AB";
856
857                 for (int j = 0; j < 10; ++j) {
858                         if (s != null)
859                                 i ++;
860                         if (t != null)
861                                 i ++;
862                         astruct = new AStruct ();
863                 }
864                 rs = "A";
865                 List<int> alist = new List<int> () { 12 };
866         }
867
868
869         [MethodImplAttribute (MethodImplOptions.NoInlining)]
870         public static void locals3 () {
871                 string s = "B";
872                 s.ToString ();
873
874                 {
875                         long i = 42;
876                         i ++;
877                         locals4 ();
878                 }
879                 {
880                         string i = "A";
881                         i.ToString ();
882                         locals5 ();
883                 }
884                 {
885                         long j = 42;
886                         j ++;
887                 }
888         }
889
890         [MethodImplAttribute (MethodImplOptions.NoInlining)]
891         public static void locals4 () {
892         }
893
894         [MethodImplAttribute (MethodImplOptions.NoInlining)]
895         public static void locals5 () {
896         }
897
898         [MethodImplAttribute (MethodImplOptions.NoInlining)]
899         public static void locals6 () {
900                 int i = 0;
901                 int j = 0;
902                 for (i = 0; i < 10; ++i)
903                         j ++;
904                 sbyte sb = 0;
905                 for (i = 0; i < 10; ++i)
906                         sb ++;
907                 locals6_1 ();
908                 locals6_2 (j);
909                 locals6_3 ();
910                 locals6_4 (j);
911                 locals6_5 ();
912                 locals6_6 (sb);
913         }
914
915         [MethodImplAttribute (MethodImplOptions.NoInlining)]
916         public static void locals6_1 () {
917         }
918
919         [MethodImplAttribute (MethodImplOptions.NoInlining)]
920         public static void locals6_2 (int arg) {
921         }
922
923         [MethodImplAttribute (MethodImplOptions.NoInlining)]
924         public static void locals6_3 () {
925                 // Clobber all registers
926                 int sum = 0, i, j, k, l, m;
927                 for (i = 0; i < 100; ++i)
928                         sum ++;
929                 for (j = 0; j < 100; ++j)
930                         sum ++;
931                 for (k = 0; k < 100; ++k)
932                         sum ++;
933                 for (l = 0; l < 100; ++l)
934                         sum ++;
935                 for (m = 0; m < 100; ++m)
936                         sum ++;
937         }
938
939         [MethodImplAttribute (MethodImplOptions.NoInlining)]
940         public static void locals6_4 (int arg) {
941         }
942
943         [MethodImplAttribute (MethodImplOptions.NoInlining)]
944         public static void locals6_5 () {
945         }
946
947         [MethodImplAttribute (MethodImplOptions.NoInlining)]
948         public static void locals6_6 (int arg) {
949         }
950
951         [MethodImplAttribute (MethodImplOptions.NoInlining)]
952         public static void locals7<T> (T arg) {
953                 T t = arg;
954                 T t2 = t;
955         }
956
957         [MethodImplAttribute (MethodImplOptions.NoInlining)]
958         public static void line_numbers () {
959                 LineNumbers.ln1 ();
960         }
961
962         [MethodImplAttribute (MethodImplOptions.NoInlining)]
963         public static void suspend () {
964                 long i = 5;
965
966                 while (true) {
967                         i ++;
968                 }
969         }
970
971         struct TypedRefTest {
972                 public int MaxValue;
973         }
974
975         [MethodImplAttribute (MethodImplOptions.NoInlining)]
976         public static void type_info () {
977                 Tests t = new Tests () { field_i = 42, field_s = "S", base_field_i = 43, base_field_s = "T", field_enum = AnEnum.B };
978                 t.ti1 (new Tests2 () { field_j = 43 }, new GClass <int> { field = 42 }, new GClass <string> { field = "FOO" });
979                 int val = 0;
980                 unsafe {
981                         AStruct s = new AStruct () { i = 42, s = "S", k = 43 };
982                         TypedRefTest reftest = new TypedRefTest () { MaxValue = 12 };
983                         TypedReference typedref = __makeref (reftest);
984                         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);
985                 }
986         }
987
988         [MethodImplAttribute (MethodImplOptions.NoInlining)]
989         public object ti1 (Tests2 t, GClass <int> gc1, GClass <string> gc2) {
990                 if (t == null || gc1 == null || gc2 == null)
991                         return null;
992                 else
993                         return this;
994         }
995
996         [MethodImplAttribute (MethodImplOptions.NoInlining)]
997         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) {
998                 return s2 [0] + s3 [0] + s4 [0, 0];
999         }
1000
1001         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1002         public static void assembly_load () {
1003                 assembly_load_2 ();
1004         }
1005
1006         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1007         public static void assembly_load_2 () {
1008                 // This will load System.dll while holding the loader lock
1009                 new Foo ();
1010         }
1011
1012         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1013         public static void invoke () {
1014                 new Tests ().invoke1 (new Tests2 (), new AStruct () { i = 42, j = (IntPtr)43 }, new GStruct<int> { j = 42 });
1015                 new Tests ().invoke_ex ();
1016         }
1017
1018         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1019         public void invoke1 (Tests2 t, AStruct s, GStruct<int> g) {
1020                 invoke2 ();
1021         }
1022
1023         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1024         public void invoke2 () {
1025         }
1026
1027         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1028         public void invoke_ex () {
1029                 invoke_ex_inner ();
1030         }
1031
1032         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1033         public void invoke_ex_inner () {
1034                 try {
1035                         throw new Exception ();
1036                 } catch {
1037                 }
1038         }
1039
1040         int counter;
1041
1042         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1043         public void invoke_single_threaded () {
1044                 // Spawn a thread incrementing a counter
1045                 bool finished = false;
1046
1047                 new Thread (delegate () {
1048                                 while (!finished)
1049                                         counter ++;
1050                 }).Start ();
1051
1052                 Thread.Sleep (100);
1053
1054                 invoke_single_threaded_2 ();
1055
1056                 finished = true;
1057         }
1058
1059         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1060         public void invoke_single_threaded_2 () {
1061         }
1062
1063         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1064         public void invoke_abort () {
1065         }
1066
1067         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1068         public void invoke_abort_2 () {
1069                 Thread.Sleep (1000000);
1070         }
1071
1072         public void invoke_return_void () {
1073         }
1074
1075         public string invoke_return_ref () {
1076                 return "ABC";
1077         }
1078
1079         public object invoke_return_null () {
1080                 return null;
1081         }
1082
1083         public int invoke_return_primitive () {
1084                 return 42;
1085         }
1086
1087         public int? invoke_return_nullable () {
1088                 return 42;
1089         }
1090
1091         public int? invoke_return_nullable_null () {
1092                 return null;
1093         }
1094
1095         public void invoke_type_load () {
1096                 new Class3 ();
1097         }
1098
1099         class Class3 {
1100         }
1101
1102         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) {
1103                 return ub + sb + ss + us + i + ui + l + (long)ul + (int)c + (b ? 1 : 0) + (int)f + (int)d;
1104         }
1105
1106         public int invoke_pass_primitive2 (bool b) {
1107                 return b ? 1 : 0;
1108         }
1109
1110         public string invoke_pass_ref (string s) {
1111                 return s;
1112         }
1113
1114         public static string invoke_static_pass_ref (string s) {
1115                 return s;
1116         }
1117
1118         public static void invoke_static_return_void () {
1119         }
1120
1121         public static void invoke_throws () {
1122                 throw new Exception ();
1123         }
1124
1125         public int invoke_iface () {
1126                 return 42;
1127         }
1128
1129         public void invoke_out (out int foo, out int[] arr) {
1130                 foo = 5;
1131                 arr = new int [10];
1132         }
1133
1134         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1135         public static void exceptions () {
1136                 try {
1137                         throw new OverflowException ();
1138                 } catch (Exception) {
1139                 }
1140                 try {
1141                         throw new OverflowException ();
1142                 } catch (Exception) {
1143                 }
1144                 try {
1145                         throw new ArgumentException ();
1146                 } catch (Exception) {
1147                 }
1148                 try {
1149                         throw new OverflowException ();
1150                 } catch (Exception) {
1151                 }
1152                 // no subclasses
1153                 try {
1154                         throw new OverflowException ();
1155                 } catch (Exception) {
1156                 }
1157                 try {
1158                         throw new Exception ();
1159                 } catch (Exception) {
1160                 }
1161
1162                 object o = null;
1163                 try {
1164                         o.GetType ();
1165                 } catch (Exception) {
1166                 }
1167
1168                 try {
1169                         exceptions2 ();
1170                 } catch (Exception) {
1171                 }
1172         }
1173
1174         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1175         public static void unhandled_exception () {
1176                 ThreadPool.QueueUserWorkItem (delegate {
1177                                 throw new InvalidOperationException ();
1178                         });
1179                 Thread.Sleep (10000);
1180         }
1181
1182         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1183         public static void unhandled_exception_endinvoke_2 () {
1184         }
1185
1186         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1187         public static void unhandled_exception_endinvoke () {
1188                         Action action = new Action (() => 
1189                         {
1190                                 throw new Exception ("thrown");
1191                         });
1192                         action.BeginInvoke ((ar) => {
1193                                 try {
1194                                         action.EndInvoke (ar);
1195                                 } catch (Exception ex) {
1196                                         //Console.WriteLine (ex);
1197                                 }
1198                         }, null);
1199                 Thread.Sleep (1000);
1200                 unhandled_exception_endinvoke_2 ();
1201         }
1202
1203         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1204         public static void unhandled_exception_user () {
1205                 System.Threading.Tasks.Task.Factory.StartNew (() => {
1206                                 Throw ();
1207                         });
1208                 Thread.Sleep (10000);
1209         }
1210
1211         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1212         public static void Throw () {
1213                 throw new Exception ();
1214         }
1215
1216         internal static Delegate create_filter_delegate (Delegate dlg, MethodInfo filter_method)
1217         {
1218                 if (dlg == null)
1219                         throw new ArgumentNullException ();
1220                 if (dlg.Target != null)
1221                         throw new ArgumentException ();
1222                 if (dlg.Method == null)
1223                         throw new ArgumentException ();
1224
1225                 var ret_type = dlg.Method.ReturnType;
1226                 var param_types = dlg.Method.GetParameters ().Select (x => x.ParameterType).ToArray ();
1227
1228                 var dynamic = new DynamicMethod (Guid.NewGuid ().ToString (), ret_type, param_types, typeof (object), true);
1229                 var ig = dynamic.GetILGenerator ();
1230
1231                 LocalBuilder retval = null;
1232                 if (ret_type != typeof (void))
1233                         retval = ig.DeclareLocal (ret_type);
1234
1235                 var label = ig.BeginExceptionBlock ();
1236
1237                 for (int i = 0; i < param_types.Length; i++)
1238                         ig.Emit (OpCodes.Ldarg, i);
1239                 ig.Emit (OpCodes.Call, dlg.Method);
1240
1241                 if (retval != null)
1242                         ig.Emit (OpCodes.Stloc, retval);
1243
1244                 ig.Emit (OpCodes.Leave, label);
1245
1246                 ig.BeginExceptFilterBlock ();
1247
1248                 ig.Emit (OpCodes.Call, filter_method);
1249
1250                 ig.BeginCatchBlock (null);
1251
1252                 ig.Emit (OpCodes.Pop);
1253
1254                 ig.EndExceptionBlock ();
1255
1256                 if (retval != null)
1257                         ig.Emit (OpCodes.Ldloc, retval);
1258
1259                 ig.Emit (OpCodes.Ret);
1260
1261                 return dynamic.CreateDelegate (dlg.GetType ());
1262         }
1263
1264         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1265         static void exception_filter_method () {
1266                 throw new InvalidOperationException ();
1267         }
1268
1269         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1270         static int exception_filter_filter (Exception exc) {
1271                 return 1;
1272         }
1273
1274         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1275         public static void exception_filter () {
1276                 var method = typeof (Tests).GetMethod (
1277                         "exception_filter_method", BindingFlags.NonPublic | BindingFlags.Static);
1278                 var filter_method = typeof (Tests).GetMethod (
1279                         "exception_filter_filter", BindingFlags.NonPublic | BindingFlags.Static);
1280
1281                 var dlg = Delegate.CreateDelegate (typeof (Action), method);
1282
1283                 var wrapper = (Action) create_filter_delegate (dlg, filter_method);
1284
1285                 wrapper ();
1286         }
1287
1288         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1289         public static bool return_true () {
1290                 return true;
1291         }
1292
1293         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1294         public static void exceptions2 () {
1295                 if (return_true ())
1296                         throw new Exception ();
1297                 Console.WriteLine ();
1298         }
1299
1300         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1301         public static void threads () {
1302                 Thread t = new Thread (delegate () {});
1303
1304                 t.Start ();
1305                 t.Join ();
1306         }
1307
1308         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1309         public static void domains () {
1310                 AppDomain domain = AppDomain.CreateDomain ("domain");
1311
1312                 CrossDomain o = (CrossDomain)domain.CreateInstanceAndUnwrap (
1313                                    typeof (CrossDomain).Assembly.FullName, "CrossDomain");
1314
1315                 domains_print_across (o);
1316
1317                 domains_2 (o, new CrossDomain ());
1318
1319                 o.invoke_2 ();
1320
1321                 o.invoke ();
1322
1323                 o.invoke_2 ();
1324
1325                 o.assembly_load ();
1326
1327                 AppDomain.Unload (domain);
1328
1329                 domains_3 ();
1330
1331                 typeof (Tests).GetMethod ("called_from_invoke").Invoke (null, null);
1332         }
1333
1334         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1335         public static void called_from_invoke () {
1336         }
1337
1338         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1339         public static void domains_2 (object o, object o2) {
1340         }
1341
1342         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1343         public static void domains_print_across (object o) {
1344         }
1345
1346         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1347         public static void domains_3 () {
1348         }
1349
1350         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1351         public static void invoke_in_domain () {
1352         }
1353
1354         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1355         public static void invoke_in_domain_2 () {
1356         }
1357
1358         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1359         public static void assembly_load_in_domain () {
1360                 Assembly.Load ("System.Transactions");
1361         }
1362
1363         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1364         public static void dynamic_methods () {
1365                 var m = new DynamicMethod ("dyn_method", typeof (void), new Type []  { typeof (int) }, typeof (object).Module);
1366                 var ig = m.GetILGenerator ();
1367
1368                 ig.Emit (OpCodes.Ldstr, "FOO");
1369                 ig.Emit (OpCodes.Call, typeof (Tests).GetMethod ("dyn_call"));
1370                 ig.Emit (OpCodes.Ret);
1371
1372                 var del = (Action<int>)m.CreateDelegate (typeof (Action<int>));
1373
1374                 del (0);
1375         }
1376
1377         public static void dyn_call (string s) {
1378         }
1379
1380         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1381         public static void ref_emit () {
1382                 AssemblyName assemblyName = new AssemblyName ();
1383                 assemblyName.Name = "foo";
1384
1385                 AssemblyBuilder assembly =
1386                         Thread.GetDomain ().DefineDynamicAssembly (
1387                                                                                                            assemblyName, AssemblyBuilderAccess.RunAndSave);
1388
1389                 ModuleBuilder module = assembly.DefineDynamicModule ("foo.dll");
1390
1391                 TypeBuilder tb = module.DefineType ("foo", TypeAttributes.Public, typeof (object));
1392                 MethodBuilder mb = tb.DefineMethod ("ref_emit_method", MethodAttributes.Public|MethodAttributes.Static, CallingConventions.Standard, typeof (void), new Type [] { });
1393                 ILGenerator ig = mb.GetILGenerator ();
1394                 ig.Emit (OpCodes.Ldstr, "FOO");
1395                 ig.Emit (OpCodes.Call, typeof (Tests).GetMethod ("ref_emit_call"));
1396                 ig.Emit (OpCodes.Ret);
1397
1398                 Type t = tb.CreateType ();
1399
1400                 t.GetMethod ("ref_emit_method").Invoke (null, null);
1401         }
1402
1403         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1404         public static void ref_emit_call (string s) {
1405         }
1406
1407         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1408         public static void frames_in_native () {
1409                 Thread.Sleep (500);
1410                 var evt = new ManualResetEvent (false);
1411                 
1412                 object mon = new object ();
1413                 ThreadPool.QueueUserWorkItem (delegate {
1414                                 frames_in_native_2 ();
1415                                 evt.Set ();
1416                         });
1417                 evt.WaitOne ();
1418         }
1419
1420         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1421         static void frames_in_native_2 () {
1422                 frames_in_native_3 ();
1423         }
1424
1425         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1426         static void frames_in_native_3 () {
1427         }
1428
1429         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1430         public static void string_call (string s) {
1431         }
1432
1433         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1434         public static void ss_regress_654694 () {
1435                 if (true) {
1436                         string h = "hi";
1437                         string_call (h);
1438                 }
1439         }
1440
1441         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1442         public static void user () {
1443                 Debugger.Break ();
1444
1445                 Debugger.Log (5, Debugger.IsLogging () ? "A" : "", "B");
1446         }
1447
1448         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1449         public static void type_load () {
1450                 type_load_2 ();
1451         }
1452
1453         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1454         static void type_load_2 () {
1455                 var c1 = new Dictionary<int, int> ();
1456                 c1.ToString ();
1457                 var c = new TypeLoadClass ();
1458                 c.ToString ();
1459                 var c2 = new TypeLoadClass2 ();
1460                 c2.ToString ();
1461         }
1462
1463         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1464         public static void regress () {
1465                 regress_2755 (DateTime.Now);
1466         }
1467
1468         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1469         public static unsafe void regress_2755 (DateTime d) {
1470                 int* buffer = stackalloc int [128];
1471
1472                 regress_2755_2 ();
1473
1474                 int sum = 0;
1475                 for (int i = 0; i < 128; ++i)
1476                         sum += buffer [i];
1477
1478                 regress_2755_3 (sum);
1479         }
1480
1481         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1482         public static void regress_2755_2 () {
1483         }
1484
1485         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1486         public static void regress_2755_3 (int sum) {
1487         }
1488
1489         static object gc_suspend_field;
1490
1491         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1492         static unsafe void set_gc_suspend_field () {
1493                 set_gc_suspend_field_2 ();
1494                 // Clear stack
1495                 int* buffer = stackalloc int [4096];
1496         }
1497
1498         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1499         static void set_gc_suspend_field_2 () {
1500                 gc_suspend_field = new object ();
1501         }
1502
1503         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1504         static void gc_suspend_1 () {
1505         }
1506
1507         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1508         public static void gc_suspend_invoke () {
1509                 gc_suspend_field = null;
1510                 GC.Collect ();
1511                 GC.WaitForPendingFinalizers ();
1512         }
1513
1514         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1515         public static void gc_suspend () {
1516                 set_gc_suspend_field ();
1517                 gc_suspend_1 ();
1518         }
1519
1520         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1521         public static void generic_method<T> () where T : class {
1522         }
1523
1524         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1525         public void evaluate_method_2 () {
1526         }
1527
1528         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1529         public void evaluate_method () {
1530                 field_i = 42;
1531                 evaluate_method_2 ();
1532         }
1533
1534         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1535         static void set_ip_1 () {
1536         }
1537
1538         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1539         static void set_ip_2 () {
1540         }
1541
1542         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1543         public static void set_ip () {
1544                 int i = 0, j;
1545
1546                 i ++;
1547                 i ++;
1548                 set_ip_1 ();
1549                 i ++;
1550                 j = 5;
1551                 set_ip_2 ();
1552         }
1553
1554         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1555         public static void step_filters () {
1556                 ClassWithCctor.cctor_filter ();
1557         }
1558
1559         class ClassWithCctor {
1560                 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1561                 static ClassWithCctor () {
1562                         int i = 1;
1563                         int j = 2;
1564                 }
1565
1566                 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1567                 public static void cctor_filter () {
1568                 }
1569         }
1570
1571         public override string virtual_method () {
1572                 return "V2";
1573         }
1574
1575         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1576         public static void threadpool_bp () { }
1577
1578         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1579         public static void threadpool_io () {
1580                 // Start a threadpool task that blocks on I/O.
1581                 // Regression test for #42625
1582                 const int nbytes = 16;
1583                 var bsOut = new byte[nbytes];
1584                 for (int i = 0; i < nbytes; i++) {
1585                         bsOut[i] = (byte)i;
1586                 }
1587                 var endPoint = NetworkHelpers.LocalEphemeralEndPoint ();
1588                 var l = new TcpListener (endPoint);
1589                 l.Start ();
1590                 Task<byte[]> t = Task.Run (async () => {
1591                         var c = new TcpClient ();
1592                         await c.ConnectAsync (endPoint.Address, endPoint.Port);
1593                         var streamIn = c.GetStream ();
1594                         var bs = new byte[nbytes];
1595                         int nread = 0;
1596                         int nremain = nbytes;
1597                         while (nread < nbytes) {
1598                                 int r = await streamIn.ReadAsync (bs, nread, nremain);
1599                                 nread += r;
1600                                 nremain -= r;
1601                         }
1602                         streamIn.Close ();
1603                         return bs;
1604                         });
1605                 var s = l.AcceptTcpClient ();
1606                 l.Stop ();
1607                 // write bytes in two groups so that the task blocks on the ReadAsync
1608                 var streamOut = s.GetStream ();
1609                 var nbytesFirst = nbytes / 2;
1610                 var nbytesRest = nbytes - nbytesFirst;
1611                 streamOut.Write (bsOut, 0, nbytesFirst);
1612                 threadpool_bp ();
1613                 streamOut.Write (bsOut, nbytesFirst, nbytesRest);
1614                 streamOut.Close ();
1615                 var bsIn = t.Result;
1616         }
1617 }
1618
1619 public class SentinelClass : MarshalByRefObject {
1620 }
1621
1622 public class CrossDomain : MarshalByRefObject
1623 {
1624         SentinelClass printMe = new SentinelClass ();
1625
1626         public void invoke () {
1627                 Tests.invoke_in_domain ();
1628         }
1629
1630         public void invoke_2 () {
1631                 Tests.invoke_in_domain_2 ();
1632         }
1633
1634         public int invoke_3 () {
1635                 return 42;
1636         }
1637
1638         public void assembly_load () {
1639                 Tests.assembly_load_in_domain ();
1640         }
1641 }       
1642
1643 public class Foo
1644 {
1645         public ProcessStartInfo info;
1646 }
1647
1648 class LocalReflectClass
1649 {
1650         public static void RunMe ()
1651         {
1652                 var reflectMe = new someClass ();
1653                 var temp = reflectMe; // Breakpoint location
1654                 reflectMe.someMethod ();
1655         }
1656
1657         class someClass : ContextBoundObject
1658         {
1659                 public object someField;
1660
1661                 public void someMethod ()
1662                 {
1663                 }
1664         }
1665 }
1666
1667 // Class used for line number info testing, don't change its layout
1668 public class LineNumbers
1669 {
1670         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1671         public static void ln1 () {
1672                 // Column 3
1673                 ln2 ();
1674                 ln3 ();
1675         }
1676
1677         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1678         public static void ln2 () {
1679         }
1680
1681         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1682         public static void ln3 () {
1683 #pragma warning disable 0219
1684                 int i = 5;
1685 #pragma warning restore 0219
1686                 #line 55 "FOO"
1687         }
1688 }
1689
1690
1691