[Mono-bugs] [Bug 500385] New: GetMethod fails to find private methods up the class hierarchy when using BindingFlags.NonPublic

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sat May 2 08:38:55 EDT 2009


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


           Summary: GetMethod fails to find private methods up the class
                    hierarchy when using BindingFlags.NonPublic
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.4.x
          Platform: i386
        OS/Version: Mac
            Status: NEW
          Severity: Critical
          Priority: P5 - None
         Component: CORLIB
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: joe at unity3d.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: Customer


GetMethod does not look for methods in base classes if the method is private
and you are using BindingFlags.NonPublic.


------
using System.Reflection;

class Test
{
        class TestInheritedMethodA
        {
            private void TestMethod()
            {

            }

            public void TestMethod2()
            {

            }
        }

        class TestInheritedMethodB : TestInheritedMethodA
        {

        }

        public static void Main ()
        {
            MethodInfo inheritedMethod =
typeof(TestInheritedMethodB).GetMethod("TestMethod", BindingFlags.Instance |
BindingFlags.Public | BindingFlags.NonPublic);
            MethodInfo baseMethod =
typeof(TestInheritedMethodB).GetMethod("TestMethod", BindingFlags.Instance |
BindingFlags.Public | BindingFlags.NonPublic);
            if (inheritedMethod != baseMethod)
                System.Console.WriteLine("Bug1");
        }
}



Running this script will print bug1, because inheritedMethod returns null. 
inheritedMethod should equal baseMethod

-- 
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