Skip to content

RCS1182 triggered for overridden default interface methods #1496

@gtbuchanan

Description

@gtbuchanan

Product and Version Used:
Roslynator 4.12.4

Steps to Reproduce:

  1. Create an interface with a default method implementation
  2. Create a parent class that implements the interface
  3. Create a child class that inherits the parent class and implements the interface
  4. Add an implementation of the interface method to override the default implementation

Actual Behavior:

internal interface IInterface
{
    void Invoke() => Console.WriteLine(nameof(IInterface));
}

internal class ParentClass : IInterface;

internal class ChildClass : ParentClass, IInterface // BUG: RCS1182 triggered here
{
    public void Invoke() => Console.WriteLine(nameof(ChildClass));
}
...
IInterface x = new ChildClass();
x.Invoke();

Expected Behavior:
RCS1182 should not be triggered. Removing the "redundant" interface implementation causes the default interface method not to be overridden (i.e. the example logs IInterface).

Related to #591

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions