Check that all types that derive from Foo, has a name that ends up with Foo

Rule ND9915 Samples of Custom rules / Custom Naming Conventions

A sample rule to adapt to your need: enforces that all classes deriving from a particular class are named with a particular suffix.

How to fix

This is a sample rule, there is nothing to fix as is.

CQLinq source

This rule is written in CQLinq, C# LINQ over the NDepend code model. It ships with every new NDepend project: you can read it, adapt it, or use it as a starting point for your own custom rules.

// <Name>Check that all types that derive from Foo, has a name that ends up with Foo</Name>
// <Id>ND9915:ExplicitId9915</Id>

warnif count > 0 from t in Application.Types where 
   t.DeriveFrom ("Foo".AllowNoMatch().MatchType()) &&
  !t.NameLike (@"Foo$")
select new { 
   t, 
   t.NbLinesOfCode,
   Debt = 5.ToMinutes().ToDebt(),
   Severity = Severity.Medium
}

//<Expl>
// The *{0}* derives from *Foo* and thus, its name should end up with *Foo*.
//</Expl>

//<Desc>
// A *sample rule to adapt to your need*: enforces that all classes deriving
// from a particular class are named with a particular suffix.
//</Desc>

//<HowToFix>
// This is a *sample rule*, there is nothing to fix *as is*.
//</HowToFix>

Samples of Custom rules / Custom Naming Conventions: all 2 items