Conditional Suppression
CommentSense automatically suppresses several built-in C# compiler diagnostics that overlap with its own rules to prevent duplicate warnings.Suppressed Compiler Diagnostics
By default, CommentSense suppresses these diagnostics globally:- CS1591 - Missing XML comment for publicly visible type or member
- CS1573 - Parameter has no matching param tag in the XML comment
- CS1572 - XML comment has a param tag for a non-existent parameter
- CS1571 - XML comment has a duplicate param tag
- CS1584 - XML comment has syntactically incorrect cref attribute
- CS1574 - XML comment has cref attribute that could not be resolved
- CS1658 - Error in XML comment (e.g., syntax error in cref)
Configuration Option
Controls how CommentSense suppresses overlapping compiler warnings.
false(default) - Suppresses the above diagnostics globally for the entire projecttrue- Suppresses diagnostics only for members that CommentSense is actively analyzing
When to Use Conditional Suppression
Conditional suppression is useful when you exclude certain members from CommentSense analysis but still want the standard C# compiler warnings to report issues for them. Example scenario:With
enable_conditional_suppression = false (default), CS1591 is suppressed globally, so you won’t see warnings for constants or internal members at all.Configuration Examples
Default behavior (global suppression):Excluding Constants
When set to
true, skips documentation requirements for constant fields.Constants like public const string Version = "1.0"; are often self-explanatory and may not need documentation.This setting only affects
const fields. Static readonly fields, properties, and other members still require documentation.When to Exclude Constants
Consider excluding constants when:- Constant names are self-documenting (e.g.,
MaxRetryCount,DefaultTimeout) - Constants represent simple configuration values
- Your codebase has many constants with obvious purposes
- Constants represent complex business rules
- Constant values have non-obvious meanings
- Constants are part of a public API contract
Excluding Enum Members
When set to
true, skips documentation requirements for enum members.Enum members with descriptive names often don’t need additional documentation.This setting only affects enum members, not the enum type itself. The enum type declaration still requires documentation.
When to Exclude Enum Members
Consider excluding enum members when:- Enum member names clearly describe their purpose
- Enums represent simple state machines or status values
- Your codebase has many enums with self-documenting names
- Enum values have specific business meanings that aren’t obvious
- Enum members represent complex states with conditions
- Enum values have deprecation notes or usage guidelines
Implicit Documentation Inheritance
Controls whether members that override or implement base members can implicitly inherit documentation.
true(default) - Allows implicit documentation inheritance for overriding/implementing membersfalse- Requires explicit documentation (e.g.,<inheritdoc />) for all members, triggering CSENSE018
Default Behavior (Implicit Inheritance Allowed)
Strict Behavior (Explicit Documentation Required)
<inheritdoc />:
CommentSense provides an automatic code fix to insert an
<inheritdoc /> tag for CSENSE018. This fix supports Fix All in document, project, or solution.Interface Implementations
The same rules apply to interface implementations:Types Always Require Explicit Documentation
Complete Advanced Configuration Example
Scoped Advanced Configuration
Apply different advanced rules to different parts of your codebase:Related Rules
- CSENSE001 - Missing XML documentation (affected by
exclude_constantsandexclude_enums) - CSENSE018 - Missing explicit documentation for inherited members (controlled by
allow_implicit_inheritdoc) - CS1591 - Compiler diagnostic for missing XML comments (affected by
enable_conditional_suppression)
Best Practices
- Use conditional suppression carefully - Only enable it if you need compiler warnings for excluded members
- Exclude constants and enums judiciously - Consider whether your constants/enums truly are self-documenting
- Require explicit inheritdoc for public APIs - Set
allow_implicit_inheritdoc = falsefor library code - Allow implicit inheritance for internal code - Keep the default
truefor application code - Use scoped configuration - Apply stricter rules to public APIs and relaxed rules to internal code
See Also
- Visibility Levels - Configure which members are analyzed
- Quality Checks - Configure documentation quality standards
- Exception Documentation - Configure exception documentation requirements