Skip to content

APICompat misses a breaking change where an interface removes a method that was present on a base interface #36502

Open
@ericstj

Description

Describe the bug

Consider the following:

public interface IBase
{    
    void M1();
    
    void M2();
}

public interface IDerived : IBase
{
    new void M2();
}

It is not compatible to remove IDerived.M2() because the runtime will fail to load a type if it claims to implement an interface member on the derived interface.

To Reproduce

See apiCompatInterface.zip for a repro.

Install apicompat tool and run the repro script.

You can run the application to demonstrate the binary breaking change:

Unhandled exception. System.MissingMethodException: Method not found: 'Void lib.IDerived.M2()'.
   at Program.<Main>$(String[] args)

Expect: Compat error for removing the method.
Actual: No error

This is likely because for classes it's compatible to remove a method if that method was hiding a method on the base. That's not the case for interfaces.

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions