Fix stack overflow when EnableLowerCamelCase is used (fixes #233)#234
Merged
BlaiseD merged 2 commits intoAutoMapper:masterfrom Jan 20, 2025
Merged
Conversation
9f33d04 to
6686a5c
Compare
Contributor
Author
|
Two things I wasn't sure about:
|
added 2 commits
January 19, 2025 21:14
DefaultExpansionsBuilder expands complex properties only, to prevent expanding navigation properties endlessly. But under EnableLowerCamelCase, it was failing to recognize navigation properties as such, due to a casing issue: GetNavigationProperties returned names as used in the EDM model (lowercase), and used it to filter a list of C# property names (uppercase). This fix works by looking up each navigation property's corresponding C# name. Another approach would be to use case-insensitive comparison, but this would not handle the scenario where EDM property names are customized.
In ExpressionBuilder tests, set the ODataQueryOptionParser to case-insensitive, since using EnableLowerCamelCase makes all of the model properties case-insensitive.
6686a5c to
892c8ef
Compare
Contributor
Author
|
@dotnet-policy-service agree |
Member
|
Member
|
Thanks |
Contributor
Author
|
Thanks. One thing I forgot about: can you check the web tests? I'm not sure how to run those; they abort immediately when I attempt to launch them. |
Member
|
To run the web tests.
|
Contributor
Author
|
All 69 tests in Web.Tests passed for master with my changes included. To get the tests to run, I did the following:
I tested using SQL Server 2022 CU17 (Linux, hosted in Docker). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes bug #233, which affects apps that use EnableLowerCamelCase. This regression was introduced in #229, due to the public EDM model using lowercase property names whereas the C# classes use capitalized names.
This fix works by looking up each navigation property's corresponding C# property name. This might not work if the EDM model was built by hand, meaning it omits annotations. If any app still has the stack overflow, we could try changing the ToHashSet calls to use
StringComparer.OrdinalIgnoreCaseas a fallback.This pull request also changes all of the tests to use
EnableLowerCamelCase, though ideally we'd test both with and without this mode.