New test.
[mono.git] / mcs / tests / test-500.cs
1 using System;\r
2 using System.Reflection;\r
3 \r
4 [AttributeUsage(AttributeTargets.Field, AllowMultiple=false)]\r
5 class SomeCustomAttribute : Attribute {\r
6         public SomeCustomAttribute ()\r
7         {\r
8         }\r
9 }\r
10 \r
11 class MainClass {\r
12 \r
13         [SomeCustomAttribute]\r
14         public int a;\r
15 \r
16         [SomeCustomAttribute]\r
17         public int x, y;\r
18 \r
19         public static int Main ()\r
20         {\r
21                 Type t = typeof (MainClass);\r
22                 FieldInfo[] fia = t.GetFields();\r
23 \r
24                 foreach (FieldInfo fi in fia) {\r
25                         object[] ca = fi.GetCustomAttributes(typeof (SomeCustomAttribute), false);\r
26                         System.Console.WriteLine ("Field: {0} [{1}]", fi.Name, ca.Length);\r
27                         if (ca.Length != 1)\r
28                                 return 1;\r
29                 }\r
30                 \r
31                 Console.WriteLine ("OK");\r
32                 \r
33                 return 0;\r
34         }\r
35 }