forked from mono/mono
/
dtest-app.cs
1993 lines (1651 loc) · 45.5 KB
/
dtest-app.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* dtest-app.cs:
*
* Application program used by the debugger tests.
*/
using System;
using System.Runtime.CompilerServices;
using System.Reflection;
using System.Reflection.Emit;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
#if !MOBILE
using MonoTests.Helpers;
#endif
public class TestsBase
{
#pragma warning disable 0414
#pragma warning disable 0169
public int base_field_i;
public string base_field_s;
static int base_static_i = 57;
static string base_static_s = "C";
#pragma warning restore 0414
#pragma warning restore 0169
public virtual string virtual_method () {
return "V1";
}
}
public enum AnEnum {
A = 0,
B= 1
}
public sealed class Tests3 {
public static void M1 () {
}
static void M2 () {
}
public void M3 () {
}
void M4 () {
}
}
public static class Tests4 {
static Tests4 () {
}
}
public class AAttribute : Attribute {
public int afield;
}
public class BAttribute : AAttribute {
public int bfield;
}
[DebuggerDisplay ("Tests", Name="FOO", Target=typeof (int))]
[DebuggerTypeProxy (typeof (Tests))]
[BAttribute (afield = 1, bfield = 2)]
public class Tests2 {
[DebuggerBrowsableAttribute (DebuggerBrowsableState.Collapsed)]
public int field_j;
public static int static_field_j;
[DebuggerBrowsableAttribute (DebuggerBrowsableState.Collapsed)]
public int AProperty {
get {
return 0;
}
}
public void invoke () {
}
}
public struct TestEnumeratorInsideGenericStruct<TKey, TValue>
{
private KeyValuePair<TKey, TValue> _bucket;
private Position _currentPosition;
internal TestEnumeratorInsideGenericStruct(KeyValuePair<TKey, TValue> bucket)
{
_bucket = bucket;
_currentPosition = Position.BeforeFirst;
}
public KeyValuePair<TKey, TValue> Current
{
get
{
if (_currentPosition == Position.BeforeFirst)
return _bucket;
return _bucket;
}
}
private enum Position
{
BeforeFirst
}
}
public struct AStruct : ITest2 {
public int i;
public string s;
public byte k;
public IntPtr j;
public int l;
/*
public AStruct () {
i = 0;
s = null;
k = 0;
j = IntPtr.Zero;
l = 0;
}
*/
public AStruct (int arg) {
i = arg;
s = null;
k = 0;
j = IntPtr.Zero;
l = 0;
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public int foo (int val) {
return val;
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static int static_foo (int val) {
return val;
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public int invoke_return_int () {
return i;
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static int invoke_static () {
return 5;
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public IntPtr invoke_return_intptr () {
return j;
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public void invoke_mutate () {
l = 5;
}
public int invoke_iface () {
return i;
}
public override string ToString () {
return i.ToString ();
}
}
public struct BlittableStruct {
public int i;
public double d;
}
public class GClass<T> {
public T field;
public static T static_field;
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public GClass () {
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public void bp<T2> () {
}
}
public struct GStruct<T> {
public T i;
public int j;
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public int invoke_return_int () {
return j;
}
}
public struct NestedStruct {
NestedInner nested1, nested2;
}
public struct NestedInner {
}
public interface IRecStruct {
void foo (object o);
}
struct RecStruct : IRecStruct {
public object o;
public void foo (object o) {
this.o = o;
}
}
interface ITest
{
void Foo ();
void Bar ();
}
interface ITest<T>
{
void Foo ();
void Bar ();
}
class TestIfaces : ITest
{
void ITest.Foo () {
}
void ITest.Bar () {
}
TestIfaces<int> Baz () {
return null;
}
}
class TestIfaces<T> : ITest<T>
{
void ITest<T>.Foo () {
}
void ITest<T>.Bar () {
}
}
public interface ITest2
{
int invoke_iface ();
}
public class Tests : TestsBase, ITest2
{
#pragma warning disable 0414
int field_i;
string field_s;
AnEnum field_enum;
bool field_bool1, field_bool2;
char field_char;
byte field_byte;
sbyte field_sbyte;
short field_short;
ushort field_ushort;
long field_long;
ulong field_ulong;
float field_float;
double field_double;
Thread field_class;
IntPtr field_intptr;
int? field_nullable;
static int static_i = 55;
static string static_s = "A";
public const int literal_i = 56;
public const string literal_s = "B";
public object child;
public AStruct field_struct;
public object field_boxed_struct;
public GStruct<int> generic_field_struct;
public KeyValuePair<int, object> boxed_struct_field;
[ThreadStatic]
public static int tls_i;
public static bool is_attached = Debugger.IsAttached;
public NestedStruct nested_struct;
static string arg;
#pragma warning restore 0414
public class NestedClass {
}
public int IntProperty {
get {
return field_i;
}
set {
field_i = value;
}
}
public int ReadOnlyProperty {
get {
return field_i;
}
}
public int this [int index] {
get {
return field_i;
}
}
public static void wait_one ()
{
ManualResetEvent evt = new ManualResetEvent (false);
evt.WaitOne ();
}
public static int Main (String[] args) {
if (args.Length == 0)
args = new String [] { Tests.arg };
tls_i = 42;
if (args.Length > 0 && args [0] == "suspend-test")
/* This contains an infinite loop, so execute it conditionally */
suspend ();
if (args.Length >0 && args [0] == "unhandled-exception") {
unhandled_exception ();
return 0;
}
if (args.Length >0 && args [0] == "unhandled-exception-endinvoke") {
unhandled_exception_endinvoke ();
return 0;
}
if (args.Length >0 && args [0] == "crash-vm") {
crash ();
return 0;
}
if (args.Length >0 && args [0] == "unhandled-exception-user") {
unhandled_exception_user ();
return 0;
}
if (args.Length >0 && args [0] == "wait-one") {
wait_one ();
return 0;
}
if (args.Length >0 && args [0] == "threadpool-io") {
#if !MOBILE
threadpool_io ();
#else
throw new Exception ("Can't run threadpool-io test on mobile");
#endif
return 0;
}
if (args.Length > 0 && args [0] == "attach") {
new Tests ().attach ();
return 0;
}
if (args.Length > 0 && args [0] == "step-out-void-async") {
var wait = new ManualResetEvent (false);
step_out_void_async (wait);
wait.WaitOne ();//Don't exist until step_out_void_async is executed...
return 0;
}
assembly_load ();
breakpoints ();
single_stepping ();
arguments ();
objects ();
objrefs ();
vtypes ();
locals ();
line_numbers ();
type_info ();
invoke ();
exceptions ();
exception_filter ();
threads ();
dynamic_methods ();
user ();
#if !MOBILE
type_load ();
#endif
regress ();
gc_suspend ();
set_ip ();
step_filters ();
pointers ();
ref_return ();
if (args.Length > 0 && args [0] == "local-reflect")
local_reflect ();
if (args.Length > 0 && args [0] == "domain-test")
/* This takes a lot of time, so execute it conditionally */
domains ();
if (args.Length > 0 && args [0] == "ref-emit-test")
ref_emit ();
if (args.Length > 0 && args [0] == "frames-in-native")
frames_in_native ();
if (args.Length > 0 && args [0] == "invoke-single-threaded")
new Tests ().invoke_single_threaded ();
if (args.Length > 0 && args [0] == "invoke-abort")
new Tests ().invoke_abort ();
new Tests ().evaluate_method ();
Bug59649 ();
inspect_enumerator_in_generic_struct();
return 3;
}
public static void local_reflect () {
//Breakpoint line below, and reflect someField via ObjectMirror;
LocalReflectClass.RunMe ();
}
public static void breakpoints () {
/* Call these early so it is JITted by the time a breakpoint is placed on it */
bp3 ();
bp7<int> ();
bp7<string> ();
bp1 ();
bp2 ();
bp3 ();
bp4 ();
bp4 ();
bp4 ();
bp5 ();
bp6<string> (new GClass <int> ());
bp7<int> ();
bp7<string> ();
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void bp1 () {
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void bp2 () {
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void bp3 () {
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void bp4 () {
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void bp5 () {
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void bp6<T> (GClass<int> gc) {
gc.bp<int> ();
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void bp7<T> () {
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void single_stepping () {
bool b = true;
ss1 ();
ss2 ();
ss3 ();
ss3_2 ();
ss4 ();
ss5 (new int [] { 1, 2, 3 }, new Func<int, bool> (is_even));
try {
ss6 (b);
} catch {
}
ss7 ();
ss_nested ();
ss_nested_with_two_args_wrapper ();
ss_regress_654694 ();
ss_step_through ();
ss_non_user_code ();
ss_recursive (1);
ss_recursive2 (1);
ss_recursive2 (1);
ss_recursive_chaotic ();
ss_fp_clobber ();
ss_no_frames ();
ss_await ();
ss_nested_with_three_args_wrapper();
ss_nested_twice_with_two_args_wrapper();
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void ss1 () {
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void ss2 () {
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static int ss3 () {
int sum = 0;
for (int i = 0; i < 10; ++i)
sum += i;
return sum;
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void ss3_2 () {
ss3_2_2 ();
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void ss3_2_2 () {
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static int ss4 () {
ss1 (); ss1 ();
ss2 ();
return 0;
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void ss5 (int[] arr, Func<int, bool> selector) {
// Call into linq which calls back into this assembly
arr.Count (selector);
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void ss6 (bool b) {
if (b) {
ss6_2 ();
throw new Exception ();
}
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void ss6_2 () {
}
[MethodImplAttribute(MethodImplOptions.NoInlining)]
public static void ss7 ()
{
ss7_2();//Used to test stepout inside ss7_2, which may not go to catch
ss7_2();//Used to test stepout inside ss7_2_1, which must go to catch
ss7_2();//Used to test stepover inside ss7_2, which must go to catch
ss7_2();//Used to test stepover inside ss7_2_1, which must go to catch
ss7_3();//Used to test stepin inside ss7_3, which must go to catch
ss7_2();//Used to test stepin inside ss7_2_1, which must go to catch
}
[MethodImplAttribute(MethodImplOptions.NoInlining)]
public static void ss7_2_1 ()
{
throw new Exception ();
}
[MethodImplAttribute(MethodImplOptions.NoInlining)]
public static void ss7_2_2 ()
{
ss7_2_1();
}
[MethodImplAttribute(MethodImplOptions.NoInlining)]
public static void ss7_2 ()
{
try {
ss7_2_2();
}
catch
{
}
}
[MethodImplAttribute(MethodImplOptions.NoInlining)]
public static void ss7_3 ()
{
try {
throw new Exception ();
}
catch
{
}
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void ss_nested () {
ss_nested_1 (ss_nested_2 ());
ss_nested_1 (ss_nested_2 ());
ss_nested_3 ();
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void ss_nested_with_two_args_wrapper () {
ss_nested_with_two_args(ss_nested_arg (), ss_nested_arg ());
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void ss_nested_with_three_args_wrapper () {
ss_nested_with_three_args(ss_nested_arg1 (), ss_nested_arg2 (), ss_nested_arg3 ());
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void ss_nested_twice_with_two_args_wrapper () {
ss_nested_with_two_args(ss_nested_arg1 (), ss_nested_with_two_args(ss_nested_arg2 (), ss_nested_arg3 ()));
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void inspect_enumerator_in_generic_struct() {
TestEnumeratorInsideGenericStruct<String, String> generic_struct = new TestEnumeratorInsideGenericStruct<String, String>(new KeyValuePair<string, string>("0", "f1"));
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static int ss_nested_with_two_args (int a1, int a2) {
return a1 + a2;
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static int ss_nested_with_three_args (int a1, int a2, int a3) {
return a1 + a2 + a3;
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static int ss_nested_arg () {
return 0;
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static int ss_nested_arg1 () {
return 0;
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static int ss_nested_arg2 () {
return 0;
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static int ss_nested_arg3 () {
return 0;
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void ss_nested_1 (int i) {
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static int ss_nested_2 () {
return 0;
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void ss_nested_3 () {
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void ss_step_through () {
step_through_1 ();
StepThroughClass.step_through_2 ();
step_through_3 ();
}
[DebuggerStepThrough]
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void step_through_1 () {
}
[DebuggerStepThrough]
class StepThroughClass {
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void step_through_2 () {
}
}
[DebuggerStepThrough]
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void step_through_3 () {
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void ss_non_user_code () {
non_user_code_1 ();
StepNonUserCodeClass.non_user_code_2 ();
non_user_code_3 ();
}
[DebuggerNonUserCode]
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void non_user_code_1 () {
}
[DebuggerNonUserCode]
class StepNonUserCodeClass {
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void non_user_code_2 () {
}
}
[DebuggerNonUserCode]
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void non_user_code_3 () {
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void ss_recursive (int n) {
if (n == 10)
return;
ss_recursive (n + 1);
}
// Breakpoint will be placed here
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void ss_recursive2_trap ()
{
}
public static void ss_recursive2_at (string s)
{
// Console.WriteLine (s);
}
// This method is used both for a step over and step out test.
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void ss_recursive2 (int x)
{
ss_recursive2_at ( "ss_recursive2 in " + x);
if (x < 5) {
int next = x + 1;
ss_recursive2_at ("ss_recursive2 descend " + x);
ss_recursive2_trap ();
ss_recursive2 (next);
}
ss_recursive2_at ("ss_recursive2 out " + x);
}
// Breakpoint will be placed here
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void ss_recursive_chaotic_trap ()
{
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void ss_recursive_chaotic_at (bool exiting, string at, int n)
{
// string indent = "";
// for (int count = 5 - n; count > 0; count--)
// indent += "\t";
// Console.WriteLine (indent + (exiting ? "<--" : "-->") + " " + at + " " + n);
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void ss_recursive_chaotic_fizz (int n)
{
ss_recursive_chaotic_at (false, "fizz", n);
if (n > 0) {
int next = n - 1;
ss_recursive_chaotic_buzz (next);
ss_recursive_chaotic_fizzbuzz (next);
} else {
ss_recursive_chaotic_trap ();
}
ss_recursive_chaotic_at (true, "fizz", n);
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void ss_recursive_chaotic_buzz (int n)
{
ss_recursive_chaotic_at (false, "buzz", n);
if (n > 0) {
int next = n - 1;
ss_recursive_chaotic_fizz (next);
ss_recursive_chaotic_fizzbuzz (next);
}
ss_recursive_chaotic_at (true, "buzz", n);
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void ss_recursive_chaotic_fizzbuzz (int n)
{
ss_recursive_chaotic_at (false, "fizzbuzz", n);
if (n > 0) {
int next = n - 1;
ss_recursive_chaotic_fizz (next);
ss_recursive_chaotic_buzz (next);
ss_recursive_chaotic_fizzbuzz (next);
}
ss_recursive_chaotic_at (true, "fizzbuzz", n);
}
// Call a complex tree of recursive calls that has tripped up "step out" in the past.
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void ss_recursive_chaotic ()
{
ss_recursive_chaotic_fizz (5);
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void ss_fp_clobber () {
double v = ss_fp_clobber_1 (5.0);
ss_fp_clobber_2 (v);
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static double ss_fp_clobber_1 (double d) {
return d + 2.0;
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void ss_fp_clobber_2 (double d) {
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void ss_no_frames () {
Action a = ss_no_frames_2;
var ar = a.BeginInvoke (null, null);
ar.AsyncWaitHandle.WaitOne ();
// Avoid waiting every time this runs
if (static_i == 56)
Thread.Sleep (200);
ss_no_frames_3 ();
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void ss_await ()
{
ss_await_1 ().Wait ();//in
ss_await_1 ().Wait ();//over
ss_await_1 ().Wait ();//out before
ss_await_1 ().Wait ();//out after
ss_await_1_exc (true, true).Wait ();//in
ss_await_1_exc (true, true).Wait ();//over
ss_await_1_exc (true, true).Wait ();//out
try {
ss_await_1_exc (true, false).Wait ();//in
} catch { }
try {
ss_await_1_exc (true, false).Wait ();//over
} catch { }
try {
ss_await_1_exc (true, false).Wait ();//out
} catch { }
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static async Task<int> ss_await_1 () {
var a = 1;
await Task.Delay (10);
return a + 2;
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static async Task<int> ss_await_1_exc (bool exc, bool handled)
{
var a = 1;
await Task.Delay (10);
if (exc) {
if (handled) {
try {
throw new Exception ();
} catch {
}
} else {
throw new Exception ();
}
}
return a + 2;
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void ss_no_frames_2 () {
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void ss_no_frames_3 () {
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static bool is_even (int i) {
return i % 2 == 0;
}
/*
lock (static_s) {
Console.WriteLine ("HIT!");
}
return 0;
}
*/
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void arguments () {
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));
int i = 42;
arg2 ("FOO", null, "BLA", ref i, new GClass <int> { field = 42 }, new object (), '\0'.ToString () + "A");
Tests t = new Tests () { field_i = 42, field_s = "S" };
t.arg3 ("BLA");
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
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) {
return (int)(sb + b + (bl ? 0 : 1) + s + us + (int)c + i + ui + l + (long)ul + f + d + (int)ip + (int)uip);
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static string arg2 (string s, string s3, object o, ref int i, GClass <int> gc, object o2, string s4) {
return s + (s3 != null ? "" : "") + o + i + gc.field + o2;
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public object arg3 (string s) {
return s + s + s + s + this;
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void objects () {
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 };
t.o1 (new Tests2 () { field_j = 43 }, new GClass <int> { field = 42 }, new GClass <string> { field = "FOO" });
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 });
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public object o1 (Tests2 t, GClass <int> gc1, GClass <string> gc2) {
if (t == null || gc1 == null || gc2 == null)
return null;
else
return this;
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static string o2 (string[] s2, int[] s3, int[,] s4, int[,] s5, IList<int> s6) {
return s2 [0] + s3 [0] + s4 [0, 0] + s6 [0];
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void objrefs () {
Tests t = new Tests () {};
set_child (t);
t.objrefs1 ();
t.child = null;
GC.Collect ();
objrefs2 ();
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void set_child (Tests t) {
t.child = new Tests ();
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public void objrefs1 () {
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void objrefs2 () {
}
public static void vtypes () {
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 ) };
AStruct s = new AStruct { i = 44, s = "T", k = 45 };
AStruct[] arr = new AStruct[] {
new AStruct () { i = 1, s = "S1" },
new AStruct () { i = 2, s = "S2" } };
TypedReference typedref = __makeref (s);
t.vtypes1 (s, arr, typedref);
vtypes2 (s);
vtypes3 (s);
vtypes4 ();
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public object vtypes1 (AStruct s, AStruct[] arr, TypedReference typedref) {
if (arr != null)
return this;
else
return null;
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void vtypes2 (AStruct s) {
s.foo (5);
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void vtypes3 (AStruct s) {