Fix options Validation with objects have indexers#92309
Conversation
|
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.
|
|
/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.