Repository navigation
Use fully qualified names, including global::, in OpenAPI XML generator output - #67972
Conversation
Co-authored-by: Youssef1313 <[email protected]>
There was a problem hiding this comment.
@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.
There was a problem hiding this comment.
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.
Co-authored-by: Youssef1313 <[email protected]>
There was a problem hiding this comment.
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.Emitterto pattern-match againstglobal::Microsoft.AspNetCore.Mvc.ModelBinding.IModelNameProvider. - Updated all
OpenApiXmlCommentSupport.generated.verified.cssnapshots 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. |
Co-authored-by: Youssef1313 <[email protected]>
|
What's this change for? 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 @copilot Please update the generator so that all types are fully qualified (including |
Co-authored-by: Youssef1313 <[email protected]>
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 => |
There was a problem hiding this comment.
@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.
global::, in OpenAPI XML generator output
Co-authored-by: Youssef1313 <[email protected]>
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.