-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Closed
Labels
area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-validationIssues related to model validation in minimal and controller-based APIsIssues related to model validation in minimal and controller-based APIs
Description
When a record class being inspected comes from metadata (i.e., a referenced assembly or a prior incremental step), its compiler-synthesised EqualityContract
property is not flagged with IsImplicitlyDeclared == true
. The current filter in ExtractValidatableMembers
relies solely on that flag, so the property slips through and a GeneratedValidatablePropertyInfo
is produced for it:
// Skip compiler-generated properties…
if (member.IsImplicitlyDeclared || resolvedRecordProperty.Contains(member, SymbolEqualityComparer.Default))
{
continue;
}
As a result of this, every metadata-based record type ends up with a spurious ValidatablePropertyInfo
for EqualityContract
which the runtime resolver will attempt to apply and fail for.
We need dd a helper that recognizes EqualityContract
by its signature, not by IsImplicitlyDeclared
, and use it in the skip logic.
private static bool IsEqualityContract(IPropertySymbol prop) =>
prop.Name == “EqualityContract”
&& prop.Type.SpecialType == SpecialType.System_Type
&& prop.DeclaredAccessibility == Accessibility.Protected;
Update the member loop:
foreach (var member in typeSymbol.GetMembers().OfType())
{
if (member.IsImplicitlyDeclared
|| IsEqualityContract(member)
|| resolvedRecordProperty.Contains(member, SymbolEqualityComparer.Default))
{
continue;
}
}
Copilot
Metadata
Metadata
Assignees
Labels
area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-validationIssues related to model validation in minimal and controller-based APIsIssues related to model validation in minimal and controller-based APIs