VCST-5427: Register dynamic property validator as singleton#3073
Open
alexeyshibanov wants to merge 1 commit into
Open
VCST-5427: Register dynamic property validator as singleton#3073alexeyshibanov wants to merge 1 commit into
alexeyshibanov wants to merge 1 commit into
Conversation
FluentValidation validators are stateless after construction; transient lifetime rebuilt the rule tree on every resolve. DynamicPropertyTypeValidator is parameterless, so singleton lifetime is safe. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
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.



Summary
FluentValidation
AbstractValidator<T>subclasses are stateless after construction — the rule tree is immutable and per-call state lives in theValidationContext. Registered as transient,DynamicPropertyTypeValidatorrebuilds its rule tree on every DI resolve.Changes
ServiceCollectionExtenions.AddDynamicProperties:AddTransient→AddSingletonforAbstractValidator<DynamicProperty>→DynamicPropertyTypeValidator. The validator has a parameterless constructor (no captive-dependency hazard), and this aligns it with every other registration inAddDynamicProperties, which are already singletons.Tests
Lifetime-only DI registration change — no validator rules, messages, or behavior changed.
Part of the same validator-lifetime effort as VirtoCommerce/vc-module-catalog#897 / VirtoCommerce/vc-module-customer#306.
Ref: VCST-5427.
🤖 Generated with Claude Code
Note
Low Risk
DI lifetime-only change for a stateless, parameterless FluentValidation validator; no validation logic changes.
Overview
Registers
AbstractValidator<DynamicProperty>/DynamicPropertyTypeValidatoras a singleton inAddDynamicPropertiesinstead of transient, so the FluentValidation rule tree is built once per app rather than on every resolve.No validator rules or validation behavior change—only DI lifetime, consistent with the other singleton registrations in the same method.
Reviewed by Cursor Bugbot for commit 2dfbe13. Bugbot is set up for automated code reviews on this repo. Configure here.
Image tag:
3.1044.0-pr-3073-2dfb-vcst-5427-2dfbe13e