Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mcs / tests / test-nameof-02.cs
1 using System;
2 using System.Collections.Generic;
3 using SCG = System.Collections.Generic;
4 using SCGL = System.Collections.Generic.List<string>;
5
6 class A<T>
7 {
8         public class B
9         {
10                 public int Foo;
11         }
12 }
13
14 class X
15 {
16         bool field;
17         long Prop { get; set; }
18         event Action ev;
19
20         public static int Main ()
21         {
22                 int res;
23                 var x = new X ();
24                 res = x.SimpleName (1);
25                 if (res != 0)
26                         return res;
27
28                 res = x.MemberAccess ();
29                 if (res != 0)
30                         return 20 + res;
31
32                 res = x.QualifiedName ();
33                 if (res != 0)
34                         return 40 + res;
35
36                 return 0;
37         }
38
39         static void GenMethod<T, U, V> ()
40         {
41         }
42
43         int SimpleName<T> (T arg)
44         {
45                 const object c = null;
46                 decimal d = 0;
47
48                 if (nameof (T) != "T")
49                         return 1;
50
51                 if (nameof (arg) != "arg")
52                         return 2;
53
54                 if (nameof (c) != "c")
55                         return 3;
56
57                 if (nameof (d) != "d")
58                         return 4;
59
60                 if (nameof (field) != "field")
61                         return 5;
62
63                 if (nameof (Prop) != "Prop")
64                         return 6;
65
66                 if (nameof (@Main) != "Main")
67                         return 7;
68
69                 if (nameof (ev) != "ev")
70                         return 8;
71
72                 if (nameof (Int32) != "Int32")
73                         return 9;
74
75                 if (nameof (Action) != "Action")
76                         return 10;
77
78                 if (nameof (List<bool>) != "List")
79                         return 11;
80
81                 if (nameof (GenMethod) != "GenMethod")
82                         return 12;
83
84                 return 0;
85         }
86
87         int MemberAccess ()
88         {
89                 if (nameof (X.field) != "field")
90                         return 1;
91
92                 if (nameof (X.Prop) != "Prop")
93                         return 2;
94
95                 if (nameof (Console.WriteLine) != "WriteLine")
96                         return 3;
97
98                 if (nameof (System.Collections.Generic.List<long>) != "List")
99                         return 4;
100
101                 if (nameof (System.Collections) != "Collections")
102                         return 5;
103
104                 if (nameof (X.GenMethod) != "GenMethod")
105                         return 6;
106
107                 if (nameof (A<char>.B) != "B")
108                         return 7;
109
110                 if (nameof (A<ushort>.B.Foo) != "Foo")
111                         return 7;
112
113                 return 0;
114         }
115
116         int QualifiedName ()
117         {
118                 if (nameof (global::System.Int32) != "Int32")
119                         return 1;
120
121                 if (nameof (SCG.List<short>) != "List")
122                         return 2;
123
124                 if (nameof (SCGL.Contains) != "Contains")
125                         return 3;
126
127                 return 0;
128         }
129 }