Xml2Doc.Core 2.4.0

dotnet add package Xml2Doc.Core --version 2.4.0
                    
NuGet\Install-Package Xml2Doc.Core -Version 2.4.0
                    
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="Xml2Doc.Core" Version="2.4.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Xml2Doc.Core" Version="2.4.0" />
                    
Directory.Packages.props
<PackageReference Include="Xml2Doc.Core" />
                    
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 Xml2Doc.Core --version 2.4.0
                    
#r "nuget: Xml2Doc.Core, 2.4.0"
                    
#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 Xml2Doc.Core@2.4.0
                    
#: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=Xml2Doc.Core&version=2.4.0
                    
Install as a Cake Addin
#tool nuget:?package=Xml2Doc.Core&version=2.4.0
                    
Install as a Cake Tool

Xml2Doc.Core

Core library for Xml2Doc. It parses C# compiler XML documentation, resolves references and inheritance, builds deterministic documentation models, and renders Markdown.

Version 2.4.0 adds deterministic document metadata, caller metadata, and authoritative multi-document output paths while preserving existing defaults.

Supported frameworks

  • netstandard2.0
  • net8.0
  • net9.0

Single-input example

using Xml2Doc.Core;
using Xml2Doc.Core.Models;

var model = Xml2Doc.Core.Models.Xml2Doc.Load("MyLibrary.xml");
var renderer = new MarkdownRenderer(
    model,
    new RendererOptions
    {
        FileNameMode = FileNameMode.CleanGenerics,
        RootNamespaceToTrim = "MyCompany.MyProduct",
        TrimRootNamespaceInFileNames = true,
        LineEndings = LineEndingStyle.Lf
    });

renderer.RenderToDirectory("docs");

Multi-input aggregation

using Xml2Doc.Core;
using Xml2Doc.Core.Models;

var model = Xml2Doc.Core.Models.Xml2Doc.LoadAggregate(new[]
{
    "ProjectA.xml",
    "ProjectB.xml"
});

var renderer = new MarkdownRenderer(
    model,
    new RendererOptions
    {
        FileNameMode = FileNameMode.CleanGenerics,
        GenerateIndex = true,
        LineEndings = LineEndingStyle.Lf
    });

renderer.RenderToDirectory("docs");

LoadAggregate canonicalizes, de-duplicates, and ordinally sorts primary input paths before loading. If two primary XML files define the same documentation member ID, loading fails deterministically with XML2DOC006 rather than selecting a winner based on caller order.

Reference XML and inheritance

Reference-only XML can be loaded after the primary model:

model.LoadReferences(new[]
{
    "Framework.Contracts.xml"
});

Reference members are available to <inheritdoc /> and reference resolution but do not become primary generated pages.

Renderer options

RendererOptions is a strongly typed record. Its public options are:

  • FileNameMode
  • RootNamespaceToTrim
  • CodeBlockLanguage
  • TrimRootNamespaceInFileNames
  • AnchorAlgorithm
  • TemplatePath
  • FrontMatterPath
  • AutoLink
  • AliasMapPath
  • ExternalDocs
  • EmitToc
  • EmitNamespaceIndex
  • BasenameOnly
  • ParallelDegree
  • GenerateIndex
  • PruneStaleFiles
  • ManifestIdentity
  • LineEndings
  • WarningSink
  • AliasProvider
  • AnchorGenerator
  • TemplateRenderer
  • FrontMatter
  • AutoLinker
  • LinkPolicy
  • ExternalSymbolResolver
  • SignatureStyle
  • SignatureRenderer
  • DiagnosticSink
  • Metadata
  • Layout
  • DocumentPathResolver

FileNameMode, AnchorAlgorithm, and LineEndings use the FileNameMode, AnchorAlgorithm, and LineEndingStyle enums respectively. Single-file output is selected through MarkdownRenderer.RenderToSingleFile(...) or RendererRunMode.SingleFile; it is not a RendererOptions property.

Built-in and consumer-provided rendering services use the same renderer pipeline.

Document paths and layouts

MarkdownRenderer.DocumentPlan exposes the immutable authoritative multi-document plan used for rendering, links, output planning, manifests, pruning, and writes. DocumentLayout.Flat is the compatible default. DocumentLayout.NamespaceFolders places type pages and namespace indexes in deterministic namespace directories.

Core consumers can implement IDocumentPathResolver and supply it through RendererOptions.DocumentPathResolver. Resolvers select paths only; Core derives relative links from the resolved source and destination paths. Logical paths must be canonical, relative, and use /. Unsafe paths fail with XML2DOC008, and case-insensitive collisions fail with XML2DOC009, before output is written. Layout selection does not affect single-file output.

