Project Structure
The CommentSense solution is organized into the following main directories:Source Projects
CommentSense.Analyzers
Contains the core diagnostic analyzers that detect documentation issues in C# code. This is the main analysis engine of CommentSense. Key Components:CommentSenseAnalyzer.cs- The main diagnostic analyzer that coordinates all analysisCommentSenseRules.cs- Defines all diagnostic rules (CSENSE001-025)CommentSenseSuppressor.cs- Suppresses overlapping compiler diagnostics (CS1591, CS1573, etc.)AnalyzerExtensions.cs- Extension methods and helper utilities
Logic/ directory contains specialized analyzers for different documentation aspects:
SummaryAnalyzer.cs- Validates<summary>tags and general documentation presenceParameterAnalyzer.cs- Validates<param>tags match method parametersTypeParameterAnalyzer.cs- Validates<typeparam>tags match generic parametersReturnValueAnalyzer.cs- Validates<returns>tags for methodsExceptionAnalyzer.cs- Detects thrown exceptions and validates<exception>tagsQualityAnalyzer.cs- Flags low-quality documentation (empty, too short, etc.)CrefAnalyzer.cs- Validatescrefattributes reference valid symbolsLangwordAnalyzer.cs- Suggests using<see langword="..."/>for keywordsGhostReferenceAnalyzer.cs- Detects parameter names not wrapped in<paramref/>TagOrderAnalyzer.cs- Enforces standard order for documentation tagsSupplementalAnalyzer.cs- Additional validation logicCollectionDocumentationAnalyzer.cs- Validates collection-related documentationDocumentationTextAnalyzer.cs- Analyzes documentation text content
CommentSense.CodeFixes
Provides automatic code fixes for diagnostics reported by the analyzers. All code fixes support Fix All in document, project, or solution scope. Key Components:CodeFixProviderBase.cs- Base class for all code fix providers
Logic/ directory contains specialized code fix providers:
ContentGenerationCodeFixProvider.cs- Generates missing documentation tags with placeholdersDocumentationSynchronizationCodeFixProvider.cs- Synchronizes documentation with code signaturesDocumentationSynchronizationLogic.cs- Core logic for synchronization operationsRedundancyRemovalCodeFixProvider.cs- Removes stray and duplicate tagsOrderSynchronizationCodeFixProvider.cs- Reorders parameter tags to match signaturesExceptionResolutionCodeFixProvider.cs- Adds missing exception documentationGhostReferenceCodeFixProvider.cs- Wraps parameter names in<paramref/>tagsKeywordToSeeLangwordCodeFixProvider.cs- Converts keywords to<see langword="..."/>LowQualityDocumentationCodeFixProvider.cs- Fixes capitalization and punctuationTagOrderCodeFixProvider.cs- Reorders top-level documentation tags
CommentSense.Core
Contains shared utilities, constants, and configuration logic used across the project. Key Components:CommentSenseDiagnosticIds.cs- Defines all diagnostic and suppression IDsUtilities/- Shared utility classes and extension methods
Diagnostic Rules
CommentSense defines diagnostics with IDs from CSENSE000 to CSENSE025:Project Configuration
- CSENSE000 - Disabled documentation parsing warning
General Documentation
- CSENSE001 - Missing XML documentation
- CSENSE007 - Unresolved
crefattribute - CSENSE016 - Low quality documentation
- CSENSE018 - Missing explicit
<inheritdoc/>for overriding members - CSENSE019 - Use
<see langword="..."/>for keywords - CSENSE022 - Stray or duplicate
<summary>tags - CSENSE024 - Incorrect tag order
- CSENSE025 - Inaccessible
crefreference
Parameters & Type Parameters
- CSENSE002/004 - Missing parameter/type parameter documentation
- CSENSE003/005 - Stray parameter/type parameter tags
- CSENSE008/010 - Parameter/type parameter order mismatch
- CSENSE009/011 - Duplicate parameter/type parameter tags
- CSENSE020/021 - Ghost parameter/type parameter references
Return Values
- CSENSE006 - Missing
<returns>tag - CSENSE013 - Stray
<returns>tag
Exceptions
- CSENSE012 - Missing exception documentation
- CSENSE017 - Invalid exception type
- CSENSE023 - Stray exception documentation
Properties
- CSENSE014 - Missing
<value>tag - CSENSE015 - Stray
<value>tag
Suppression System
CommentSense automatically suppresses overlapping C# compiler diagnostics to prevent duplicate warnings:- CS1591 - Missing XML comment (suppressed by CSENSESUP001)
- CS1573 - Missing param tag (suppressed by CSENSESUP002)
- CS1572 - Stray param tag (suppressed by CSENSESUP003)
- CS1571 - Duplicate param tag (suppressed by CSENSESUP004)
- CS1584/1658 - Invalid cref syntax (suppressed by CSENSESUP005/007)
- CS1574 - Unresolved cref (suppressed by CSENSESUP006)
Extension Points
When adding new analyzers or code fixes:- New Analyzer - Create a class in
Logic/directory and register inCommentSenseAnalyzer - New Rule - Add diagnostic ID to
CommentSenseDiagnosticIdsand define rule inCommentSenseRules - New Code Fix - Create provider in
CodeFixes/Logic/and register with appropriate diagnostic IDs - Configuration Option - Add to analyzer configuration parsing and document in
.editorconfig
All analyzers should follow the Roslyn analyzer guidelines and avoid unnecessary allocations for optimal performance.