-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Description
Is there an existing issue for this?
- I have searched the existing issuesTo pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
Describe the bug
While trying out the changes to the XML source-generated documentation for Open API introduced with .NET 10 preview 4, I ran into an issue regarding Minimal API handlers defined in another assembly.
The Open API XML operation transformer fails to locate the correct source-generated XML comment. It seems to be due to the source-generator missing the ~ReturnType
of the cache key.
This only happens if the handler is defined in another assembly. Handlers in the same assembly as the Microsoft.AspNetCore.OpenApi
NuGet package works.
Expected Behavior
The OpenAPI to successfully resolve the XML <summary>
regardless of the assembly the handler is defined in.
From debugging, it looks like the XmlCommentSchemaTransformer
and XmlCommentOperationTransformer
(added by the source generator) correctly builds the XML documentation ID with the return type.
Steps To Reproduce
I've reduced the bug to a simple solution: https://github.com/Trivivium/dotnet-xml-comments-bug
Compling the linked solution, and inspecting the source-generated output shows:
// ... more source-gen code above
file static class XmlCommentCache
{
private static Dictionary<string, XmlComment>? _cache;
public static Dictionary<string, XmlComment> Cache => _cache ??= GenerateCacheEntries();
private static Dictionary<string, XmlComment> GenerateCacheEntries()
{
var cache = new Dictionary<string, XmlComment>();
cache.Add(@"M:OtherAssembly.B.Handle", new XmlComment(@"This is B handler", null, null, null, null, false, null, null, null));
cache.Add(@"M:A.Handle~Foo", new XmlComment(@"This is A handler", null, null, null, null, false, null, null, null));
return cache;
}
}
// ... more source-gen code after
Notice, the A.Handle
have its return type, while the B.Handle
in another assembly doesn't.
There are no exceptions at runtime.
There are no warnings at build time (except for the "CS1591 : Missing XML comment for publicly visible type or member", I omitted those to keep the sample concise).
Exceptions (if any)
No response
.NET Version
10.0.100-preview.4.25258.110
Anything else?
.NET SDK:
Version: 10.0.100-preview.4.25258.110
Commit: c22dcd0c7a
Workload version: 10.0.100-manifests.e9b6aa6e
MSBuild version: 17.15.0-preview-25258-110+c22dcd0c7
Runtime Environment:
OS Name: Windows
OS Version: 10.0.26100
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\10.0.100-preview.4.25258.110\
.NET workloads installed:
There are no installed workloads to display.
Configured to use workload sets when installing new manifests.
Workloads are configured to install and update using workload versions, but none were found. Run "dotnet workload restore" to install a workload version.
Host:
Version: 10.0.0-preview.4.25258.110
Architecture: x64
Commit: c22dcd0c7a
.NET SDKs installed:
3.1.201 [C:\Program Files\dotnet\sdk]
6.0.103 [C:\Program Files\dotnet\sdk]
9.0.300 [C:\Program Files\dotnet\sdk]
10.0.100-preview.4.25258.110 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 10.0.0-preview.4.25258.110 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 10.0.0-preview.4.25258.110 [C:\Program
Microsoft.WindowsDesktop.App 8.0.16 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 10.0.0-preview.4.25258.110 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Environment variables:
Not set
global.json file:
Not found
Activity
Trivivium commentedon Jun 22, 2025
Hi @martincostello, do you know if this bug can be addressed within the .NET 10 time-frame? Given the focus on Open API and XML docs in the roadmap for .NET 10, it seems like the perfect time to do this.
I'm looking to migrate a couple of projects to use the XML-based documentation from the source-generator, and those projects have handlers in separate assemblies. The end-goal is to have the documentation embedded in an Open API spec-file generated at build time, and import it into an API management solution. Having the documentation in the spec-file would simplify the process of keeping it up-to-date.
martincostello commentedon Jun 22, 2025
Sorry, I do not.
captainsafia commentedon Jul 30, 2025
This is fixed in .NET 10 Preview 6.