2010-04-13 Sebastien Pouliot <sebastien@ximian.com>
[mono-project.git] / mcs / tests / test-454.cs
blobf0a3e6bf5439f3874408b4fd2d19b48aec3f1aa1
1 // Test various kinds of arrays as custom attribute parameters
2 using System;
4 enum EnumType {
5 X,
7 };
9 class FooAttribute : Attribute
11 public string [] StringValues;
12 public object [] ObjectValues;
13 public EnumType [] EnumValues;
14 public Type [] Types;
16 public FooAttribute ()
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)}
26 class Test
28 public static int Main ()
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)
43 return 1;
45 return 0;