Uh oh!
There was an error while loading. Please reload this page.
Fix options Validation with objects have indexers - #92309
Conversation
ghost
commented
Sep 19, 2023
Tagging subscribers to this area: @dotnet/area-extensions-options Issue DetailsIn .NET 8.0, we have introduced support for object validation using the newly introduced attributes ValidateObjectMembersAttribute and ValidateEnumeratedItemsAttribute. However, an issue arises when an object contains an indexer (e.g., in collections) because the validation process attempts to retrieve the property value using reflection, which expects a parameter and results in an exception being thrown. The solution here is to exclude indexers from the validation process, ensuring that only properties are validated.
|
tarekgh
commented
Sep 19, 2023
/backport to release/8.0-rc2 |
Started backporting to release/8.0-rc2: https://github.com/dotnet/runtime/actions/runs/6241680105 |
#92276
In .NET 8.0, we have introduced support for object validation using the newly introduced attributes ValidateObjectMembersAttribute and ValidateEnumeratedItemsAttribute. However, an issue arises when an object contains an indexer (e.g., in collections) because the validation process attempts to retrieve the property value using reflection, which expects a parameter and results in an exception being thrown.
The solution here is to exclude indexers from the validation process, ensuring that only properties are validated.