CommentsExtractor.RuntimeDependencies
26.1.63689
dotnet add package CommentsExtractor.RuntimeDependencies --version 26.1.63689
NuGet\Install-Package CommentsExtractor.RuntimeDependencies -Version 26.1.63689
<PackageReference Include="CommentsExtractor.RuntimeDependencies" Version="26.1.63689" />
<PackageVersion Include="CommentsExtractor.RuntimeDependencies" Version="26.1.63689" />
<PackageReference Include="CommentsExtractor.RuntimeDependencies" />
paket add CommentsExtractor.RuntimeDependencies --version 26.1.63689
#r "nuget: CommentsExtractor.RuntimeDependencies, 26.1.63689"
#:package CommentsExtractor.RuntimeDependencies@26.1.63689
#addin nuget:?package=CommentsExtractor.RuntimeDependencies&version=26.1.63689
#tool nuget:?package=CommentsExtractor.RuntimeDependencies&version=26.1.63689
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.GetCommentsmethod 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
Reference the Attributes and Generator: In your project file (
.csproj), add the following:<ItemGroup> <PackageReference Include="CommentExtractor" Version="*" OutputItemType="Analyzer" ReferenceOutputAssembly="false" /> </ItemGroup>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:
- Extracts the XML documentation string using Roslyn's
GetDocumentationCommentXml(). - Generates a private constant string containing the XML.
- 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 | Versions 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. |
-
.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 |