An identifier has an incorrect suffix.
By default, this rule only looks at externally visible identifiers, but this is configurable.
Rule descriptionBy 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.
In addition, the following suffixes should not be used:
Delegate
Enum
Ex
or similar suffix to distinguish it from an earlier version of the same typeFlag
or Flags
for enum typesImpl
(use Core
instead)New
if a member with the same name but without the New
suffix already existsNaming 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.
How to fix violationsRemove the suffix from the type name.
When to suppress warningsDo not suppress a warning from this rule unless the suffix has an unambiguous meaning in the application domain.
Suppress a warningIf you just want to suppress a single violation, add preprocessor directives to your source file to disable and then re-enable the rule.
#pragma warning disable CA1711
// The code that's violating the rule is on this line.
#pragma warning restore CA1711
To disable the rule for a file, folder, or project, set its severity to none
in the configuration file.
[*.{cs,vb}]
dotnet_diagnostic.CA1711.severity = none
For more information, see How to suppress code analysis warnings.
Configure code to analyzeUse the following options to configure which parts of your codebase to run this rule on.
You can configure these options for just this rule, for all rules they apply to, or for all rules in this category (Naming) that they apply to. For more information, see Code quality rule configuration options.
Include specific API surfacesYou can configure which parts of your codebase to run this rule on, based on their accessibility, by setting the api_surface option. For example, to specify that the rule should run only against the non-public API surface, add the following key-value pair to an .editorconfig file in your project:
dotnet_code_quality.CAXXXX.api_surface = private, internal
Note
Replace the XXXX
part of CAXXXX
with the ID of the applicable rule.
You can configure a list of allowed suffixes, with each suffix separated by the pipe character ("|"). For example, to specify that the rule should not run against Flag and Flags suffixes, add the following key-value pair to an .editorconfig file in your project:
dotnet_code_quality.ca1711.allowed_suffixes = Flag|Flags
See also
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4