Skip to content
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

Protocol tests issue 30 #3266

Closed
wants to merge 3 commits into from
Closed

Conversation

peterrsongg
Copy link
Contributor

@peterrsongg peterrsongg commented Apr 5, 2024

Description

This PR fixes DOTNET-7357 issue 30. Issue 30 (Related to issue 29) Incorrectly unmarshalling responses which used xmlName on the request

A little more context: This specifically fixes the case where xml name is used on a key or value of a map. This makes it so that we don't search for a hardcoded "key" or "value" and instead pass that down from the model.

  • (Review manual changes) commit 86f10b3 - Fixes for issue 30.
  • (Reference generated changes) commit 675e504 - Generated changes for issue 30.

MERGE into protocol-tests feature branch only

Builds on prior PR: #3265
Merge order: 111 (I'm going to start mine from 100 and increment to keep separate from Bo's)
Ticket: DOTNET-7357

Motivation and Context

Testing

N/A - the test cases are the protocol tests. A final dry-run will be done on the protocol-tests feature branch once everything is merged into the feature branch.

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have read the README document
  • I have added tests to cover my changes
  • All new and existing tests passed

License

  • I confirm that this pull request can be released under the Apache 2 license

@peterrsongg peterrsongg requested a review from boblodgett April 5, 2024 01:11
This was referenced Apr 5, 2024
/// For map shapes the KeyXmlName represents the "locationName" on the map shape's key member. This can be changed
/// via the @xmlName trait. This ensures that we don't check for a hardcoded "key" value, if the key's name was changed.
/// </summary>
public string KeyXmlName
Copy link
Contributor

@boblodgett boblodgett Apr 5, 2024

Choose a reason for hiding this comment

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

nit: these could be public string KeyXmlName { get; set; } without needing member variables. Even if you set the default you can do so with the easier syntax.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

used auto properties

Comment on lines 355 to 356
private string valueXmlName = "";
private string keyXmlName = "";
Copy link
Contributor

@boblodgett boblodgett Apr 5, 2024

Choose a reason for hiding this comment

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

Should the defaults be key and value? This would ensure the class would at least work for the default case out of the box without setting values for the properties.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added defaults

Copy link
Contributor

@dscpinheiro dscpinheiro left a comment

Choose a reason for hiding this comment

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

I'd follow Bo's suggestion to use auto-properties, but other than that PR looks good.

@peterrsongg peterrsongg requested a review from normj April 5, 2024 17:30
@@ -72,6 +72,8 @@ namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
if (member.IsMap || member.IsList)
{
#>
context.KeyXmlName = "<#=member.Shape.KeyMarshallName#>";
Copy link
Member

Choose a reason for hiding this comment

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

This mechanism of storing the current key and value name for the shape being marshalled to the context seems like it would be broken if we had values that were maps as well that had different KeyMarshallName. When we made the recursive call to to the child map being marshalled the context would be changed and then when we process the next element in the parent map we would have different KeyXmlName or ValueXmlName.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Going to have to update this, to handle nested xmlNames on key/values. Will push an update with that fix later

@peterrsongg
Copy link
Contributor Author

Nested maps with xml names need more investigation. closing

@peterrsongg peterrsongg closed this Apr 6, 2024
@peterrsongg peterrsongg deleted the protocol-tests-issue-30 branch August 9, 2024 19:06
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