add bug info
[mcs.git] / tests / dtest-001.cs
blobcb51ff556d79697b540225b2be401d0b10c221cd
1 //
2 // dynamic type attribute decoration
3 //
5 using System;
6 using System.Collections;
7 using System.Runtime.CompilerServices;
8 using System.Collections.Generic;
9 using System.Linq;
11 class C
13 public C (dynamic d)
17 public dynamic a;
18 public const dynamic c = default (dynamic);
20 public dynamic Prop { set; get; }
21 public dynamic Prop2 { set { } }
23 public dynamic this[dynamic d] { set { } get { return 1; } }
25 public dynamic Method (dynamic d)
27 return null;
30 // Transformation handling required
31 public dynamic[] t;
32 public dynamic[,] t2;
33 public Func<dynamic, int, dynamic[]> v;
36 delegate dynamic Del (dynamic d);
38 class Test
40 public static int Main ()
42 Type t = typeof (C);
43 Type ca = typeof (System.Runtime.CompilerServices.DynamicAttribute);
45 if (t.GetMember ("a")[0].GetCustomAttributes (ca, false).Length != 1)
46 return 1;
48 if (t.GetMember ("c")[0].GetCustomAttributes (ca, false).Length != 1)
49 return 3;
51 if (t.GetMember ("Prop")[0].GetCustomAttributes (ca, false).Length != 1)
52 return 4;
54 if (t.GetMember ("get_Prop")[0].GetCustomAttributes (ca, false).Length != 0)
55 return 5;
57 if (t.GetMethod ("get_Prop").ReturnParameter.GetCustomAttributes (ca, false).Length != 1)
58 return 6;
60 if (t.GetMember ("set_Prop")[0].GetCustomAttributes (ca, false).Length != 0)
61 return 7;
63 if (t.GetMethod ("set_Prop").ReturnParameter.GetCustomAttributes (ca, false).Length != 0)
64 return 8;
66 if (t.GetMethod ("set_Prop").GetParameters ()[0].GetCustomAttributes (ca, false).Length != 1)
67 return 9;
69 if (t.GetMember ("Prop2")[0].GetCustomAttributes (ca, false).Length != 1)
70 return 10;
72 if (t.GetMember ("set_Prop2")[0].GetCustomAttributes (ca, false).Length != 0)
73 return 11;
75 if (t.GetMember ("Item")[0].GetCustomAttributes (ca, false).Length != 1)
76 return 12;
78 if (t.GetMethod ("get_Item").ReturnParameter.GetCustomAttributes (ca, false).Length != 1)
79 return 13;
81 if (t.GetMethod ("get_Item").GetParameters ()[0].GetCustomAttributes (ca, false).Length != 1)
82 return 14;
84 if (t.GetMethod ("set_Item").ReturnParameter.GetCustomAttributes (ca, false).Length != 0)
85 return 15;
87 if (t.GetMethod ("set_Item").GetParameters ()[0].GetCustomAttributes (ca, false).Length != 1)
88 return 16;
90 if (t.GetMethod ("set_Item").GetParameters ()[1].GetCustomAttributes (ca, false).Length != 1)
91 return 17;
93 if (t.GetMember ("Method")[0].GetCustomAttributes (ca, false).Length != 0)
94 return 18;
96 if (t.GetMethod ("Method").GetParameters ()[0].GetCustomAttributes (ca, false).Length != 1)
97 return 19;
99 if (t.GetConstructors ()[0].GetParameters ()[0].GetCustomAttributes (ca, false).Length != 1)
100 return 20;
102 if (t.GetConstructors ()[0].GetCustomAttributes (ca, false).Length != 0)
103 return 21;
105 // Transformations
106 DynamicAttribute da;
107 da = t.GetMember ("t")[0].GetCustomAttributes (ca, false)[0] as DynamicAttribute;
108 if (da == null)
109 return 40;
111 if (!da.TransformFlags.SequenceEqual (new bool[] { false, true }))
112 return 41;
114 da = t.GetMember ("t2")[0].GetCustomAttributes (ca, false)[0] as DynamicAttribute;
115 if (da == null)
116 return 42;
118 if (!da.TransformFlags.SequenceEqual (new bool[] { false, true }))
119 return 43;
121 da = t.GetMember ("v")[0].GetCustomAttributes (ca, false)[0] as DynamicAttribute;
122 if (da == null)
123 return 44;
124 if (!da.TransformFlags.SequenceEqual (new bool[] { false, true, false, false, true }))
125 return 45;
127 t = typeof (Del);
129 if (t.GetMember ("Invoke")[0].GetCustomAttributes (ca, false).Length != 0)
130 return 100;
132 if (t.GetMethod ("Invoke").GetParameters ()[0].GetCustomAttributes (ca, false).Length != 1)
133 return 101;
135 if (t.GetMethod ("Invoke").ReturnParameter.GetCustomAttributes (ca, false).Length != 1)
136 return 102;
138 Console.WriteLine ("ok");
139 return 0;