Repository navigation
Add LaunchPad.Validation: runtime package, attribute rules, function and class validators - #3382
Merged
Merged
Conversation
LaunchPad owns validation (#3374). This is the first two parts (#3375, #3376): the decision and design, the runtime package, and the generator for rules declared with attributes. ZeroAlloc.Validation is still what validates everywhere else. - ADR-0012 and docs/design/validation.md. - src/Validation: the builder a Validate function or an IValidator<T> class declares rules on, IValidate<T> and IValidateAsync<T>, the result types, the message formatter and provider, the built-in rules, their attributes and the rule manifest attributes. - src/Validation.Analyzers: ValidatorGenerator writes a validator, with a rule method per member, for every type whose members carry LaunchPad rule attributes or the DataAnnotations attributes it compiles, and the method that registers an assembly's validators. LPAD3001 and its fixes for nested validation; LPAD3101 to LPAD3106 for what it refuses. - test/Validation.Tests and test/Validation.Analyzers.Tests. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 698 |
| Duplication | 12 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Test Results 33 files + 2 33 suites +2 2h 7m 13s ⏱️ + 21m 52s Results for commit ad721bf. ± Comparison against base commit 53af1e5. This pull request removes 34 and adds 143 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
The third part of LaunchPad's validation (#3377). - A function validator (static void Validate(IValidationBuilder<T> v, ...dependencies), in any partial type) and a class validator (a partial class that implements IValidator<T>) are found by shape. Their bodies are read at build time and never run: each chain becomes part of a rule method written into the type that contains it, and each lambda a local function of that method. - The attributes, functions and classes of one type merge into its one validator, now named {Type}GeneratedValidator. - A rule that waits (MustAsync, or a member validated with the validator of such a type) makes the type's validator an IValidateAsync<T> only. LPAD3002 is an error on IValidate<T> of such a type, with a fix. - A validator that takes services or asks for nested validators is registered scoped. - The generated rule methods name the Validate they were read from, so a private one nobody calls is not removed as unused. - String rules keep the member's own nullability; IMemberRules is covariant in the member's type. - LPAD3107 to LPAD3111 for what the generator can't read in a body. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
CI builds in Release, where the repository's analyzers are errors: no LINQ or string concatenation inside a loop in the generator (ZA0601, ZA0201), a summary the formatter had emptied (RCS1138), and a reference to Microsoft.Extensions.Options the test projects already get from the framework (NU1510). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Codacy's Markdown check reads IValidate<T> in the notes column as an HTML element. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The lint job formats without building the validation generator, so the private Validate that only generated code names looked unused: the bot deleted it, and then what only it used, in three commits. Restore it and suppress IDE0051 on it. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
SummarySummary
CoverageRocket.Surgery.LaunchPad.Analyzers - 93.2%
Rocket.Surgery.LaunchPad.AspNetCore - 79.7%
Rocket.Surgery.LaunchPad.AspNetCore.Mvc - 86.1%
Rocket.Surgery.LaunchPad.EntityFramework - 100%
Rocket.Surgery.LaunchPad.Foundation - 87.5%
Rocket.Surgery.LaunchPad.Foundation.Tasks - 83.9%
Rocket.Surgery.LaunchPad.Grpc - 100%
Rocket.Surgery.LaunchPad.Hosting - 100%
Rocket.Surgery.LaunchPad.HotChocolate - 35.7%
Rocket.Surgery.LaunchPad.NodaTime - 97.4%
Rocket.Surgery.LaunchPad.NodaTime.HotChocolate - 100%
Rocket.Surgery.LaunchPad.NodaTime.StrawberryShake - 100%
Rocket.Surgery.LaunchPad.Primitives - 100%
Rocket.Surgery.LaunchPad.Primitives.Analyzers - 96.4%
Rocket.Surgery.LaunchPad.Spatial - 83%
Rocket.Surgery.LaunchPad.StrawberryShake - 100%
Rocket.Surgery.LaunchPad.StrawberryShake.Spatial - 44.8%
Rocket.Surgery.LaunchPad.Validation - 59.2%
Rocket.Surgery.LaunchPad.Validation.Analyzers - 95.3%
Rocket.Surgery.LaunchPad.ZeroAlloc.AspNetCore - 65.5%
Sample.BlazorServer - 27.6%
Sample.BlazorWasm - 19.2%
Sample.Classic.Restful - 8.5%
Sample.Command - 7.2%
Sample.Core - 86.2%
Sample.Graphql.Executable - 85.8%
Sample.Grpc - 85.1%
Sample.Minimal - 70.7%
Sample.Pages - 13%
Sample.Restful - 71.7%
Sample.Worker - 2.9%
|
This was referenced Dec 4, 2026
david-driscoll
marked this pull request as ready for review
December 4, 2026 06:21
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3382 +/- ##
============================
============================
☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
What
The first three parts of LaunchPad's own validation (#3374): the decision and design, the runtime package (#3375), the generator for rules declared with attributes (#3376), and function and class validators (#3377). ZeroAlloc.Validation is still what validates everywhere else; nothing in the samples or the other packages changes here.
docs/design/validation.md(the spec, with an "As built" section for where the code differs from it).src/Validation(Rocket.Surgery.LaunchPad.Validation), which depends on no other LaunchPad package: the builder aValidatefunction or anIValidator<T>class declares rules on,IValidate<T>andIValidateAsync<T>,ValidationResult/ValidationFailure(path, code, message, severity, placeholder values),IValidationMessageProvider, the built-in rules (Rule), their attributes, and the rule manifest attributes.src/Validation.Analyzers:ValidatorGeneratorwrites{Type}GeneratedValidatorfor every class, struct or record whose members carry LaunchPad rule attributes or theSystem.ComponentModel.DataAnnotationsattributes it compiles, andAdd{AssemblyName}Validators(). A validator of a class is anIValidateOptions<T>too.static void Validate(IValidationBuilder<T> v, ...dependencies)in any partial type, and partial classes that implementIValidator<T>. The body never runs: each chain is written as a rule method into the type that contains it, and each lambda is copied as a local function. A type with aMustAsyncrule is validated asynchronously only.[ValidateNested]nor[SkipValidation]) with both fixes; LPAD3002 (synchronous use of an asynchronous validator) with a fix; LPAD3101 to LPAD3111 for what the generator refuses.Not in this pull request
The rules of base classes and interfaces,
[InheritFrom]and[Mutable](#3378, stacked as #3384), the integrations (#3379), and removing ZeroAlloc.Validation (#3380).Known gaps in what is here: generic types with rules are an error (LPAD3101);
[Phone],[CreditCard],[Base64String],[AllowedValues]and[DeniedValues]are reported and not compiled (LPAD3104); there is no incremental-caching test for the generator yet.Testing
test/Validation.Tests(59 tests): the built-in rules, paths, severity, messages, and the generated validators running as they do in an application, including registration, options validation and function and class validators.test/Validation.Analyzers.Tests(12 tests): snapshots of what the generator writes and reports, and of LPAD3001 and LPAD3002 with their fixes.CI builds the whole solution and is green on this branch.
🤖 Generated with Claude Code