[Mono-bugs] [Bug 78020][Wis] New - Mcs Custom Attribute Handling

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Wed Apr 5 04:16:22 EDT 2006


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 norbert at spice.gia.rwth-aachen.de.

http://bugzilla.ximian.com/show_bug.cgi?id=78020

--- shadow/78020	2006-04-05 04:16:22.000000000 -0400
+++ shadow/78020.tmp.3344	2006-04-05 04:16:22.000000000 -0400
@@ -0,0 +1,98 @@
+Bug#: 78020
+Product: Mono: Compilers
+Version: 1.1
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: C#
+AssignedTo: rharinath at novell.com                            
+ReportedBy: norbert at spice.gia.rwth-aachen.de               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Mcs Custom Attribute Handling
+
+Description of Problem:
+======================
+
+Recent version(s) of mcs (1.1.14 and may be earlier) introduce a bug custom
+attribute handling. In a declaration of the form
+
+class SomeClass {
+  [SomeCustomAttribute] int x, y;
+}
+
+the field 'x' does not have any 'SomeCustomAttribute' attached to it,
+but the field 'y' does have two 'SomeCustomAttribute' attached to it.
+
+Steps to reproduce the problem: Compile the following:
+=====================================================
+
+using System;
+using System.Reflection;
+
+[AttributeUsage(AttributeTargets.Field)]
+class SomeCustomAttribute : Attribute {
+  public SomeCustomAttribute ()
+  {
+  }
+}
+
+class MainClass {
+
+  // Here, the custom attribute is attached correctly
+  [SomeCustomAttribute]
+  public int a;
+
+  // Here, the custom attribute attachment has a flaw
+  [SomeCustomAttribute]
+  public int x, y;
+
+  public static void Main ()
+  {
+    Type t = typeof (MainClass);
+    FieldInfo[] fia = t.GetFields();
+
+    foreach (FieldInfo fi in fia) {
+      object[] ca = fi.GetCustomAttributes(false);
+      System.Console.WriteLine ("Field: {0} [{1}]", fi.Name, ca.Length);
+      foreach (Attribute a in ca)
+        System.Console.WriteLine ("  Attribute: {0}", a);
+    }
+  }
+
+}
+
+
+Actual Results:
+==============
+
+Field: a [1]
+  Attribute: SomeCustomAttribute
+Field: x [0]
+Field: y [2]
+  Attribute: SomeCustomAttribute
+  Attribute: SomeCustomAttribute
+
+Expected Results:
+================
+
+Field: a [1]
+  Attribute: SomeCustomAttribute
+Field: x [1]
+  Attribute: SomeCustomAttribute
+Field: y [1]
+  Attribute: SomeCustomAttribute
+
+How often does this happen?
+==========================
+
+Anytime, behaviour is deterministic.
+
+Additional Information:
+======================
+None.


More information about the mono-bugs mailing list