Skip to content

Conversation

@tarekgh
Copy link
Member

@tarekgh tarekgh commented Sep 19, 2023

#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.

@ghost ghost assigned tarekgh Sep 19, 2023
@ghost
Copy link

ghost commented Sep 19, 2023

Tagging subscribers to this area: @dotnet/area-extensions-options
See info in area-owners.md if you want to be subscribed.

Issue Details

#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.

Author: tarekgh
Assignees: tarekgh
Labels:

area-Extensions-Options

Milestone: -

@tarekgh
Copy link
Member Author

tarekgh commented Sep 19, 2023

/backport to release/8.0-rc2

@github-actions
Copy link
Contributor

Started backporting to release/8.0-rc2: https://github.com/dotnet/runtime/actions/runs/6241680105

@tarekgh tarekgh added this to the 8.0.0 milestone Sep 19, 2023
@ericstj ericstj merged commit 5883b72 into dotnet:main Sep 20, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Oct 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants