[Mono-dev] Mono's reflection implementation

Kris Mok rednaxela0607 at hotmail.com
Thu Sep 10 08:59:20 EDT 2009

Hi Robert,

No, MS.NET's delegate declares _target, _methodBase, _methodPtr and 
_methodPtrAux in System.Delegate, the same way Mono's System.Delegate 
declares m_target, method_ptr and the like. But they might have had some 
special treatment to the delegates' implementations. Both MS.NET and Mono 
show the same output for the following snippet:

using System;
using System.Reflection;

class Foo {
    int _a;

class Bar {
    int _b;

static class Program {
    static void PrintNonPublicMembers(Type type) {
        Console.WriteLine("non-public instance fields of {0}", type);
        var mInfos = type.GetFields(BindingFlags.NonPublic | 
        if (0 == mInfos.Length) Console.WriteLine("mInfos is empty");
        foreach (var mi in mInfos) {

    static void Main(string[] args) {

You're right that BindingFlags.NonPublic doesn't return inherited fields. 
Looks like I should have sent a bug report to MS instead :)

Thank you for your reply,
Kris Mok

> Date: Thu, 10 Sep 2009 14:10:09 +0200
> From: Robert Jordan <robertj at gmx.net>
> Subject: Re: [Mono-dev] Mono's reflection implementation
> To: mono-devel-list at lists.ximian.com
> Message-ID: <h8aqb2$gnp$1 at ger.gmane.org>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> Hi,
> This is not a bug. BindingFlags.NonPublic does not return inherited
> non-public class members.
> It seems that MS.NET's internal delegate implementation is different
> from Mono's. Maybe they are explicitly defining these fields in
> inherited delegates.
> Robert

More information about the Mono-devel-list mailing list