[Mono-bugs] [Bug 54679][Nor] New - mcs does not handle custom attributes for const fields
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Fri, 20 Feb 2004 20:12:44 -0500 (EST)
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 mathpup@mylinuxisp.com.
http://bugzilla.ximian.com/show_bug.cgi?id=54679
--- shadow/54679 2004-02-20 20:12:44.000000000 -0500
+++ shadow/54679.tmp.29665 2004-02-20 20:12:44.000000000 -0500
@@ -0,0 +1,84 @@
+Bug#: 54679
+Product: Mono/Compilers
+Version: unspecified
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: C#
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: mathpup@mylinuxisp.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: mcs does not handle custom attributes for const fields
+
+Description of Problem:
+
+mcs does not appear to handle custom attributes correctly when they are
+applied to const fields of classes. This appears to be an mcs bug rather
+than a runtime or library bug because code compiled by csc does run
+correctly.
+
+Test case below.
+
+
+Steps to reproduce the problem:
+1. mcs const2.cs
+2. mono const2.exe
+
+
+Actual Results:
+
+(No output)
+
+Expected Results:
+
+Prints "AccessibleAttribute"
+
+
+How often does this happen?
+
+Always
+
+
+Additional Information:
+
+using System;
+using System.Reflection;
+
+
+[AttributeUsage(AttributeTargets.Field)] public class
+AccessibleAttribute:Attribute {}
+
+
+public class MyClass
+{
+ [Accessible] public const int MyConst = 1;
+
+
+ public void GetMyConst()
+ {
+ }
+}
+
+
+public class Test
+{
+ public static void Main()
+ {
+ FieldInfo fieldInfo = typeof(MyClass).GetField("MyConst",
+ BindingFlags.Static | BindingFlags.Public);
+
+ AccessibleAttribute[] attributes =
+ fieldInfo.GetCustomAttributes(
+ typeof(AccessibleAttribute), true) as AccessibleAttribute[];
+
+ foreach ( Attribute a in attributes )
+ Console.WriteLine(a);
+
+ }
+}