Skip to main content

Installing CommentSense

CommentSense is distributed as a NuGet package that includes both analyzers and code fix providers. Choose your preferred installation method below.

Using .NET CLI

dotnet add package CommentSense
Replace * with a specific version number in the PackageReference example, or use Version="*" to always get the latest version.

For Multiple Projects

If you have a solution with multiple projects, you can install CommentSense in all projects at once using Directory.Build.props:
1

Create Directory.Build.props

Create a Directory.Build.props file in your solution root directory.
2

Add PackageReference

Add the following content:
Directory.Build.props
<Project>
  <ItemGroup>
    <PackageReference Include="CommentSense" Version="*" />
  </ItemGroup>
</Project>
3

Build Your Solution

All projects in your solution will now automatically reference CommentSense.
Using Directory.Build.props ensures consistent analyzer versions across your entire solution and simplifies maintenance.

Enabling XML Documentation

CommentSense requires XML documentation generation to be enabled in your project. Without this, you’ll see the CSENSE000 warning.

Enable for a Single Project

Edit your .csproj file and add the following property:
YourProject.csproj
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <GenerateDocumentationFile>true</GenerateDocumentationFile>
  </PropertyGroup>
  
  <!-- Your existing content -->
</Project>

Enable for All Projects

Add this to your Directory.Build.props file:
Directory.Build.props
<Project>
  <PropertyGroup>
    <GenerateDocumentationFile>true</GenerateDocumentationFile>
  </PropertyGroup>
  
  <ItemGroup>
    <PackageReference Include="CommentSense" Version="*" />
  </ItemGroup>
</Project>
CSENSE000 will be reported if GenerateDocumentationFile is not set to true. CommentSense relies on the compiler’s documentation parsing to analyze your code.

Verifying Installation

After installation, verify that CommentSense is working correctly:
1

Build Your Project

Build your project to ensure the analyzer is loaded:
dotnet build
2

Check for CSENSE000

If you haven’t enabled XML documentation yet, you should see a CSENSE000 warning indicating that documentation parsing is disabled.
3

Enable Documentation Generation

Add <GenerateDocumentationFile>true</GenerateDocumentationFile> to your project.
4

Rebuild and See Diagnostics

Rebuild your project. You should now see CommentSense diagnostics for any undocumented public members.

IDE Integration

CommentSense works seamlessly with popular C# development environments:

Visual Studio

  • Diagnostics appear in the Error List window
  • Code fixes are available via the light bulb icon (Ctrl+.) or screwdriver icon
  • Supports Fix All in Document, Project, or Solution scope
  • Real-time analysis as you type

Visual Studio Code

When using the C# Dev Kit or C# extension:
  • Diagnostics appear as squiggles in the editor
  • Code fixes available via Quick Fix (Ctrl+. or Cmd+.)
  • Diagnostics shown in the Problems panel

JetBrains Rider

  • Diagnostics appear in the Errors in Solution window
  • Code fixes available via Alt+Enter
  • Supports batch code fixes
CommentSense is a standard Roslyn analyzer and works with any IDE that supports .NET analyzers.

Troubleshooting

CommentSense Not Showing Diagnostics

Ensure <GenerateDocumentationFile>true</GenerateDocumentationFile> is set in your .csproj file. If this is missing, you’ll only see CSENSE000.
Run dotnet list package to verify CommentSense appears in your package references.
Sometimes the analyzer cache needs to be cleared:
dotnet clean
dotnet build
If using Visual Studio or Rider, restart the IDE to ensure analyzers are reloaded.
By default, CommentSense analyzes public and protected members. If you want to analyze internal or private members, configure comment_sense.visibility_level in .editorconfig.

Build Performance Impact

CommentSense is designed to be performant, but if you experience build slowdowns:
Consider adjusting the visibility level to reduce the number of analyzed members, or exclude constants and enum members using .editorconfig options.

Uninstalling CommentSense

To remove CommentSense from your project:
dotnet remove package CommentSense

Next Steps

Quick Start

Get from installation to your first working example

Configuration

Customize CommentSense behavior via .editorconfig

Build docs developers (and LLMs) love