[Mono-bugs] [Bug 499569] New: Attribute.GetCustomAttribute not returning inherited attributes

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Apr 29 19:29:08 EDT 2009


http://bugzilla.novell.com/show_bug.cgi?id=499569


           Summary: Attribute.GetCustomAttribute not returning inherited
                    attributes
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.2.x
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: CORLIB
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: lluis at novell.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


In the following test case, a call to Attribute.GetCustomAttribute is failing
to return an attribute defined in a base class. It works fine in MS.NET but not
in Mono.

using System;
using System.Reflection;

class App
{
    public static void Main (string[] args)
    {
    MemberInfo m = typeof(Sub).GetProperty ("Name");
    object attr = Attribute.GetCustomAttribute (m, typeof(MyAttribute), true);
    Console.WriteLine ("Found: " + (attr != null));
    }
}

abstract class Abs
{
    public abstract string Name { get; set; }
}

class Base: Abs
{
    [MyAttribute]
    public override string Name {
        get { return ""; }
        set {}
    }
}

class Sub: Base
{
    public override string Name {
        get { return ""; }
        set {}
    }
}

class MyAttribute: Attribute
{
}

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list