Skip to content

Resource value build test - #1346

Merged
xuzhg merged 6 commits into
OData:masterfrom
xuzhg:ResourceValue
Dec 18, 2018
Merged

xuzhg merged 6 commits into
OData:masterfrom
xuzhg:ResourceValue

Conversation

@xuzhg

@xuzhg xuzhg commented Nov 29, 2018

Copy link
Copy Markdown
Contributor

Issues

This pull request fixes issue #xxx.

Description

Briefly describe the changes of this pull request.

Checklist (Uncheck if it is not completed)

  • Test cases added
  • Build and test with one-click build and test script passed

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.

@xuzhg
xuzhg force-pushed the ResourceValue branch 2 times, most recently from ceeac06 to 4ed9079 Compare December 6, 2018 20:18
}
else if ((collection = property.Value as ODataCollectionValue) != null)
{
if (collection.Items != null && collection.Items != null && collection.Items.Any(t => t is ODataResourceValue))

@mikepizzo mikepizzo Dec 13, 2018 •

Copy link
Copy Markdown
Contributor

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

@xuzhg xuzhg Dec 13, 2018 •

Copy link
Copy Markdown
Contributor Author

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)
///
private ODataResourceValue ReadResourceValue(

@mikepizzo mikepizzo Dec 13, 2018 •

Copy link
Copy Markdown
Contributor

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

@xuzhg xuzhg Dec 14, 2018 •

Copy link
Copy Markdown
Contributor Author

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)

@mikepizzo mikepizzo Dec 13, 2018 •

Copy link
Copy Markdown
Contributor

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

@xuzhg xuzhg Dec 13, 2018 •

Copy link
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown
Contributor

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)

@xuzhg xuzhg Dec 18, 2018 •

Copy link
Copy Markdown
Contributor Author

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,

@mikepizzo mikepizzo Dec 13, 2018 •

Copy link
Copy Markdown
Contributor

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

@xuzhg xuzhg Dec 13, 2018 •

Copy link
Copy Markdown
Contributor Author

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

@mikepizzo mikepizzo Dec 18, 2018 •

Copy link
Copy Markdown
Contributor

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)

@xuzhg xuzhg Dec 18, 2018 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@mikepizzo removed. #Resolved. #Resolved

@vgangireddyin vgangireddyin Jul 27, 2020 •

Copy link
Copy Markdown

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.

@xuzhg xuzhg Jul 27, 2020 •

Copy link
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hi @xuzhg, Thanks for your help on this. writing the complex entity same as the writing entity set solves my issue. Later I found this blog post which explains the same thing.


///
/// Converts the given string to an ODataResourceValue and returns it.
/// Tries in both JSON light and Verbose JSON.

@mikepizzo mikepizzo Dec 13, 2018 •

Copy link
Copy Markdown
Contributor

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

@xuzhg xuzhg Dec 13, 2018 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

#removed. #Resolved

@madansr7 madansr7 added this to the 7.6 milestone Dec 17, 2018
@xuzhg xuzhg added the Ready for review Use this label if a pull request is ready to be reviewed label Dec 18, 2018
@xuzhg

xuzhg commented Dec 18, 2018 •

Copy link
Copy Markdown
Contributor Author

@mikepizzo I added the validation for the top level property. #Resolved

@mikepizzo

Copy link
Copy Markdown
Contributor

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.

@mikepizzo mikepizzo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

:shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for review Use this label if a pull request is ready to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants