https://bugzilla.novell.com/show_bug.cgi?id=483247


           Summary: IsDefined on methods does not work for interface-type
                    queries
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.2.x
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: CORLIB
        AssignedTo: [email protected]
        ReportedBy: [email protected]
         QAContact: [email protected]
          Found By: ---


Created an attachment (id=277887)
 --> (https://bugzilla.novell.com/attachment.cgi?id=277887)
Sample program to reproduce the bug

User-Agent:       Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; GTB5;
SLCC1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.5.21022; WWTClient2;
NET CLR 3.5.30729; .NET CLR 3.0.30618; MS-RTC LM 8)

Suppose an attribute implements an interface. When IsDefined is called on a
MethodInfo object to check whether the attribute is defined on the method or
not and the first argument is the interface type then IsDefined returns false.
The Microsoft .NET Framework implementation, on the other hand, returns true
for the same scenario.

Reproducible: Always

Steps to Reproduce:
Following is the source code of a simple C# console program to demonstrate the
bug:

using System;

interface IFoo {}

[AttributeUsage(AttributeTargets.Method)]
class FooAttribute : Attribute, IFoo {}

class Bar
{
    [Foo]
    public void Baz() {}
}

static class Program
{
    static void Main()
    {
        var method = typeof(Bar).GetMethod("Baz");
        Console.WriteLine("FooAttribute? " +
method.IsDefined(typeof(FooAttribute), true));
        Console.WriteLine("IFoo? " + method.IsDefined(typeof(IFoo), true));
    }
}

Actual Results:  
The output of the program demonstrating the bug is:

FooAttribute? True
IFoo? False


Expected Results:  
The expected output was:

FooAttribute? True
IFoo? True

-- 
Configure bugmail: https://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.
_______________________________________________
mono-bugs maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-bugs

Reply via email to