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

test-500.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: dd2ca605bc6315beb6ca5b38fd6f820a65b52ef9 (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
using System;
using System.Reflection;

[AttributeUsage(AttributeTargets.Field, AllowMultiple=false)]
class SomeCustomAttribute : Attribute {
	public SomeCustomAttribute ()
	{
	}
}

class MainClass {

	[SomeCustomAttribute]
	public int a;

	[SomeCustomAttribute]
	public int x, y;

	public static int Main ()
	{
		Type t = typeof (MainClass);
		FieldInfo[] fia = t.GetFields();

		foreach (FieldInfo fi in fia) {
			object[] ca = fi.GetCustomAttributes(typeof (SomeCustomAttribute), false);
			System.Console.WriteLine ("Field: {0} [{1}]", fi.Name, ca.Length);
			if (ca.Length != 1)
				return 1;
		}
		
		Console.WriteLine ("OK");
		
		return 0;
	}
}