Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

OpenAPI: Fix duplicate xml documentation ids for Generic properties and references#64404

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
desjoerd wants to merge1 commit intodotnet:main
base:main
Choose a base branch
Loading
fromdesjoerd:fix/gh-64378

Conversation

@desjoerd
Copy link
Contributor

OpenAPI: Fix duplicate xml documentation ids for Generic properties and references

Fixes two instances where xml comment documentation ids where duplicated.
First one was for constructed generic type properties.Foo<int>.
Second one was for Xml comment files exposing internal classes with the same namespace.

Fixes#64378

CopilotAI review requested due to automatic review settingsNovember 17, 2025 21:27
@github-actionsgithub-actionsbot added the needs-area-labelUsed by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically labelNov 17, 2025
Copilot finished reviewing on behalf ofdesjoerdNovember 17, 2025 21:29
returncomments;
}

internalstaticIEnumerable<(string,XmlComment?)>ParseCommentsReference(
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

If someone has a better idea for this, let me know. The main difference compared toParseCommentsApplicationAssembly is that it only allows "accessible" types

@dotnet-policy-servicedotnet-policy-servicebot added the community-contributionIndicates that the PR has been added by a community member labelNov 17, 2025
@dotnet-policy-service
Copy link
Contributor

Thanks for your PR, @@desjoerd. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

Copy link
Contributor

CopilotAI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Pull Request Overview

This PR fixes duplicate XML documentation IDs in OpenAPI source generation by addressing two specific issues:

  1. Generic type properties with different type arguments (e.g.,GenericFoo<string> vsGenericFoo<int>) were generating duplicate documentation IDs
  2. Internal classes with the same namespace in different referenced assemblies were causing duplicate documentation IDs

Key Changes

  • Separated comment parsing logic into application assembly vs reference assembly methods
  • ModifiedAssemblyTypeSymbolsVisitor to use unbound generic types for documentation ID generation
  • Added new test case to verify that duplicate documentation IDs are not generated

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
FileDescription
XmlCommentDocumentationIdTests.csAdded comprehensive test case verifying that generic properties and duplicate internal classes don't cause duplicate documentation IDs
OpenApiXmlCommentSupport.generated.verified.csGenerated snapshot file showing expected output with properly deduplicated documentation IDs
XmlCommentGenerator.csRenamedParseComments to separate methods for application and reference assemblies
XmlCommentGenerator.Parser.csSplit comment parsing into two methods with different filtering logic for application vs reference assemblies
AssemblyTypeSymbolsVisitor.csAdded logic to convert constructed generic types to unbound generic types for consistent documentation ID generation

Comment on lines +148 to +149
// Only include symbols that are accessible from the application assembly.
symbol.IsAccessibleType()&&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@desjoerd this seems okay, but should this PR also revisit the use ofsymbol.IsAccessible() up onL124?

Specifically, it seems like this source generator should default toexcluding types marked withEmbeddedAttribute, since those are accessible from the application assembly, but seem to be of dubious worth w.r.t. embedding constants into the assembly for (what I assume are largely going to be) marker attributes for source generators, dev dependencies, etc.

(e.g. thinking about this from the aot perspective where I don't want paragraphs and paragraphs xml docs from internal/dev-time-only marker attributes getting baked into the executable)

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

For the application assembly types with [Embedded] are accessible and could even be used within your Api I think.

For referenced assemblies they will be already excluded as it will only emit xml comments for types marked aspublic.
https://github.com/dotnet/aspnetcore/blob/main/src%2FOpenApi%2Fgen%2FHelpers%2FISymbolExtensions.cs#L193

varparsedCommentsFromXmlFile=commentsFromXmlFile
.Combine(context.CompilationProvider)
.Select(ParseComments);
.Select(ParseCommentsReference);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Hmmm...is this change related to the fix for generic types?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This one is to fix the comments coming from a documentation file when a type also exists in the main compilation.

When an internal type with the same namespace and class name exists in the Application assembly.

In the unit tests it's theSample.Duplicate which is internal in the Application assembly. When it processes it from a different assembly it would resolve toSample.Duplicate.

I duplicated theParseComments intoParseCommentsReference andParseCommentsApplicationAssembly to have a different condition.ParseCommentsReference only includespublic types.ParseCommentsApplicationAssembly includespublic types and types available in the compilation.

@gfoidlgfoidl added feature-openapi area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etc and removed needs-area-labelUsed by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically labelsNov 19, 2025
@dotnet-policy-service
Copy link
Contributor

Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime.
To make sure no conflicting changes have occurred, please rerun validation before merging. You can do this by leaving an/azp run comment here (requires commit rights), or by simply closing and reopening.

@dotnet-policy-servicedotnet-policy-servicebot added the pending-ci-rerunWhen assigned to a PR indicates that the CI checks should be rerun labelNov 26, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@captainsafiacaptainsafiacaptainsafia left review comments

Copilot code reviewCopilotCopilot left review comments

+1 more reviewer

@austindrenskiaustindrenskiaustindrenski left review comments

Reviewers whose approvals may not affect merge requirements

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etccommunity-contributionIndicates that the PR has been added by a community memberfeature-openapipending-ci-rerunWhen assigned to a PR indicates that the CI checks should be rerun

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

OpenApi XML comment cache gneration fails with System.ArgumentException: An item with the same key has already been added

4 participants

@desjoerd@captainsafia@austindrenski@gfoidl

[8]ページ先頭

©2009-2025 Movatter.jp