[Mono-bugs] [Bug 75723][Nor] New - CS0182 reported on valid
attributes
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Fri Aug 5 05:53:35 EDT 2005
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by gcomeau at hotmail.com.
http://bugzilla.ximian.com/show_bug.cgi?id=75723
--- shadow/75723 2005-08-05 05:53:35.000000000 -0400
+++ shadow/75723.tmp.20421 2005-08-05 05:53:35.000000000 -0400
@@ -0,0 +1,75 @@
+Bug#: 75723
+Product: Mono: Compilers
+Version: 1.1
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: C#
+AssignedTo: mono-bugs at ximian.com
+ReportedBy: gcomeau at hotmail.com
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: CS0182 reported on valid attributes
+
+Getting error CS0182: An attribute argument must be a constant expression,
+typeof expression or array creation expression
+on near trivial sample of code that goes through csc just fine.
+
+
+Code sample:
+using System;
+
+
+// The attribute
+internal class MyAttr : Attribute {
+ internal MyAttr() { }
+ internal MyAttr(Type type) { }
+ internal MyAttr(string name) { }
+ internal MyAttr(int i) { }
+}
+
+// The Classes
+[MyAttr()]
+internal class ClassA { }
+
+[MyAttr(typeof(string))]
+internal class ClassB { }
+
+[MyAttr("abc")]
+internal class ClassC { }
+
+[MyAttr(3)]
+internal class ClassD { }
+
+// Just to compile
+internal class Top {
+ public static void Main (string[] strgs){}
+}
+
+
+Result:
+$ mcs classes.cs
+classes.cs(21) error CS0182: An attribute argument must be a constant
+expression
+, typeof expression or array creation expression
+classes.cs(24) error CS0182: An attribute argument must be a constant
+expression
+, typeof expression or array creation expression
+classes.cs(27) error CS0182: An attribute argument must be a constant
+expression
+, typeof expression or array creation expression
+classes.cs(30) error CS0182: An attribute argument must be a constant
+expression
+, typeof expression or array creation expression
+Compilation failed: 4 error(s), 0 warnings
+
+
+
+Expected Results: Should compile
+
+How often does this happen: Always.
More information about the mono-bugs
mailing list