Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
.NET compiler platform (Roslyn) analyzers inspect your C# or Visual Basic code for code quality and code style issues. These analyzers are included with the .NET SDK.
- Code quality analysis ("CAxxxx" rules):
- Implemented in the dotnet/sdk repo (previously implemented in
dotnet/roslyn-analyzersrepo). - Documented here in the
dotnet/docsrepo. See Contribute docs for 'CAxxxx' rules.
- Implemented in the dotnet/sdk repo (previously implemented in
- Code style analysis ("IDExxxx" rules):
- Implemented in the dotnet/roslyn repo.
- Documented here in the
dotnet/docsrepo. See Contribute docs for 'IDExxxx' rules.
Contribute docs for 'CAxxxx' rules
Please follow the following steps to contribute documentation for code quality analysis rules to the dotnet/docs repo:
- Determine
Rule IDandCategory: Ensure that you know the 'CAxxxx' rule ID and category for the rule to be documented. This means either your CA analyzer has been merged into the dotnet/sdk repo or you have an open PR with an approved ID and category that has been assigned to the rule. - Add rule doc:
- Clone an existing CA rule file under root folder, say
ca1000.md, and rename it. - Update the content of the file appropriately.
- Clone an existing CA rule file under root folder, say
- Add an entry for the rule to following tables:
- In table of contents file under the rule category list. For example, for a CA rule with
Performancecategory, search for the term- name: Performance rulesin the file and add an entry to the list. If none exists, create a new category list under- name: Code quality rules. - In top-level rule index file.
- In
categorybased rule index file:- Identify the category based index file under root folder. For example, for a CA rule with
Performancecategory, this file is namedperformance-warnings.md. If none exists, create a new category based index file by cloning an existing one. - Add an entry for the rule ID in this file.
- Identify the category based index file under root folder. For example, for a CA rule with
- In table of contents file under the rule category list. For example, for a CA rule with
Tip
Perform a repo search in the dotnet/docs repo for a known, existing CA rule ID to identify potential places that might need an update. For example, see https://github.com/dotnet/docs/search?q=CA2000.
Contribute docs for 'IDExxxx' rules
Please follow the following steps to contribute documentation for code style analysis rules to the dotnet/docs repo:
- Determine
Rule IDand code style options, if any: Ensure that you know the 'IDExxxx' rule ID and code style options for the rule to be documented. This means either the IDE analyzer has been merged into the dotnet/roslyn repo or you have an open PR with an approved ID and code style options that have been assigned to the rule. - Determine rule
subcategory: IDE rules have categoryStyle. Identify the rule subcategory by reading through the introductory section of Code style rules. Most of the IDE code style rules are under theLanguagesubcategory. - Determine rule
preference group: Identify thepreference groupfor the rule by reading through the preferences headers here.- If the rule has known, associated code style option(s), the preferences group will match the
OptionGroupspecified in the code style option declaration. - Otherwise, determine if the rule belongs to an existing preference group or needs a new preference group.
- If the rule has known, associated code style option(s), the preferences group will match the
- Add rule doc:
- Clone an existing IDE rule file under root folder, say
ide0011.md, and rename it. - Update the content of the file appropriately.
- Clone an existing IDE rule file under root folder, say
- Add an entry for the IDE rule and/or code style option(s) to the following tables:
- In table of contents file under the rule's sub-category and preferences list. For example, for an IDE code style rule with
Languagesubcategory andModifier preferencesgroup, search for the term- name: Language rulesand a child node- name: Modifier preferencesin the file and add an entry to the list. If either the subcategory list or the preferences list under the subcategory does not exist, create a new one under- name: Code style rules. - In the code style option-based index file.
- In the rule ID-based index file.
- In
preferences groupbased rule index file:- Identify the preferences group based index file under root folder. For example, for an IDE rule for
Modifier preferences, this file is namedmodifier-preferences.md. If none exists, create a new preferences group based index file by cloning an existing one. - Add an entry for the rule ID in this file.
- Identify the preferences group based index file under root folder. For example, for an IDE rule for
- In table of contents file under the rule's sub-category and preferences list. For example, for an IDE code style rule with
Tip
Perform a repo search in the dotnet/docs repo, for a known, existing IDE rule and/or code style option(s) to identify potential places that might need an update. For example, see https://github.com/dotnet/docs/search?q=IDE0011 and https://github.com/dotnet/docs/search?q=csharp_prefer_braces.