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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -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

context.ValueXmlName = "<#=member.Shape.ValueMarshallName#>";
var item = unmarshaller.Unmarshall(context);
response.<#=MemberAccessorFor(member.PropertyName)#>.Add(item);
<#
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
if (member.IsMap || member.IsList)
{
#>
context.KeyXmlName = "<#=member.Shape.KeyMarshallName#>";
context.ValueXmlName = "<#=member.Shape.ValueMarshallName#>";
var item = unmarshaller.Unmarshall(context);
response.<#=MemberAccessorFor(member.PropertyName)#>.Add(item);
<#
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
#>
if (context.TestExpression("<#=member.MarshallName#>", targetDepth))
{
context.KeyXmlName = "<#=member.Shape.KeyMarshallName#>";
context.ValueXmlName = "<#=member.Shape.ValueMarshallName#>";
var unmarshaller = <#= member.DetermineTypeUnmarshallerInstantiate() #>;
response.<#=member.PropertyName#>.Add(unmarshaller.Unmarshall(context));
continue;
Expand All @@ -174,6 +176,8 @@ namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
#>
if (context.TestExpression("<#=member.MarshallName#>", targetDepth))
{
context.KeyXmlName = "<#=member.Shape.KeyMarshallName#>";
context.ValueXmlName = "<#=member.Shape.ValueMarshallName#>";
var unmarshaller = <#= member.DetermineTypeUnmarshallerInstantiate() #>;
response.<#=member.PropertyName#> = unmarshaller.Unmarshall(context);
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace ServiceClientGenerator.Generators.Marshallers
/// Class to produce the template output
/// </summary>

#line 1 "C:\Dev\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
#line 1 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")]
public partial class RestXmlStructureUnmarshaller : BaseResponseUnmarshaller
{
Expand All @@ -29,7 +29,7 @@ public partial class RestXmlStructureUnmarshaller : BaseResponseUnmarshaller
public override string TransformText()
{

#line 6 "C:\Dev\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
#line 6 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"

AddLicenseHeader();

Expand All @@ -40,36 +40,36 @@ public override string TransformText()
#line hidden
this.Write("\r\nnamespace ");

#line 12 "C:\Dev\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
#line 12 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Config.Namespace));

#line default
#line hidden
this.Write(".Model.Internal.MarshallTransformations\r\n{\r\n /// <summary>\r\n /// Response U" +
"nmarshaller for ");

#line 15 "C:\Dev\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
#line 15 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));

#line default
#line hidden
this.Write(" Object\r\n /// </summary> \r\n public class ");

#line 17 "C:\Dev\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
#line 17 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));

#line default
#line hidden
this.Write("Unmarshaller : IUnmarshaller<");

#line 17 "C:\Dev\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
#line 17 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));

#line default
#line hidden
this.Write(", XmlUnmarshallerContext>, IUnmarshaller<");

#line 17 "C:\Dev\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
#line 17 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));

#line default
Expand All @@ -79,28 +79,28 @@ public override string TransformText()
"\r\n /// <param name=\"context\"></param>\r\n /// <returns></returns>\r\n " +
" public ");

#line 24 "C:\Dev\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
#line 24 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));

#line default
#line hidden
this.Write(" Unmarshall(XmlUnmarshallerContext context)\r\n {\r\n ");

#line 26 "C:\Dev\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
#line 26 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));

#line default
#line hidden
this.Write(" unmarshalledObject = new ");

#line 26 "C:\Dev\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
#line 26 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));

#line default
#line hidden
this.Write("();\r\n");

#line 27 "C:\Dev\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
#line 27 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"

if(this.Structure != null && this.Structure.IsEvent && !this.Structure.HasImplicitEventPayloadMembers())
{
Expand All @@ -114,14 +114,14 @@ public override string TransformText()
this.Write(" using (var sr = new StreamReader(context.Stream))\r\n {\r\n " +
" unmarshalledObject.");

#line 36 "C:\Dev\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
#line 36 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(eventPayloadMember.PropertyName));

#line default
#line hidden
this.Write(" = sr.ReadToEnd();\r\n }\r\n");

#line 38 "C:\Dev\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
#line 38 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"

}
else
Expand All @@ -132,14 +132,14 @@ public override string TransformText()
#line hidden
this.Write(" unmarshalledObject.");

#line 43 "C:\Dev\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
#line 43 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(eventPayloadMember.PropertyName));

#line default
#line hidden
this.Write(" = context.Stream as MemoryStream;\r\n");

#line 44 "C:\Dev\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
#line 44 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"

}
}
Expand All @@ -148,7 +148,7 @@ public override string TransformText()
#line default
#line hidden

#line 48 "C:\Dev\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
#line 48 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"

//HasImplicitEventPayloadMembers means that the structure does not have a member with the EventPayload trait
if(this.Structure != null && (this.Structure.HasImplicitEventPayloadMembers() || !this.Structure.IsEvent))
Expand All @@ -169,15 +169,15 @@ public override string TransformText()
{
");

#line 63 "C:\Dev\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
#line 63 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"

}


#line default
#line hidden

#line 66 "C:\Dev\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
#line 66 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"

if(this.Structure != null && (!this.Structure.IsEvent || this.Structure.HasImplicitEventPayloadMembers()))
{
Expand All @@ -193,35 +193,35 @@ public override string TransformText()
#line hidden
this.Write("\t\t\t\t\tif (context.TestExpression(\"");

#line 76 "C:\Dev\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
#line 76 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallName));

#line default
#line hidden
this.Write("/");

#line 76 "C:\Dev\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
#line 76 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(listMarshallName));

#line default
#line hidden
this.Write("\", targetDepth))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tvar unmarshaller = ");

#line 78 "C:\Dev\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
#line 78 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.DetermineTypeUnmarshallerInstantiate()));

#line default
#line hidden
this.Write(";\r\n\t\t\t\t\t\tunmarshalledObject.");

#line 79 "C:\Dev\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
#line 79 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName));

#line default
#line hidden
this.Write(".Add(unmarshaller.Unmarshall(context));\r\n\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t}\r\n");

#line 82 "C:\Dev\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
#line 82 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"

}
else
Expand All @@ -232,28 +232,28 @@ public override string TransformText()
#line hidden
this.Write("\t\t\t\t\tif (context.TestExpression(\"");

#line 87 "C:\Dev\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
#line 87 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallName));

#line default
#line hidden
this.Write("\", targetDepth))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tvar unmarshaller = ");

#line 89 "C:\Dev\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
#line 89 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.DetermineTypeUnmarshallerInstantiate()));

#line default
#line hidden
this.Write(";\r\n\t\t\t\t\t\tunmarshalledObject.");

#line 90 "C:\Dev\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
#line 90 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName));

#line default
#line hidden
this.Write(" = unmarshaller.Unmarshall(context);\r\n\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t}\r\n");

#line 93 "C:\Dev\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
#line 93 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"

}
}
Expand All @@ -278,15 +278,15 @@ public override string TransformText()
/// <returns></returns>
public ");

