Welcome to mirror list, hosted at ThFree Co, Russian Federation.

test-454.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f0a3e6bf5439f3874408b4fd2d19b48aec3f1aa1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Test various kinds of arrays as custom attribute parameters
using System;

enum EnumType {
	X,
	Y
};

class FooAttribute : Attribute
{
	public string [] StringValues;
	public object [] ObjectValues;
	public EnumType [] EnumValues;
	public Type [] Types;

	public FooAttribute ()
	{
	}
}

[Foo (StringValues = new string [] {"foo", "bar", "baz"},
	ObjectValues = new object [] {1, 'A', "B"},
	EnumValues = new EnumType [] { EnumType.X, EnumType.Y },
	Types = new Type [] {typeof (int), typeof (Type)}
	)]
class Test
{
	public static int Main () 
	{
		FooAttribute foo = (FooAttribute) typeof (Test)
			.GetCustomAttributes (false) [0];
		if (foo.StringValues [0] != "foo"
			|| foo.StringValues [1] != "bar"
			|| foo.StringValues [2] != "baz"
			|| 1 != (int) foo.ObjectValues [0]
			|| 'A' != (char) foo.ObjectValues [1]
			|| "B" != (string) foo.ObjectValues [2]
			|| EnumType.X != foo.EnumValues [0]
			|| EnumType.Y != foo.EnumValues [1]
			|| foo.Types [0] != typeof (int)
			|| foo.Types [1] != typeof (Type)
			)
			return 1;
		
		return 0;
	}
}