2 // tuple names attribute decoration
6 using System
.Collections
;
7 using System
.Runtime
.CompilerServices
;
8 using System
.Collections
.Generic
;
19 class C
// : B<(int a, int b)> // TODO: I<(a, b)
21 public C((int a
, int b
) d
)
25 public (int a
, int b
) a
;
26 public (int, (int a
, int b
)) c
;
28 public (int a
, int b
) Prop { set; get; }
29 public (int a
, int b
) Prop2 { set { }
}
31 public (int a
, int b
)? this[(int a
, int b
) d
] { set { }
get { return null; }
}
33 public (int a
, int b
)? Method(ref (int a
, int b
) d
)
38 public (int a
, int b
)[] t
;
39 public (int a
, int b
)[,] t2
;
40 // TODO: public Func<(int a, int b), int, (int c, int d)[]> v;
41 // public I<(int a, int b)>[] iface;
42 // TODO: public Action<(long, (long u, long))[], object, (int a, int b)> d2;
43 public (((int aa1
, int aa2
) a1
, (int, int) a2
) x1
, ((int cc1
, int cc2
) b1
, (int dd1
, int dd2
) b2
) x2
) d3
;
46 delegate (int a
, int b
) Del((int a
, int b
) d
);
50 public static int Main()
53 Type ca
= typeof(TupleElementNamesAttribute
);
54 TupleElementNamesAttribute da
;
56 if (t
.GetMember("a")[0].GetCustomAttributes(ca
, false).Length
!= 1)
59 if (t
.GetMember("c")[0].GetCustomAttributes(ca
, false).Length
!= 1)
62 if (t
.GetMember("Prop")[0].GetCustomAttributes(ca
, false).Length
!= 1)
65 if (t
.GetMember("get_Prop")[0].GetCustomAttributes(ca
, false).Length
!= 0)
68 if (t
.GetMethod("get_Prop").ReturnParameter
.GetCustomAttributes(ca
, false).Length
!= 1)
71 if (t
.GetMember("set_Prop")[0].GetCustomAttributes(ca
, false).Length
!= 0)
74 if (t
.GetMethod("set_Prop").ReturnParameter
.GetCustomAttributes(ca
, false).Length
!= 0)
77 if (t
.GetMethod("set_Prop").GetParameters()[0].GetCustomAttributes(ca
, false).Length
!= 1)
80 if (t
.GetMember("Prop2")[0].GetCustomAttributes(ca
, false).Length
!= 1)
83 if (t
.GetMember("set_Prop2")[0].GetCustomAttributes(ca
, false).Length
!= 0)
86 if (t
.GetMember("Item")[0].GetCustomAttributes(ca
, false).Length
!= 1)
89 if (t
.GetMethod("get_Item").ReturnParameter
.GetCustomAttributes(ca
, false).Length
!= 1)
92 if (t
.GetMethod("get_Item").GetParameters()[0].GetCustomAttributes(ca
, false).Length
!= 1)
95 if (t
.GetMethod("set_Item").ReturnParameter
.GetCustomAttributes(ca
, false).Length
!= 0)
98 if (t
.GetMethod("set_Item").GetParameters()[0].GetCustomAttributes(ca
, false).Length
!= 1)
101 if (t
.GetMethod("set_Item").GetParameters()[1].GetCustomAttributes(ca
, false).Length
!= 1)
104 if (t
.GetMember("Method")[0].GetCustomAttributes(ca
, false).Length
!= 0)
107 var res
= t
.GetMethod("Method").GetParameters()[0].GetCustomAttributes(ca
, false);
111 da
= res
[0] as TupleElementNamesAttribute
;
114 if (!da
.TransformNames
.SequenceEqual(new string[] { "a", "b" }
))
117 if (t
.GetConstructors()[0].GetParameters()[0].GetCustomAttributes(ca
, false).Length
!= 1)
120 if (t
.GetConstructors()[0].GetCustomAttributes(ca
, false).Length
!= 0)
123 // if (t.GetCustomAttributes(ca, false).Length != 1)
127 da
= t
.GetMember("t")[0].GetCustomAttributes(ca
, false)[0] as TupleElementNamesAttribute
;
131 if (!da
.TransformNames
.SequenceEqual(new string[] { "a", "b" }
))
134 da
= t
.GetMember("t2")[0].GetCustomAttributes(ca
, false)[0] as TupleElementNamesAttribute
;
138 if (!da
.TransformNames
.SequenceEqual(new string[] { "a", "b" }
))
141 //da = t.GetMember("v")[0].GetCustomAttributes(ca, false)[0] as TupleElementNamesAttribute;
145 //if (!da.TransformNames.SequenceEqual(new string[] { "a", "b", "c", "d" }))
148 //da = t.GetMember("iface")[0].GetCustomAttributes(ca, false)[0] as TupleElementNamesAttribute;
152 //if (!da.TransformNames.SequenceEqual(new string[] { "a", "b" }))
155 //da = t.GetMember("d2")[0].GetCustomAttributes(ca, false)[0] as TupleElementNamesAttribute;
158 //if (!da.TransformNames.SequenceEqual(new string[] { null, null, "u", null, "a", "b" }))
161 da
= t
.GetMember("d3")[0].GetCustomAttributes(ca
, false)[0] as TupleElementNamesAttribute
;
164 if (!da
.TransformNames
.SequenceEqual(new string[] { "x1", "x2", "a1", "a2", "aa1", "aa2", null, null, "b1", "b2", "cc1", "cc2", "dd1", "dd2" }
))
169 if (t
.GetMember("Invoke")[0].GetCustomAttributes(ca
, false).Length
!= 0)
172 if (t
.GetMethod("Invoke").GetParameters()[0].GetCustomAttributes(ca
, false).Length
!= 1)
175 if (t
.GetMethod("Invoke").ReturnParameter
.GetCustomAttributes(ca
, false).Length
!= 1)
178 Console
.WriteLine("ok");