DiagnosticSuppressor to automatically suppress built-in C# compiler warnings that overlap with its own, more comprehensive diagnostics. This prevents duplicate warnings and provides a cleaner development experience.
Suppressed Compiler Warnings
The following compiler diagnostics are suppressed when CommentSense is active:CS1591: Missing XML comment for publicly visible type or member
CS1591: Missing XML comment for publicly visible type or member
Why it’s suppressed: CommentSense provides CSENSE001 which offers more granular control over which members require documentation, including:
- Configurable visibility thresholds
- Support for
<inheritdoc />tags - Options to exclude constants and enum members
- Better detection of implicit documentation inheritance
CS1573: Parameter has no matching param tag in XML comment
CS1573: Parameter has no matching param tag in XML comment
Why it’s suppressed: CommentSense provides CSENSE002 which not only detects missing parameter documentation but also:
- Offers automatic code fixes to generate missing tags
- Provides fuzzy matching to suggest renaming stray tags
- Supports Fix All operations across documents, projects, or solutions
CS1572: XML comment has a param tag for a non-existent parameter
CS1572: XML comment has a param tag for a non-existent parameter
Why it’s suppressed: CommentSense provides CSENSE003 with enhanced capabilities:
- Automatically removes stray tags via code fix
- Uses fuzzy matching to detect renamed parameters
- Offers intelligent rename suggestions
- Supports Fix All for bulk cleanup
CS1571: XML comment has a duplicate param tag
CS1571: XML comment has a duplicate param tag
Why it’s suppressed: CommentSense provides CSENSE009 which:
- Detects duplicate parameter tags
- Provides code fixes to remove duplicates
- Works with Fix All to clean up entire projects
CS1584: XML comment has syntactically incorrect cref attribute
CS1584: XML comment has syntactically incorrect cref attribute
Why it’s suppressed: CommentSense provides CSENSE007 for validating
cref attributes with:- More detailed error messages
- Better integration with the analyzer pipeline
- Consistent diagnostic format with other CommentSense rules
CS1574: XML comment has cref attribute that could not be resolved
CS1574: XML comment has cref attribute that could not be resolved
Why it’s suppressed: CommentSense provides CSENSE007 which handles unresolved
cref attributes and additionally offers:- CSENSE025: Detects accessibility mismatches (e.g., public member referencing internal type)
- Better semantic analysis of symbol references
CS1658: Error in XML comment (e.g., syntax error in cref)
CS1658: Error in XML comment (e.g., syntax error in cref)
Why it’s suppressed: This is a general XML comment error diagnostic that overlaps with multiple CommentSense rules:
- CSENSE007 (invalid cref)
- CSENSE022 (stray summary tags)
- CSENSE023 (stray exception tags)
How Suppression Works
CommentSense implements suppression through theCommentSenseSuppressor class, which is a Roslyn DiagnosticSuppressor:
Suppression Descriptors
Each suppressed diagnostic has a correspondingSuppressionDescriptor defined in CommentSenseSuppressions.cs:
Suppression Modes
CommentSense supports two suppression modes:Global Suppression (Default)
By default, compiler warnings are suppressed globally for the entire project. This means:- All instances of CS1591, CS1573, CS1572, etc. are hidden
- CommentSense rules (CSENSE001, CSENSE002, etc.) are shown instead
- Simpler configuration, cleaner error list
Conditional Suppression
If you want compiler warnings to still appear for members that CommentSense doesn’t analyze (e.g., because they’re excluded or below the visibility threshold), enable conditional suppression:-
CommentSense checks if the member is eligible for analysis based on:
- Visibility level (
comment_sense.visibility_level) - Constant exclusion (
comment_sense.exclude_constants) - Enum exclusion (
comment_sense.exclude_enums)
- Visibility level (
- If the member is analyzed by CommentSense → suppress compiler warning
- If the member is not analyzed → allow compiler warning to show
When to Use Conditional Suppression
Configuration Examples
Scenario 1: Clean Error List
Goal: Only show CommentSense diagnostics, no compiler warnings.Scenario 2: Partial Coverage
Goal: CommentSense analyzes public APIs, but compiler warnings should still appear for internal members.- Public members: CommentSense rules (CSENSE001, etc.)
- Internal/private members: Compiler warnings (CS1591, etc.)
Scenario 3: Exclude Specific Member Types
Goal: Skip documentation for constants and enums, but still get compiler warnings for them.Viewing Suppressed Warnings
To see which warnings are being suppressed:Troubleshooting
I still see CS1591 warnings
I still see CS1591 warnings
This can happen if:
- CommentSense is not installed or enabled
- The analyzer is disabled in your project settings
- You have
<NoWarn>1591</NoWarn>in your.csproj(this takes precedence)
NoWarn configurations.I want to disable specific CommentSense rules
I want to disable specific CommentSense rules
Suppression isn't working in my CI/CD pipeline
Suppression isn't working in my CI/CD pipeline
Ensure:
- CommentSense NuGet package is restored
- You’re using a compatible SDK version
- The build has analyzer support enabled (it’s on by default in modern SDKs)
Summary
CommentSense’s suppression system:- Eliminates duplicate warnings from the C# compiler
- Provides better diagnostics with more context and code fixes
- Offers flexible configuration via global or conditional suppression
- Integrates seamlessly with existing projects without manual
NoWarnentries
- Configuration Guide for
.editorconfigoptions - Rules Reference for CommentSense diagnostic details