Skip to content

Use fully qualified names, including global::, in OpenAPI XML generator output - #67972

Merged
Youssef1313 merged 5 commits into
mainfrom
copilot/update-imodelnameprovider
Aug 19, 2026
Merged

Youssef1313 merged 5 commits into
mainfrom
copilot/update-imodelnameprovider

Conversation

Copilot AI commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

This is safer, and is the recommended and common practice for source generators.

This ensures there is not going to be any type conflicts with user-defined types that happen to clash with any types we reference.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot Remove this as well, here and in the snapshots you already updated.
You don't need to run any tests. Make the change blindly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in 8383c6a. I removed that using Microsoft.AspNetCore.Mvc.ModelBinding; line from XmlCommentGenerator.Emitter.cs and from all corresponding snapshots updated in this PR.

Copilot AI requested a review from Youssef1313 July 23, 2026 08:02
@Youssef1313
Youssef1313 marked this pull request as ready for review July 23, 2026 08:43
@Youssef1313
Youssef1313 requested a review from a team as a code owner July 23, 2026 08:43
Copilot AI review requested due to automatic review settings July 23, 2026 08:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates the OpenAPI XML comment source generator output to use a fully-qualified IModelNameProvider type reference, and aligns all checked-in generator snapshot baselines accordingly. This helps ensure the generated code binds to the intended MVC interface even when unqualified type names could be ambiguous in consumer compilations.

Changes:

  • Updated XmlCommentGenerator.Emitter to pattern-match against global::Microsoft.AspNetCore.Mvc.ModelBinding.IModelNameProvider.
  • Updated all OpenApiXmlCommentSupport.generated.verified.cs snapshots to match the new fully-qualified type name.

Reviewed changes

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

Show a summary per file
File Description
src/OpenApi/gen/XmlCommentGenerator.Emitter.cs Emits the fully-qualified IModelNameProvider reference in GetModelName.
src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/XmlCommentDocumentationIdTests.ShouldNotDuplicateDocumentationIds#OpenApiXmlCommentSupport.generated.verified.cs Snapshot baseline updated to the fully-qualified interface name.
src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/XmlCommentDocumentationIdTests.CanMergeXmlCommentsWithDifferentDocumentationIdFormats#OpenApiXmlCommentSupport.generated.verified.cs Snapshot baseline updated to the fully-qualified interface name.
src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/SchemaTests.XmlCommentsOnPropertiesShouldApplyToSchemaReferences#OpenApiXmlCommentSupport.generated.verified.cs Snapshot baseline updated to the fully-qualified interface name.
src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/SchemaTests.SupportsXmlCommentsOnSchemas#OpenApiXmlCommentSupport.generated.verified.cs Snapshot baseline updated to the fully-qualified interface name.
src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/OperationTests.SupportsXmlCommentsOnShadowedPropertiesFromControllers#OpenApiXmlCommentSupport.generated.verified.cs Snapshot baseline updated to the fully-qualified interface name.
src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/OperationTests.SupportsXmlCommentsOnOperationsFromMinimalApis#OpenApiXmlCommentSupport.generated.verified.cs Snapshot baseline updated to the fully-qualified interface name.
src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/OperationTests.SupportsXmlCommentsOnOperationsFromControllers#OpenApiXmlCommentSupport.generated.verified.cs Snapshot baseline updated to the fully-qualified interface name.
src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/OperationTests.SupportsXmlCommentsOnInheritedPropertiesFromControllers#OpenApiXmlCommentSupport.generated.verified.cs Snapshot baseline updated to the fully-qualified interface name.
src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/OperationTests.SupportsRouteParametersFromControllers#OpenApiXmlCommentSupport.generated.verified.cs Snapshot baseline updated to the fully-qualified interface name.
src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/OperationTests.SupportsParametersWithCustomNamesFromControllers#OpenApiXmlCommentSupport.generated.verified.cs Snapshot baseline updated to the fully-qualified interface name.
src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/OperationTests.ShouldNotApplyFromServicesDocumentationToRequestBody#OpenApiXmlCommentSupport.generated.verified.cs Snapshot baseline updated to the fully-qualified interface name.
src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/OperationTests.ShouldNotApplyCancellationTokenDocumentationToRequestBody#OpenApiXmlCommentSupport.generated.verified.cs Snapshot baseline updated to the fully-qualified interface name.
src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/OperationTests.ShouldApplyFormParameterDocumentationToRequestBody#OpenApiXmlCommentSupport.generated.verified.cs Snapshot baseline updated to the fully-qualified interface name.
src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/OperationTests.DoesNotMisattributeDocumentationWhenMemberNameCollidesWithAnotherBindingName#OpenApiXmlCommentSupport.generated.verified.cs Snapshot baseline updated to the fully-qualified interface name.
src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/CompletenessTests.SupportsAllXmlTagsOnSchemas#OpenApiXmlCommentSupport.generated.verified.cs Snapshot baseline updated to the fully-qualified interface name.
src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/AddOpenApiTests.CanInterceptAddOpenApi#OpenApiXmlCommentSupport.generated.verified.cs Snapshot baseline updated to the fully-qualified interface name.
src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/AdditionalTextsTests.CanHandleXmlForSchemasInAdditionalTexts#OpenApiXmlCommentSupport.generated.verified.cs Snapshot baseline updated to the fully-qualified interface name.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot Replace all BindingSource type usages with global::Microsoft.AspNetCore.Mvc.ModelBinding.BindingSource as well. Update snapshots too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in b3ab738.

Copilot AI requested a review from Youssef1313 July 23, 2026 10:42
@BrennanConroy

Copy link
Copy Markdown
Member

What's this change for? Why not fully qualify all types we reference if we're worried about collisions with customer types?

@Youssef1313

Copy link
Copy Markdown
Member

Why not fully qualify all types we reference if we're worried about collisions with customer types?

Ideally that's what we should do. The usage of IModelNameProvider was introduced only very recently and I did this to defensively avoid a regression.

@copilot Please update the generator so that all types are fully qualified (including global::) and remove all using ...;

Copilot AI commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Why not fully qualify all types we reference if we're worried about collisions with customer types?

Ideally that's what we should do. The usage of IModelNameProvider was introduced only very re...

Addressed in 6491c2e.

public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddOpenApi(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services)
{
return services.AddOpenApi("v1", options =>
return global::Microsoft.AspNetCore.OpenApi.OpenApiServiceCollectionExtensions.AddOpenApi(services, "v1", options =>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot The OpenApiServiceCollectionExtensions is in Microsoft.Extensions.DependencyInjection namespace.

Update this usage and other usages of the same type, and update all snapshots as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 79bfe7b.

@Youssef1313 Youssef1313 changed the title Qualify IModelNameProvider in OpenAPI XML generator output Use fully qualified names, including global::, in OpenAPI XML generator output Jul 24, 2026
@Youssef1313
Youssef1313 merged commit b128b9a into main Aug 19, 2026
24 checks passed
@Youssef1313
Youssef1313 deleted the copilot/update-imodelnameprovider branch August 19, 2026 10:12
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants