[API Proposal]: Provide trim-safe overload for ValidationContext
construction
#113134
Labels
api-ready-for-review
API is ready for review, it is NOT ready for implementation
area-System.ComponentModel.DataAnnotations
Milestone
Background and motivation
The only trim-unsafe codepaths in the
ValidationContext
currently are invoked when no explicitDisplay
is set on aValidationContext
. In this case, theValidationContext
will use unbounded reflection to discover theDisplay
attribute on a type to support resolving it.This presents a challenge to components that always initialize the
DisplayName
property as they always have to mark the construction of theValidationContext
as trim-safe even when it is not.API Proposal
API Usage
Alternative Designs
The proposed API only adds the
displayName
parameter to the most-specific constructor on theValidationContext
type. We can consider adding constructors with the other permutations of this type.Risks
No response
The text was updated successfully, but these errors were encountered: