Identifiers No Incorrect Suffix

ID

csharp.identifiers_no_incorrect_suffix

Severity

info

Remediation Complexity

trivial

Remediation Risk

medium

Remediation Effort

low

Resource

Naming Convention

Language

CSharp

Tags

naming

Description

Reports C# type declarations whose name ends with a type-revealing suffix that the .NET design guidelines discourage. By default the rule rejects the suffixes Enum, Class, Collection, Flags and Delegate. These suffixes encode the kind of the type in the name itself and add no value for the callers reading the code.

The list is configurable via the suffixes property; if a project wants to flag misuse of Exception or Attribute suffixes (which are mandated by the framework only on genuine subclasses), it can add those names to the list. The rule automatically skips types whose direct base type ends with the same suffix, so legitimate *Exception and *Attribute types pass.

Rationale

Type-revealing suffixes are noise. OrderClass is just Order; ColorEnum is just Color. Removing the suffix yields a cleaner API and matches the .NET naming guidelines.

public class Order { }                     // OK
public class OrderClass { }                // FLAW — Class suffix
public enum Color { }                      // OK
public enum ColorEnum { }                  // FLAW — Enum suffix
public class OrderCollection { }           // FLAW — Collection suffix
public delegate void OnClickDelegate();    // FLAW — Delegate suffix
public class Permissions { }               // OK
public class PermissionsFlags { }          // FLAW — Flags suffix

Remediation

Remove the type-revealing suffix from the name. For example, rename ColorEnum to Color, or OrderClass to Order.