浏览代码

Add

svn path=/trunk/mcs/; revision=3788
Ravi Pratap M 24 年之前
父节点
当前提交
8ea6a01db9
共有 2 个文件被更改,包括 39 次插入1 次删除
  1. 35 0
      mcs/errors/cs-20.cs
  2. 4 1
      mcs/errors/errors.txt

+ 35 - 0
mcs/errors/cs-20.cs

@@ -0,0 +1,35 @@
+// cs-20.cs : Cannot find attribute type My (maybe you forgot to set the usage using the AttributeUsage attribute ?).
+// Line : 18
+
+using System;
+using System.Reflection;
+
+namespace Test {
+	
+       	//[AttributeUsage (AttributeTargets.All)]
+	public class MyAttribute: Attribute {
+		public string val;
+		public MyAttribute (string stuff) {
+			System.Console.WriteLine (stuff);
+			val = stuff;
+		}
+	}
+	
+	[My("testclass")]
+
+	public class Test {
+		static public 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 != 2)
+				return 1;
+			MyAttribute attr = (MyAttribute) attributes [0];
+			if (attr.val != "testclass")
+				return 2;
+			return 0;
+		}
+	}
+}

+ 4 - 1
mcs/errors/errors.txt

@@ -50,4 +50,7 @@ numbers to match the Microsoft numbers:
 
 -18	Do not know how to generate debugging information for this platform.
 
--19     Can not find required utility function in the core libraries.
+-19     Can not find required utility function in the core libraries.
+
+-20	Cannot find attribute type Blah (maybe you forgot to set the 
+	usage using the AttributeUsage attribute ?).