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

Address Protocol Tests that are breaking changes #3474

Merged
merged 4 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions generator/.DevConfigs/475af10c-85c6-4181-9fe8-f3c157c08726.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"core": {
"changeLogMessages": [
"Address protocol tests that are breaking changes.",
"Xml Responses that returned pure whitespace in the body of an xml element will now return all the whitespace instead of an empty element.",
"If a payload of a response has no data, instead of returning an empty memory stream as the payload we will return null as the payload.",
"Unmarshalling an attribute with @xsi as part of the localName was not working, since xsi is a prefix. We will now successfully unmarshall an attribute with a prefix.",
"Other non-breaking changes include: We will now not send empty lists over the wire in headers only, since the service rejects these anyways."
],
"type": "patch",
"updateMinimum": true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,6 @@ private ProtocolTestCustomizations() {

);
public static final List<String> VNextTests = Arrays.asList(
// The tests below change the response and are breaking changes. We'll have to fix in V4.
"XmlNamespaceSimpleScalarProperties",
"HttpPayloadTraitsWithNoBlobBody",
"RestJsonHttpPayloadTraitsWithNoBlobBody",
"SimpleScalarPropertiesPureWhiteSpace",
//The tests below require a change in how empty collections are handled. These will be handled in vNext
"XmlEmptyLists",
"XmlEmptyMaps",
"Ec2EmptyQueryLists",
"EmptyQueryLists",
"serializes_empty_list_shapes",
"serializes_empty_map_shapes",
// These tests are not actually breaking change but have their own backlog item to be addressed.
// To avoid creating yet another list to check we'll add these here so they have an ignore flag.
"XmlMapsXmlName",
Expand All @@ -112,12 +100,11 @@ private ProtocolTestCustomizations() {
"QueryQueryXmlMapsXmlName",
"QueryQueryFlattenedXmlMapWithXmlName",
"QueryQueryFlattenedXmlMapWithXmlNamespace",
"RestXmlXmlMapWithXmlNamespace",
// the .NET SDK will not support these tests as the service should be sending back valid xml in the response even if
// the response is empty. Net's built-in xml serializer throws an exception if no root element is present.
"QueryEmptyInputAndEmptyOutput",
"QueryNoInputAndNoOutput",
"QueryNoInputAndOutput",
"RestXmlXmlMapWithXmlNamespace",
// something in v4 broke the the test below. we should investigate and fix it.
"RestJsonNullAndEmptyHeaders",
"NullAndEmptyHeaders"
"QueryNoInputAndOutput"
);
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -82,31 +82,36 @@ namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
variableNameFragment + "listValueIndex",
GeneratorHelpers.DetermineAWSQueryListMemberSuffix(this.Operation, member));
#>
<#=new string(' ', level * 4)#> int <#=variableNameFragment#>listValueIndex = 1;
<#=new string(' ', level * 4)#> foreach(var <#=variableNameFragment#>listValue in <#=variableName#>.<#=member.PropertyName#>)
<#=new string(' ', level * 4)#> if (<#=variableName#>.<#=member.PropertyName#>.Count == 0)
<#=new string(' ', level * 4)#> request.Parameters.Add(<#=context#>, "");
<#=new string(' ', level * 4)#> else
<#=new string(' ', level * 4)#> {
<#=new string(' ', level * 4)#> int <#=variableNameFragment#>listValueIndex = 1;
<#=new string(' ', level * 4)#> foreach(var <#=variableNameFragment#>listValue in <#=variableName#>.<#=member.PropertyName#>)
<#=new string(' ', level * 4)#> {
<#+
if(member.Shape.ListShape.IsStructure)
{
ProcessMembers(level + 2, listItemContext, variableNameFragment + "listValue", member.Shape.ListShape.Members);
ProcessMembers(level + 3, listItemContext, variableNameFragment + "listValue", member.Shape.ListShape.Members);
}
else
{
if(string.IsNullOrEmpty(member.CustomMarshallerTransformation))
{
#>
<#=new string(' ', level * 4)#> request.Parameters.Add(<#=listItemContext#>, <#=member.Shape.ListShape.PrimitiveMarshaller(MarshallLocation.Body)#>(<#=variableNameFragment#>listValue));
<#=new string(' ', level * 4)#> request.Parameters.Add(<#=listItemContext#>, <#=member.Shape.ListShape.PrimitiveMarshaller(MarshallLocation.Body)#>(<#=variableNameFragment#>listValue));
<#+
}
else
{
#>
<#=new string(' ', level * 4)#> request.Parameters.Add(<#=listItemContext#>, <#=member.CustomMarshallerTransformation + "(" + variableNameFragment + "listValue)"#>);
<#=new string(' ', level * 4)#> request.Parameters.Add(<#=listItemContext#>, <#=member.CustomMarshallerTransformation + "(" + variableNameFragment + "listValue)"#>);
<#+
}
}
#>
<#=new string(' ', level * 4)#> <#=variableNameFragment#>listValueIndex++;
<#=new string(' ', level * 4)#> <#=variableNameFragment#>listValueIndex++;
<#=new string(' ', level * 4)#> }
<#=new string(' ', level * 4)#> }
<#+
}
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:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseRequestMarshaller.tt"
#line 1 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseRequestMarshaller.tt"
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")]
public partial class BaseRequestMarshaller : BaseMarshaller
{
Expand All @@ -32,7 +32,7 @@ public override string TransformText()
return this.GenerationEnvironment.ToString();
}

