-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue when calling Validator.TryValidateObject #24237
Comments
Looks like a bug to me. Any thoughts @divega? |
@ajcvickers Sure, seems like it should be an easy fix too. |
I suspect that an issue in these lines of code: If it's a proper way from your point of view I'll do it. |
@FSou1 Yes, that looks reasonable. It would be great if you could send a PR for this. Please also add a test. |
Great, I'll do it |
Looks like NETFX x86 Release Build — was failed but i'm not pretty sure if my changes were the root cause. Let me know if I have to fix it. |
@FSou1 thanks for you interest to fix the bug. I have sent you Collaborator invite, so that we can assign it to you (GH limitation). Please ping me once you accept (assigning to myself for now). Pro-tip: Disable notifications for the repo (you will be auto-subscribed) as there's plenty (500+ per day) and opt-in into "your mentions / subscriptions" notification setting. |
@karelz ok, i've just accepted the invite. Ok, i got it. |
@karelz Would you mind helping me to determine the proper way to close this issue? As you've already mentioned a label should be assigned and an attribute for test ignoring on NET FX have to be added. I'm afraid i'm stuck with both of them:
|
@FSou1 only members have permissions to change labels - it is tied to commit permissions. @FSou1 let's keep PR discussion in the PR (testResults.xml) |
…25693) * Fix ArgumentNullException in case of IValidatableObject returns null (#25495) * Skip validatable null check tests on NETFX (#25495) * Fix an issue with tests ignore
Hi,
The method TryValidateObject will throw an exception when trying to validate an object. It seems that the GetObjectValidationErrors method does not check if result of alidatable.Validate(validationContext) is not null. Is this a bug or a desired design?
Regards,
Jérôme Piquot
Method : System.ComponentModel.DataAnnotations.GetObjectValidationErrors
===> foreach (var result in results.Where(r => r != ValidationResult.Success))
{
errors.Add(new ValidationError(null, instance, result));
}
}
Call Stack :
System.ArgumentNullException: Value cannot be null.
Parameter name: source
at System.Linq.Enumerable.Where[TSource](IEnumerable
1 source, Func
2 predicate)at System.ComponentModel.DataAnnotations.Validator.GetObjectValidationErrors(Object instance, ValidationContext validationContext, Boolean validateAllProperties, Boolean breakOnFirstError)
at System.ComponentModel.DataAnnotations.Validator.TryValidateObject(Object instance, ValidationContext validationContext, ICollection`1 validationResults, Boolean validateAllProperties)
at Flexmind.Framework.Database.ApplicationDbContext.ValidateObject(IValidatableObject toValidate) in C:\Dev\Tyndareus\Flexmind.Framework\Flexmind.Framework\src\Core\Flexmind.Framework.Database\ApplicationDbContext.cs:line 148
at Flexmind.Framework.Database.ApplicationDbContext.BeforeSave() in C:\Dev\Tyndareus\Flexmind.Framework\Flexmind.Framework\src\Core\Flexmind.Framework.Database\ApplicationDbContext.cs:line 127
at Flexmind.Framework.Database.ApplicationDbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) in C:\Dev\Tyndareus\Flexmind.Framework\Flexmind.Framework\src\Core\Flexmind.Framework.Database\ApplicationDbContext.cs:line 102
at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(CancellationToken cancellationToken)
The text was updated successfully, but these errors were encountered: