Exception class name should be suffixed with 'Exception'

Rule ND2004 Naming Conventions

Warns about exception classes not suffixed with Exception, a common .NET practice. ExceptionBase is also accepted for base classes.

How to fix

Suffix the names of matched exception classes with Exception.

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>Exception class name should be suffixed with 'Exception'</Name>
// <Id>ND2004:ExceptionClassNameShouldBeSuffixedWithException</Id>

warnif count > 0 from t in Application.Types where 
  t.IsExceptionClass &&
  
  // We use SimpleName, because in case of generic Exception type
  // SimpleName suppresses the generic suffix (like <T>).
 !t.SimpleNameLike(@"Exception$") &&
 !t.SimpleNameLike(@"ExceptionBase$") // Allow the second suffix Base
                                      // for base exception classes.
select new {
   t,
   Debt = 5.ToMinutes().ToDebt(),
   Severity = Severity.High
}

//<Expl>
// The *exception {0}'s name* should be suffixed with *Exception*.
//</Expl>

//<Desc>
// Warns about *exception classes* not suffixed with **Exception**, a common
// .NET practice. **ExceptionBase** is also accepted for base classes.
//</Desc>

//<HowToFix>
// Suffix the names of matched exception classes with **Exception**.
//</HowToFix>

Naming Conventions: all 23 items