-
Notifications
You must be signed in to change notification settings - Fork 352
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
Fix the issue when read nested resource untyped in the request #2179
Conversation
@@ -9,6 +9,7 @@ | |||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> | |||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> | |||
<RestorePackages>true</RestorePackages> | |||
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute> |
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.
can ignore this change. It seems I have to add this configuration at my side to make the VS happen.
|
||
using (var msgReader = readRequest ? | ||
new ODataMessageReader((IODataResponseMessage)message, readerSettings, this.serverModel) : | ||
new ODataMessageReader((IODataResponseMessage)message, readerSettings, this.serverModel)) |
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.
What's the difference between the consequent and the alternative expressions here? #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.
+1 -- should line 90 cast message to IODataRequestMessage?
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.
Yes. Thanks.
? ReadExpandedResourceSetNestedResourceInfo(resourceState, null, payloadTypeReference.ToStructuredType(), propertyName, /*isDeltaResourceSet*/ false) | ||
: ReadEntityReferenceLinksForCollectionNavigationLinkInRequest(resourceState, null, propertyName, /*isExpanded*/ true); | ||
readerNestedResourceInfo = | ||
ReadExpandedResourceSetNestedResourceInfo(resourceState, null, payloadTypeReference.ToStructuredType(), propertyName, /*isDeltaResourceSet*/ false); |
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.
For my own understanding, how does removing the alternative expression fix the issue? #Pending
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.
@xuzhg, please correct my understanding if wrong, but just to make sure that I understand the change --
The old code assumed that only links would ever be sent in a request payload, so it didn't support reading nested content.
In fact, it should be valid to have nested content in a request payload as well as a response payload, so removing the special case code for request payload handles nested content (whether links or actual content) for both cases.
Right?
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.
Yes.
For "normal" (aka declared) property, the process never goes into this method.
For "undeclared" property, since it's undeclared, we don't know the type. Since, we don't know the type, why shall we treat it as entity/entity reference if it's a request payload.
So, I think in the "undeclared" property reading, we should read it as nested resource info no matter it's request or response.
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.
Please see minor comments. Assuming the behavior doesn't change for reading nested links in a request payload, I'm fine with the change.
|
||
using (var msgReader = readRequest ? | ||
new ODataMessageReader((IODataResponseMessage)message, readerSettings, this.serverModel) : | ||
new ODataMessageReader((IODataResponseMessage)message, readerSettings, this.serverModel)) |
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.
+1 -- should line 90 cast message to IODataRequestMessage?
} | ||
else | ||
{ | ||
readerNestedResourceInfo = this.ReadingResponse | ||
? ReadExpandedResourceNestedResourceInfo(resourceState, null, propertyName, payloadTypeReference.ToStructuredType(), this.MessageReaderSettings) |
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.
Are "ReadExpandedResourceNestedResourceInfo"
and "ReadEntityReferenceLinksForCollectionNavigationLinkInRequest" still used, or can those methods be deleted? #Closed
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.
@mikepizzo I think ReadExpandedResourceNestedResourceInfo
is still being used
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.
The change is only in 'InnerReadUndeclaredProperty', We are in the method because It's "Undeclared" property.
For normal property, 'ReadEntityReferenceLinksForCollectionNavigationLinkInRequest' and other methods are still in use.
@@ -425,15 +425,12 @@ protected ODataJsonLightReaderNestedResourceInfo InnerReadUndeclaredProperty(IOD | |||
ValidateExpandedNestedResourceInfoPropertyValue(this.JsonReader, isCollection, propertyName, payloadTypeReference); | |||
if (isCollection) | |||
{ | |||
readerNestedResourceInfo = this.ReadingResponse | |||
? ReadExpandedResourceSetNestedResourceInfo(resourceState, null, payloadTypeReference.ToStructuredType(), propertyName, /*isDeltaResourceSet*/ false) |
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.
I assume that ReadExpandedResourceSetNestedResourceInfo (and ReadExpandedResourceNestedResourceInfo) handle the case of the payload just containing links, and that the developer experience behaves the same for this case?
? ReadExpandedResourceSetNestedResourceInfo(resourceState, null, payloadTypeReference.ToStructuredType(), propertyName, /*isDeltaResourceSet*/ false) | ||
: ReadEntityReferenceLinksForCollectionNavigationLinkInRequest(resourceState, null, propertyName, /*isExpanded*/ true); | ||
readerNestedResourceInfo = | ||
ReadExpandedResourceSetNestedResourceInfo(resourceState, null, payloadTypeReference.ToStructuredType(), propertyName, /*isDeltaResourceSet*/ false); |
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.
@xuzhg, please correct my understanding if wrong, but just to make sure that I understand the change --
The old code assumed that only links would ever be sent in a request payload, so it didn't support reading nested content.
In fact, it should be valid to have nested content in a request payload as well as a response payload, so removing the special case code for request payload handles nested content (whether links or actual content) for both cases.
Right?
No, it doesn't change. The change is only for the Undeclared. In reply to: 748268333 |
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) |
@mikepizzo @gathogojr are the comments ok for you? Shall I go to merge it? BingAds is waiting the hot release. |
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.
Issues
*This pull request fixes #2165
Description
Checklist (Uncheck if it is not completed)
Additional work necessary
If documentation update is needed, please add "Docs Needed" label to the issue and provide details about the required document change in the issue.