Add Mono.Runtime::GetNativeStackTrace method to make the new backtracing facility...
[mono-project.git] / mcs / tests / dtest-001.cs
blob06f2fed3fdea5f221591e1894a5e9aefdd8c911f
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 C
17 public C (dynamic d)
21 public dynamic a;
22 public const dynamic c = default (dynamic);
24 public dynamic Prop { set; get; }
25 public dynamic Prop2 { set { } }
27 public dynamic this[dynamic d] { set { } get { return 1; } }
29 public dynamic Method (dynamic d)
31 return null;
34 // Transformation handling required
35 public dynamic[] t;
36 public dynamic[,] t2;
37 public Func<dynamic, int, dynamic[]> v;
38 public I<dynamic>[] iface;
41 delegate dynamic Del (dynamic d);
43 class Test
45 public static int Main ()
47 Type t = typeof (C);
48 Type ca = typeof (System.Runtime.CompilerServices.DynamicAttribute);
50 if (t.GetMember ("a")[0].GetCustomAttributes (ca, false).Length != 1)
51 return 1;
53 if (t.GetMember ("c")[0].GetCustomAttributes (ca, false).Length != 1)
54 return 3;
56 if (t.GetMember ("Prop")[0].GetCustomAttributes (ca, false).Length != 1)
57 return 4;
59 if (t.GetMember ("get_Prop")[0].GetCustomAttributes (ca, false).Length != 0)
60 return 5;
62 if (t.GetMethod ("get_Prop").ReturnParameter.GetCustomAttributes (ca, false).Length != 1)
63 return 6;
65 if (t.GetMember ("set_Prop")[0].GetCustomAttributes (ca, false).Length != 0)
66 return 7;
68 if (t.GetMethod ("set_Prop").ReturnParameter.GetCustomAttributes (ca, false).Length != 0)
69 return 8;
71 if (t.GetMethod ("set_Prop").GetParameters ()[0].GetCustomAttributes (ca, false).Length != 1)
72 return 9;
74 if (t.GetMember ("Prop2")[0].GetCustomAttributes (ca, false).Length != 1)
75 return 10;
77 if (t.GetMember ("set_Prop2")[0].GetCustomAttributes (ca, false).Length != 0)
78 return 11;
80 if (t.GetMember ("Item")[0].GetCustomAttributes (ca, false).Length != 1)
81 return 12;
83 if (t.GetMethod ("get_Item").ReturnParameter.GetCustomAttributes (ca, false).Length != 1)
84 return 13;
86 if (t.GetMethod ("get_Item").GetParameters ()[0].GetCustomAttributes (ca, false).Length != 1)
87 return 14;
89 if (t.GetMethod ("set_Item").ReturnParameter.GetCustomAttributes (ca, false).Length != 0)
90 return 15;
92 if (t.GetMethod ("set_Item").GetParameters ()[0].GetCustomAttributes (ca, false).Length != 1)
93 return 16;
95 if (t.GetMethod ("set_Item").GetParameters ()[1].GetCustomAttributes (ca, false).Length != 1)
96 return 17;
98 if (t.GetMember ("Method")[0].GetCustomAttributes (ca, false).Length != 0)
99 return 18;
101 if (t.GetMethod ("Method").GetParameters ()[0].GetCustomAttributes (ca, false).Length != 1)
102 return 19;
104 if (t.GetConstructors ()[0].GetParameters ()[0].GetCustomAttributes (ca, false).Length != 1)
105 return 20;
107 if (t.GetConstructors ()[0].GetCustomAttributes (ca, false).Length != 0)
108 return 21;
110 // Transformations
111 DynamicAttribute da;
112 da = t.GetMember ("t")[0].GetCustomAttributes (ca, false)[0] as DynamicAttribute;
113 if (da == null)
114 return 40;
116 if (!da.TransformFlags.SequenceEqual (new bool[] { false, true }))
117 return 41;
119 da = t.GetMember ("t2")[0].GetCustomAttributes (ca, false)[0] as DynamicAttribute;
120 if (da == null)
121 return 42;
123 if (!da.TransformFlags.SequenceEqual (new bool[] { false, true }))
124 return 43;
126 da = t.GetMember ("v")[0].GetCustomAttributes (ca, false)[0] as DynamicAttribute;
127 if (da == null)
128 return 44;
129 if (!da.TransformFlags.SequenceEqual (new bool[] { false, true, false, false, true }))
130 return 45;
132 da = t.GetMember ("iface")[0].GetCustomAttributes (ca, false)[0] as DynamicAttribute;
133 if (da == null)
134 return 46;
135 if (!da.TransformFlags.SequenceEqual (new bool[] { false, false, true }))
136 return 47;
138 t = typeof (Del);
140 if (t.GetMember ("Invoke")[0].GetCustomAttributes (ca, false).Length != 0)
141 return 100;
143 if (t.GetMethod ("Invoke").GetParameters ()[0].GetCustomAttributes (ca, false).Length != 1)
144 return 101;
146 if (t.GetMethod ("Invoke").ReturnParameter.GetCustomAttributes (ca, false).Length != 1)
147 return 102;
149 Console.WriteLine ("ok");
150 return 0;