CommentsExtractor.RuntimeDependencies 26.1.63689

dotnet add package CommentsExtractor.RuntimeDependencies --version 26.1.63689
                    
NuGet\Install-Package CommentsExtractor.RuntimeDependencies -Version 26.1.63689
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CommentsExtractor.RuntimeDependencies" Version="26.1.63689" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CommentsExtractor.RuntimeDependencies" Version="26.1.63689" />
                    
Directory.Packages.props
<PackageReference Include="CommentsExtractor.RuntimeDependencies" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CommentsExtractor.RuntimeDependencies --version 26.1.63689
                    
#r "nuget: CommentsExtractor.RuntimeDependencies, 26.1.63689"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CommentsExtractor.RuntimeDependencies@26.1.63689
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CommentsExtractor.RuntimeDependencies&version=26.1.63689
                    
Install as a Cake Addin
#tool nuget:?package=CommentsExtractor.RuntimeDependencies&version=26.1.63689
                    
Install as a Cake Tool

CommentExtractor Source Generator

A Roslyn-based source code generator for C# (.NET 10) that extracts XML documentation comments from public methods and properties at compile time and makes them available at runtime.

Features

  • Automatic Extraction: Automatically finds all classes annotated with [ExtractComments].
  • Public Member Support: Extracts triple-slash (///) XML documentation for all public methods and properties.
  • Overload Support: Correctly handles method overloads, allowing you to retrieve all matching comments by member name.
  • Unique Identification: Generates unique constant names for each member, including parameter types for methods to ensure no collisions.
  • Efficient Retrieval: Provides a static CommentRegistry.GetComments method lookup.

Project Structure

  • CommentExtractor.Attributes: Contains the [ExtractComments] attribute.
  • CommentExtractor.Generator: The Roslyn Incremental Source Generator.
  • CommentExtractor.Tests: A sample project demonstrating usage and verification.

Setup

  1. Reference the Attributes and Generator: In your project file (.csproj), add the following:

    <ItemGroup>
      <PackageReference Include="CommentExtractor" Version="*"
                        OutputItemType="Analyzer" 
                        ReferenceOutputAssembly="false" />
    </ItemGroup>
    
  2. Enable XML Documentation: The generator relies on the compiler's XML documentation extraction. You must enable it in your .csproj:

    <PropertyGroup>
      <GenerateDocumentationFile>true</GenerateDocumentationFile>
    
      <NoWarn>$(NoWarn);CS1591</NoWarn>
    </PropertyGroup>
    

Usage

1. Annotate your class

using CommentExtractor.Attributes;

namespace MyNamespace;

[ExtractComments]
public class MyService
{
    /// <summary>
    /// This is a sample method.
    /// </summary>
    /// <param name="id">The identifier.</param>
    public void DoWork(int id) { }

    /// <summary>
    /// Gets or sets the name.
    /// </summary>
    public string Name { get; set; }
}

2. Retrieve comments at runtime

Use the CommentRegistry class (located in the CommentExtractor.Attributes namespace):

using CommentExtractor.Attributes;

string[] comments = CommentRegistry.GetComments("MyNamespace.MyService", "DoWork");

foreach (var comment in comments)
{
    Console.WriteLine(comment);
}

How it works

The generator scans for classes marked with [ExtractComments]. For each such class, it iterates through all public methods and properties. It then:

  1. Extracts the XML documentation string using Roslyn's GetDocumentationCommentXml().
  2. Generates a private constant string containing the XML.
  3. Populates a static dictionary mapping (FullTypeName, MemberName) to an array of these constants.

This allows for extremely fast retrieval of documentation at runtime without using heavy Reflection or parsing XML files manually.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on CommentsExtractor.RuntimeDependencies:

Package Downloads
CommentsExtractor

Source-code generator to automatically extract source-code XML-style comments and inject them in the assembly.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
26.1.63689 2,255 1/23/2026
26.1.63688 153 1/23/2026
26.1.63642 180 1/21/2026
26.1.63641 157 1/21/2026
26.1.63640 155 1/21/2026
26.1.63639 149 1/21/2026
26.1.63638 156 1/21/2026