-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Description
Description
We are upgrading our solutions from .NET 5 and .NET 6 and it went well until in one solutions a lot of unittests started failing. It seems that when you use TryValidateObject from System.ComponentModel.DataAnnotations it won't go through all the (custom) validation attributes of the same type when there are multiple on a property. While debugging in .NET 5 you go through the IsValid method as many times as you have added the attribute but in .NET 6 it will only call the IsValid and it seems to be of the last attribute.
Reproduction Steps
I have tried to make an as minimal repo as possible:
Running this will pass the test.
Running this will fail the test.
Expected behavior
The expected behavior (unless i missed a breaking change) would be the behavior which we get in .NET 5.
Actual behavior
IsValid isn't called on all the attributes of the same type.
Regression?
Worked in .NET 5
Known Workarounds
No response
Configuration
No response
Other information
No response