[LoongArch64] Part-5:add loongarch support in some files for LoongArch64. (#21769)
[mono-project.git] / mcs / tests / dtest-001.cs
blob78de1d8253d0238728d07127d8fd5d831fe27c7b
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 interface I<T>
15 class B<T>
19 class C : B<dynamic>
21 public C (dynamic d)
25 public dynamic a;
26 public const dynamic c = default (dynamic);
28 public dynamic Prop { set; get; }
29 public dynamic Prop2 { set { } }
31 public dynamic this[dynamic d] { set { } get { return 1; } }
33 public dynamic Method (dynamic d)
35 return null;
38 // Transformation handling required
39 public dynamic[] t;
40 public dynamic[,] t2;
41 public Func<dynamic, int, dynamic[]> v;
42 public I<dynamic>[] iface;
43 public Action<int[], object, dynamic> d2;
46 delegate dynamic Del (dynamic d);
48 class Test
50 public static int Main ()
52 Type t = typeof (C);
53 Type ca = typeof (System.Runtime.CompilerServices.DynamicAttribute);
55 if (t.GetMember ("a")[0].GetCustomAttributes (ca, false).Length != 1)
56 return 1;
58 if (t.GetMember ("c")[0].GetCustomAttributes (ca, false).Length != 1)
59 return 3;
61 if (t.GetMember ("Prop")[0].GetCustomAttributes (ca, false).Length != 1)
62 return 4;
64 if (t.GetMember ("get_Prop")[0].GetCustomAttributes (ca, false).Length != 0)
65 return 5;
67 if (t.GetMethod ("get_Prop").ReturnParameter.GetCustomAttributes (ca, false).Length != 1)
68 return 6;
70 if (t.GetMember ("set_Prop")[0].GetCustomAttributes (ca, false).Length != 0)
71 return 7;
73 if (t.GetMethod ("set_Prop").ReturnParameter.GetCustomAttributes (ca, false).Length != 0)
74 return 8;
76 if (t.GetMethod ("set_Prop").GetParameters ()[0].GetCustomAttributes (ca, false).Length != 1)
77 return 9;
79 if (t.GetMember ("Prop2")[0].GetCustomAttributes (ca, false).Length != 1)
80 return 10;
82 if (t.GetMember ("set_Prop2")[0].GetCustomAttributes (ca, false).Length != 0)
83 return 11;
85 if (t.GetMember ("Item")[0].GetCustomAttributes (ca, false).Length != 1)
86 return 12;
88 if (t.GetMethod ("get_Item").ReturnParameter.GetCustomAttributes (ca, false).Length != 1)
89 return 13;
91 if (t.GetMethod ("get_Item").GetParameters ()[0].GetCustomAttributes (ca, false).Length != 1)
92 return 14;
94 if (t.GetMethod ("set_Item").ReturnParameter.GetCustomAttributes (ca, false).Length != 0)
95 return 15;
97 if (t.GetMethod ("set_Item").GetParameters ()[0].GetCustomAttributes (ca, false).Length != 1)
98 return 16;
100 if (t.GetMethod ("set_Item").GetParameters ()[1].GetCustomAttributes (ca, false).Length != 1)
101 return 17;
103 if (t.GetMember ("Method")[0].GetCustomAttributes (ca, false).Length != 0)
104 return 18;
106 if (t.GetMethod ("Method").GetParameters ()[0].GetCustomAttributes (ca, false).Length != 1)
107 return 19;
109 if (t.GetConstructors ()[0].GetParameters ()[0].GetCustomAttributes (ca, false).Length != 1)
110 return 20;
112 if (t.GetConstructors ()[0].GetCustomAttributes (ca, false).Length != 0)
113 return 21;
115 if (t.GetCustomAttributes (ca, false).Length != 1)
116 return 22;
118 // Transformations
119 DynamicAttribute da;
120 da = t.GetMember ("t")[0].GetCustomAttributes (ca, false)[0] as DynamicAttribute;
121 if (da == null)
122 return 40;
124 if (!da.TransformFlags.SequenceEqual (new bool[] { false, true }))
125 return 41;
127 da = t.GetMember ("t2")[0].GetCustomAttributes (ca, false)[0] as DynamicAttribute;
128 if (da == null)
129 return 42;
131 if (!da.TransformFlags.SequenceEqual (new bool[] { false, true }))
132 return 43;
134 da = t.GetMember ("v")[0].GetCustomAttributes (ca, false)[0] as DynamicAttribute;
135 if (da == null)
136 return 44;
137 if (!da.TransformFlags.SequenceEqual (new bool[] { false, true, false, false, true }))
138 return 45;
140 da = t.GetMember ("iface")[0].GetCustomAttributes (ca, false)[0] as DynamicAttribute;
141 if (da == null)
142 return 46;
143 if (!da.TransformFlags.SequenceEqual (new bool[] { false, false, true }))
144 return 47;
146 da = t.GetMember ("d2")[0].GetCustomAttributes (ca, false)[0] as DynamicAttribute;
147 if (da == null)
148 return 48;
149 if (!da.TransformFlags.SequenceEqual (new bool[] { false, false, false, false, true }))
150 return 49;
152 t = typeof (Del);
154 if (t.GetMember ("Invoke")[0].GetCustomAttributes (ca, false).Length != 0)
155 return 100;
157 if (t.GetMethod ("Invoke").GetParameters ()[0].GetCustomAttributes (ca, false).Length != 1)
158 return 101;
160 if (t.GetMethod ("Invoke").ReturnParameter.GetCustomAttributes (ca, false).Length != 1)
161 return 102;
163 Console.WriteLine ("ok");
164 return 0;