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

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

namespace Test {
	
	public class MyAttribute: Attribute {
		public string val;
		public MyAttribute (string stuff) {
			System.Console.WriteLine (stuff);
			val = stuff;
		}
	}

        public interface ITest {
                string TestProperty {
                        [My ("testifaceproperty")] get;
                }
        }
	
	[My("testclass")]
	public class Test {
		public static int Main () {
			System.Reflection.MemberInfo info = typeof (Test);
			object[] attributes = info.GetCustomAttributes (false);
			for (int i = 0; i < attributes.Length; i ++) {
				System.Console.WriteLine(attributes[i]);
			}
			if (attributes.Length != 1)
				return 1;
			MyAttribute attr = (MyAttribute) attributes [0];
			if (attr.val != "testclass")
				return 2;

                        info = typeof (ITest).GetMethod ("get_TestProperty");
			attributes = info.GetCustomAttributes (false);
			for (int i = 0; i < attributes.Length; i ++) {
				System.Console.WriteLine(attributes[i]);
			}
			if (attributes.Length != 1)
				return 3;

                        attr = (MyAttribute) attributes [0];
			if (attr.val != "testifaceproperty")
				return 4;
                        
			return 0;
		}
	}
}