-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Description
Old Issue description
The documentation for CA1xxx rules do not state what their full.editorconfigrule names are.This makes it impossible to suppress or configure rules using.editorconfiggiven that the Error List's Suppress and Configure menus are currently broken at-present if you don't already know what the name is.Also, given that some rules (especially code style rules) have bothIDE0000-style names and Editorconfig-standard names this makes things even more confusing.Additionally so when rules' names change between legacy FxCop, Roslyn-based, and NuGet-package-based releases.
Additionally, the generic example given in the documentation implies that every rule is underdotnet_code_qualitywhich is not true, but it's used for every rule's documentation. For example, CA1054 isdotnet_diagnostic.CA1054, notdotnet_code_quality.CA1054. However I couldn't find any documentation for CA1054's full name - I found it out through trial-and-error.
(Revised) Issue description
Ask 1: Please list all .editorconfig names for each rule (at the top of each page):
The documentation pages for both Code Analysis and Code Style do not clearly document all of the .editorconfig names for each rule.
Specifically, the problem I experienced is that each rule has very different names for setting a rule's options compared to setting a rule's severity or for suppressing it - which also differs from the name used for suppressing entire categories.
For example, for CA1000 (comments inline):
# If you want to disable CA1000 then you need this:
dotnet_diagnostic.CA1000.severity = none
# If you want to configure CA1000 then you need this:
dotnet_code_quality.CA1000.api_surface = private, intern
# If you want to suppress all rules in the same category then you need this:
dotnet_analyzer_diagnostic.category-Design.severity = none
For Code style it's even more inconsistent:
# If you want to disable IDE0058 then you need this:
dotnet_diagnostic.IDE0058.severity = none
# If you want to configure IDE0058 then you need this:
csharp_style_unused_value_expression_statement_preference = discard_variable
# ...but you can do this too:
csharp_style_unused_value_expression_statement_preference = discard_variable:none
# If you want to suppress all rules in the same category then you need this:
dotnet_analyzer_diagnostic.category-Style.severity = none
To clarify: I'm not complaining that the names are inconsistent (well, I am...), but I'm complaining that the documentation does not serve as a quick and easy reference to discover the other names of a rule.
So I'm asking for the info-table in every rule's documentation to show all 3 .editorconfig names (the specific rule's name, the name for when suppressing it or configuring its severity, and the name for when configuring its category's severity), as well as all available options in a succinct list.
So this:
Should be something like this:
Ask 2: Include copypastable severity syntaxes in every rule page:
Given the most likely reason for visiting Code Analysis documentation is to figure out how to suppress a rule, I'd also like to see table rows containing copypastable suppression syntaxes, in all 3 formats:
- Preprocessor directive:
#pragma warning disable CA1000 // Do not declare static members on generic types
- Global Suppression File:
[assembly: SuppressMessage("Microsoft.Design","CA1000:DoNotDeclareStaticMembersOnGenericTypes", Scope = "Type")]
- .editorconfig (single rule):
dotnet_diagnostic.CA1000.severity = none(orsilent)
- .editorconfig (entire rule category):
dotnet_analyzer_diagnostic.category-Design.severity = none(orsilent)
Ask 3: Document the .editorconfig rule prefixes:
I would also like to see a page document why the rule name prefixes are different, and as they are different, what they represent. I'm asking because the names are not self-describing at all:
dotnet_diagnosticdotnet_analyzer_diagnosticdotnet_code_quality
Ask 4: The Code quality rule configuration options page should also mention severity
The Code quality rule configuration options page should also have a section for configuring a rule's severity and/or how to suppress it, as I was under the mistaken belief that setting the severity uses the same syntax as setting an OptionValue.

