Skip to content

Call to an explicit interface implementation misses a cast in decompiled source (C# and VB) #793

@jmairboeck

Description

@jmairboeck

Suppose you have the following interfaces:

interface IBase {
 int Property { get; }
}
interface IDerived : IBase {
 new int Property { get; } // this hides IBase.Property
}

A possible implementation of IDerived can have two implementations of the Property getter (via explicit implementation).

If you have some instance of IDerived and want to to call IBase's Property getter, you need a cast on the call site. However, ILSpy doesn't generate a cast.

IDerived instance = ...;
int x = ((IBase)instance).Property; //ILSpy doesn't generate this cast, calling the wrong property

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions