You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG][csharp-netcore] Compilation-Error if you have a property named Validate in your schema ("already contains a definition for 'Validate'") #14462
If you have a property named Validate in your schema you end up with two validates (one property "validate" and a method named "Validate" from your side.
So instead of public IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> Validate(ValidationContext validationContext) change it to IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext) (without public and explicit IValidatableObject)
This compiles and should have no side effects as far as I know.
Activity
Cyber1000 commentedon Jan 14, 2023
ok seeing an Interface IValidatableObject, which prevents renaming of Validate
the solution then would be to change it to an explicit interface implementation (https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/interfaces/explicit-interface-implementation):
So instead of
public IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> Validate(ValidationContext validationContext)change it toIEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)(without public and explicit IValidatableObject)This compiles and should have no side effects as far as I know.