-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdtest-001.cs
152 lines (111 loc) · 3.97 KB
/
dtest-001.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
//
// dynamic type attribute decoration
//
using System;
using System.Collections;
using System.Runtime.CompilerServices;
using System.Collections.Generic;
using System.Linq;
interface I<T>
{
}
class C
{
public C (dynamic d)
{
}
public dynamic a;
public const dynamic c = default (dynamic);
public dynamic Prop { set; get; }
public dynamic Prop2 { set { } }
public dynamic this[dynamic d] { set { } get { return 1; } }
public dynamic Method (dynamic d)
{
return null;
}
// Transformation handling required
public dynamic[] t;
public dynamic[,] t2;
public Func<dynamic, int, dynamic[]> v;
public I<dynamic>[] iface;
}
delegate dynamic Del (dynamic d);
class Test
{
public static int Main ()
{
Type t = typeof (C);
Type ca = typeof (System.Runtime.CompilerServices.DynamicAttribute);
if (t.GetMember ("a")[0].GetCustomAttributes (ca, false).Length != 1)
return 1;
if (t.GetMember ("c")[0].GetCustomAttributes (ca, false).Length != 1)
return 3;
if (t.GetMember ("Prop")[0].GetCustomAttributes (ca, false).Length != 1)
return 4;
if (t.GetMember ("get_Prop")[0].GetCustomAttributes (ca, false).Length != 0)
return 5;
if (t.GetMethod ("get_Prop").ReturnParameter.GetCustomAttributes (ca, false).Length != 1)
return 6;
if (t.GetMember ("set_Prop")[0].GetCustomAttributes (ca, false).Length != 0)
return 7;
if (t.GetMethod ("set_Prop").ReturnParameter.GetCustomAttributes (ca, false).Length != 0)
return 8;
if (t.GetMethod ("set_Prop").GetParameters ()[0].GetCustomAttributes (ca, false).Length != 1)
return 9;
if (t.GetMember ("Prop2")[0].GetCustomAttributes (ca, false).Length != 1)
return 10;
if (t.GetMember ("set_Prop2")[0].GetCustomAttributes (ca, false).Length != 0)
return 11;
if (t.GetMember ("Item")[0].GetCustomAttributes (ca, false).Length != 1)
return 12;
if (t.GetMethod ("get_Item").ReturnParameter.GetCustomAttributes (ca, false).Length != 1)
return 13;
if (t.GetMethod ("get_Item").GetParameters ()[0].GetCustomAttributes (ca, false).Length != 1)
return 14;
if (t.GetMethod ("set_Item").ReturnParameter.GetCustomAttributes (ca, false).Length != 0)
return 15;
if (t.GetMethod ("set_Item").GetParameters ()[0].GetCustomAttributes (ca, false).Length != 1)
return 16;
if (t.GetMethod ("set_Item").GetParameters ()[1].GetCustomAttributes (ca, false).Length != 1)
return 17;
if (t.GetMember ("Method")[0].GetCustomAttributes (ca, false).Length != 0)
return 18;
if (t.GetMethod ("Method").GetParameters ()[0].GetCustomAttributes (ca, false).Length != 1)
return 19;
if (t.GetConstructors ()[0].GetParameters ()[0].GetCustomAttributes (ca, false).Length != 1)
return 20;
if (t.GetConstructors ()[0].GetCustomAttributes (ca, false).Length != 0)
return 21;
// Transformations
DynamicAttribute da;
da = t.GetMember ("t")[0].GetCustomAttributes (ca, false)[0] as DynamicAttribute;
if (da == null)
return 40;
if (!da.TransformFlags.SequenceEqual (new bool[] { false, true }))
return 41;
da = t.GetMember ("t2")[0].GetCustomAttributes (ca, false)[0] as DynamicAttribute;
if (da == null)
return 42;
if (!da.TransformFlags.SequenceEqual (new bool[] { false, true }))
return 43;
da = t.GetMember ("v")[0].GetCustomAttributes (ca, false)[0] as DynamicAttribute;
if (da == null)
return 44;
if (!da.TransformFlags.SequenceEqual (new bool[] { false, true, false, false, true }))
return 45;
da = t.GetMember ("iface")[0].GetCustomAttributes (ca, false)[0] as DynamicAttribute;
if (da == null)
return 46;
if (!da.TransformFlags.SequenceEqual (new bool[] { false, false, true }))
return 47;
t = typeof (Del);
if (t.GetMember ("Invoke")[0].GetCustomAttributes (ca, false).Length != 0)
return 100;
if (t.GetMethod ("Invoke").GetParameters ()[0].GetCustomAttributes (ca, false).Length != 1)
return 101;
if (t.GetMethod ("Invoke").ReturnParameter.GetCustomAttributes (ca, false).Length != 1)
return 102;
Console.WriteLine ("ok");
return 0;
}
}