When a base type explicitly implements a public interface method, property or event, that member is only accessible in derived types through a
reference to the current instance (namely this). If the derived type explicitly overrides that interface member, the base implementation
becomes inaccessible.
This rule raises an issue when an unsealed, externally visible type provides an explicit member implementation of an interface and
does not provide an alternate, externally visible member with the same name.
This rule does not report a violation for an explicit implementation of IDisposable.Dispose when an externally visible
Close() or System.IDisposable.Dispose(Boolean) method is provided.
Make the class sealed, change the class member to a non-explicit declaration, or provide a new class member exposing the functionality of the explicit interface member.
public interface IMyInterface
{
void MyMethod();
}
public class Foo : IMyInterface
{
void IMyInterface.MyMethod() // Noncompliant
{
MyMethod();
}
}
public interface IMyInterface
{
void MyMethod();
}
public class Foo : IMyInterface
{
void IMyInterface.MyMethod()
{
MyMethod();
}
// This method can be public or protected
protected void MyMethod()
{
// Do something ...
}
}