#line 7 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseRequestMarshaller.tt"
#line 7 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseRequestMarshaller.tt"

// The operation the marshaller will be used on
public Operation Operation { get; set; }
Expand Down Expand Up @@ -61,49 +61,49 @@ protected void AddRequestSingletonMethod()
#line default
#line hidden

#line 30 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseRequestMarshaller.tt"
#line 30 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseRequestMarshaller.tt"
this.Write(" private static ");


#line default
#line hidden

#line 31 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseRequestMarshaller.tt"
#line 31 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseRequestMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Operation.Name));


#line default
#line hidden

#line 31 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseRequestMarshaller.tt"
#line 31 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseRequestMarshaller.tt"
this.Write("RequestMarshaller _instance = new ");


#line default
#line hidden

#line 31 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseRequestMarshaller.tt"
#line 31 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseRequestMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Operation.Name));


#line default
#line hidden

#line 31 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseRequestMarshaller.tt"
#line 31 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseRequestMarshaller.tt"
this.Write("RequestMarshaller(); \r\n\r\n\t\tinternal static ");


#line default
#line hidden

#line 33 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseRequestMarshaller.tt"
#line 33 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseRequestMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Operation.Name));


#line default
#line hidden

#line 33 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseRequestMarshaller.tt"
#line 33 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseRequestMarshaller.tt"
this.Write("RequestMarshaller GetInstance()\r\n\t\t{\r\n\t\t\treturn _instance;\r\n\t\t}\r\n\r\n /// <s" +
"ummary>\r\n /// Gets the singleton.\r\n /// </summary> \r\n\t\tpublic sta" +
"tic ");
Expand All @@ -112,22 +112,22 @@ protected void AddRequestSingletonMethod()
#line default
#line hidden

#line 41 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseRequestMarshaller.tt"
#line 41 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseRequestMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Operation.Name));


#line default
#line hidden

#line 41 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseRequestMarshaller.tt"
#line 41 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseRequestMarshaller.tt"
this.Write("RequestMarshaller Instance\r\n\t\t{\r\n\t\t\tget\r\n\t\t\t{\r\n\t\t\t\treturn _instance;\r\n\t\t\t}\r\n\t\t}\r\n" +
"\r\n");


#line default
#line hidden

#line 49 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseRequestMarshaller.tt"
#line 49 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseRequestMarshaller.tt"

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1669,7 +1669,7 @@ protected void ProcessStatusCode()
2. Use the value of the locationName on the member's target if present
3. Use the name of the member's target
*/
protected string DetermineXmlMarshallName(Member member)
protected string DetermineXmlMarshallName(Member member, bool withPrefix = true)
{
var locationName = member.data[ServiceModel.LocationNameKey];
if (locationName == null)
Expand All @@ -1680,6 +1680,12 @@ protected string DetermineXmlMarshallName(Member member)
return member.Shape.Name;
return member.MarshallName;
}
if (!withPrefix)
{
var locationNameString = locationName.ToString();
int colonIndex = locationNameString.IndexOf(":");
return colonIndex != -1 ? locationNameString.Substring(colonIndex + 1) : locationNameString;
}
// the locationName and modeled name must only be different for those members which are marshalled on the body.
if (!string.Equals(locationName.ToString(), member.ModeledName, StringComparison.Ordinal) || member.MarshallLocation != MarshallLocation.Body)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ using Amazon.Runtime.Internal.Util;
2. Use the value of the locationName on the member's target if present
3. Use the name of the member's target
*/
protected string DetermineXmlMarshallName(Member member)
protected string DetermineXmlMarshallName(Member member, bool withPrefix = true)
{
var locationName = member.data[ServiceModel.LocationNameKey];
if (locationName == null)
Expand All @@ -395,6 +395,12 @@ using Amazon.Runtime.Internal.Util;
return member.Shape.Name;
return member.MarshallName;
}
if (!withPrefix)
{
var locationNameString = locationName.ToString();
int colonIndex = locationNameString.IndexOf(":");
return colonIndex != -1 ? locationNameString.Substring(colonIndex + 1) : locationNameString;
}
// the locationName and modeled name must only be different for those members which are marshalled on the body.
if (!string.Equals(locationName.ToString(), member.ModeledName, StringComparison.Ordinal) || member.MarshallLocation != MarshallLocation.Body)
{
Expand Down
Loading