Skip to content
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

Fixes #1171: ODataResourceSetDeserializer type cast wrong #1175

Merged
merged 1 commit into from
Feb 29, 2024
Merged

Conversation

xuzhg
Copy link
Member

@xuzhg xuzhg commented Feb 26, 2024

Fixes #1171.

  1. Add the 'Definition'
  2. Add a test case.

};

IODataRequestMessage request = ODataMessageWrapperHelper.Create(await content.ReadAsStreamAsync(), headerDict);
ODataMessageReader reader = new ODataMessageReader(request, new ODataMessageReaderSettings(), _model);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: ODataMessageReader implements IDisposable. To go with the philosophy that test code is code and best practices should apply, we should use a using block here.

@@ -60,7 +60,7 @@ public override async Task<object> ReadAsync(ODataMessageReader messageReader, T
throw Error.Argument("edmType", SRResources.ArgumentMustBeOfType, "Collection of complex, entity or untyped");
}

IEdmStructuredType structuredType = edmType.AsCollection().ElementType() as IEdmStructuredType;
IEdmStructuredType structuredType = edmType.AsCollection().ElementType().Definition as IEdmStructuredType;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious, how come this issue is only being caught now? Does it mean this code path is rarely executed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's non-sense to read a top-level resource collection before delta payload in the Web API side.
That mean it's only valid (to call ReadAsync) in ODataResourceSetDeserializer for delta payload in patch request.
Meanwhile, the structuredType is not-necessary to create the ODataReader since null value is acceptable for some time.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not nonsense, since the specs allow to PUT a collection resource, thus overriding it. I'm not sure your library supports that, I was just using mamually the ODataInputFormatter

Copy link
Contributor

@gathogojr gathogojr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a couple of comments, otherwise LGTM

@xuzhg xuzhg merged commit d4aa9a5 into main Feb 29, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ODataResourceSetDeserializer wrong cast
3 participants