Fix XML doc member ID lookup for generic type parameters#26
Merged
Conversation
Cecil's TypeReference.FullName encodes generic instantiations as
TypeName\N<Arg1,Arg2> but XML doc member IDs require TypeName{Arg1,Arg2}.
Methods whose parameter types include closed generic types (e.g.
IEnumerable<string>, IReadOnlyDictionary<string,object>, Action<T>) were
silently returning 'No description provided.' because the generated key
never matched the XML doc file entry.
Fix: add DotNetEmitter.ToXmlDocTypeName() that strips backtick-arity
markers and converts angle brackets to curly braces, then apply it in
both BuildMethodId (DotNetEmitter) and BuildMethodIdFromReference
(DotNetGenerator) for parameter and return types.
Tests added:
- 6 unit theory cases for ToXmlDocTypeName in DotNetEmitterTests
- Regression integration test in DotNetGeneratorTests using new
GenericParameterClass fixture with IEnumerable<string>,
IReadOnlyDictionary<string,object>, and Action<string> parameters
All 156 tests passing (net8/net9/net10).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Adds three fixtures and six integration tests covering the intersection
of inheritdoc resolution and generic-type XML doc ID encoding:
- IGenericParamInterface: interface with Process(IEnumerable<string>)
and Transform(IReadOnlyDictionary<string,object>, Action<string>)
- GenericParamImplementation: bare <inheritdoc /> on both methods,
exercising the chain-resolution path with generic parameter types
- CrefGenericDocClass: <inheritdoc cref='...' /> in both naming styles
- Short C# alias form: IEnumerable{string}, Action{string}
- Fully-qualified CLR form: System.Collections.Generic.IEnumerable{System.String}
Tests confirm:
- Bare inheritdoc resolves summary for single and multiple generic params
- Cref inheritdoc resolves summary using short alias form (compiler normalises)
- Cref inheritdoc resolves summary using fully-qualified CLR form
- None of the above render 'No description provided'
All 162 tests passing (net8/net9/net10).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request fixes XML doc member ID generation for methods whose signatures include generic instantiations by normalizing Mono.Cecil type names into the XML-doc encoding expected by compiled documentation, improving doc lookup/rendering in ApiMark.DotNet.
Changes:
- Added
DotNetEmitter.ToXmlDocTypeNameto normalize Cecil generic type names (backtick arity + angle brackets) into XML doc ID form (curly braces) and normalize nested type separators. - Updated XML doc method-ID construction to use
ToXmlDocTypeNamefor parameter and conversion-operator return types. - Added regression tests and new fixture types covering direct summaries and inherited documentation (
<inheritdoc />and<inheritdoc cref="..."/>) for generic-parameter signatures.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/ApiMark.DotNet/DotNetEmitter.cs |
Introduces ToXmlDocTypeName and applies it to method ID generation for parameters/return types. |
src/ApiMark.DotNet/DotNetGenerator.cs |
Uses ToXmlDocTypeName when building method IDs from MethodReference (notably for inheritdoc/cref scenarios). |
test/ApiMark.DotNet.Tests/DotNetEmitterTests.cs |
Adds unit tests validating Cecil-to-XML-doc type-name normalization. |
test/ApiMark.DotNet.Tests/DotNetGeneratorTests.cs |
Adds end-to-end regression tests ensuring docs resolve for generic-parameter methods (direct and inherited/cref). |
test/ApiMark.DotNet.Fixtures/IGenericParamInterface.cs |
New fixture interface with methods using generic-parameter types. |
test/ApiMark.DotNet.Fixtures/GenericParamImplementation.cs |
New fixture implementation using bare <inheritdoc /> for generic-parameter methods. |
test/ApiMark.DotNet.Fixtures/GenericParameterClass.cs |
New fixture class with generic-parameter method signatures and direct summaries. |
test/ApiMark.DotNet.Fixtures/CrefGenericDocClass.cs |
New fixture class using cref-based inheritdoc for generic-parameter methods (short and fully-qualified forms). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This was referenced Jun 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request improves the handling of generic parameter types in XML documentation ID generation for .NET assemblies, ensuring accurate resolution and rendering of documentation for methods with generic parameters. The main change introduces a utility to correctly convert Mono.Cecil type names to the XML doc format, fixing issues where documentation was not found for such methods. Comprehensive regression and validation tests are also added to ensure correct behavior for both direct and inherited documentation, including cref-based inheritdoc scenarios.
Generic type name normalization and XML doc ID fixes:
ToXmlDocTypeNameutility inDotNetEmitterto convert Mono.Cecil generic type names (e.g., `TypeNameThis pull request improves the handling of generic parameter types in XML documentation ID generation for .NET assemblies, ensuring accurate resolution and rendering of documentation for methods with generic parameters. The main change introduces a utility to correctly convert Mono.Cecil type names to the XML doc format, fixing issues where documentation was not found for such methods. Comprehensive regression and validation tests are also added to ensure correct behavior for both direct and inherited documentation, including cref-based inheritdoc scenarios.Generic type name normalization and XML doc ID fixes:
1
) to the XML doc ID format (e.g.,TypeName{Arg}`), handling nested types and generic arguments. This ensures that generated XML doc IDs match those in the source documentation.DotNetEmitterandDotNetGeneratorwhere parameter and return type names are used in XML doc ID generation to useToXmlDocTypeName, fixing documentation lookup for methods with generic parameters. [1] [2] [3]Testing and validation:
ToXmlDocTypeNameconversion logic, ensuring various generic and nested type cases are handled correctly.DotNetGeneratorTeststo verify that methods with generic parameter types correctly resolve and render their XML documentation, including:<inheritdoc />.Test fixtures for generic parameter scenarios:
GenericParameterClass,IGenericParamInterface,GenericParamImplementation,CrefGenericDocClass) to cover a variety of generic parameter and inheritdoc scenarios in testing. [1] [2] [3] [4]