[Mono-bugs] [Bug 82431][Nor] New - Attribute.IsDefined returns true when it shouldn't

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Mon Aug 13 19:21:08 EDT 2007


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 daniel at hofmannmail.ath.cx.

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

--- shadow/82431	2007-08-13 19:21:08.000000000 -0400
+++ shadow/82431.tmp.19517	2007-08-13 19:21:08.000000000 -0400
@@ -0,0 +1,62 @@
+Bug#: 82431
+Product: Mono: Class Libraries
+Version: 1.2
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: CORLIB
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: daniel at hofmannmail.ath.cx               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Attribute.IsDefined returns true when it shouldn't
+
+Description of Problem:
+I've defined a custom Attribute and marked it non-inheritable.
+When querying this Attribute via Attribute.IsDefined(Type,Type) on a type
+that doesn't have defined the attribute but its parent class has, it
+returns true while it shouldn't.
+
+Steps to reproduce the problem:
+1. Compile & Run the following C#-code
+-------------------------------------------------------------------
+using System;
+
+[System.AttributeUsage(
+        System.AttributeTargets.Class |
+        System.AttributeTargets.Struct,
+        AllowMultiple = false,
+        Inherited = false) ]
+public class MyAttribute : Attribute {}
+
+[MyAttribute]
+public class Parent {}
+
+public class Child : Parent {}
+
+public class Test {
+
+    public static void Main ()
+    {
+        Console.WriteLine (Attribute.IsDefined(typeof(Child),
+typeof(MyAttribute)));
+    }
+}
+------------------------------------------------------------------
+Actual Results:
+true
+
+Expected Results:
+false
+
+How often does this happen? 
+Always
+
+Additional Information:
+I got the true-result running the above code on my debian-mono 1.2.4
+and the false-result running it on .Net.


More information about the mono-bugs mailing list