Skip to content

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Aug 25, 2025

Backport of #63414 to release/10.0

/cc @javiercn @oroztocil

Emit validation info for types that have IValidatableObject interface and no validation attributes

Fixes issue with a supported scenario in the new validation infrastructure used by Minimal APIs and Blazor.

Description

Currently, when you use the new validation features (enabled by the AddValidation call during application startup) and have a type that is validated only with the IValidatbleObject method (i.e. the type has no validation attributes or properties with validation attributes), then the Microsoft.Extensions.Validation source generator does not create the necessary code for that type. This leads to the validation rule being ignored during run-time.

This PR changes the logic in ValidationsGenerator.ExtractValidatableTypes so that such types get their validation code properly emitted.

Fixes #63394

Customer Impact

This bug prevents validations from working in a legitimate scenario which we claim as supported.

Regression?

  • Yes
  • No

This fixes a bug in a new feature released in .NET 10.

Risk

  • High
  • Medium
  • Low

This fixes a bug in a special scenario for a new feature released in .NET 10.

Verification

  • Manual (required)
  • Automated

Manual testing: Verified that a Minimal API app that reproduced the reported problem now works as expected.

Automated tests: Added new test coverage for the impacted scenarios.

Packaging changes reviewed?

  • Yes
  • No
  • N/A

@javiercn javiercn added this to the 10.0-rc2 milestone Aug 25, 2025
@javiercn javiercn added the Servicing-consider Shiproom approval is required for the issue label Aug 25, 2025
@oroztocil oroztocil requested a review from javiercn August 26, 2025 09:19
@github-actions github-actions bot force-pushed the backport/pr-63414-to-release/10.0 branch from 5e6ccc3 to 7a64683 Compare August 26, 2025 09:53
@lewing lewing enabled auto-merge (squash) August 26, 2025 17:17
@lewing lewing added Servicing-approved Shiproom has approved the issue and removed Servicing-consider Shiproom approval is required for the issue labels Aug 26, 2025
@lewing
Copy link
Member

lewing commented Aug 26, 2025

m2 approved

@lewing lewing disabled auto-merge August 26, 2025 19:36
@lewing lewing merged commit 70cded5 into release/10.0 Aug 26, 2025
28 checks passed
@lewing lewing deleted the backport/pr-63414-to-release/10.0 branch August 26, 2025 19:36
@dotnet-policy-service dotnet-policy-service bot modified the milestone: 10.0-rc2 Aug 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Servicing-approved Shiproom has approved the issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants