[Mono-dev] FindMembers() for TypeBuilder excluding overriden ones

Atsushi Eno atsushi at ximian.com
Mon Nov 14 02:03:00 EST 2005


Hi,

Thanks for the hints, Hari.

Raja R Harinath wrote:
> Hi,
> 
> Atsushi Eno <atsushi at ximian.com> writes:
> 
>> In mcs(.exe) I want to get a MemberInfo array which has a certain
>> name and does not contain overriden base members i.e. something
>> like Type.FindMembers() with Type.FilterName (TypeBuilder.GetMethods()
>> returns base ones, and it should be fine).
>>
>> (For example, suppose I'm building System.Xml.dll, I don't want
>> XmlReader.Read() while we have XmlTextReader.Read() for XmlTextReader.)
>>
>> Is there any preferable way I can go, or do I have to create such one?
>> It would be useful to fix one /doc bug; #76690.
> 
> I'm assuming that DeclaredOnly is too strict a filter.  It's somewhat

Yes, DeclaredOnly is not what I need (I still need XmlTextReader.Read()
on MyDerivedXmlTextReader where if I have no overriden one).

> non-trivial.  If you use Expression.MemberLookup or
> TypeManager.MemberLookup instead of Type.FindMembers, you can use
> 
>    mi.DeclaringType != t && mi.IsVirtual && !TypeManager.IsOverride (mi)
> 
> to filter out base virtual methods.  However, to ensure that it actually
> is overriden, you have to compare the signatures, and/or use
> GetBaseDefinition().

Seems like TypeManager.FindMembers() handles that mess, and your test
above nicely works :-)

I checked in a fix based on above, but please feel free to move
DocUtil.FindMembers(Type,BindingFlags,MethodSignature) if you want it
in TypeManager.

Atsushi Eno



More information about the Mono-devel-list mailing list