-
Notifications
You must be signed in to change notification settings - Fork 351
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
updated odata.context computation to remove trailing cast segments th… #2681
Conversation
…at are following by key segments as well as the case where the standard key syntax is used within a cast segment
@KenitoInc @habbes @xuzhg @ElizabethOkerio @gathogojr @chrisspre @mikepizzo I'd really love to get a review on this |
@KenitoInc @habbes @xuzhg @ElizabethOkerio @gathogojr @chrisspre @mikepizzo ping...this is going to start blocking an AGS workload soon |
src/Microsoft.Spatial/System/Collections/Generic/ReadOnlyCollectionExtensions.cs
Outdated
Show resolved
Hide resolved
test/FunctionalTests/Microsoft.OData.Core.Tests/JsonLight/ODataJsonLightWriterTests.cs
Show resolved
Hide resolved
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.
We should have unit tests for the new public extension method.
Otherwise the PR looks good to merge
This PR has Quantification details
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a
What can I do to optimize my changes
How to interpret the change counts in git diff output
Was this comment helpful? 👍 :ok_hand: :thumbsdown: (Email) |
Thanks @KenitoInc. I've added the unit test, but there are a number of other changes too if you can take another look. |
@KenitoInc @habbes @xuzhg @ElizabethOkerio @gathogojr @chrisspre @mikepizzo can you please take a look when you get a chance? |
…at are following by key segments as well as the case where the standard key syntax is used within a cast segment
Issues
This pull request fixes #2680.
Description
When the request URL ends in a cast segment followed by a key segment, we throw an exception because the
@odata.context
should not end in such segments, but we do not trim them out of the request URL when generating the@odata.context
.To fix this, the
ODataContextUrlInfo
has been updated to call a new trim extension method forODataPath
which trims all cast and key segments from the ends of the path, regardless of the order of the segments. Since there were two methods which both had this logic that needed to be updated, those two methods were refactored to have a single method that contains the relevant logic that both methods call into (reducing duplicate code).Checklist (Uncheck if it is not completed)
Additional work necessary
We likely shouldn't throw an exception in this case, but instead return a "bad"
@odata.context
. We should keep the check as aDebug.Assert
probably, but not throw in release configurations.The new trim method does not leverage the
WalkWith
methods onODataPath
.WalkWith
always starts at the beginning, and always requires enumerating the entire path, even when not necessary. We should update and consolidate other trim variants onODataPath
to remove the use of these handlers wherever feasible.We could also optimize the use of the
Take
LINQ query by havingODataPath
take in anIReadOnlyList
, and then having a "slice" extension on it to allow theODataPath
to not need to always enumerate all of the segments passed into the constructor.