[Mono-dev] Methods implementing interfaces are emitted twice
Gert Driesen
gert.driesen at telenet.be
Mon May 29 11:59:55 EDT 2006
> -----Original Message-----
> From: mono-devel-list-bounces at lists.ximian.com
> [mailto:mono-devel-list-bounces at lists.ximian.com] On Behalf
> Of Gert Driesen
> Sent: maandag 29 mei 2006 17:05
> To: 'mono-devel mailing list'
> Subject: [Mono-dev] Methods implementing interfaces are emitted twice
>
> Hi,
>
> I noticed that methods that implement an interface member are
> emitted twice
> by mcs: once as a normal method and once as an explicit inteface
> implementation.
>
> For example, take a look at the IL for System.String in mscorlib. It
> contains the following methods:
>
> // method line 741
> .method private final virtual hidebysig newslot
> instance default string System.IConvertible.ToString (class
> System.IFormatProvider format) cil managed
> {
> // Method begins at RVA 0xa740
> .override class System.IConvertible::ToString
> // Code size 2 (0x2)
> .maxstack 8
> IL_0000: ldarg.0
> IL_0001: ret
> } // end of method String::instance default string
> System.IConvertible.ToString (class System.IFormatProvider format)
>
> .method public hidebysig
> instance default string ToString (class
> System.IFormatProvider
> provider) cil managed
> {
> // Method begins at RVA 0xb7ec
> // Code size 2 (0x2)
> .maxstack 8
> IL_0000: ldarg.0
> IL_0001: ret
> } // end of method String::instance default string ToString (class
> System.IFormatProvider provider)
>
> while there should have only been this method:
>
> .method public hidebysig newslot virtual final
> instance string ToString(class System.IFormatProvider
> provider) cil managed
> {
> .maxstack 8
> IL_0000: ldarg.0
> IL_0001: ret
> }
>
> Problem is that I can only see evidence of this in mscorlib,
> and I cannot
> reproduce it using another custom-built assembly.
>
> Can someone look into this ?
>
> As a result of this issue, we get quite some bogus warnings
> in the class
> status pages for the NET_1_1 profile
> (http://mono.ximian.com/class-status/mono-HEAD-vs-fx-1-1/class
> -status-mscorl
> ib.html), as corcompare is complaining that the Mono methods
> are not virtual
> final.
>
> As for the class status page warnings: there's an easy
> workaround to get rid
> of the warnings, but it would need a rebuild of the
> masterinfos for MS.NET.
>
> Let me know if you want me to submit a patch for that
> workaround (but I'd
> prefer a real fix for the issue instead).
My mistake, apparently there are in fact two ToString (IFormatProvider)
methods in the source for System.String.
The explicit interface implementation should ofcourse be removed.
Is it ok to remove these ? I'll post a new message containing a patch.
Gert
More information about the Mono-devel-list
mailing list