What is CommentSense?
CommentSense is a Roslyn-based diagnostic analyzer for C# designed to ensure that public-facing APIs are consistently and meaningfully documented. It goes beyond the standard C# compiler warnings to provide comprehensive XML documentation analysis, automatic code fixes, and intelligent quality checks.Key Features
Comprehensive Documentation Analysis
Analyzes XML documentation for completeness, quality, and correctness across all public API surfaces including classes, methods, properties, parameters, and exceptions.
Intelligent Code Fixes
Automatic code fixes for common documentation issues with full support for Fix All in document, project, or solution scope.
Quality Enforcement
Detects low-quality documentation such as empty summaries, placeholder text, or descriptions that simply repeat the member name.
Highly Configurable
Fine-tune behavior through .editorconfig with options for visibility levels, quality thresholds, ignored exceptions, and more.
Why CommentSense?
The C# compiler provides basic XML documentation warnings (CS1591, CS1573, etc.), but they’re limited in scope and functionality. CommentSense builds on these foundations to provide:- Quality Analysis: Ensure documentation is meaningful, not just present
- Exception Tracking: Automatically detect thrown exceptions and ensure they’re documented
- Smart References: Flag parameter and keyword references that should use proper XML tags
- Consistency Checks: Enforce tag ordering, proper use of
<inheritdoc />, and more - Automatic Suppression: Replaces overlapping C# compiler warnings to reduce noise
CommentSense automatically suppresses several built-in C# compiler diagnostics (CS1591, CS1573, CS1572, CS1571, CS1584, CS1574, CS1658) that overlap with its own rules, providing a cleaner experience.
Documentation Rules Overview
CommentSense provides 26 diagnostic rules organized into categories:General Documentation
- CSENSE001: Missing XML documentation on public members
- CSENSE016: Low-quality documentation detection
- CSENSE007: Invalid
crefattribute validation - CSENSE019: C# keyword recommendations for
<see langword="..." /> - CSENSE024: XML documentation tag ordering
Parameters & Type Parameters
- CSENSE002/004: Missing parameter or type parameter documentation
- CSENSE003/005: Stray parameter tags
- CSENSE008/010: Parameter ordering enforcement
- CSENSE020/021: Ghost reference detection (unwrapped parameter names)
Return Values & Exceptions
- CSENSE006: Missing
<returns>tags - CSENSE012: Missing exception documentation with body scanning
- CSENSE017: Exception type validation
Properties
- CSENSE014: Optional
<value>tag requirements - CSENSE015: Stray
<value>tags
See the full Rules Reference for detailed information about each diagnostic.
Getting Started
Installation
Install CommentSense via NuGet and configure your project
Quick Start
Get from installation to your first working example in minutes
Configuration
Learn how to customize CommentSense behavior via .editorconfig
Rules Reference
Explore all available diagnostic rules and their options
Requirements
CommentSense requires XML documentation generation to be enabled in your project. Add this to your.csproj file:
Example
Here’s what CommentSense helps you catch:Next Steps
Install CommentSense
Follow the installation guide to add CommentSense to your project.
Complete the Quick Start
Work through the quick start guide to see CommentSense in action.
Configure Your Preferences
Customize behavior using the configuration guide.
Explore the Rules
Review the rules reference to understand all available diagnostics.