Move Enum and CorElementType to shared (dotnet/coreclr#23177)
[mono-project.git] / mcs / tests / test-157.cs
blob109942fedef49fa5ac0466b9fd36603dcbbcd423
1 using System;
2 using System.Reflection;
4 namespace Test {
6 public class MyAttribute: Attribute {
7 public string val;
8 public MyAttribute (string stuff) {
9 System.Console.WriteLine (stuff);
10 val = stuff;
14 public interface ITest {
15 string TestProperty {
16 [My ("testifaceproperty")] get;
20 [My("testclass")]
21 public class Test {
22 public static int Main () {
23 System.Reflection.MemberInfo info = typeof (Test);
24 object[] attributes = info.GetCustomAttributes (false);
25 for (int i = 0; i < attributes.Length; i ++) {
26 System.Console.WriteLine(attributes[i]);
28 if (attributes.Length != 1)
29 return 1;
30 MyAttribute attr = (MyAttribute) attributes [0];
31 if (attr.val != "testclass")
32 return 2;
34 info = typeof (ITest).GetMethod ("get_TestProperty");
35 attributes = info.GetCustomAttributes (false);
36 for (int i = 0; i < attributes.Length; i ++) {
37 System.Console.WriteLine(attributes[i]);
39 if (attributes.Length != 1)
40 return 3;
42 attr = (MyAttribute) attributes [0];
43 if (attr.val != "testifaceproperty")
44 return 4;
46 return 0;