Skip to content

Commit

Permalink
Address PR Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
peterrsongg committed May 9, 2024
1 parent 3e68e73 commit 6056d15
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -459,44 +459,23 @@ public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext conte

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

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

#line default
#line hidden
this.Write(" == null)\r\n {\r\n response.");

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

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

#line 192 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.DetermineType()));

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

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

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

#line 195 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt"
#line 191 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.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 198 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt"
#line 194 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt"

}
}
Expand All @@ -510,14 +489,14 @@ public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext conte
#line hidden
this.Write("\t\t\t\t\tif (context.TestExpression(\"");

#line 206 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt"
#line 202 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(DetermineXmlMarshallName(member)));

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

#line 207 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt"
#line 203 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt"

}
else
Expand All @@ -528,14 +507,14 @@ public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext conte
#line hidden
this.Write(" if (context.TestExpression(\"@");

#line 212 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt"
#line 208 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(DetermineXmlMarshallName(member)));

#line default
#line hidden
this.Write("\", targetDepth - 1))\r\n");

#line 213 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt"
#line 209 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt"

}

Expand All @@ -544,21 +523,21 @@ public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext conte
#line hidden
this.Write("\t\t\t\t\t{\r\n\t\t\t\t\t\tvar unmarshaller = ");

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

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

#line 218 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt"
#line 214 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.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 221 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt"
#line 217 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt"

}
}
Expand All @@ -571,28 +550,28 @@ public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext conte
#line hidden
this.Write("\t\t\t\t\tif (context.TestExpression(\"");

#line 228 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt"
#line 224 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(DetermineXmlMarshallName(payload)));

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

#line 230 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt"
#line 226 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(payload.DetermineTypeUnmarshallerInstantiate()));

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

#line 231 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt"
#line 227 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(payload.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 234 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt"
#line 230 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt"

}

Expand All @@ -603,7 +582,7 @@ public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext conte
"\r\n {\r\n return;\r\n }\r\n " +
" }\r\n \r\n return;\r\n }\r\n");

#line 246 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt"
#line 242 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt"

}

