Skip to content

[feature/10.0] Use validation source generator #8165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: feature/10.0
Choose a base branch
from

Conversation

sbomer
Copy link
Member

@sbomer sbomer commented Apr 30, 2025

This uses the new model for source generated validation from dotnet/aspnetcore#46349.

For now this checks in the generated code, with some tweaks to work around the following issues:

and the generator is disabled.

Once those issues are fixed, we can:

  • remove checked-in ValidatableInfoResolver.cs
  • turn the generator back on
  • remove a couple of the types from ValidatableTypes.cs (see comments)

This uses the new model for source generated validation from
dotnet/aspnetcore#46349.
@sbomer sbomer requested a review from jander-msft April 30, 2025 00:05
@sbomer sbomer requested a review from a team as a code owner April 30, 2025 00:05
context.ValidationContext.MemberName = originalMemberName;
if (hasErrors)
{
return;
Copy link
Member Author

Choose a reason for hiding this comment

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

The custom implementation of ValidateAsync for CollectionRuleOptions exists to preserve the short-circuiting behavior here for incorrect use of templates:

Without this short-circuiting, we'd get extra errors about a missing Type field in addition to the bad template reference, which is undesirable because the Type field should not be set directly if using a template.

@sbomer sbomer changed the title Use validation source generator [feature/10.0] Use validation source generator Apr 30, 2025
sbomer added 6 commits April 30, 2025 23:16
- Re-run latest version of generators
- Add comments to help point out places
  where manual changes were made to the
  generated code
Something was wrong with the previous update
(maybe a caching issue). This uses the latest version
of the generator.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant