Identifiers should not have incorrect suffix
Identifiers should not have incorrect suffix
Microsoft docsDescription
By convention, only the names of types that extend certain base types or that implement certain interfaces, or types derived from these types, should end with specific reserved suffixes. Other type names should not use these reserved suffixes.
The following table lists the reserved suffixes and the base types and interfaces with which they're associated.
| Suffix | Base type/Interface | |----------------|-------------------------------------------------------------| | Attribute | System.Attribute | | Collection | System.Collections.ICollection<br/><br/>System.Collections.IEnumerable<br/><br/>System.Collections.Queue<br/><br/>System.Collections.Stack<br/><br/>System.Collections.Generic.ICollection1<br/><br/>System.Data.DataSet<br/><br/>System.Data.DataTable | | Dictionary | System.Collections.IDictionary<br/><br/>System.Collections.Generic.IDictionary2 | | EventArgs | System.EventArgs | | EventHandler | An event-handler delegate | | Exception | System.Exception | | Permission | System.Security.IPermission | | Queue | System.Collections.Queue | | Stack | System.Collections.Stack | | Stream | System.IO.Stream |
In addition, the following suffixes should not be used:
DelegateEnumExor similar suffix to distinguish it from an earlier version of the same typeFlagorFlagsfor enum typesImpl(useCoreinstead)Newif a member with the same name but without theNewsuffix already exists
Naming conventions provide a common look for libraries that target the .NET common language runtime. These conventions reduce the learning curve that's required for new software libraries and increase customer confidence that the library was developed by someone with expertise in developing managed code. For more information, see Naming guidelines: Classes, Structs, and Interfaces.
Cause
An identifier has an incorrect suffix.
By default, this rule only looks at externally visible identifiers, but this is configurable.
How to fix violations
Remove the suffix from the type name.
Example
class BadEmployeeCollection { } // Violates CA1711
// Good
class Employee { }
class GoodEmployeeCollection : ICollection<Employee>
{
// Implementations
}
class Employees { } // GoodWhen to suppress
Do not suppress a warning from this rule unless the suffix has an unambiguous meaning in the application domain.