Skip to content

ValidatableTypeAttribute Fails to Generate Validation Metadata Across Assemblies #63626

@pwelter34

Description

@pwelter34

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When applying the [ValidatableType] attribute to a class located in a different assembly than the one invoking builder.Services.AddValidation(), the validation metadata for that class is not generated into the GeneratedValidatableInfoResolver.

Expected Behavior

All types annotated with [ValidatableType], regardless of the assembly they reside in, should be included in the generated GeneratedValidatableInfoResolver.

Steps To Reproduce

  1. Create a class in Assembly A and annotate it with [ValidatableType].
  2. In Assembly B, call builder.Services.AddValidation().
  3. Observe that the class from Assembly A is not included in the generated resolver.

Exceptions (if any)

No response

.NET Version

10.0.100-rc.1.25451.107

Anything else?

Proposed Solutions

Primary Solution:

Enhance the source generator to scan all referenced assemblies for [ValidatableType] attributes and include them in the generated GeneratedValidatableInfoResolver.

Alternative Solution:

Generate a separate ValidatableInfoResolver per assembly. These resolvers could then be manually registered with ValidationOptions to compose a complete validation metadata set.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-validationIssues related to model validation in minimal and controller-based APIs

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions