summaryrefslogtreecommitdiff
path: root/mcs/tests/test-nameof-02.cs
blob: 7cdecb1e1e64efd80e7ed17ea66d777beeb288ad (plain)
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
using System;
using System.Collections.Generic;
using SCG = System.Collections.Generic;
using SCGL = System.Collections.Generic.List<string>;

class A<T>
{
	public class B
	{
		public int Foo;
	}
}

class X
{
	bool field;
	long Prop { get; set; }
	event Action ev;

	public static int Main ()
	{
		int res;
		var x = new X ();
		res = x.SimpleName (1);
		if (res != 0)
			return res;

		res = x.MemberAccess ();
		if (res != 0)
			return 20 + res;

		res = x.QualifiedName ();
		if (res != 0)
			return 40 + res;

		return 0;
	}

	static void GenMethod<T, U, V> ()
	{
	}

	int SimpleName<T> (T arg)
	{
		const object c = null;
		decimal d = 0;

		if (nameof (T) != "T")
			return 1;

		if (nameof (arg) != "arg")
			return 2;

		if (nameof (c) != "c")
			return 3;

		if (nameof (d) != "d")
			return 4;

		if (nameof (field) != "field")
			return 5;

		if (nameof (Prop) != "Prop")
			return 6;

		if (nameof (@Main) != "Main")
			return 7;

		if (nameof (ev) != "ev")
			return 8;

		if (nameof (Int32) != "Int32")
			return 9;

		if (nameof (Action) != "Action")
			return 10;

		if (nameof (List<bool>) != "List")
			return 11;

		if (nameof (GenMethod) != "GenMethod")
			return 12;

		return 0;
	}

	int MemberAccess ()
	{
		if (nameof (X.field) != "field")
			return 1;

		if (nameof (X.Prop) != "Prop")
			return 2;

		if (nameof (Console.WriteLine) != "WriteLine")
			return 3;

		if (nameof (System.Collections.Generic.List<long>) != "List")
			return 4;

		if (nameof (System.Collections) != "Collections")
			return 5;

		if (nameof (X.GenMethod) != "GenMethod")
			return 6;

		if (nameof (A<char>.B) != "B")
			return 7;

		if (nameof (A<ushort>.B.Foo) != "Foo")
			return 7;

		return 0;
	}

	int QualifiedName ()
	{
		if (nameof (global::System.Int32) != "Int32")
			return 1;

		if (nameof (SCG.List<short>) != "List")
			return 2;

		if (nameof (SCGL.Contains) != "Contains")
			return 3;

		return 0;
	}
}