Merge pull request #4327 from vkargov/vk-abcremedy
[mono.git] / mcs / tests / test-454.cs
1 // Test various kinds of arrays as custom attribute parameters
2 using System;
3
4 enum EnumType {
5         X,
6         Y
7 };
8
9 class FooAttribute : Attribute
10 {
11         public string [] StringValues;
12         public object [] ObjectValues;
13         public EnumType [] EnumValues;
14         public Type [] Types;
15
16         public FooAttribute ()
17         {
18         }
19 }
20
21 [Foo (StringValues = new string [] {"foo", "bar", "baz"},
22         ObjectValues = new object [] {1, 'A', "B"},
23         EnumValues = new EnumType [] { EnumType.X, EnumType.Y },
24         Types = new Type [] {typeof (int), typeof (Type)}
25         )]
26 class Test
27 {
28         public static int Main () 
29         {
30                 FooAttribute foo = (FooAttribute) typeof (Test)
31                         .GetCustomAttributes (false) [0];
32                 if (foo.StringValues [0] != "foo"
33                         || foo.StringValues [1] != "bar"
34                         || foo.StringValues [2] != "baz"
35                         || 1 != (int) foo.ObjectValues [0]
36                         || 'A' != (char) foo.ObjectValues [1]
37                         || "B" != (string) foo.ObjectValues [2]
38                         || EnumType.X != foo.EnumValues [0]
39                         || EnumType.Y != foo.EnumValues [1]
40                         || foo.Types [0] != typeof (int)
41                         || foo.Types [1] != typeof (Type)
42                         )
43                         return 1;
44                 
45                 return 0;
46         }
47 }