Skip to content

Gendarme.Rules.Naming.AvoidTypeInterfaceInconsistencyRule(git)

Sebastien Pouliot edited this page Mar 2, 2011 · 1 revision

AvoidTypeInterfaceInconsistencyRule

Assembly: Gendarme.Rules.Naming
Version: git

Description

This rule will fire if an assembly has a namespace which contains an interface IFoo and a type Foo, but the type does not implement the interface. If an interface and a type name differ only by the I prefix (of the interface) then we can logically expect the type to implement this interface.

Examples

Bad example:

public interface IMember {
    string Name {
        get;
    }
}
public class Member {
    public string Name {
        get {
            return String.Empty;
        }
    }
}

Good example:

public interface IMember {
    string Name {
        get;
    }
}
public class Member : IMember {
    public string Name {
        get {
            return String.Empty;
        }
    }
}

Notes

  • This rule is available since Gendarme 2.4

Source code

You can browse the latest source code of this rule on github.com

Clone this wiki locally