-
Notifications
You must be signed in to change notification settings - Fork 160
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
Conversation
}; | ||
|
||
IODataRequestMessage request = ODataMessageWrapperHelper.Create(await content.ReadAsStreamAsync(), headerDict); | ||
ODataMessageReader reader = new ODataMessageReader(request, new ODataMessageReaderSettings(), _model); |
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.
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; |
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.
Curious, how come this issue is only being caught now? Does it mean this code path is rarely executed?
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.
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.
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.
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
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.
Left a couple of comments, otherwise LGTM
Fixes #1171.