-
-
Couldn't load subscription status.
- Fork 237
DynamicExpressionParser - Handle indexed properties with any number of indices in expression #950
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
DynamicExpressionParser - Handle indexed properties with any number of indices in expression #950
Conversation
…f indices in expression
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a bug in the DynamicExpressionParser where indexed properties with multiple indices would throw an ArgumentException. The parser was incorrectly assuming that indexers could only have a single parameter, causing failures when trying to access multi-dimensional indexers.
- Replaced hardcoded single-parameter indexer logic with dynamic parameter handling
- Added proper type conversion for each indexer parameter
- Added comprehensive test coverage for both single and multi-dimensional indexers
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/System.Linq.Dynamic.Core/Parser/ExpressionParser.cs | Updated ParseElementAccess method to handle indexers with any number of parameters |
| test/System.Linq.Dynamic.Core.Tests/DynamicExpressionParserTests.cs | Added test class and test methods to verify multi-dimensional indexer functionality |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Issue
Currently, when trying to parse with `DynamicExpressionParser an expression container an indexed property with more than 1 index, it would throw with the following exception (cf. added unit test illustrating the issue)
The fix is rather straightforward, consisting in removing the hardcoded assumption that .NET indexer can't have more than 1 index parameter.