Skip to content

VCST-5427: Register dynamic property validator as singleton#3073

Open
alexeyshibanov wants to merge 1 commit into
devfrom
perf/VCST-5427
Open

VCST-5427: Register dynamic property validator as singleton#3073
alexeyshibanov wants to merge 1 commit into
devfrom
perf/VCST-5427

Conversation

@alexeyshibanov

@alexeyshibanov alexeyshibanov commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

FluentValidation AbstractValidator<T> subclasses are stateless after construction — the rule tree is immutable and per-call state lives in the ValidationContext. Registered as transient, DynamicPropertyTypeValidator rebuilds its rule tree on every DI resolve.

Changes

ServiceCollectionExtenions.AddDynamicProperties: AddTransientAddSingleton for AbstractValidator<DynamicProperty>DynamicPropertyTypeValidator. The validator has a parameterless constructor (no captive-dependency hazard), and this aligns it with every other registration in AddDynamicProperties, 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> / DynamicPropertyTypeValidator as a singleton in AddDynamicProperties instead 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

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>
@sonarqubecloud

sonarqubecloud Bot commented Jul 9, 2026

Copy link
Copy Markdown

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.

1 participant