[CLEAN] Synthetic Benchmark PR #64401 - [release/10.0] Fix ModelMetadata null reference exception in emitted XMLComment transformers#91
Open
tomerqodo wants to merge 4 commits intobase_pr_64401_20260121_8909from
Conversation
…ment transformers When a route parameter does not have a bound model it would case a null reference exception because the ModelMetadata on the ParameterDescriptor was null. This is fixed by adding a null reference check Fixes dotnet#63757
As I think this was the encoding before my change
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.
Benchmark PR dotnet#64401
Type: Clean (correct implementation)
Original PR Title: [release/10.0] Fix ModelMetadata null reference exception in emitted XMLComment transformers
Original PR Description: Backport of dotnet#63872 to release/10.0
/cc @captainsafia @desjoerd
OpenAPI: Fix ModelMetadata null reference exception in emitted XMLComment transformers
Description
OpenAPI XML comment support walks
ParameterDescriptionsand previously assumed thatparameterDescription.ModelMetadatawas always non-null. For controller route parameters (including those coming from[Route]on the controller or inherited controllers),ModelMetadatacan benull, which caused aNullReferenceExceptionin the generated XML comment operation transformer while trying to inspectmetadata.MetadataKind.This change:
nullbefore checkingMetadataKindand other members:SupportsRouteParametersFromControllers) that verifies:[Route("[controller]")]and[HttpGet("{userId}")]does not throw during OpenAPI document generation.<summary>on the route parameter is correctly applied to the OpenAPI parameter description in the generated document.Fixes dotnet#64185
Customer Impact
Without this fix, apps that:
[Route]on the controller (common in versioned APIs), andAddOpenApi,will see OpenAPI document generation fail with a
NullReferenceExceptionwhen hitting their OpenAPI endpoint or UI. This prevents customers from using the built-in OpenAPI + XML comments experience in affected controller scenarios and can break development and diagnostics workflows that depend on the generated spec.With this fix:
ModelMetadataisnullfor a parameter.ModelMetadata.Regression?
This is a bug in the new XML documentation–backed OpenAPI support introduced in .NET 10; there wasn’t a previously working version of this feature for this specific scenario.
Risk
The change is limited to:
ModelMetadatain the generated XML comment transformers.If
ModelMetadatais non-null, behavior is unchanged. When it is null (previously a hard crash), the transformer now simply skips property-based XML comment lookup for that parameter, which is a safe and expected fallback. The change is localized to OpenAPI XML comment handling and does not affect other MVC or OpenAPI paths.Verification
Packaging changes reviewed?
Original PR URL: [release/10.0] Fix ModelMetadata null reference exception in emitted XMLComment transformers dotnet/aspnetcore#64401