Per-document metadata

Core-created TemplateRenderContext instances expose an immutable DocumentDescriptor through context.Document. The descriptor identifies the logical document without requiring templates or front-matter providers to parse rendered Markdown:

  • type pages use their complete XML documentation ID, such as T:Temp.Widget;
  • namespace pages use N:<namespace>;
  • the primary index uses xml2doc:index;
  • the namespace overview uses xml2doc:namespaces;
  • consolidated output uses xml2doc:single-file.

Type descriptors also expose the documented namespace and unqualified symbol. Xml2Doc does not infer whether a type is a class, interface, record, struct, or enum because compiler XML does not contain that information.

TemplateRenderContext.OutputPath contains the resolved output-root-relative logical path using forward slashes. It is null for RenderToString() because in-memory rendering has no resolved output location. Direct callers can continue constructing and deconstructing TemplateRenderContext with its existing Content, Title, and Kind values; Document and OutputPath remain null for those directly constructed contexts.

File templates can consume the same values through {{documentId}}, {{namespace}}, {{symbol}}, and {{outputPath}}. A token renders as an empty string when that value does not apply to the current document.

Caller-supplied metadata

Set RendererOptions.Metadata to a generic dictionary of scalar or list values. The renderer copies and validates the collection at construction, exposes the immutable merged values through TemplateRenderContext.Metadata, and emits deterministic YAML front matter:

var options = new RendererOptions(
    Metadata: new Dictionary<string, object?>
    {
        ["package"] = "MyCompany.MyProduct",
        ["version"] = "2.4.0",
        ["tags"] = new[] { "api", "stable" }
    });

Generic caller keys have the lowest precedence. A programmatic FrontMatter provider may override them for one document. Core-derived documentId, documentKind, namespace, symbol, and outputPath values are authoritative when caller metadata participates in the merge and win collisions. Keys are serialized in ordinal order. Supported values are null, strings, booleans, numeric values, dates, enums, and recursively nested lists of those scalars.

Caller metadata cannot be combined with literal FrontMatterPath; that existing mode continues to prepend its configured file unchanged. Without caller metadata, default output and existing programmatic front-matter behavior are unchanged.

Runner pipeline

RendererRunner coordinates output planning and execution around an initialized MarkdownRenderer.

using Xml2Doc.Core.Pipeline;

var runner = new RendererRunner(renderer);
var request = new RendererRunRequest(
    "docs",
    RendererRunMode.PerType);

var result = runner.Run(request);

The runner is the shared execution boundary used by host integrations for planning, deterministic rendering, incremental write results, pruning, and dry-run behavior.

Determinism and output ownership

  • Generated Markdown uses LF by default on every platform.
  • Per-type rendering can run in parallel while preserving deterministic output.
  • Unchanged files are skipped instead of rewritten.
  • Stale pruning is per-type only and requires a stable ManifestIdentity.
  • Ownership manifests are stored under <output-root>/.xml2doc/manifests and authorize deletion only for the matching invocation identity.

Diagnostics

Core exposes stable diagnostics consumed by the CLI and MSBuild hosts. Aggregation-specific diagnostics are:

  • XML2DOC006 — duplicate documentation-member ownership across primary XML inputs.
  • XML2DOC007 is MSBuild-specific and is emitted by repository aggregation ownership validation.

See the repository-level Xml2Doc.md for the complete diagnostic table and host usage examples.

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 is compatible.  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 is compatible.  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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.4.0 42 9/1/2026
2.3.1 79 8/30/2026
2.3.0 95 8/17/2026
2.2.0 92 8/17/2026
2.1.0 98 8/16/2026
2.0.3 87 8/15/2026
2.0.2 96 8/14/2026
2.0.1 99 8/14/2026
2.0.0 84 8/13/2026
2.0.0-preview.113-g69c1a44 51 8/13/2026
1.4.0 92 8/13/2026
1.4.0-preview.111-g7a5369b 58 8/13/2026
1.4.0-preview.110-g1edd8f0 60 8/13/2026
1.4.0-preview.109-g42abc6e 64 8/13/2026
1.4.0-preview.108-g611e3f5 57 8/13/2026
1.4.0-preview.107-gc4dc99b 55 8/13/2026
1.4.0-preview.106-gffe4bab 52 8/13/2026
1.4.0-preview.105-gd9e6cf3 57 8/13/2026
1.4.0-preview.104-gfa11148 55 8/13/2026
1.4.0-preview.103-gc413f43 55 8/13/2026
Loading failed