Expand Down Expand Up @@ -632,7 +611,7 @@ public override AmazonServiceException UnmarshallException(XmlUnmarshallerContex
{
");

#line 268 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt"
#line 264 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt"

foreach (var exception in this.Operation.Exceptions)
{
Expand All @@ -642,22 +621,22 @@ public override AmazonServiceException UnmarshallException(XmlUnmarshallerContex
#line hidden
this.Write(" if (errorResponse.Code != null && errorResponse.Code.Equals(\"");

#line 272 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt"
#line 268 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(exception.Code));

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

#line 274 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt"
#line 270 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(exception.Name));

#line default
#line hidden
this.Write("Unmarshaller.Instance.Unmarshall(contextCopy, errorResponse);\r\n }\r" +
"\n");

#line 276 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt"
#line 272 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt"

}

Expand All @@ -666,15 +645,15 @@ public override AmazonServiceException UnmarshallException(XmlUnmarshallerContex
#line hidden
this.Write(" }\r\n return new ");

#line 280 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt"
#line 276 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.BaseException));

#line default
#line hidden
this.Write("(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, e" +
"rrorResponse.RequestId, statusCode);\r\n }\r\n\r\n");

#line 283 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt"
#line 279 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt"

this.AddResponseSingletonMethod();

Expand All @@ -685,7 +664,7 @@ public override AmazonServiceException UnmarshallException(XmlUnmarshallerContex
return this.GenerationEnvironment.ToString();
}

#line 288 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt"
#line 284 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt"

/* The rules for determining the marshallName for xml services is different than json services
1. Use the member locationName if the value doesn't match the member's name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,6 @@ namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
#>
if (context.TestExpression("<#=DetermineXmlMarshallName(member)#>", targetDepth))
{
if (response.<#=member.PropertyName#> == null)
{
response.<#=member.PropertyName#> = new <#=member.DetermineType()#>();
}
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 @@ -921,10 +921,13 @@ public List<I> Unmarshall(JsonUnmarshallerContext context)
{
context.Read(); // Read [ or null
if (context.CurrentTokenType == JsonToken.Null)
{
if (AWSConfigs.InitializeCollections)
return new List<I>();
else
return null;
}


// If a list is present in the response, use AlwaysSendList,
// so if the response was empty, reusing the object in the request we will
Expand Down Expand Up @@ -978,10 +981,13 @@ public Dictionary<TKey, TValue> Unmarshall(JsonUnmarshallerContext context)
{
context.Read(); // Read { or null
if (context.CurrentTokenType == JsonToken.Null)
{
if (AWSConfigs.InitializeCollections)
return new Dictionary<TKey, TValue>();
else
return null;
}


// If a dictionary is present in the response, use AlwaysSendDictionary,
// so if the response was empty, reusing the object in the request we will
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,6 @@ private static void UnmarshallResult(XmlUnmarshallerContext context, GetAccessPo
}
if (context.TestExpression("Endpoints", targetDepth))
{
if (response.Endpoints == null)
{
response.Endpoints = new Dictionary<string, string>();
}
var unmarshaller = new DictionaryUnmarshaller<string, string, StringUnmarshaller, StringUnmarshaller>(StringUnmarshaller.Instance, StringUnmarshaller.Instance);
response.Endpoints = unmarshaller.Unmarshall(context);
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@ private static void UnmarshallResult(XmlUnmarshallerContext context, NestedXmlMa
}
if (context.TestExpression("nestedMap", targetDepth))
{
if (response.NestedMap == null)
{
response.NestedMap = new Dictionary<string, Dictionary<string, string>>();
}
var unmarshaller = new DictionaryUnmarshaller<string, Dictionary<string, string>, StringUnmarshaller, DictionaryUnmarshaller<string, string, StringUnmarshaller, StringUnmarshaller>>(StringUnmarshaller.Instance, new DictionaryUnmarshaller<string, string, StringUnmarshaller, StringUnmarshaller>(StringUnmarshaller.Instance, StringUnmarshaller.Instance));
response.NestedMap = unmarshaller.Unmarshall(context);
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ private static void UnmarshallResult(XmlUnmarshallerContext context, XmlEmptyMap
{
if (context.TestExpression("myMap", targetDepth))
{
if (response.MyMap == null)
{
response.MyMap = new Dictionary<string, GreetingStruct>();
}
var unmarshaller = new DictionaryUnmarshaller<string, GreetingStruct, StringUnmarshaller, GreetingStructUnmarshaller>(StringUnmarshaller.Instance, GreetingStructUnmarshaller.Instance);
response.MyMap = unmarshaller.Unmarshall(context);
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,6 @@ private static void UnmarshallResult(XmlUnmarshallerContext context, XmlEnumsRes
}
if (context.TestExpression("fooEnumMap", targetDepth))
{
if (response.FooEnumMap == null)
{
response.FooEnumMap = new Dictionary<string, string>();
}
var unmarshaller = new DictionaryUnmarshaller<string, string, StringUnmarshaller, StringUnmarshaller>(StringUnmarshaller.Instance, StringUnmarshaller.Instance);
response.FooEnumMap = unmarshaller.Unmarshall(context);
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,6 @@ private static void UnmarshallResult(XmlUnmarshallerContext context, XmlIntEnums
}
if (context.TestExpression("intEnumMap", targetDepth))
{
if (response.IntEnumMap == null)
{
response.IntEnumMap = new Dictionary<string, int>();
}
var unmarshaller = new DictionaryUnmarshaller<string, int, StringUnmarshaller, IntUnmarshaller>(StringUnmarshaller.Instance, IntUnmarshaller.Instance);
response.IntEnumMap = unmarshaller.Unmarshall(context);
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ private static void UnmarshallResult(XmlUnmarshallerContext context, XmlMapWithX
{
if (context.TestExpression("KVP", targetDepth))
{
if (response.MyMap == null)
{
response.MyMap = new Dictionary<string, string>();
}
var unmarshaller = new DictionaryUnmarshaller<string, string, StringUnmarshaller, StringUnmarshaller>(StringUnmarshaller.Instance, StringUnmarshaller.Instance);
response.MyMap = unmarshaller.Unmarshall(context);
continue;
Expand Down
Loading

0 comments on commit 6056d15

Please sign in to comment.