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
Resource value build test #1346
Conversation
ceeac06
to
4ed9079
Compare
} | ||
else if ((collection = property.Value as ODataCollectionValue) != null) | ||
{ | ||
if (collection.Items != null && collection.Items != null && collection.Items.Any(t => t is ODataResourceValue)) |
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.
collection.Items != null [](start = 56, length = 24)
collection.Items != null [](start = 56, length = 24)
You check this twice -- you really don't want collection.Items to be null! :-) #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.
copied and pasted in the wrong place. Thanks for catching #Resolved
/// JsonNodeType.EndObject - the end object of the resource value object. | ||
/// Post-Condition: almost anything - the node after the resource value (after the EndObject) | ||
/// </remarks> | ||
private ODataResourceValue ReadResourceValue( |
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.
private ODataResourceValue ReadResourceValue [](start = 8, length = 44)
This is the duplicated code that concerns me. What changes to regular resource would need to be made here as well? #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.
I had your concerns, but I think they are two different using scenarios.
Basically, reading a value is very low level process, if we delegate the value reading to high level, in return, the high level will also call the low level process again. So, I am worry about the feasibility.
Of course, I did experiment using the top-level ODataReader
. For example as below:
private ODataResourceValue ReadResourceValue(...)
{
ODataReader reader = this.JsonLightInputContext.CreateUriParameterResourceReader(null,
structuredTypeReference == null ? null : structuredTypeReference.StructuredDefinition());
return ReadResourceValue(reader);
}
private static ODataResourceValue ReadResourceValue(ODataReader reader)
{
while (reader.Read())
{
switch (reader.State)
{
case ODataReaderState.ResourceStart:
....
}
}
}
but, So far, i can't make the above to work.
I think we are on the same page that we should have a method named "ReadResourceValue", the concern is about how to implement this private method.
Maybe we can postpone this detail implementation and focus on the step1 (adding class) and step2 (writing), hope we are on the same page about step1 and step2.
#Resolved
ODataResourceValue resourceValue, | ||
bool isOpenPropertyType) | ||
{ | ||
if (!this.currentPropertyInfo.IsTopLevel) |
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.
would an ODataResourceValue ever be toplevel? #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 don't limit end user to create a property with value as ODataResourceValue.
In my opinion, We should not limit end user to write a top level property with value as "ODataResourceValue". #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.
Now that we prohibit writing a resource value at the top level, can we get rid of this code that checks to see if it's top level?
In reply to: 241587425 [](ancestors = 241587425)
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 removed. #Resolved. #Resolved
public virtual void WriteResourceValue( | ||
ODataResourceValue resourceValue, | ||
IEdmTypeReference metadataTypeReference, | ||
bool isTopLevel, |
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.
is an ODataResource ever top level? #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.
Same. We don't limit end user to create a property with value as ODataResourceValue.
In my opinion, We should not limit end user to write a top level property with value as "ODataResourceValue". #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.
Now that we've prohibited writing resource values at the top level, can we get rid of this code that handles writing a resource value at the top level?
In reply to: 241587501 [](ancestors = 241587501)
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 removed. #Resolved. #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.
In my opinion, We should not limit end user to write a top level property with value as "ODataResourceValue".
Hi @xuzhg, we are heavily depending on creating "ODataResourceValue" at top level, but after upgrading to 7.6.4 we are unable to perform this operation.
Our example URL format will look like below.
URL: root-url/Mailbox('4f89d8bc-4aaa-4aec-a459-5b5a7335b955')/Exchange.GetMailboxStatistics()
Here, the idea is Exchange.GetMailboxStatistics() operational segment should return MailboxStatistics (which is an ODataResourceValue) at top level.
Our main goal is not to change the URL format as lot of customers are rely on mentioned format.
Any suggested work around for this? Please suggest me if I need to create an issue for this.
Thanks,
Venu.
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.
@ve9u Why don't use binding (deserializer) to accept the top level complex? @mikepizzo
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.
@@ -61,6 +61,22 @@ internal static string ConvertToUriEnumLiteral(ODataEnumValue value, ODataVersio | |||
return string.Format(CultureInfo.InvariantCulture, "{0}'{1}'", value.TypeName, value.Value); | |||
} | |||
|
|||
/// <summary> | |||
/// Converts the given string <paramref name="value"/> to an ODataResourceValue and returns it. | |||
/// Tries in both JSON light and Verbose JSON. |
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 remove support for Verbose JSON (and certainly not advertise it in documentation) #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.
#removed. #Resolved
@mikepizzo I added the validation for the top level property. #Resolved |
Code to handle validation looks good, but the methods that we call still seem to have code to handle writing a resource value at the top level; can we now safely remove that code? In reply to: 448054198 [](ancestors = 448054198) |
1. Move all ODataValue related classes into Value subfolder 2. Add ODataResourceValue class derived from ODataValue into Value subfolder 3. Update the PublicApi 4. Verify the property value in ODataResource 5. Add the unit tests related to ODataResourceValue
…ataResourceValue or Collection of ODataResourceValue
1. Write property value as ODataResourceValue 2. Write Instance annotaiton value as ODataResourceValue 3. Write Collection value item as ODataResourceValue 4. Convert ODataResource to Uri literal 5. Add the Unit test cases Be noted, for Parameter value writing, so far for the resource, resourceset and collection, ODL recommends to use corresponding writer to write. so, in the changeset, we don't include the support for the parameter value as ODataResourceValue writing.
1. Read the value as ODataResourceValue 2. Read the instance annotation value as ODataResourceValue 3. Read the collection value item as ODataResourceValue 4. Add reading Unit tests Be noted: 1) for the parameter value reading, ODL recommends to use the corresonding resource, resourceset, collection reader to read the parameter value if the value is not primitive or enum. So, this change doesn't change the parameter reader. 2) for the collection reader, for the collection of resource, ODL recommends to use the ODataResourceSet reader.So, not change for collection reader.
…llection of resource value
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 issue #xxx.
Description
Briefly describe the changes of this pull request.
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.