Skip to content

Reorder child resource output #596

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

Merged
merged 1 commit into from
Jul 14, 2015

Conversation

DeepakRajendranMsft
Copy link
Contributor

Reordering Child resource output.

This is a just "good to have" in the current cycle, so doesnt need to be merged if it is going to delay the msi release.

@azurecla
Copy link

Hi @DeepakRajendranMsft, I'm your friendly neighborhood Azure Pull Request Bot (You can call me AZPRBOT). Thanks for your contribution!
You've already signed the contribution license agreement. Thanks!
We will now validate the agreement and then real humans will evaluate your PR.

TTYL, AZPRBOT;

@@ -21,10 +21,13 @@ namespace Microsoft.Azure.Commands.Network.Models

public class PSBackendAddressPool : PSChildResource
{
[JsonProperty(Order = 1)]
Copy link
Member

Choose a reason for hiding this comment

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

How does making every property Order=1 change the behavior? Do you have a test for the new serialization?

@DeepakRajendranMsft
Copy link
Contributor Author

@markcowl
Since PSBackendaddresspool, inherits from PSChildResource, the properties from PSBackendAddressPool gets printed first followed by PSChildResource (contains name, id, etag), like
BackendAddressPools : [
{
"BackendIpConfigurations": [],
"LoadBalancingRules": [],
"ProvisioningState": "Succeeded",
"Name": "bepool1",
"Etag": "W/"971e92ac-7882-4539-8950-18df75644e63"",
"Id": "/subscriptions/9532a63e-f2eb-4649-bb23-5ed01077ce80/resourceGroups/ptest/provider
s/Microsoft.Network/loadBalancers/lbname1/backendAddressPools/bepool1"
}
]

However, we want the output to be

BackendAddressPools : [
{
"Name": "bepool1",
"Etag": "W/"971e92ac-7882-4539-8950-18df75644e63"",
"Id": "/subscriptions/9532a63e-f2eb-4649-bb23-5ed01077ce80/resourceGroups/ptest/provider
s/Microsoft.Network/loadBalancers/lbname1/backendAddressPools/bepool1"

                           "BackendIpConfigurations": [],
                           "LoadBalancingRules": [],
                           "ProvisioningState": "Succeeded",
                         }  
                       ]

By default, the order of a property is 0 and when you serialize an object in json, it serializes in the ascending order. So, we are now changing the Jsonproperties of the derived classes to be 1, so that the base class properties get printed first. (see http://www.newtonsoft.com/json/help/html/JsonPropertyOrder.htm)

Regarding test, since this is only a formatting change and not a change to the output object, i am not sure what kind of test i can write. (i can write to a stream and read from it, but that seems to be overkill since we are not changing the property value but only the order)

@DeepakRajendranMsft
Copy link
Contributor Author

I just realized that the better way to fix this is in PSchildResource rather than the individual derived classes. Will update the PR shortly.

@markcowl
Copy link
Member

It seems like writing the object to and reading from a memory stream would be the best way to test this. I won't hold up the PR on this, though, please just add this test the next time you are updatign tests oc cmdlets.

@DeepakRajendranMsft
Copy link
Contributor Author

@markcowl Thanks, will add a test to verify the serialization later.

Also, this PR is good as it is. Changing on the base class doesnt work. So we are good to merge now.

Regarding reading and verifying from stream, we should have a bigger conversation with xrp folks since we dont have any tests which verify the formal.xml files either.

@markcowl
Copy link
Member

@DeepakRajendranMsft This is just protection from regression - you'll need to make sure to do this with each derived class from this point forward.

markcowl added a commit that referenced this pull request Jul 14, 2015
@markcowl markcowl merged commit 01d0588 into Azure:dev Jul 14, 2015
@DeepakRajendranMsft DeepakRajendranMsft deleted the ReorderChildOutput branch August 13, 2015 00:09
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.

4 participants