Skip to content

[release/10.0] Fix ModelMetadata null reference exception in emitted XMLComment transformers#8

Open
tomerqodo wants to merge 5 commits into
coderabbit_full_base_release_100_fix_modelmetadata_null_reference_exception_in_emitted_xmlcomment_transformers_pr8from
coderabbit_full_head_release_100_fix_modelmetadata_null_reference_exception_in_emitted_xmlcomment_transformers_pr8
Open

[release/10.0] Fix ModelMetadata null reference exception in emitted XMLComment transformers#8
tomerqodo wants to merge 5 commits into
coderabbit_full_base_release_100_fix_modelmetadata_null_reference_exception_in_emitted_xmlcomment_transformers_pr8from
coderabbit_full_head_release_100_fix_modelmetadata_null_reference_exception_in_emitted_xmlcomment_transformers_pr8

Conversation

@tomerqodo

@tomerqodo tomerqodo commented Jan 29, 2026

Copy link
Copy Markdown

Benchmark PR from agentic-review-benchmarks#8

Summary by CodeRabbit

  • Tests

    • Added test coverage for route parameter binding in OpenAPI documentation generation.
  • Bug Fixes

    • Improved null-safety guards in OpenAPI metadata handling to prevent potential null reference exceptions.

✏️ Tip: You can customize this high-level summary in your review settings.

desjoerd and others added 5 commits January 25, 2026 11:59
…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
@coderabbitai

coderabbitai Bot commented Jan 29, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

A new test case is added to verify route parameter binding from controller actions into OpenAPI documentation. Multiple snapshot test files are updated with null-checks to prevent NullReferenceException when accessing parameter metadata properties during OpenAPI XML comment processing.

Changes

Cohort / File(s) Summary
New Test Case
src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/OperationTests.Controllers.cs
Adds SupportsRouteParametersFromControllers() test method to verify that route parameters from controller actions are correctly exposed in generated OpenAPI documentation with proper parameter descriptions.
Null-Check Guards in Snapshots
src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/AddOpenApiTests.CanInterceptAddOpenApi#OpenApiXmlCommentSupport.generated.verified.cs, AdditionalTextsTests.CanHandleXmlForSchemasInAdditionalTexts#OpenApiXmlCommentSupport.generated.verified.cs, CompletenessTests.SupportsAllXmlTagsOnSchemas#OpenApiXmlCommentSupport.generated.verified.cs, OperationTests.SupportsXmlCommentsOnOperationsFromControllers#OpenApiXmlCommentSupport.generated.verified.cs, OperationTests.SupportsXmlCommentsOnOperationsFromMinimalApis#OpenApiXmlCommentSupport.generated.verified.cs, SchemaTests.SupportsXmlCommentsOnSchemas#OpenApiXmlCommentSupport.generated.verified.cs, SchemaTests.XmlCommentsOnPropertiesShouldApplyToSchemaReferences#OpenApiXmlCommentSupport.generated.verified.cs, XmlCommentDocumentationIdTests.CanMergeXmlCommentsWithDifferentDocumentationIdFormats#OpenApiXmlCommentSupport.generated.verified.cs
Applies null-checks for metadata before accessing MetadataKind and related properties in parameter description processing, preventing potential NullReferenceException during OpenAPI XML comment transformation.
Large Generated Snapshot
src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/OperationTests.SupportsRouteParametersFromControllers#OpenApiXmlCommentSupport.generated.verified.cs
Introduces comprehensive generated OpenAPI XML comment support module with data structures (XmlComment, XmlParameterComment, XmlResponseComment), caching logic, documentation ID helpers, operation and schema transformers, and service registration for XML doc comment propagation into OpenAPI metadata.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A hop, skip, and null-check away,
Route parameters now have their say,
XML comments dance in the light,
OpenAPI metadata shines so bright!
Safety guards keep crashes at bay. ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 26.09% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing a null reference exception in XMLComment transformers by adding null checks for ModelMetadata.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

2 participants