#line 112 "C:\Dev\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
#line 112 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));

#line default
#line hidden
this.Write(" Unmarshall(JsonUnmarshallerContext context)\r\n {\r\n throw new No" +
"tImplementedException();\r\n }\r\n\r\n");

#line 117 "C:\Dev\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
#line 117 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"

this.AddStructureSingletonMethod();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -651,15 +651,15 @@ public KeyValuePair<K, V> Unmarshall(XmlUnmarshallerContext context)

while (context.Read())
{
if (context.TestExpression("key", targetDepth))
if (context.TestExpression(context.KeyXmlName, targetDepth))
{
key = this.keyUnmarshaller.Unmarshall(context);
}
else if (context.TestExpression("name", targetDepth))
{
key = this.keyUnmarshaller.Unmarshall(context);
}
else if (context.TestExpression("value", targetDepth))
else if (context.TestExpression(context.ValueXmlName, targetDepth))
{
value = this.valueUnmarshaller.Unmarshall(context);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,19 @@ public Stream Stream
}
}

/// <summary>
/// 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 { get; set; } = "key";

/// <summary>
/// For map shapes the ValueXmlName represents the "locationName" on the map shape's value member. This can be changed
/// via the @xmlName trait. If the value is a structure type, we want to also check for the ValueXmlName when reading
/// the expression, since the map's value may define a different locationName for the structure other than the structure's
/// default locationName.
/// </summary>
public string ValueXmlName { get; set; } = "value";
/// <summary>
/// Lookup of element names that are not skipped if empty within the XML response structure.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ private static void UnmarshallResult(XmlUnmarshallerContext context, BatchDelete
if (context.TestExpression("FailedScheduledActions/member", targetDepth))
{
var unmarshaller = FailedScheduledUpdateGroupActionRequestUnmarshaller.Instance;
context.KeyXmlName = "key";
context.ValueXmlName = "value";
var item = unmarshaller.Unmarshall(context);
response.FailedScheduledActions.Add(item);
continue;
Expand Down
Loading