diff --git a/generator/ServiceClientGeneratorLib/Generators/Marshallers/AWSQueryEC2ResponseUnmarshaller.cs b/generator/ServiceClientGeneratorLib/Generators/Marshallers/AWSQueryEC2ResponseUnmarshaller.cs
index bb9e2298f1cc..c7e2a92fc95b 100644
--- a/generator/ServiceClientGeneratorLib/Generators/Marshallers/AWSQueryEC2ResponseUnmarshaller.cs
+++ b/generator/ServiceClientGeneratorLib/Generators/Marshallers/AWSQueryEC2ResponseUnmarshaller.cs
@@ -273,7 +273,7 @@ public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext conte
///
public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
{
- ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);
+ ErrorResponse errorResponse = XmlErrorResponseUnmarshaller.GetInstance().Unmarshall(context);
");
#line 121 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryEC2ResponseUnmarshaller.tt"
diff --git a/generator/ServiceClientGeneratorLib/Generators/Marshallers/AWSQueryEC2ResponseUnmarshaller.tt b/generator/ServiceClientGeneratorLib/Generators/Marshallers/AWSQueryEC2ResponseUnmarshaller.tt
index 378de529009f..6207a8edd2bf 100644
--- a/generator/ServiceClientGeneratorLib/Generators/Marshallers/AWSQueryEC2ResponseUnmarshaller.tt
+++ b/generator/ServiceClientGeneratorLib/Generators/Marshallers/AWSQueryEC2ResponseUnmarshaller.tt
@@ -117,7 +117,7 @@ namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
///
public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
{
- ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);
+ ErrorResponse errorResponse = XmlErrorResponseUnmarshaller.GetInstance().Unmarshall(context);
<#
foreach (var exception in this.Operation.Exceptions)
{
diff --git a/generator/ServiceClientGeneratorLib/Generators/Marshallers/AWSQueryExceptionUnmarshaller.cs b/generator/ServiceClientGeneratorLib/Generators/Marshallers/AWSQueryExceptionUnmarshaller.cs
index 01aa30211aa1..1ddd526d3a47 100644
--- a/generator/ServiceClientGeneratorLib/Generators/Marshallers/AWSQueryExceptionUnmarshaller.cs
+++ b/generator/ServiceClientGeneratorLib/Generators/Marshallers/AWSQueryExceptionUnmarshaller.cs
@@ -18,7 +18,7 @@ namespace ServiceClientGenerator.Generators.Marshallers
/// Class to produce the template output
///
- #line 1 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
+ #line 1 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")]
public partial class AWSQueryExceptionUnmarshaller : BaseResponseUnmarshaller
{
@@ -29,7 +29,7 @@ public partial class AWSQueryExceptionUnmarshaller : BaseResponseUnmarshaller
public override string TransformText()
{
- #line 6 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
+ #line 6 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
AddLicenseHeader();
@@ -40,7 +40,7 @@ public override string TransformText()
#line hidden
this.Write("#pragma warning disable CS0612,CS0618\r\nnamespace ");
- #line 12 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
+ #line 12 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Config.Namespace));
#line default
@@ -48,21 +48,21 @@ public override string TransformText()
this.Write(".Model.Internal.MarshallTransformations\r\n{\r\n /// \r\n /// Response U" +
"nmarshaller for ");
- #line 15 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
+ #line 15 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
#line default
#line hidden
this.Write(" operation\r\n /// \r\n public class ");
- #line 17 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
+ #line 17 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
#line default
#line hidden
- this.Write("Unmarshaller : IErrorResponseUnmarshaller<");
+ this.Write("Unmarshaller : IXmlErrorResponseUnmarshaller<");
- #line 17 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
+ #line 17 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
#line default
@@ -72,7 +72,7 @@ public override string TransformText()
"\n /// \r\n /// \r\n " +
" public ");
- #line 24 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
+ #line 24 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
#line default
@@ -90,7 +90,7 @@ public override string TransformText()
///
public ");
- #line 35 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
+ #line 35 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
#line default
@@ -98,14 +98,14 @@ public override string TransformText()
this.Write(" Unmarshall(XmlUnmarshallerContext context, Amazon.Runtime.Internal.ErrorResponse" +
" errorResponse)\r\n {\r\n ");
- #line 37 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
+ #line 37 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
#line default
#line hidden
this.Write(" response = new ");
- #line 37 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
+ #line 37 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
#line default
@@ -125,7 +125,7 @@ public override string TransformText()
{
");
- #line 50 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
+ #line 50 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
if(this.Structure != null)
{
@@ -138,14 +138,14 @@ public override string TransformText()
#line hidden
this.Write(" if (context.TestExpression(\"");
- #line 57 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
+ #line 57 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(testExpression));
#line default
#line hidden
this.Write("\", targetDepth))\r\n {\r\n");
- #line 59 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
+ #line 59 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
if (member.IsMap || member.IsList)
{
@@ -155,42 +155,42 @@ public override string TransformText()
#line hidden
this.Write(" if (response.");
- #line 63 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
+ #line 63 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(MemberAccessorFor(member.PropertyName)));
#line default
#line hidden
this.Write(" == null)\r\n {\r\n response.");
- #line 65 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
+ #line 65 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(MemberAccessorFor(member.PropertyName)));
#line default
#line hidden
this.Write(" = new ");
- #line 65 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
+ #line 65 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.DetermineType()));
#line default
#line hidden
this.Write("();\r\n }\r\n var item = ");
- #line 67 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
+ #line 67 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.DetermineTypeUnmarshallerInstantiate()));
#line default
#line hidden
this.Write(".Unmarshall(context);\r\n response.");
- #line 68 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
+ #line 68 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(MemberAccessorFor(member.PropertyName)));
#line default
#line hidden
this.Write(".Add(item);\r\n");
- #line 69 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
+ #line 69 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
}
else
@@ -201,21 +201,21 @@ public override string TransformText()
#line hidden
this.Write(" response.");
- #line 74 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
+ #line 74 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(MemberAccessorFor(member.PropertyName)));
#line default
#line hidden
this.Write(" = ");
- #line 74 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
+ #line 74 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.DetermineTypeUnmarshallerInstantiate()));
#line default
#line hidden
this.Write(".Unmarshall(context);\r\n");
- #line 75 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
+ #line 75 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
}
@@ -224,7 +224,7 @@ public override string TransformText()
#line hidden
this.Write(" }\r\n");
- #line 79 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
+ #line 79 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
}
}
@@ -234,7 +234,7 @@ public override string TransformText()
#line hidden
this.Write(" }\r\n }\r\n return response;\r\n }\r\n\r\n");
- #line 88 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
+ #line 88 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
this.AddStructureSingletonMethod();
@@ -245,7 +245,7 @@ public override string TransformText()
return this.GenerationEnvironment.ToString();
}
- #line 94 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
+ #line 94 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryExceptionUnmarshaller.tt"
// if the result fields have been wrapped in a subordinate structure, wire the accessor
// to use it when addressing a member
diff --git a/generator/ServiceClientGeneratorLib/Generators/Marshallers/AWSQueryExceptionUnmarshaller.tt b/generator/ServiceClientGeneratorLib/Generators/Marshallers/AWSQueryExceptionUnmarshaller.tt
index 0f17743a821d..ea6fd3f5d926 100644
--- a/generator/ServiceClientGeneratorLib/Generators/Marshallers/AWSQueryExceptionUnmarshaller.tt
+++ b/generator/ServiceClientGeneratorLib/Generators/Marshallers/AWSQueryExceptionUnmarshaller.tt
@@ -14,7 +14,7 @@ namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
///
/// Response Unmarshaller for <#=this.UnmarshallerBaseName #> operation
///
- public class <#=this.UnmarshallerBaseName #>Unmarshaller : IErrorResponseUnmarshaller<<#=this.UnmarshallerBaseName #>, XmlUnmarshallerContext>
+ public class <#=this.UnmarshallerBaseName #>Unmarshaller : IXmlErrorResponseUnmarshaller<<#=this.UnmarshallerBaseName #>, XmlUnmarshallerContext>
{
///
/// Unmarshaller the response from the service to the response class.
diff --git a/generator/ServiceClientGeneratorLib/Generators/Marshallers/AWSQueryResponseUnmarshaller.cs b/generator/ServiceClientGeneratorLib/Generators/Marshallers/AWSQueryResponseUnmarshaller.cs
index 65d9a560f376..9fca6b480d3f 100644
--- a/generator/ServiceClientGeneratorLib/Generators/Marshallers/AWSQueryResponseUnmarshaller.cs
+++ b/generator/ServiceClientGeneratorLib/Generators/Marshallers/AWSQueryResponseUnmarshaller.cs
@@ -316,7 +316,7 @@ public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext conte
///
public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
{
- ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);
+ ErrorResponse errorResponse = XmlErrorResponseUnmarshaller.GetInstance().Unmarshall(context);
errorResponse.InnerException = innerException;
errorResponse.StatusCode = statusCode;
diff --git a/generator/ServiceClientGeneratorLib/Generators/Marshallers/AWSQueryResponseUnmarshaller.tt b/generator/ServiceClientGeneratorLib/Generators/Marshallers/AWSQueryResponseUnmarshaller.tt
index 772e6bc50820..f5f0c8d075a9 100644
--- a/generator/ServiceClientGeneratorLib/Generators/Marshallers/AWSQueryResponseUnmarshaller.tt
+++ b/generator/ServiceClientGeneratorLib/Generators/Marshallers/AWSQueryResponseUnmarshaller.tt
@@ -138,7 +138,7 @@ namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
///
public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
{
- ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);
+ ErrorResponse errorResponse = XmlErrorResponseUnmarshaller.GetInstance().Unmarshall(context);
errorResponse.InnerException = innerException;
errorResponse.StatusCode = statusCode;
diff --git a/generator/ServiceClientGeneratorLib/Generators/Marshallers/AWSQueryStructureUnmarshaller.cs b/generator/ServiceClientGeneratorLib/Generators/Marshallers/AWSQueryStructureUnmarshaller.cs
index 43daa547babb..16f6324eb5b0 100644
--- a/generator/ServiceClientGeneratorLib/Generators/Marshallers/AWSQueryStructureUnmarshaller.cs
+++ b/generator/ServiceClientGeneratorLib/Generators/Marshallers/AWSQueryStructureUnmarshaller.cs
@@ -18,7 +18,7 @@ namespace ServiceClientGenerator.Generators.Marshallers
/// Class to produce the template output
///
- #line 1 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
+ #line 1 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")]
public partial class AWSQueryStructureUnmarshaller : BaseResponseUnmarshaller
{
@@ -29,7 +29,7 @@ public partial class AWSQueryStructureUnmarshaller : BaseResponseUnmarshaller
public override string TransformText()
{
- #line 6 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
+ #line 6 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
AddLicenseHeader();
@@ -40,7 +40,7 @@ public override string TransformText()
#line hidden
this.Write("#pragma warning disable CS0612,CS0618\r\nnamespace ");
- #line 12 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
+ #line 12 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Config.Namespace));
#line default
@@ -48,52 +48,45 @@ public override string TransformText()
this.Write(".Model.Internal.MarshallTransformations\r\n{\r\n /// \r\n /// Response U" +
"nmarshaller for ");
- #line 15 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
+ #line 15 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
#line default
#line hidden
this.Write(" Object\r\n /// \r\n public class ");
- #line 17 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
+ #line 17 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
#line default
#line hidden
- this.Write("Unmarshaller : IUnmarshaller<");
+ this.Write("Unmarshaller : IXmlUnmarshaller<");
- #line 17 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
+ #line 17 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
#line default
#line hidden
- this.Write(", XmlUnmarshallerContext>, IUnmarshaller<");
+ this.Write(", XmlUnmarshallerContext>\r\n {\r\n /// \r\n /// Unmarshaller" +
+ " the response from the service to the response class.\r\n /// \r" +
+ "\n /// \r\n /// \r\n " +
+ " public ");
- #line 17 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
- this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
-
- #line default
- #line hidden
- this.Write(", JsonUnmarshallerContext>\r\n {\r\n /// \r\n /// Unmarshalle" +
- "r the response from the service to the response class.\r\n /// " +
- "\r\n /// \r\n /// \r\n " +
- " public ");
-
- #line 24 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
+ #line 24 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
#line default
#line hidden
this.Write(" Unmarshall(XmlUnmarshallerContext context)\r\n {\r\n ");
- #line 26 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
+ #line 26 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
#line default
#line hidden
this.Write(" unmarshalledObject = new ");
- #line 26 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
+ #line 26 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
#line default
@@ -111,7 +104,7 @@ public override string TransformText()
{
");
- #line 37 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
+ #line 37 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
if(this.Structure != null)
{
@@ -124,7 +117,7 @@ public override string TransformText()
#line hidden
this.Write(" if (context.TestExpression(\"");
- #line 44 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
+ #line 44 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(testExpression));
#line default
@@ -132,14 +125,14 @@ public override string TransformText()
this.Write("\", targetDepth))\r\n {\r\n var unmarshaller" +
" = ");
- #line 46 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
+ #line 46 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.DetermineTypeUnmarshallerInstantiate()));
#line default
#line hidden
this.Write(";\r\n");
- #line 47 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
+ #line 47 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
if (member.IsMap || member.IsList)
{
@@ -149,7 +142,7 @@ public override string TransformText()
#line hidden
this.Write(" if (unmarshalledObject.");
- #line 51 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
+ #line 51 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName));
#line default
@@ -157,14 +150,14 @@ public override string TransformText()
this.Write(" == null)\r\n {\r\n unmarshalledObj" +
"ect.");
- #line 53 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
+ #line 53 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName));
#line default
#line hidden
this.Write(" = new ");
- #line 53 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
+ #line 53 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.DetermineType()));
#line default
@@ -172,14 +165,14 @@ public override string TransformText()
this.Write("();\r\n }\r\n var item = unmarshaller.U" +
"nmarshall(context);\r\n unmarshalledObject.");
- #line 56 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
+ #line 56 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName));
#line default
#line hidden
this.Write(".Add(item);\r\n");
- #line 57 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
+ #line 57 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
}
else
@@ -190,14 +183,14 @@ public override string TransformText()
#line hidden
this.Write(" unmarshalledObject.");
- #line 62 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
+ #line 62 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName));
#line default
#line hidden
this.Write(" = unmarshaller.Unmarshall(context);\r\n");
- #line 63 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
+ #line 63 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
}
@@ -206,7 +199,7 @@ public override string TransformText()
#line hidden
this.Write(" continue;\r\n }\r\n");
- #line 68 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
+ #line 68 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
}
}
@@ -224,22 +217,9 @@ public override string TransformText()
return unmarshalledObject;
}
- ///
- /// Unmarshaller error response to exception.
- ///
- ///
- ///
- public ");
-
- #line 87 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
- this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
-
- #line default
- #line hidden
- this.Write(" Unmarshall(JsonUnmarshallerContext context)\r\n {\r\n return null;" +
- "\r\n }\r\n\r\n\r\n");
+");
- #line 93 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
+ #line 82 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\AWSQueryStructureUnmarshaller.tt"
this.AddStructureSingletonMethod();
diff --git a/generator/ServiceClientGeneratorLib/Generators/Marshallers/AWSQueryStructureUnmarshaller.tt b/generator/ServiceClientGeneratorLib/Generators/Marshallers/AWSQueryStructureUnmarshaller.tt
index d5ca583c4f05..15453b45a2c4 100644
--- a/generator/ServiceClientGeneratorLib/Generators/Marshallers/AWSQueryStructureUnmarshaller.tt
+++ b/generator/ServiceClientGeneratorLib/Generators/Marshallers/AWSQueryStructureUnmarshaller.tt
@@ -14,7 +14,7 @@ namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
///
/// Response Unmarshaller for <#=this.UnmarshallerBaseName #> Object
///
- public class <#=this.UnmarshallerBaseName #>Unmarshaller : IUnmarshaller<<#=this.UnmarshallerBaseName #>, XmlUnmarshallerContext>, IUnmarshaller<<#=this.UnmarshallerBaseName #>, JsonUnmarshallerContext>
+ public class <#=this.UnmarshallerBaseName #>Unmarshaller : IXmlUnmarshaller<<#=this.UnmarshallerBaseName #>, XmlUnmarshallerContext>
{
///
/// Unmarshaller the response from the service to the response class.
@@ -79,17 +79,6 @@ namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
return unmarshalledObject;
}
- ///
- /// Unmarshaller error response to exception.
- ///
- ///
- ///
- public <#=this.UnmarshallerBaseName #> Unmarshall(JsonUnmarshallerContext context)
- {
- return null;
- }
-
-
<#
this.AddStructureSingletonMethod();
#>
diff --git a/generator/ServiceClientGeneratorLib/Generators/Marshallers/JsonRPCExceptionUnmarshaller.cs b/generator/ServiceClientGeneratorLib/Generators/Marshallers/JsonRPCExceptionUnmarshaller.cs
index cfb8e819b070..a76b07e68f69 100644
--- a/generator/ServiceClientGeneratorLib/Generators/Marshallers/JsonRPCExceptionUnmarshaller.cs
+++ b/generator/ServiceClientGeneratorLib/Generators/Marshallers/JsonRPCExceptionUnmarshaller.cs
@@ -18,7 +18,7 @@ namespace ServiceClientGenerator.Generators.Marshallers
/// Class to produce the template output
///
- #line 1 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
+ #line 1 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")]
public partial class JsonRPCExceptionUnmarshaller : BaseResponseUnmarshaller
{
@@ -29,7 +29,7 @@ public partial class JsonRPCExceptionUnmarshaller : BaseResponseUnmarshaller
public override string TransformText()
{
- #line 6 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
+ #line 6 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
AddLicenseHeader();
@@ -38,10 +38,10 @@ public override string TransformText()
#line default
#line hidden
- this.Write("using ThirdParty.Json.LitJson;\r\n\r\n#pragma warning disable CS0612,CS0618\r\nnamespac" +
- "e ");
+ this.Write("using System.Text.Json;\r\nusing Amazon.Util;\r\n#pragma warning disable CS0612,CS061" +
+ "8\r\nnamespace ");
- #line 14 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
+ #line 14 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Config.Namespace));
#line default
@@ -49,38 +49,43 @@ public override string TransformText()
this.Write(".Model.Internal.MarshallTransformations\r\n{\r\n /// \r\n /// Response U" +
"nmarshaller for ");
- #line 17 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
+ #line 17 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
#line default
#line hidden
this.Write(" Object\r\n /// \r\n public class ");
- #line 19 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
+ #line 19 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
#line default
#line hidden
- this.Write("Unmarshaller : IErrorResponseUnmarshaller<");
+ this.Write("Unmarshaller : IJsonErrorResponseUnmarshaller<");
- #line 19 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
+ #line 19 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
#line default
#line hidden
- this.Write(", JsonUnmarshallerContext>\r\n {\r\n /// \r\n /// Unmarshalle" +
- "r the response from the service to the response class.\r\n /// " +
- "\r\n /// \r\n /// \r\n " +
- " public ");
+ this.Write(@", JsonUnmarshallerContext>
+ {
+ ///
+ /// Unmarshaller the response from the service to the response class.
+ ///
+ ///
+ ///
+ ///
+ public ");
- #line 26 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
+ #line 27 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
#line default
#line hidden
- this.Write(@" Unmarshall(JsonUnmarshallerContext context)
+ this.Write(@" Unmarshall(JsonUnmarshallerContext context, ref StreamingUtf8JsonReader reader)
{
- return this.Unmarshall(context, new Amazon.Runtime.Internal.ErrorResponse());
+ return this.Unmarshall(context, new Amazon.Runtime.Internal.ErrorResponse(), ref reader);
}
///
@@ -88,18 +93,20 @@ public override string TransformText()
///
///
///
+ ///
///
public ");
- #line 37 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
+ #line 39 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
#line default
#line hidden
this.Write(" Unmarshall(JsonUnmarshallerContext context, Amazon.Runtime.Internal.ErrorRespons" +
- "e errorResponse)\r\n {\r\n context.Read();\r\n\r\n");
+ "e errorResponse, ref StreamingUtf8JsonReader reader)\r\n {\r\n con" +
+ "text.Read(ref reader);\r\n\r\n");
- #line 41 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
+ #line 43 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
if (this.Config.ServiceModel.IsAwsQueryCompatible)
{
@@ -110,14 +117,14 @@ public override string TransformText()
#line hidden
this.Write(" ");
- #line 46 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
+ #line 48 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
#line default
#line hidden
this.Write(" unmarshalledObject = new ");
- #line 46 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
+ #line 48 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
#line default
@@ -125,7 +132,7 @@ public override string TransformText()
this.Write("(errorResponse.Message, errorResponse.InnerException,\r\n errorType," +
" errorCode, errorResponse.RequestId, errorResponse.StatusCode);\r\n");
- #line 48 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
+ #line 50 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
}
else
@@ -136,14 +143,14 @@ public override string TransformText()
#line hidden
this.Write(" ");
- #line 53 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
+ #line 55 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
#line default
#line hidden
this.Write(" unmarshalledObject = new ");
- #line 53 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
+ #line 55 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
#line default
@@ -152,7 +159,7 @@ public override string TransformText()
"nse.Type, errorResponse.Code, errorResponse.RequestId, errorResponse.StatusCode)" +
";\r\n");
- #line 55 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
+ #line 57 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
}
@@ -160,9 +167,9 @@ public override string TransformText()
#line default
#line hidden
this.Write(" \r\n int targetDepth = context.CurrentDepth;\r\n while " +
- "(context.ReadAtDepth(targetDepth))\r\n {\r\n");
+ "(context.ReadAtDepth(targetDepth, ref reader))\r\n {\r\n");
- #line 62 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
+ #line 64 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
if(this.Structure != null)
{
@@ -174,29 +181,29 @@ public override string TransformText()
#line hidden
this.Write(" if (context.TestExpression(\"");
- #line 68 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
+ #line 70 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallName));
#line default
#line hidden
this.Write("\", targetDepth))\r\n {\r\n var unmarshaller = ");
- #line 70 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
+ #line 72 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.DetermineTypeUnmarshallerInstantiate()));
#line default
#line hidden
this.Write(";\r\n unmarshalledObject.");
- #line 71 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
+ #line 73 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName));
#line default
#line hidden
- this.Write(" = unmarshaller.Unmarshall(context);\r\n continue;\r\n " +
- " }\r\n");
+ this.Write(" = unmarshaller.Unmarshall(context, ref reader);\r\n continue;\r\n" +
+ " }\r\n");
- #line 74 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
+ #line 76 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
}
}
@@ -206,7 +213,7 @@ public override string TransformText()
#line hidden
this.Write(" }\r\n \r\n return unmarshalledObject;\r\n }\r\n\r\n");
- #line 83 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
+ #line 85 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
this.AddStructureSingletonMethod();
diff --git a/generator/ServiceClientGeneratorLib/Generators/Marshallers/JsonRPCExceptionUnmarshaller.tt b/generator/ServiceClientGeneratorLib/Generators/Marshallers/JsonRPCExceptionUnmarshaller.tt
index 97ebdf03a760..2c75b5a2d328 100644
--- a/generator/ServiceClientGeneratorLib/Generators/Marshallers/JsonRPCExceptionUnmarshaller.tt
+++ b/generator/ServiceClientGeneratorLib/Generators/Marshallers/JsonRPCExceptionUnmarshaller.tt
@@ -8,24 +8,25 @@
AddCommonUsingStatements();
#>
-using ThirdParty.Json.LitJson;
-
+using System.Text.Json;
+using Amazon.Util;
#pragma warning disable CS0612,CS0618
namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
{
///
/// Response Unmarshaller for <#=this.UnmarshallerBaseName #> Object
///
- public class <#=this.UnmarshallerBaseName #>Unmarshaller : IErrorResponseUnmarshaller<<#=this.UnmarshallerBaseName #>, JsonUnmarshallerContext>
+ public class <#=this.UnmarshallerBaseName #>Unmarshaller : IJsonErrorResponseUnmarshaller<<#=this.UnmarshallerBaseName #>, JsonUnmarshallerContext>
{
///
/// Unmarshaller the response from the service to the response class.
///
///
+ ///
///
- public <#=this.UnmarshallerBaseName #> Unmarshall(JsonUnmarshallerContext context)
+ public <#=this.UnmarshallerBaseName #> Unmarshall(JsonUnmarshallerContext context, ref StreamingUtf8JsonReader reader)
{
- return this.Unmarshall(context, new Amazon.Runtime.Internal.ErrorResponse());
+ return this.Unmarshall(context, new Amazon.Runtime.Internal.ErrorResponse(), ref reader);
}
///
@@ -33,10 +34,11 @@ namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
///
///
///
+ ///
///
- public <#=this.UnmarshallerBaseName #> Unmarshall(JsonUnmarshallerContext context, Amazon.Runtime.Internal.ErrorResponse errorResponse)
+ public <#=this.UnmarshallerBaseName #> Unmarshall(JsonUnmarshallerContext context, Amazon.Runtime.Internal.ErrorResponse errorResponse, ref StreamingUtf8JsonReader reader)
{
- context.Read();
+ context.Read(ref reader);
<#
if (this.Config.ServiceModel.IsAwsQueryCompatible)
@@ -57,7 +59,7 @@ namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
#>
int targetDepth = context.CurrentDepth;
- while (context.ReadAtDepth(targetDepth))
+ while (context.ReadAtDepth(targetDepth, ref reader))
{
<#
if(this.Structure != null)
@@ -68,7 +70,7 @@ namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
if (context.TestExpression("<#=member.MarshallName#>", targetDepth))
{
var unmarshaller = <#= member.DetermineTypeUnmarshallerInstantiate() #>;
- unmarshalledObject.<#=member.PropertyName#> = unmarshaller.Unmarshall(context);
+ unmarshalledObject.<#=member.PropertyName#> = unmarshaller.Unmarshall(context, ref reader);
continue;
}
<#
diff --git a/generator/ServiceClientGeneratorLib/Generators/Marshallers/JsonRPCRequestMarshaller.cs b/generator/ServiceClientGeneratorLib/Generators/Marshallers/JsonRPCRequestMarshaller.cs
index 85a51a68f195..0189b2265863 100644
--- a/generator/ServiceClientGeneratorLib/Generators/Marshallers/JsonRPCRequestMarshaller.cs
+++ b/generator/ServiceClientGeneratorLib/Generators/Marshallers/JsonRPCRequestMarshaller.cs
@@ -38,31 +38,31 @@ public override string TransformText()
#line default
#line hidden
- this.Write("using System.Text.Json;\r\nusing System.Buffers;\r\n#pragma warning disable CS0612,CS" +
- "0618\r\nnamespace ");
+ this.Write("using System.Text.Json;\r\nusing System.Buffers;\r\n#if !NETFRAMEWORK\r\nusing ThirdPar" +
+ "ty.RuntimeBackports;\r\n#endif\r\n#pragma warning disable CS0612,CS0618\r\nnamespace ");
- #line 14 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
+ #line 17 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Config.Namespace));
#line default
#line hidden
this.Write(".Model.Internal.MarshallTransformations\r\n{\r\n\t/// \r\n\t/// ");
- #line 17 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
+ #line 20 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Operation.Name));
#line default
#line hidden
this.Write(" Request Marshaller\r\n\t/// \r\n\tpublic class ");
- #line 19 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
+ #line 22 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Operation.Name));
#line default
#line hidden
this.Write("RequestMarshaller : IMarshaller\r\n /// \r\n\t\tpublic IReque" +
"st Marshall(");
- #line 36 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
+ #line 39 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Operation.Name));
#line default
@@ -96,14 +96,14 @@ public IRequest Marshall(AmazonWebServiceRequest input)
this.Write("Request publicRequest)\r\n\t\t{\r\n\t\t\tIRequest request = new DefaultRequest(publicReque" +
"st, \"");
- #line 38 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
+ #line 41 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Config.Namespace));
#line default
#line hidden
this.Write("\");\r\n");
- #line 39 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
+ #line 42 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
SetCompressionAlgorithmEncoding(this.Operation);
@@ -115,21 +115,21 @@ public IRequest Marshall(AmazonWebServiceRequest input)
#line hidden
this.Write("\t\t\tstring target = \"");
- #line 45 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
+ #line 48 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Config.ServiceModel.TargetPrefix));
#line default
#line hidden
this.Write(".");
- #line 45 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
+ #line 48 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Operation.Name));
#line default
#line hidden
this.Write("\";\r\n\t\t\trequest.Headers[\"X-Amz-Target\"] = target;\r\n");
- #line 47 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
+ #line 50 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
}
if (this.Operation.HttpMethod != "GET" && this.Operation.HttpMethod != "DELETE")
@@ -143,14 +143,14 @@ public IRequest Marshall(AmazonWebServiceRequest input)
#line hidden
this.Write("\t\t\trequest.Headers[\"Content-Type\"] = \"");
- #line 55 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
+ #line 58 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Config.ServiceModel.Customizations.OverrideContentType));
#line default
#line hidden
this.Write("\";\r\n");
- #line 56 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
+ #line 59 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
}
else if (this.Config.ServiceModel.Type != ServiceType.Rest_Json)
@@ -161,14 +161,14 @@ public IRequest Marshall(AmazonWebServiceRequest input)
#line hidden
this.Write("\t\t\trequest.Headers[\"Content-Type\"] = \"application/x-amz-json-");
- #line 61 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
+ #line 64 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Config.ServiceModel.JsonVersion));
#line default
#line hidden
this.Write("\";\r\n");
- #line 62 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
+ #line 65 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
}
else if (this.Operation.RequestHasBodyMembers || this.Operation.RequestPayloadMember != null)
@@ -179,7 +179,7 @@ public IRequest Marshall(AmazonWebServiceRequest input)
#line hidden
this.Write("\t\t\trequest.Headers[\"Content-Type\"] = \"application/json\";\r\n");
- #line 68 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
+ #line 71 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
}
}
@@ -189,21 +189,21 @@ public IRequest Marshall(AmazonWebServiceRequest input)
#line hidden
this.Write(" request.Headers[Amazon.Util.HeaderKeys.XAmzApiVersion] = \"");
- #line 72 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
+ #line 75 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Config.ServiceModel.APIVersion));
#line default
#line hidden
this.Write("\";\r\n request.HttpMethod = \"");
- #line 73 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
+ #line 76 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Operation.HttpMethod));
#line default
#line hidden
this.Write("\";\r\n\r\n");
- #line 75 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
+ #line 78 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
var requestStructure = this.Operation.RequestStructure;
@@ -221,14 +221,14 @@ public IRequest Marshall(AmazonWebServiceRequest input)
#line hidden
this.Write("\t\t\trequest.ResourcePath = \"");
- #line 87 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
+ #line 90 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Operation.RequestUri));
#line default
#line hidden
this.Write("\";\r\n");
- #line 88 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
+ #line 91 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
var payload = this.Operation.RequestPayloadMember;
@@ -240,16 +240,16 @@ public IRequest Marshall(AmazonWebServiceRequest input)
#line default
#line hidden
- this.Write(@"#if NETCOREAPP3_1_OR_GREATER
- ArrayBufferWriter arrayBufferWriter = new ArrayBufferWriter();
- using Utf8JsonWriter writer = new Utf8JsonWriter(arrayBufferWriter);
+ this.Write(@"#if !NETFRAMEWORK
+ using ArrayPoolBufferWriter arrayPoolBufferWriter = new ArrayPoolBufferWriter();
+ using Utf8JsonWriter writer = new Utf8JsonWriter(arrayPoolBufferWriter);
#else
using var memoryStream = new MemoryStream();
using Utf8JsonWriter writer = new Utf8JsonWriter(memoryStream);
#endif
");
- #line 103 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
+ #line 106 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
if (shouldMarshallPayload)
{
@@ -259,7 +259,7 @@ public IRequest Marshall(AmazonWebServiceRequest input)
#line hidden
this.Write("\t\t\tvar context = new JsonMarshallerContext(request, writer);\r\n");
- #line 108 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
+ #line 111 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
ProcessStructure(0, "publicRequest." + payload.PropertyName, payload.Shape);
@@ -268,7 +268,7 @@ public IRequest Marshall(AmazonWebServiceRequest input)
#line hidden
this.Write("\t\t\twriter.Flush();\r\n");
- #line 112 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
+ #line 115 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
}
else
@@ -280,7 +280,7 @@ public IRequest Marshall(AmazonWebServiceRequest input)
this.Write("\t\t\twriter.WriteStartObject();\r\n\t\t\tvar context = new JsonMarshallerContext(request" +
", writer);\r\n");
- #line 119 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
+ #line 122 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
ProcessMembers(0, "publicRequest", this.Operation.RequestBodyMembers);
@@ -289,18 +289,18 @@ public IRequest Marshall(AmazonWebServiceRequest input)
#line hidden
this.Write("\t\t\twriter.WriteEndObject();\r\n\t\t\twriter.Flush();\r\n");
- #line 124 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
+ #line 127 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
}
#line default
#line hidden
- this.Write("#if NETCOREAPP3_1_OR_GREATER\r\n request.Content = arrayBufferWriter.Wri" +
- "ttenMemory.ToArray();\r\n#else\r\n\t\t\trequest.Content = memoryStream.ToArray();\r\n#end" +
- "if\r\n");
+ this.Write("\t\t\t// ToArray() must be called here because aspects of sigv4 signing require a by" +
+ "te array\r\n#if !NETFRAMEWORK\r\n\t\t\trequest.Content = arrayPoolBufferWriter.WrittenM" +
+ "emory.ToArray();\r\n#else\r\n\t\t\trequest.Content = memoryStream.ToArray();\r\n#endif\r\n");
- #line 132 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
+ #line 136 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
GenerateRequestChecksumHandling(this.Operation, "snippet");
@@ -309,7 +309,7 @@ public IRequest Marshall(AmazonWebServiceRequest input)
#line hidden
this.Write("\t\t\t\r\n\r\n");
- #line 136 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
+ #line 140 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
}
else if (payload?.Shape.IsString == true)
@@ -320,14 +320,14 @@ public IRequest Marshall(AmazonWebServiceRequest input)
#line hidden
this.Write("\t\t\trequest.Content = System.Text.Encoding.UTF8.GetBytes(publicRequest.");
- #line 141 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
+ #line 145 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(payload.PropertyName));
#line default
#line hidden
this.Write(");\r\n");
- #line 142 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
+ #line 146 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
}
else if (payload?.IsMemoryStream == true)
@@ -338,14 +338,14 @@ public IRequest Marshall(AmazonWebServiceRequest input)
#line hidden
this.Write("\t\t\trequest.ContentStream = publicRequest.");
- #line 147 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
+ #line 151 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(payload.PropertyName));
#line default
#line hidden
this.Write(" ?? new MemoryStream();\r\n");
- #line 148 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
+ #line 152 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
var requiresLength = payload.RequiresLength;
if (!requiresLength && payload.Shape.IsStreaming && this.Operation.AuthType == OperationAuthType.V4UnsignedBody)
@@ -366,7 +366,7 @@ public IRequest Marshall(AmazonWebServiceRequest input)
}
");
- #line 163 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
+ #line 167 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
}
else
@@ -381,7 +381,7 @@ public IRequest Marshall(AmazonWebServiceRequest input)
"onException(\"Cannot determine stream length for the payload when content-length " +
"is required.\");\r\n\t\t\t}\r\n");
- #line 174 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
+ #line 178 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
}
@@ -393,7 +393,7 @@ public IRequest Marshall(AmazonWebServiceRequest input)
"ader] =\r\n\t\t\t\trequest.ContentStream.Length.ToString(CultureInfo.InvariantCulture)" +
";\r\n");
- #line 183 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
+ #line 187 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
}
@@ -403,7 +403,7 @@ public IRequest Marshall(AmazonWebServiceRequest input)
this.Write("\t\t\trequest.Headers[Amazon.Util.HeaderKeys.ContentTypeHeader] = \"application/octet" +
"-stream\";\r\n");
- #line 187 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
+ #line 191 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
}
else if (payload?.Shape.IsPrimitiveType == true)
@@ -423,7 +423,7 @@ public IRequest Marshall(AmazonWebServiceRequest input)
this.Write("\t\t\tvar content = \"{}\";\r\n request.Content = System.Text.Encoding.UTF8.G" +
"etBytes(content);\r\n");
- #line 202 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
+ #line 206 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
GenerateRequestChecksumHandling(this.Operation, "content");
@@ -431,7 +431,7 @@ public IRequest Marshall(AmazonWebServiceRequest input)
#line default
#line hidden
- #line 205 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
+ #line 209 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
}
@@ -460,7 +460,7 @@ public IRequest Marshall(AmazonWebServiceRequest input)
#line hidden
this.Write("\t\t\trequest.UseQueryString = true;\r\n");
- #line 218 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
+ #line 222 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
}
// We skip endpoint host prefix handling for S3 and S3 Control as it's implemented by endpoint rules.
@@ -474,7 +474,7 @@ public IRequest Marshall(AmazonWebServiceRequest input)
#line hidden
this.Write("\r\n\t\t\treturn request;\r\n\t\t}\r\n");
- #line 229 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
+ #line 233 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCRequestMarshaller.tt"
this.AddRequestSingletonMethod();
diff --git a/generator/ServiceClientGeneratorLib/Generators/Marshallers/JsonRPCRequestMarshaller.tt b/generator/ServiceClientGeneratorLib/Generators/Marshallers/JsonRPCRequestMarshaller.tt
index f90fe691939c..2383fd36653f 100644
--- a/generator/ServiceClientGeneratorLib/Generators/Marshallers/JsonRPCRequestMarshaller.tt
+++ b/generator/ServiceClientGeneratorLib/Generators/Marshallers/JsonRPCRequestMarshaller.tt
@@ -10,6 +10,9 @@
#>
using System.Text.Json;
using System.Buffers;
+#if !NETFRAMEWORK
+using ThirdParty.RuntimeBackports;
+#endif
#pragma warning disable CS0612,CS0618
namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
{
@@ -93,9 +96,9 @@ namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
if (this.Operation.RequestHasBodyMembers || shouldMarshallPayload)
{
#>
-#if NETCOREAPP3_1_OR_GREATER
- ArrayBufferWriter arrayBufferWriter = new ArrayBufferWriter();
- using Utf8JsonWriter writer = new Utf8JsonWriter(arrayBufferWriter);
+#if !NETFRAMEWORK
+ using ArrayPoolBufferWriter arrayPoolBufferWriter = new ArrayPoolBufferWriter();
+ using Utf8JsonWriter writer = new Utf8JsonWriter(arrayPoolBufferWriter);
#else
using var memoryStream = new MemoryStream();
using Utf8JsonWriter writer = new Utf8JsonWriter(memoryStream);
@@ -124,8 +127,9 @@ namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
<#
}
#>
-#if NETCOREAPP3_1_OR_GREATER
- request.Content = arrayBufferWriter.WrittenMemory.ToArray();
+ // ToArray() must be called here because aspects of sigv4 signing require a byte array
+#if !NETFRAMEWORK
+ request.Content = arrayPoolBufferWriter.WrittenMemory.ToArray();
#else
request.Content = memoryStream.ToArray();
#endif
diff --git a/generator/ServiceClientGeneratorLib/Generators/Marshallers/JsonRPCResponseUnmarshaller.cs b/generator/ServiceClientGeneratorLib/Generators/Marshallers/JsonRPCResponseUnmarshaller.cs
index 053f57ad0c6c..6749cdb7781c 100644
--- a/generator/ServiceClientGeneratorLib/Generators/Marshallers/JsonRPCResponseUnmarshaller.cs
+++ b/generator/ServiceClientGeneratorLib/Generators/Marshallers/JsonRPCResponseUnmarshaller.cs
@@ -38,8 +38,8 @@ public override string TransformText()
#line default
#line hidden
- this.Write("using ThirdParty.Json.LitJson;\r\n\r\n#pragma warning disable CS0612,CS0618\r\nnamespac" +
- "e ");
+ this.Write("using System.Text.Json;\r\nusing Amazon.Util;\r\n#pragma warning disable CS0612,CS061" +
+ "8\r\nnamespace ");
#line 14 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Config.Namespace));
@@ -84,9 +84,9 @@ public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext cont
#line default
#line hidden
- this.Write("Response();\r\n\r\n");
+ this.Write("Response();\r\n");
- #line 30 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
+ #line 29 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
var payload = this.Operation.ResponsePayloadMember;
var unmarshallPayload = payload != null && payload.IsStructure;
@@ -114,21 +114,21 @@ public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext cont
#line hidden
this.Write(" response.");
- #line 52 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
+ #line 51 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(payload.PropertyName));
#line default
#line hidden
this.Write(" = new ");
- #line 52 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
+ #line 51 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(payload.Shape.Name));
#line default
#line hidden
this.Write("(context.Stream);\r\n");
- #line 53 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
+ #line 52 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
}
else if (payloadIsStream)
@@ -141,14 +141,14 @@ public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext cont
#line hidden
this.Write(" response.");
- #line 60 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
+ #line 59 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(payload.PropertyName));
#line default
#line hidden
this.Write(" = context.Stream;\r\n");
- #line 61 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
+ #line 60 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
}
else if (payload.ModelShape.IsString)
@@ -160,14 +160,14 @@ public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext cont
this.Write(" using (var sr = new StreamReader(context.Stream))\r\n {\r\n " +
" response.");
- #line 68 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
+ #line 67 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(payload.PropertyName));
#line default
#line hidden
this.Write(" = sr.ReadToEnd();\r\n }\r\n");
- #line 70 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
+ #line 69 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
}
else if (payload.ModelShape.IsMemoryStream)
@@ -180,14 +180,14 @@ public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext cont
"yStream(context.Stream, ms);\r\n ms.Seek(0, SeekOrigin.Begin);\r\n " +
" if (ms.Length > 0)\r\n response.");
- #line 79 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
+ #line 78 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(payload.PropertyName));
#line default
#line hidden
this.Write(" = ms;\r\n");
- #line 80 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
+ #line 79 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
}
else
@@ -205,7 +205,8 @@ public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext cont
#line default
#line hidden
- this.Write(" var unmarshaller = ");
+ this.Write(" StreamingUtf8JsonReader reader = new StreamingUtf8JsonReader(context." +
+ "Stream);\r\n var unmarshaller = ");
#line 94 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(payload.DetermineTypeUnmarshallerInstantiate()));
@@ -219,7 +220,7 @@ public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext cont
#line default
#line hidden
- this.Write(" = unmarshaller.Unmarshall(context);\r\n");
+ this.Write(" = unmarshaller.Unmarshall(context, ref reader);\r\n");
#line 96 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
@@ -244,7 +245,7 @@ public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext cont
#line default
#line hidden
- this.Write("Unmarshaller.Instance.Unmarshall(context);\r\n");
+ this.Write("Unmarshaller.Instance.Unmarshall(context, ref reader);\r\n");
#line 102 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
@@ -255,10 +256,14 @@ public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext cont
#line default
#line hidden
- this.Write(" context.Read();\r\n int targetDepth = context.CurrentDepth;\r" +
- "\n while (context.ReadAtDepth(targetDepth))\r\n {\r\n");
+ this.Write(@" StreamingUtf8JsonReader reader = new StreamingUtf8JsonReader(context.Stream);
+ context.Read(ref reader);
+ int targetDepth = context.CurrentDepth;
+ while (context.ReadAtDepth(targetDepth, ref reader))
+ {
+");
- #line 111 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
+ #line 112 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
foreach (var member in this.Operation.ResponseBodyMembers)
@@ -269,29 +274,29 @@ public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext cont
#line hidden
this.Write(" if (context.TestExpression(\"");
- #line 116 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
+ #line 117 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallName));
#line default
#line hidden
this.Write("\", targetDepth))\r\n {\r\n var unmarshaller = ");
- #line 118 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
+ #line 119 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.DetermineTypeUnmarshallerInstantiate()));
#line default
#line hidden
this.Write(";\r\n response.");
- #line 119 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
+ #line 120 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName));
#line default
#line hidden
- this.Write(" = unmarshaller.Unmarshall(context);\r\n continue;\r\n " +
- " }\r\n");
+ this.Write(" = unmarshaller.Unmarshall(context, ref reader);\r\n continue;\r\n" +
+ " }\r\n");
- #line 122 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
+ #line 123 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
}
@@ -300,7 +305,7 @@ public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext cont
#line hidden
this.Write(" }\r\n");
- #line 126 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
+ #line 127 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
}
}
@@ -323,7 +328,8 @@ public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext cont
///
public override AmazonServiceException UnmarshallException(JsonUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
{
- var errorResponse = JsonErrorResponseUnmarshaller.GetInstance().Unmarshall(context);
+ StreamingUtf8JsonReader reader = new StreamingUtf8JsonReader(context.Stream);
+ var errorResponse = JsonErrorResponseUnmarshaller.GetInstance().Unmarshall(context, ref reader);
errorResponse.InnerException = innerException;
errorResponse.StatusCode = statusCode;
@@ -332,7 +338,7 @@ public override AmazonServiceException UnmarshallException(JsonUnmarshallerConte
using (var streamCopy = new MemoryStream(responseBodyBytes))
");
- #line 152 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
+ #line 154 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
if (this.Config.ServiceModel.IsAwsQueryCompatible)
{
@@ -341,17 +347,19 @@ public override AmazonServiceException UnmarshallException(JsonUnmarshallerConte
#line default
#line hidden
- #line 156 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
+ #line 158 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
// Create a copy of context with headers in the response
+
+
#line default
#line hidden
- this.Write("\r\n using (var contextCopy = new JsonUnmarshallerContext(streamCopy, tr" +
- "ue, context.ResponseData))\r\n");
+ this.Write(" using (var contextCopy = new JsonUnmarshallerContext(streamCopy, true" +
+ ", context.ResponseData))\r\n");
- #line 159 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
+ #line 162 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
- }
+ }
else
{
@@ -361,16 +369,18 @@ public override AmazonServiceException UnmarshallException(JsonUnmarshallerConte
this.Write(" using (var contextCopy = new JsonUnmarshallerContext(streamCopy, fals" +
"e, null))\r\n");
- #line 165 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
+ #line 168 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
+ // Create a new reader because the stream has been read already in the original context
}
#line default
#line hidden
- this.Write(" {\r\n");
+ this.Write(" {\r\n StreamingUtf8JsonReader readerCopy = new Streaming" +
+ "Utf8JsonReader(streamCopy);\r\n");
- #line 169 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
+ #line 174 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
foreach (var exception in this.Operation.Exceptions)
{
@@ -380,22 +390,22 @@ public override AmazonServiceException UnmarshallException(JsonUnmarshallerConte
#line hidden
this.Write(" if (errorResponse.Code != null && errorResponse.Code.Equals(\"");
- #line 173 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
+ #line 178 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(exception.Code));
#line default
#line hidden
this.Write("\"))\r\n {\r\n return ");
- #line 175 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
+ #line 180 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(exception.Name));
#line default
#line hidden
- this.Write("Unmarshaller.Instance.Unmarshall(contextCopy, errorResponse);\r\n }\r" +
- "\n");
+ this.Write("Unmarshaller.Instance.Unmarshall(contextCopy, errorResponse, ref readerCopy);\r\n " +
+ " }\r\n");
- #line 177 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
+ #line 182 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
}
@@ -404,7 +414,7 @@ public override AmazonServiceException UnmarshallException(JsonUnmarshallerConte
#line hidden
this.Write(" }\r\n");
- #line 181 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
+ #line 186 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
if (this.Config.ServiceModel.IsAwsQueryCompatible)
{
@@ -415,7 +425,7 @@ public override AmazonServiceException UnmarshallException(JsonUnmarshallerConte
#line hidden
this.Write(" return new ");
- #line 186 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
+ #line 191 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.BaseException));
#line default
@@ -423,7 +433,7 @@ public override AmazonServiceException UnmarshallException(JsonUnmarshallerConte
this.Write("(errorResponse.Message, errorResponse.InnerException, errorType, errorCode, error" +
"Response.RequestId, errorResponse.StatusCode);\r\n");
- #line 187 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
+ #line 192 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
}
else
@@ -434,7 +444,7 @@ public override AmazonServiceException UnmarshallException(JsonUnmarshallerConte
#line hidden
this.Write(" return new ");
- #line 192 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
+ #line 197 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.BaseException));
#line default
@@ -442,7 +452,7 @@ public override AmazonServiceException UnmarshallException(JsonUnmarshallerConte
this.Write("(errorResponse.Message, errorResponse.InnerException, errorResponse.Type, errorRe" +
"sponse.Code, errorResponse.RequestId, errorResponse.StatusCode);\r\n");
- #line 193 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
+ #line 198 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
}
@@ -451,7 +461,7 @@ public override AmazonServiceException UnmarshallException(JsonUnmarshallerConte
#line hidden
this.Write(" }\r\n\r\n");
- #line 198 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
+ #line 203 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
if (payload != null && payload.Shape.IsStreaming)
{
@@ -472,7 +482,7 @@ public override bool HasStreamingProperty
");
- #line 213 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
+ #line 218 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
}
this.AddResponseSingletonMethod();
@@ -481,7 +491,7 @@ public override bool HasStreamingProperty
#line default
#line hidden
- #line 217 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
+ #line 222 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
if(isEventStreamOutput)
{
@@ -505,7 +515,7 @@ protected override bool ShouldReadEntireResponse(IWebResponseData response, bool
public override bool HasStreamingProperty => true;
");
- #line 235 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
+ #line 240 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCResponseUnmarshaller.tt"
}
diff --git a/generator/ServiceClientGeneratorLib/Generators/Marshallers/JsonRPCResponseUnmarshaller.tt b/generator/ServiceClientGeneratorLib/Generators/Marshallers/JsonRPCResponseUnmarshaller.tt
index e2e75b05f40c..f26f178159f2 100644
--- a/generator/ServiceClientGeneratorLib/Generators/Marshallers/JsonRPCResponseUnmarshaller.tt
+++ b/generator/ServiceClientGeneratorLib/Generators/Marshallers/JsonRPCResponseUnmarshaller.tt
@@ -8,8 +8,8 @@
AddCommonUsingStatements();
#>
-using ThirdParty.Json.LitJson;
-
+using System.Text.Json;
+using Amazon.Util;
#pragma warning disable CS0612,CS0618
namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
{
@@ -26,7 +26,6 @@ namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
{
<#=this.UnmarshallerBaseName #>Response response = new <#=this.Operation.Name #>Response();
-
<#
var payload = this.Operation.ResponsePayloadMember;
var unmarshallPayload = payload != null && payload.IsStructure;
@@ -91,22 +90,24 @@ namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
else if (unmarshallPayload)
{
#>
+ StreamingUtf8JsonReader reader = new StreamingUtf8JsonReader(context.Stream);
var unmarshaller = <#= payload.DetermineTypeUnmarshallerInstantiate() #>;
- response.<#=payload.PropertyName#> = unmarshaller.Unmarshall(context);
+ response.<#=payload.PropertyName#> = unmarshaller.Unmarshall(context, ref reader);
<#
}
else if (this.IsWrapped)
{
#>
- response.<#=this.WrappedResultMember#> = <#=this.Structure.Name#>Unmarshaller.Instance.Unmarshall(context);
+ response.<#=this.WrappedResultMember#> = <#=this.Structure.Name#>Unmarshaller.Instance.Unmarshall(context, ref reader);
<#
}
else
{
#>
- context.Read();
+ StreamingUtf8JsonReader reader = new StreamingUtf8JsonReader(context.Stream);
+ context.Read(ref reader);
int targetDepth = context.CurrentDepth;
- while (context.ReadAtDepth(targetDepth))
+ while (context.ReadAtDepth(targetDepth, ref reader))
{
<#
@@ -116,7 +117,7 @@ namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
if (context.TestExpression("<#=member.MarshallName#>", targetDepth))
{
var unmarshaller = <#= member.DetermineTypeUnmarshallerInstantiate() #>;
- response.<#=member.PropertyName#> = unmarshaller.Unmarshall(context);
+ response.<#=member.PropertyName#> = unmarshaller.Unmarshall(context, ref reader);
continue;
}
<#
@@ -142,7 +143,8 @@ namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
///
public override AmazonServiceException UnmarshallException(JsonUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
{
- var errorResponse = JsonErrorResponseUnmarshaller.GetInstance().Unmarshall(context);
+ StreamingUtf8JsonReader reader = new StreamingUtf8JsonReader(context.Stream);
+ var errorResponse = JsonErrorResponseUnmarshaller.GetInstance().Unmarshall(context, ref reader);
errorResponse.InnerException = innerException;
errorResponse.StatusCode = statusCode;
@@ -153,26 +155,29 @@ namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
if (this.Config.ServiceModel.IsAwsQueryCompatible)
{
#>
-<# // Create a copy of context with headers in the response #>
+<# // Create a copy of context with headers in the response
+#>
using (var contextCopy = new JsonUnmarshallerContext(streamCopy, true, context.ResponseData))
<#
- }
+ }
else
{
#>
using (var contextCopy = new JsonUnmarshallerContext(streamCopy, false, null))
<#
+ // Create a new reader because the stream has been read already in the original context
}
#>
{
+ StreamingUtf8JsonReader readerCopy = new StreamingUtf8JsonReader(streamCopy);
<#
foreach (var exception in this.Operation.Exceptions)
{
#>
if (errorResponse.Code != null && errorResponse.Code.Equals("<#=exception.Code #>"))
{
- return <#=exception.Name#>Unmarshaller.Instance.Unmarshall(contextCopy, errorResponse);
+ return <#=exception.Name#>Unmarshaller.Instance.Unmarshall(contextCopy, errorResponse, ref readerCopy);
}
<#
}
diff --git a/generator/ServiceClientGeneratorLib/Generators/Marshallers/JsonRPCStructureMarshaller.cs b/generator/ServiceClientGeneratorLib/Generators/Marshallers/JsonRPCStructureMarshaller.cs
index 6efe94572797..c9c3f1b2b5d8 100644
--- a/generator/ServiceClientGeneratorLib/Generators/Marshallers/JsonRPCStructureMarshaller.cs
+++ b/generator/ServiceClientGeneratorLib/Generators/Marshallers/JsonRPCStructureMarshaller.cs
@@ -38,31 +38,30 @@ public override string TransformText()
#line default
#line hidden
- this.Write("using ThirdParty.Json.LitJson;\r\n\r\n#pragma warning disable CS0612,CS0618\r\nnamespac" +
- "e ");
+ this.Write("#pragma warning disable CS0612,CS0618\r\nnamespace ");
- #line 14 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureMarshaller.tt"
+ #line 12 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Config.Namespace));
#line default
#line hidden
this.Write(".Model.Internal.MarshallTransformations\r\n{\r\n\t/// \r\n\t/// ");
- #line 17 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureMarshaller.tt"
+ #line 15 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Structure.Name));
#line default
#line hidden
this.Write(" Marshaller\r\n\t/// \r\n\tpublic class ");
- #line 19 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureMarshaller.tt"
+ #line 17 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Structure.Name));
#line default
#line hidden
this.Write("Marshaller : IRequestMarshaller<");
- #line 19 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureMarshaller.tt"
+ #line 17 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Structure.Name));
#line default
@@ -77,7 +76,7 @@ public override string TransformText()
///
public void Marshall(");
- #line 27 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureMarshaller.tt"
+ #line 25 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Structure.Name));
#line default
@@ -85,7 +84,7 @@ public override string TransformText()
this.Write(" requestObject, JsonMarshallerContext context)\r\n\t\t{\r\n\t\t\tif(requestObject == null)" +
"\r\n\t\t\t\treturn;\r\n");
- #line 31 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureMarshaller.tt"
+ #line 29 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureMarshaller.tt"
ProcessMembers(0, "requestObject", this.Structure.Members);
@@ -95,14 +94,14 @@ public override string TransformText()
this.Write("\t\t}\r\n\r\n /// \r\n /// Singleton Marshaller.\r\n /// \r\n\t\tpublic readonly static ");
- #line 39 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureMarshaller.tt"
+ #line 37 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Structure.Name));
#line default
#line hidden
this.Write("Marshaller Instance = new ");
- #line 39 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureMarshaller.tt"
+ #line 37 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Structure.Name));
#line default
@@ -111,7 +110,7 @@ public override string TransformText()
return this.GenerationEnvironment.ToString();
}
- #line 44 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureMarshaller.tt"
+ #line 42 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureMarshaller.tt"
protected void ProcessMembers(int level, string variableName, IEnumerable members)
{
@@ -122,91 +121,91 @@ protected void ProcessMembers(int level, string variableName, IEnumerable
-using ThirdParty.Json.LitJson;
-
#pragma warning disable CS0612,CS0618
namespace <#= this.Config.Namespace #>.Model.Internal.MarshallTransformations
{
diff --git a/generator/ServiceClientGeneratorLib/Generators/Marshallers/JsonRPCStructureUnmarshaller.cs b/generator/ServiceClientGeneratorLib/Generators/Marshallers/JsonRPCStructureUnmarshaller.cs
index 770b04b9de17..975db418ad89 100644
--- a/generator/ServiceClientGeneratorLib/Generators/Marshallers/JsonRPCStructureUnmarshaller.cs
+++ b/generator/ServiceClientGeneratorLib/Generators/Marshallers/JsonRPCStructureUnmarshaller.cs
@@ -38,10 +38,9 @@ public override string TransformText()
#line default
#line hidden
- this.Write("using ThirdParty.Json.LitJson;\r\n\r\n#pragma warning disable CS0612,CS0618\r\nnamespac" +
- "e ");
+ this.Write("using System.Text.Json;\r\n#pragma warning disable CS0612,CS0618\r\nnamespace ");
- #line 14 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
+ #line 13 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Config.Namespace));
#line default
@@ -49,83 +48,58 @@ public override string TransformText()
this.Write(".Model.Internal.MarshallTransformations\r\n{\r\n /// \r\n /// Response U" +
"nmarshaller for ");
- #line 17 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
+ #line 16 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
#line default
#line hidden
this.Write(" Object\r\n /// \r\n public class ");
- #line 19 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
+ #line 18 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
#line default
#line hidden
- this.Write("Unmarshaller : IUnmarshaller<");
+ this.Write("Unmarshaller : IJsonUnmarshaller<");
- #line 19 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
+ #line 18 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
#line default
#line hidden
- this.Write(", XmlUnmarshallerContext>, IUnmarshaller<");
-
- #line 19 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
- this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
-
- #line default
- #line hidden
- this.Write(", JsonUnmarshallerContext>\r\n {\r\n /// \r\n /// Unmarshalle" +
- "r the response from the service to the response class.\r\n /// " +
- "\r\n /// \r\n /// \r\n " +
- " ");
-
- #line 26 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
- this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
-
- #line default
- #line hidden
- this.Write(" IUnmarshaller<");
-
- #line 26 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
- this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
-
- #line default
- #line hidden
- this.Write(@", XmlUnmarshallerContext>.Unmarshall(XmlUnmarshallerContext context)
- {
- throw new NotImplementedException();
- }
-
+ this.Write(@", JsonUnmarshallerContext>
+ {
///
/// Unmarshaller the response from the service to the response class.
///
///
+ ///
/// The unmarshalled object
public ");
- #line 36 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
+ #line 26 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
#line default
#line hidden
- this.Write(" Unmarshall(JsonUnmarshallerContext context)\r\n {\r\n ");
+ this.Write(" Unmarshall(JsonUnmarshallerContext context, ref StreamingUtf8JsonReader reader)\r" +
+ "\n {\r\n ");
- #line 38 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
+ #line 28 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
#line default
#line hidden
this.Write(" unmarshalledObject = new ");
- #line 38 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
+ #line 28 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
#line default
#line hidden
this.Write("();\r\n if (context.IsEmptyResponse)\r\n return null;\r\n");
- #line 41 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
+ #line 31 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
//HasImplicitEventPayloadMembers means that the structure does not have a member with the EventPayload trait
if(this.Structure != null && this.Structure.IsEvent && !this.Structure.HasImplicitEventPayloadMembers())
@@ -140,14 +114,14 @@ public override string TransformText()
this.Write(" using (var sr = new StreamReader(context.Stream))\r\n {\r\n " +
" unmarshalledObject.");
- #line 51 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
+ #line 41 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(eventPayloadMember.PropertyName));
#line default
#line hidden
this.Write(" = sr.ReadToEnd();\r\n }\r\n");
- #line 53 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
+ #line 43 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
}
@@ -155,7 +129,7 @@ public override string TransformText()
#line default
#line hidden
- #line 56 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
+ #line 46 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
else
{
@@ -165,14 +139,14 @@ public override string TransformText()
#line hidden
this.Write(" unmarshalledObject.");
- #line 60 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
+ #line 50 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(eventPayloadMember.PropertyName));
#line default
#line hidden
this.Write(" = context.Stream as MemoryStream;\r\n");
- #line 61 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
+ #line 51 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
}
@@ -180,7 +154,7 @@ public override string TransformText()
#line default
#line hidden
- #line 64 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
+ #line 54 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
}
@@ -188,7 +162,7 @@ public override string TransformText()
#line default
#line hidden
- #line 67 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
+ #line 57 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
if(this.Structure != null && (this.Structure.HasImplicitEventPayloadMembers() || !this.Structure.IsEvent))
{
@@ -196,12 +170,16 @@ public override string TransformText()
#line default
#line hidden
- this.Write(" context.Read();\r\n if (context.CurrentTokenType == JsonToke" +
- "n.Null) \r\n return null;\r\n\r\n int targetDepth = context." +
- "CurrentDepth;\r\n while (context.ReadAtDepth(targetDepth))\r\n " +
- " {\r\n");
+ this.Write(@" context.Read(ref reader);
+ if (context.CurrentTokenType == JsonTokenType.Null)
+ return null;
+
+ int targetDepth = context.CurrentDepth;
+ while (context.ReadAtDepth(targetDepth, ref reader))
+ {
+");
- #line 78 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
+ #line 68 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
}
@@ -209,7 +187,7 @@ public override string TransformText()
#line default
#line hidden
- #line 81 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
+ #line 71 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
if(this.Structure != null && (!this.Structure.IsEvent || this.Structure.HasImplicitEventPayloadMembers()))
{
@@ -221,29 +199,29 @@ public override string TransformText()
#line hidden
this.Write(" if (context.TestExpression(\"");
- #line 87 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
+ #line 77 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallName));
#line default
#line hidden
this.Write("\", targetDepth))\r\n {\r\n var unmarshaller = ");
- #line 89 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
+ #line 79 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.DetermineTypeUnmarshallerInstantiate()));
#line default
#line hidden
this.Write(";\r\n unmarshalledObject.");
- #line 90 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
+ #line 80 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName));
#line default
#line hidden
- this.Write(" = unmarshaller.Unmarshall(context);\r\n continue;\r\n " +
- " }\r\n");
+ this.Write(" = unmarshaller.Unmarshall(context, ref reader);\r\n continue;\r\n" +
+ " }\r\n");
- #line 93 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
+ #line 83 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
}
}
@@ -252,7 +230,7 @@ public override string TransformText()
#line default
#line hidden
- #line 97 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
+ #line 87 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
if(this.Structure != null && (!this.Structure.IsEvent || this.Structure.HasImplicitEventPayloadMembers()))
{
@@ -262,7 +240,7 @@ public override string TransformText()
#line hidden
this.Write(" }\r\n");
- #line 102 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
+ #line 92 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
}
@@ -271,7 +249,7 @@ public override string TransformText()
#line hidden
this.Write(" return unmarshalledObject;\r\n }\r\n\r\n\r\n");
- #line 109 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
+ #line 99 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCStructureUnmarshaller.tt"
this.AddStructureSingletonMethod();
diff --git a/generator/ServiceClientGeneratorLib/Generators/Marshallers/JsonRPCStructureUnmarshaller.tt b/generator/ServiceClientGeneratorLib/Generators/Marshallers/JsonRPCStructureUnmarshaller.tt
index 87a63ddc1437..f46be03f43a3 100644
--- a/generator/ServiceClientGeneratorLib/Generators/Marshallers/JsonRPCStructureUnmarshaller.tt
+++ b/generator/ServiceClientGeneratorLib/Generators/Marshallers/JsonRPCStructureUnmarshaller.tt
@@ -8,32 +8,22 @@
AddCommonUsingStatements();
#>
-using ThirdParty.Json.LitJson;
-
+using System.Text.Json;
#pragma warning disable CS0612,CS0618
namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
{
///
/// Response Unmarshaller for <#=this.UnmarshallerBaseName #> Object
///
- public class <#=this.UnmarshallerBaseName #>Unmarshaller : IUnmarshaller<<#=this.UnmarshallerBaseName #>, XmlUnmarshallerContext>, IUnmarshaller<<#=this.UnmarshallerBaseName #>, JsonUnmarshallerContext>
+ public class <#=this.UnmarshallerBaseName #>Unmarshaller : IJsonUnmarshaller<<#=this.UnmarshallerBaseName #>, JsonUnmarshallerContext>
{
///
/// Unmarshaller the response from the service to the response class.
///
///
- ///
- <#=this.UnmarshallerBaseName #> IUnmarshaller<<#=this.UnmarshallerBaseName #>, XmlUnmarshallerContext>.Unmarshall(XmlUnmarshallerContext context)
- {
- throw new NotImplementedException();
- }
-
- ///
- /// Unmarshaller the response from the service to the response class.
- ///
- ///
+ ///
/// The unmarshalled object
- public <#=this.UnmarshallerBaseName #> Unmarshall(JsonUnmarshallerContext context)
+ public <#=this.UnmarshallerBaseName #> Unmarshall(JsonUnmarshallerContext context, ref StreamingUtf8JsonReader reader)
{
<#=this.UnmarshallerBaseName #> unmarshalledObject = new <#=this.UnmarshallerBaseName #>();
if (context.IsEmptyResponse)
@@ -68,12 +58,12 @@ namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
if(this.Structure != null && (this.Structure.HasImplicitEventPayloadMembers() || !this.Structure.IsEvent))
{
#>
- context.Read();
- if (context.CurrentTokenType == JsonToken.Null)
+ context.Read(ref reader);
+ if (context.CurrentTokenType == JsonTokenType.Null)
return null;
int targetDepth = context.CurrentDepth;
- while (context.ReadAtDepth(targetDepth))
+ while (context.ReadAtDepth(targetDepth, ref reader))
{
<#
}
@@ -87,7 +77,7 @@ namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
if (context.TestExpression("<#=member.MarshallName#>", targetDepth))
{
var unmarshaller = <#= member.DetermineTypeUnmarshallerInstantiate() #>;
- unmarshalledObject.<#=member.PropertyName#> = unmarshaller.Unmarshall(context);
+ unmarshalledObject.<#=member.PropertyName#> = unmarshaller.Unmarshall(context, ref reader);
continue;
}
<#
diff --git a/generator/ServiceClientGeneratorLib/Generators/Marshallers/RestXmlExceptionUnmarshaller.cs b/generator/ServiceClientGeneratorLib/Generators/Marshallers/RestXmlExceptionUnmarshaller.cs
index 7f4188e6d184..516fcc2b4f42 100644
--- a/generator/ServiceClientGeneratorLib/Generators/Marshallers/RestXmlExceptionUnmarshaller.cs
+++ b/generator/ServiceClientGeneratorLib/Generators/Marshallers/RestXmlExceptionUnmarshaller.cs
@@ -18,7 +18,7 @@ namespace ServiceClientGenerator.Generators.Marshallers
/// Class to produce the template output
///
- #line 1 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
+ #line 1 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")]
public partial class RestXmlExceptionUnmarshaller : BaseResponseUnmarshaller
{
@@ -29,7 +29,7 @@ public partial class RestXmlExceptionUnmarshaller : BaseResponseUnmarshaller
public override string TransformText()
{
- #line 6 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
+ #line 6 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
AddLicenseHeader();
@@ -40,7 +40,7 @@ public override string TransformText()
#line hidden
this.Write("\r\n#pragma warning disable CS0612,CS0618\r\nnamespace ");
- #line 13 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
+ #line 13 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Config.Namespace));
#line default
@@ -48,21 +48,21 @@ public override string TransformText()
this.Write(".Model.Internal.MarshallTransformations\r\n{\r\n /// \r\n /// Response U" +
"nmarshaller for ");
- #line 16 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
+ #line 16 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
#line default
#line hidden
this.Write(" operation\r\n /// \r\n public class ");
- #line 18 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
+ #line 18 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
#line default
#line hidden
- this.Write("Unmarshaller : IErrorResponseUnmarshaller<");
+ this.Write("Unmarshaller : IXmlErrorResponseUnmarshaller<");
- #line 18 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
+ #line 18 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
#line default
@@ -72,7 +72,7 @@ public override string TransformText()
"\n /// \r\n /// \r\n " +
" public ");
- #line 25 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
+ #line 25 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
#line default
@@ -90,7 +90,7 @@ public override string TransformText()
///
public ");
- #line 36 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
+ #line 36 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
#line default
@@ -98,14 +98,14 @@ public override string TransformText()
this.Write(" Unmarshall(XmlUnmarshallerContext context, Amazon.Runtime.Internal.ErrorResponse" +
" errorResponse)\r\n {\r\n ");
- #line 38 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
+ #line 38 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
#line default
#line hidden
this.Write(" response = new ");
- #line 38 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
+ #line 38 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
#line default
@@ -119,7 +119,7 @@ public override string TransformText()
{
");
- #line 45 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
+ #line 45 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
foreach (var member in this.Structure.Members)
{
@@ -132,56 +132,56 @@ public override string TransformText()
#line hidden
this.Write(" if (context.TestExpression(\"");
- #line 52 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
+ #line 52 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallName));
#line default
#line hidden
this.Write("/");
- #line 52 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
+ #line 52 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(listMarshallName));
#line default
#line hidden
this.Write("\"))\r\n {\r\n var unmarshaller = ");
- #line 54 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
+ #line 54 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.DetermineTypeUnmarshallerInstantiate()));
#line default
#line hidden
this.Write(";\r\n if (response.");
- #line 55 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
+ #line 55 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName));
#line default
#line hidden
this.Write(" == null)\r\n {\r\n response.");
- #line 57 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
+ #line 57 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName));
#line default
#line hidden
this.Write(" = new ");
- #line 57 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
+ #line 57 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.DetermineType()));
#line default
#line hidden
this.Write("();\r\n }\r\n response.");
- #line 59 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
+ #line 59 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName));
#line default
#line hidden
this.Write(".Add(unmarshaller.Unmarshall(context));\r\n }\r\n");
- #line 61 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
+ #line 61 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
}
else
@@ -192,28 +192,28 @@ public override string TransformText()
#line hidden
this.Write(" if (context.TestExpression(\"");
- #line 66 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
+ #line 66 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallName));
#line default
#line hidden
this.Write("\"))\r\n {\r\n var unmarshaller = ");
- #line 68 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
+ #line 68 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.DetermineTypeUnmarshallerInstantiate()));
#line default
#line hidden
this.Write(";\r\n response.");
- #line 69 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
+ #line 69 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName));
#line default
#line hidden
this.Write(" = unmarshaller.Unmarshall(context);\r\n }\r\n");
- #line 71 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
+ #line 71 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
}
}
@@ -223,7 +223,7 @@ public override string TransformText()
#line hidden
this.Write(" }\r\n }\r\n return response;\r\n }\r\n\r\n");
- #line 80 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
+ #line 80 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
this.AddStructureSingletonMethod();
diff --git a/generator/ServiceClientGeneratorLib/Generators/Marshallers/RestXmlExceptionUnmarshaller.tt b/generator/ServiceClientGeneratorLib/Generators/Marshallers/RestXmlExceptionUnmarshaller.tt
index 07d55b10dca8..6c8ce78f5466 100644
--- a/generator/ServiceClientGeneratorLib/Generators/Marshallers/RestXmlExceptionUnmarshaller.tt
+++ b/generator/ServiceClientGeneratorLib/Generators/Marshallers/RestXmlExceptionUnmarshaller.tt
@@ -15,7 +15,7 @@ namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
///
/// Response Unmarshaller for <#=this.UnmarshallerBaseName #> operation
///
- public class <#=this.UnmarshallerBaseName #>Unmarshaller : IErrorResponseUnmarshaller<<#=this.UnmarshallerBaseName #>, XmlUnmarshallerContext>
+ public class <#=this.UnmarshallerBaseName #>Unmarshaller : IXmlErrorResponseUnmarshaller<<#=this.UnmarshallerBaseName #>, XmlUnmarshallerContext>
{
///
/// Unmarshaller the response from the service to the response class.
diff --git a/generator/ServiceClientGeneratorLib/Generators/Marshallers/RestXmlResponseUnmarshaller.cs b/generator/ServiceClientGeneratorLib/Generators/Marshallers/RestXmlResponseUnmarshaller.cs
index 9fb648ede0a3..74ab4807fd95 100644
--- a/generator/ServiceClientGeneratorLib/Generators/Marshallers/RestXmlResponseUnmarshaller.cs
+++ b/generator/ServiceClientGeneratorLib/Generators/Marshallers/RestXmlResponseUnmarshaller.cs
@@ -581,7 +581,7 @@ public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext conte
///
public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
{
- ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);
+ ErrorResponse errorResponse = XmlErrorResponseUnmarshaller.GetInstance().Unmarshall(context);
errorResponse.InnerException = innerException;
errorResponse.StatusCode = statusCode;
diff --git a/generator/ServiceClientGeneratorLib/Generators/Marshallers/RestXmlResponseUnmarshaller.tt b/generator/ServiceClientGeneratorLib/Generators/Marshallers/RestXmlResponseUnmarshaller.tt
index e473947324a2..a5b3af7512b1 100644
--- a/generator/ServiceClientGeneratorLib/Generators/Marshallers/RestXmlResponseUnmarshaller.tt
+++ b/generator/ServiceClientGeneratorLib/Generators/Marshallers/RestXmlResponseUnmarshaller.tt
@@ -246,7 +246,7 @@ namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
///
public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
{
- ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);
+ ErrorResponse errorResponse = XmlErrorResponseUnmarshaller.GetInstance().Unmarshall(context);
errorResponse.InnerException = innerException;
errorResponse.StatusCode = statusCode;
diff --git a/generator/ServiceClientGeneratorLib/Generators/Marshallers/RestXmlStructureUnmarshaller.cs b/generator/ServiceClientGeneratorLib/Generators/Marshallers/RestXmlStructureUnmarshaller.cs
index 42e69ac2f4d0..edb58da33d98 100644
--- a/generator/ServiceClientGeneratorLib/Generators/Marshallers/RestXmlStructureUnmarshaller.cs
+++ b/generator/ServiceClientGeneratorLib/Generators/Marshallers/RestXmlStructureUnmarshaller.cs
@@ -60,24 +60,17 @@ public override string TransformText()
#line default
#line hidden
- this.Write("Unmarshaller : IUnmarshaller<");
+ this.Write("Unmarshaller : IXmlUnmarshaller<");
#line 18 "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 18 "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(", JsonUnmarshallerContext>\r\n {\r\n /// \r\n /// Unmarshalle" +
- "r the response from the service to the response class.\r\n /// " +
- "\r\n /// \r\n /// \r\n " +
- " public ");
+ this.Write(", XmlUnmarshallerContext>\r\n {\r\n /// \r\n /// Unmarshaller" +
+ " the response from the service to the response class.\r\n /// \r" +
+ "\n /// \r\n /// \r\n " +
+ " public ");
#line 25 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
@@ -321,23 +314,9 @@ public override string TransformText()
}
return unmarshalledObject;
}
-
- ///
- /// Unmarshaller the response from the service to the response class.
- ///
- ///
- ///
- public ");
-
- #line 128 "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 133 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
+ #line 122 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlStructureUnmarshaller.tt"
this.AddStructureSingletonMethod();
diff --git a/generator/ServiceClientGeneratorLib/Generators/Marshallers/RestXmlStructureUnmarshaller.tt b/generator/ServiceClientGeneratorLib/Generators/Marshallers/RestXmlStructureUnmarshaller.tt
index 4dd4fe8f796f..1cc56dbbf1de 100644
--- a/generator/ServiceClientGeneratorLib/Generators/Marshallers/RestXmlStructureUnmarshaller.tt
+++ b/generator/ServiceClientGeneratorLib/Generators/Marshallers/RestXmlStructureUnmarshaller.tt
@@ -15,7 +15,7 @@ namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
///
/// Response Unmarshaller for <#=this.UnmarshallerBaseName #> Object
///
- public class <#=this.UnmarshallerBaseName #>Unmarshaller : IUnmarshaller<<#=this.UnmarshallerBaseName #>, XmlUnmarshallerContext>, IUnmarshaller<<#=this.UnmarshallerBaseName #>, JsonUnmarshallerContext>
+ public class <#=this.UnmarshallerBaseName #>Unmarshaller : IXmlUnmarshaller<<#=this.UnmarshallerBaseName #>, XmlUnmarshallerContext>
{
///
/// Unmarshaller the response from the service to the response class.
@@ -119,17 +119,6 @@ namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
}
return unmarshalledObject;
}
-
- ///
- /// Unmarshaller the response from the service to the response class.
- ///
- ///
- ///
- public <#=this.UnmarshallerBaseName #> Unmarshall(JsonUnmarshallerContext context)
- {
- throw new NotImplementedException();
- }
-
<#
this.AddStructureSingletonMethod();
#>
diff --git a/generator/ServiceClientGeneratorLib/Generators/SourceFiles/EventStreamGenerator.cs b/generator/ServiceClientGeneratorLib/Generators/SourceFiles/EventStreamGenerator.cs
index ecc5b4f08fee..60f64abc0828 100644
--- a/generator/ServiceClientGeneratorLib/Generators/SourceFiles/EventStreamGenerator.cs
+++ b/generator/ServiceClientGeneratorLib/Generators/SourceFiles/EventStreamGenerator.cs
@@ -18,7 +18,7 @@ namespace ServiceClientGenerator.Generators.SourceFiles
/// Class to produce the template output
///
- #line 1 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ #line 1 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")]
public partial class EventStreamGenerator : StructureGenerator
{
@@ -29,7 +29,7 @@ public partial class EventStreamGenerator : StructureGenerator
public override string TransformText()
{
- #line 6 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ #line 6 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
bool isRequest = this.Operation.RequestStructure.Members.Any(x => x.ModelShape.MarshallName == this.Structure.Name);
bool isResponse = this.Operation.ResponseStructure.Members.Any(x => x.ModelShape.MarshallName == this.Structure.Name);
@@ -40,7 +40,7 @@ public override string TransformText()
this.Write(" [System.Diagnostics.CodeAnalysis.SuppressMessage(\"Naming\", \"CA1710:Identifier" +
"s should have correct suffix\", Justification = \"");
- #line 10 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ #line 10 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Structure.Name));
#line default
@@ -49,14 +49,14 @@ public override string TransformText()
[System.Diagnostics.CodeAnalysis.SuppressMessage(""Microsoft.Design"", ""CA1063"", Justification = ""IDisposable is a transient interface from IEventStream. Users need to be able to call Dispose."")]
public sealed class ");
- #line 12 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ #line 12 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Structure.Name));
#line default
#line hidden
this.Write(" : EnumerableEventStream new InitialResponseEvent(payload)},\r\n" +
"");
- #line 36 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ #line 36 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
}
@@ -106,7 +106,7 @@ public sealed class ");
#line default
#line hidden
- #line 39 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ #line 39 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
else if(isRequest)
{
@@ -116,7 +116,7 @@ public sealed class ");
#line hidden
this.Write(" {\"Initial-Request\", payload => new InitialRequestEvent(payload)},\r\n");
- #line 44 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ #line 44 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
}
@@ -124,41 +124,76 @@ public sealed class ");
#line default
#line hidden
- #line 47 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ #line 47 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
foreach(var member in this.Structure.Members)
{
- if(member.ModelShape.IsEvent)
+ if(member.ModelShape.IsEvent)
{
+ if (protocol == "Json")
+ {
#line default
#line hidden
this.Write(" {\"");
- #line 53 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ #line 55 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName));
#line default
#line hidden
- this.Write("\", payload => new ");
+ this.Write("\", payload => \r\n {\r\n var context = EventStreamU" +
+ "tils.ConvertMessageTo");
+
+ #line 57 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(protocol));
+
+ #line default
+ #line hidden
+ this.Write("Context(payload);\r\n var reader = new StreamingUtf8JsonReader(c" +
+ "ontext.Stream);\r\n return new ");
- #line 53 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ #line 59 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.DetermineType()));
#line default
#line hidden
- this.Write("Unmarshaller().Unmarshall(EventStreamUtils.ConvertMessageTo");
+ this.Write("Unmarshaller().Unmarshall(context, ref reader);\r\n }\r\n }" +
+ ",\r\n");
- #line 53 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
- this.Write(this.ToStringHelper.ToStringWithCulture(protocol));
+ #line 62 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+
+ }
+ else if (protocol == "Xml")
+ {
+
+
+ #line default
+ #line hidden
+ this.Write(" {\"");
+
+ #line 67 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName));
#line default
#line hidden
- this.Write("Context(payload))},\r\n");
+ this.Write("\", payload => new ");
+
+ #line 67 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(member.DetermineType()));
- #line 54 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ #line default
+ #line hidden
+ this.Write("Unmarshaller().Unmarshall(context);},\r\n");
+
+ #line 68 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ }
+ else
+ {
+ throw new NotImplementedException("The given protocol is not supported");
+ }
}
}
@@ -170,7 +205,7 @@ public sealed class ");
"\r\n protected override IDictionary> ExceptionMapping {get;} =\r\n new Dictionary>(StringComparer.OrdinalIgnoreCase)\r\n {\r\n");
- #line 65 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ #line 84 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
foreach(var member in this.Structure.Members)
{
if(member.ModelShape.IsException)
{
+ if (protocol == "Json")
+ {
+
+
+ #line default
+ #line hidden
+ this.Write(" {\"");
+
+ #line 92 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName));
+
+ #line default
+ #line hidden
+ this.Write("\", payload => \r\n {\r\n var contex" +
+ "t = EventStreamUtils.ConvertMessageTo");
+
+ #line 94 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(protocol));
+
+ #line default
+ #line hidden
+ this.Write("Context(payload);\r\n var reader = new StreamingUtf8Json" +
+ "Reader(context.Stream);\r\n return new ");
+
+ #line 96 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(this.Config.ClassName));
+
+ #line default
+ #line hidden
+ this.Write("EventStreamException(Encoding.UTF8.GetString(payload.Payload), new ");
+
+ #line 96 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(member.ModelShape));
+
+ #line default
+ #line hidden
+ this.Write("Unmarshaller().Unmarshall(context, ref reader));\r\n }\r\n " +
+ " },\r\n");
+
+ #line 99 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+
+ }
+ else if (protocol == "Xml")
+ {
#line default
#line hidden
this.Write(" { \"");
- #line 71 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ #line 104 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName));
#line default
#line hidden
this.Write("\", payload => new ");
- #line 71 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ #line 104 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Config.ClassName));
#line default
#line hidden
this.Write("EventStreamException(Encoding.UTF8.GetString(payload.Payload), new ");
- #line 71 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ #line 104 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.ModelShape));
#line default
#line hidden
this.Write("Unmarshaller().Unmarshall(EventStreamUtils.ConvertMessageTo");
- #line 71 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ #line 104 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(protocol));
#line default
#line hidden
this.Write("Context(payload))) },\r\n");
- #line 72 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ #line 105 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ }
+ else
+ throw new NotImplementedException("The given protocol is not supported");
}
}
@@ -257,14 +339,14 @@ protected override bool IsProcessing
///
public override event EventHandler> ExceptionReceived;\r\n");
- #line 99 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ #line 135 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
if(isResponse)
{
@@ -276,7 +358,7 @@ protected override bool IsProcessing
"/summary>\r\n public event EventHandler> InitialResponseReceived;\r\n");
- #line 107 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ #line 143 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
}
else if(isRequest)
@@ -289,7 +371,7 @@ protected override bool IsProcessing
"summary>\r\n public event EventHandler> InitialRequestReceived;\r\n");
- #line 116 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ #line 152 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
}
@@ -297,7 +379,7 @@ protected override bool IsProcessing
#line default
#line hidden
- #line 119 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ #line 155 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
foreach(var member in this.Structure.Members)
{
@@ -309,7 +391,7 @@ protected override bool IsProcessing
#line hidden
this.Write(" ///\r\n ///Raised when an ");
- #line 126 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ #line 162 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName));
#line default
@@ -317,21 +399,21 @@ protected override bool IsProcessing
this.Write(" event is received\r\n ///\r\n public event EventHandler> ");
- #line 128 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ #line 164 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName));
#line default
#line hidden
this.Write("Received;\r\n");
- #line 129 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ #line 165 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
}
@@ -339,7 +421,7 @@ protected override bool IsProcessing
#line default
#line hidden
- #line 132 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ #line 168 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
}
@@ -349,7 +431,7 @@ protected override bool IsProcessing
this.Write("\r\n /// \r\n /// Construct an instance\r\n /// \r\n /// \r\n public ");
- #line 140 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ #line 176 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Structure.Name));
#line default
@@ -365,7 +447,7 @@ protected override bool IsProcessing
///
public ");
- #line 149 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ #line 185 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Structure.Name));
#line default
@@ -394,7 +476,7 @@ protected override bool IsProcessing
var _ =
");
- #line 171 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ #line 207 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
if(isResponse)
@@ -403,7 +485,7 @@ protected override bool IsProcessing
#line hidden
this.Write(" RaiseEvent(InitialResponseReceived, ev) ||\r\n");
- #line 175 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ #line 211 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
else if(isRequest)
@@ -412,7 +494,7 @@ protected override bool IsProcessing
#line hidden
this.Write(" RaiseEvent(InitialRequestReceived,ev) ||\r\n");
- #line 179 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ #line 215 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
var eventMembers = this.Structure.Members.Where(m => m.ModelShape.IsEvent).ToArray();
@@ -424,14 +506,14 @@ protected override bool IsProcessing
#line hidden
this.Write(" RaiseEvent(");
- #line 185 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ #line 221 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(eventMembers[0].PropertyName));
#line default
#line hidden
this.Write("Received,ev);\r\n");
- #line 186 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ #line 222 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
}
else if (eventMembers.Length > 1)
@@ -444,14 +526,14 @@ protected override bool IsProcessing
#line hidden
this.Write(" RaiseEvent(");
- #line 193 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ #line 229 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(eventMembers[i].PropertyName));
#line default
#line hidden
this.Write("Received,ev) ||\r\n");
- #line 194 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ #line 230 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
}
@@ -460,14 +542,14 @@ protected override bool IsProcessing
#line hidden
this.Write(" RaiseEvent(");
- #line 197 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ #line 233 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(eventMembers.Last().PropertyName));
#line default
#line hidden
this.Write("Received,ev);\r\n");
- #line 198 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
+ #line 234 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamGenerator.tt"
}
diff --git a/generator/ServiceClientGeneratorLib/Generators/SourceFiles/EventStreamGenerator.tt b/generator/ServiceClientGeneratorLib/Generators/SourceFiles/EventStreamGenerator.tt
index f0898a735b8e..ae8709b6b001 100644
--- a/generator/ServiceClientGeneratorLib/Generators/SourceFiles/EventStreamGenerator.tt
+++ b/generator/ServiceClientGeneratorLib/Generators/SourceFiles/EventStreamGenerator.tt
@@ -47,11 +47,30 @@
<#
foreach(var member in this.Structure.Members)
{
- if(member.ModelShape.IsEvent)
+ if(member.ModelShape.IsEvent)
{
+ if (protocol == "Json")
+ {
#>
- {"<#=member.PropertyName#>", payload => new <#=member.DetermineType()#>Unmarshaller().Unmarshall(EventStreamUtils.ConvertMessageTo<#=protocol#>Context(payload))},
+ {"<#=member.PropertyName#>", payload =>
+ {
+ var context = EventStreamUtils.ConvertMessageTo<#=protocol#>Context(payload);
+ var reader = new StreamingUtf8JsonReader(context.Stream);
+ return new <#=member.DetermineType()#>Unmarshaller().Unmarshall(context, ref reader);
+ }
+ },
<#
+ }
+ else if (protocol == "Xml")
+ {
+#>
+ {"<#=member.PropertyName#>", payload => new <#=member.DetermineType()#>Unmarshaller().Unmarshall(context);},
+<#
+ }
+ else
+ {
+ throw new NotImplementedException("The given protocol is not supported");
+ }
}
}
#>
@@ -67,9 +86,26 @@
{
if(member.ModelShape.IsException)
{
+ if (protocol == "Json")
+ {
+#>
+ {"<#=member.PropertyName#>", payload =>
+ {
+ var context = EventStreamUtils.ConvertMessageTo<#=protocol#>Context(payload);
+ var reader = new StreamingUtf8JsonReader(context.Stream);
+ return new <#=this.Config.ClassName#>EventStreamException(Encoding.UTF8.GetString(payload.Payload), new <#=member.ModelShape#>Unmarshaller().Unmarshall(context, ref reader));
+ }
+ },
+<#
+ }
+ else if (protocol == "Xml")
+ {
#>
{ "<#=member.PropertyName#>", payload => new <#=this.Config.ClassName#>EventStreamException(Encoding.UTF8.GetString(payload.Payload), new <#=member.ModelShape#>Unmarshaller().Unmarshall(EventStreamUtils.ConvertMessageTo<#=protocol#>Context(payload))) },
<#
+ }
+ else
+ throw new NotImplementedException("The given protocol is not supported");
}
}
#>
diff --git a/generator/ServiceClientGeneratorLib/Generators/SourceFiles/StructureGenerator.cs b/generator/ServiceClientGeneratorLib/Generators/SourceFiles/StructureGenerator.cs
index e2d4572a6af7..e47f73e6b866 100644
--- a/generator/ServiceClientGeneratorLib/Generators/SourceFiles/StructureGenerator.cs
+++ b/generator/ServiceClientGeneratorLib/Generators/SourceFiles/StructureGenerator.cs
@@ -79,9 +79,9 @@ public override string TransformText()
#line default
#line hidden
this.Write(".Model.Internal.MarshallTransformations;\r\nusing Amazon.Runtime.EventStreams.Utils" +
- ";\r\n");
+ ";\r\nusing Amazon.Runtime.Internal.Util;\r\n");
- #line 38 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 39 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
}
@@ -90,14 +90,14 @@ public override string TransformText()
#line hidden
this.Write("\r\n#pragma warning disable CS0612,CS0618,CS1570\r\nnamespace ");
- #line 43 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 44 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Config.Namespace));
#line default
#line hidden
this.Write(".Model\r\n{\r\n");
- #line 45 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 46 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
if(this.StructureType == StructureType.Request)
this.FormatOperationRequestDocumentation(this.Operation);
@@ -111,14 +111,14 @@ public override string TransformText()
#line hidden
this.Write(" /// \r\n /// This is the response object from the ");
- #line 54 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 55 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Operation.Name));
#line default
#line hidden
this.Write(" operation.\r\n /// \r\n");
- #line 56 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 57 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
}
else
@@ -128,7 +128,7 @@ public override string TransformText()
#line default
#line hidden
- #line 61 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 62 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
if(this.Structure != null && this.Structure.IsDeprecated)
{
@@ -138,14 +138,14 @@ public override string TransformText()
#line hidden
this.Write(" [Obsolete(\"");
- #line 65 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 66 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Structure.DeprecationMessage));
#line default
#line hidden
this.Write("\")]\r\n");
- #line 66 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 67 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
}
if(this.Structure is ExceptionShape)
@@ -156,7 +156,7 @@ public override string TransformText()
#line hidden
this.Write(" #if !NETSTANDARD\r\n [Serializable]\r\n #endif\r\n");
- #line 74 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 75 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
}
@@ -164,7 +164,7 @@ public override string TransformText()
#line default
#line hidden
- #line 77 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 78 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
if(this.Structure != null && this.Structure.IsEventStream)
@@ -181,14 +181,14 @@ public override string TransformText()
#line hidden
this.Write(" ");
- #line 88 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 89 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(EventStreamOutput));
#line default
#line hidden
this.Write("\r\n");
- #line 89 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 90 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
}
@@ -196,7 +196,7 @@ public override string TransformText()
#line default
#line hidden
- #line 92 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 93 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
bool hasStreamingMember = this.Structure?.Members.Any(member => member.Shape.IsStreaming) ?? false;
@@ -214,20 +214,20 @@ public override string TransformText()
#line hidden
this.Write(" public partial class ");
- #line 104 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 105 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.ClassName));
#line default
#line hidden
- #line 104 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 105 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.BaseClassString));
#line default
#line hidden
this.Write(", IDisposable\r\n {\r\n");
- #line 106 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 107 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
}
else
@@ -237,7 +237,7 @@ public override string TransformText()
#line default
#line hidden
- #line 111 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 112 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
if( (this.Structure == null) || (structureIsNotEventStream))
{
@@ -247,20 +247,20 @@ public override string TransformText()
#line hidden
this.Write(" public partial class ");
- #line 115 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 116 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.ClassName));
#line default
#line hidden
- #line 115 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 116 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.BaseClassString));
#line default
#line hidden
this.Write("\r\n");
- #line 116 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 117 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
if(structureIsEvent)
{
@@ -270,7 +270,7 @@ public override string TransformText()
#line hidden
this.Write(" : IEventStreamEvent\r\n");
- #line 121 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 122 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
}
@@ -279,7 +279,7 @@ public override string TransformText()
#line hidden
this.Write(" {\r\n");
- #line 125 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 126 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
}
@@ -287,7 +287,7 @@ public override string TransformText()
#line default
#line hidden
- #line 128 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 129 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
}
@@ -295,7 +295,7 @@ public override string TransformText()
#line default
#line hidden
- #line 131 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 132 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
if(structureIsNotEventStream)
{
@@ -307,28 +307,28 @@ public override string TransformText()
#line hidden
this.Write(" private ");
- #line 137 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 138 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Structure.Name));
#line default
#line hidden
this.Write(" _response;\r\n\r\n /// \r\n /// Gets and sets the ");
- #line 140 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 141 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Structure.Name));
#line default
#line hidden
this.Write(" property.\r\n /// \r\n public ");
- #line 142 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 143 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Structure.Name));
#line default
#line hidden
this.Write(" ");
- #line 142 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 143 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Structure.Name));
#line default
@@ -336,7 +336,7 @@ public override string TransformText()
this.Write("\r\n {\r\n get { return this._response; }\r\n set { this._" +
"response = value; }\r\n }\r\n");
- #line 147 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 148 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
}
else
@@ -359,27 +359,27 @@ public override string TransformText()
#line hidden
this.Write(" private ");
- #line 164 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 165 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.DetermineType()));
#line default
#line hidden
this.Write(" ");
- #line 164 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 165 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.VariableName));
#line default
#line hidden
- #line 164 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 165 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.IsCollection ? string.Format(" = AWSConfigs.InitializeCollections ? new {0}() : null;", member.DetermineType()) : ";"));
#line default
#line hidden
this.Write("\r\n");
- #line 165 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 166 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
}
@@ -388,7 +388,7 @@ public override string TransformText()
#line hidden
this.Write("\r\n");
- #line 169 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 170 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
AddSimpleRequestConstructors(this.ClassName, this.Structure, this.Config.Namespace);
@@ -403,14 +403,14 @@ public override string TransformText()
#line hidden
this.Write(" private RetryableDetails _retryableDetails = new RetryableDetails(");
- #line 178 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 179 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(exceptionShape.Throttling.ToString().ToLower()));
#line default
#line hidden
this.Write(");\r\n");
- #line 179 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 180 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
@@ -418,7 +418,7 @@ public override string TransformText()
#line hidden
this.Write("\r\n");
- #line 182 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 183 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
}
@@ -645,7 +645,7 @@ public override void GetObjectData(System.Runtime.Serialization.SerializationInf
this.Write(" }\r\n#endif\r\n");
this.Write("\r\n");
- #line 187 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 188 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
}
foreach(var member in this.Structure.Members)
@@ -665,13 +665,13 @@ public override void GetObjectData(System.Runtime.Serialization.SerializationInf
#line default
#line hidden
- #line 202 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 203 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.FormatPropertyDocumentation(member);
#line default
#line hidden
- #line 203 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 204 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
if(member.IsDeprecated)
{
@@ -681,14 +681,14 @@ public override void GetObjectData(System.Runtime.Serialization.SerializationInf
#line hidden
this.Write(" [Obsolete(\"");
- #line 207 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 208 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.DeprecationMessage));
#line default
#line hidden
this.Write("\")]\r\n");
- #line 208 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 209 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
}
@@ -717,14 +717,14 @@ public override void GetObjectData(System.Runtime.Serialization.SerializationInf
#line hidden
this.Write(" [AWSProperty(");
- #line 231 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 232 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(string.Join(", ", propertyAttributes)));
#line default
#line hidden
this.Write(")]\r\n");
- #line 232 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 233 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
}
@@ -736,48 +736,55 @@ public override void GetObjectData(System.Runtime.Serialization.SerializationInf
#line hidden
this.Write(" ");
- #line 238 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 239 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.AccessModifier));
#line default
#line hidden
this.Write(" ");
- #line 238 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 239 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName.Equals("Equals") || (this.Structure is ExceptionShape && member.PropertyName.Equals("Retryable")) ? "new " : ""));
#line default
#line hidden
- #line 238 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 239 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.DetermineType()));
#line default
#line hidden
this.Write(" ");
- #line 238 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 239 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName));
#line default
#line hidden
this.Write("\r\n {\r\n get { return this.");
- #line 240 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 241 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.VariableName));
#line default
#line hidden
this.Write("; }\r\n set { this.");
- #line 241 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 242 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(member.IsBackwardsCompatibleDateTimeProperty ? "this." + member.BackwardCompatibilityVariableName + " = " : ""));
+
+ #line default
+ #line hidden
+ this.Write("this.");
+
+ #line 242 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.VariableName));
#line default
#line hidden
this.Write(" = value; }\r\n }\r\n\r\n");
- #line 244 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 245 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
if (member.EmitIsSetProperties)
{
@@ -788,7 +795,7 @@ public override void GetObjectData(System.Runtime.Serialization.SerializationInf
this.Write(" /// \r\n /// This property is set to true if the property <" +
"seealso cref=\"");
- #line 249 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 250 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName));
#line default
@@ -804,7 +811,7 @@ public override void GetObjectData(System.Runtime.Serialization.SerializationInf
///
");
- #line 258 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 259 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
if(member.IsDeprecated)
{
@@ -814,14 +821,14 @@ public override void GetObjectData(System.Runtime.Serialization.SerializationInf
#line hidden
this.Write(" [Obsolete(\"");
- #line 262 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 263 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.DeprecationMessage));
#line default
#line hidden
this.Write("\")]\r\n");
- #line 263 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 264 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
}
@@ -830,7 +837,7 @@ public override void GetObjectData(System.Runtime.Serialization.SerializationInf
#line hidden
this.Write(" public bool Is");
- #line 266 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 267 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName));
#line default
@@ -838,7 +845,7 @@ public override void GetObjectData(System.Runtime.Serialization.SerializationInf
this.Write("Set\r\n {\r\n get\r\n {\r\n return Amazon.Uti" +
"l.Internal.InternalSDKUtils.GetIsSet(this.");
- #line 270 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 271 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.VariableName));
#line default
@@ -846,14 +853,41 @@ public override void GetObjectData(System.Runtime.Serialization.SerializationInf
this.Write(");\r\n }\r\n set\r\n {\r\n Amazon.Util.In" +
"ternal.InternalSDKUtils.SetIsSet(value, ref this.");
- #line 274 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 275 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.VariableName));
#line default
#line hidden
this.Write(");\r\n }\r\n }\r\n\r\n");
- #line 278 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 276 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+
+ if(member.IsBackwardsCompatibleDateTimeProperty)
+ {
+
+
+ #line default
+ #line hidden
+ this.Write(" \r\n Amazon.Util.Internal.InternalSDKUtils.SetIsSet(value, ref thi" +
+ "s.");
+
+ #line 280 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(member.BackwardCompatibilityVariableName));
+
+ #line default
+ #line hidden
+ this.Write(");\r\n");
+
+ #line 281 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+
+ }
+
+
+ #line default
+ #line hidden
+ this.Write(" }\r\n }\r\n\r\n");
+
+ #line 287 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
}
@@ -862,21 +896,21 @@ public override void GetObjectData(System.Runtime.Serialization.SerializationInf
#line hidden
this.Write(" // Check to see if ");
- #line 281 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 290 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName));
#line default
#line hidden
this.Write(" property is set\r\n internal bool IsSet");
- #line 282 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 291 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName));
#line default
#line hidden
this.Write("()\r\n {\r\n");
- #line 284 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 293 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
if (member.EmitIsSetProperties)
{
@@ -886,14 +920,14 @@ public override void GetObjectData(System.Runtime.Serialization.SerializationInf
#line hidden
this.Write(" return this.Is");
- #line 288 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 297 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName));
#line default
#line hidden
this.Write("Set; \r\n");
- #line 289 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 298 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
}
else if (member.IsNullable)
@@ -904,14 +938,14 @@ public override void GetObjectData(System.Runtime.Serialization.SerializationInf
#line hidden
this.Write(" return this.");
- #line 294 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 303 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.VariableName));
#line default
#line hidden
this.Write(".HasValue; \r\n");
- #line 295 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 304 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
}
else if (member.IsList && (member.MarshallLocation == MarshallLocation.Header || member.MarshallLocation == MarshallLocation.Headers))
@@ -924,21 +958,21 @@ public override void GetObjectData(System.Runtime.Serialization.SerializationInf
#line hidden
this.Write(" return this.");
- #line 302 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 311 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.VariableName));
#line default
#line hidden
this.Write(" != null && this.");
- #line 302 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 311 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.VariableName));
#line default
#line hidden
this.Write(".Count > 0;\r\n");
- #line 303 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 312 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
}
else if (member.IsMap || member.IsList)
@@ -949,21 +983,21 @@ public override void GetObjectData(System.Runtime.Serialization.SerializationInf
#line hidden
this.Write(" return this.");
- #line 308 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 317 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.VariableName));
#line default
#line hidden
this.Write(" != null && (this.");
- #line 308 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 317 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.VariableName));
#line default
#line hidden
this.Write(".Count > 0 || !AWSConfigs.InitializeCollections); \r\n");
- #line 309 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 318 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
}
else if (member.IsDocument)
@@ -974,14 +1008,14 @@ public override void GetObjectData(System.Runtime.Serialization.SerializationInf
#line hidden
this.Write(" return !this.");
- #line 314 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 323 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.VariableName));
#line default
#line hidden
this.Write(".IsNull();\r\n");
- #line 315 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 324 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
}
else
@@ -996,14 +1030,14 @@ public override void GetObjectData(System.Runtime.Serialization.SerializationInf
#line hidden
this.Write(" return !string.IsNullOrEmpty(this.");
- #line 324 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 333 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.VariableName));
#line default
#line hidden
this.Write(");\r\n");
- #line 325 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 334 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
}
else
@@ -1014,14 +1048,14 @@ public override void GetObjectData(System.Runtime.Serialization.SerializationInf
#line hidden
this.Write(" return this.");
- #line 330 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 339 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.VariableName));
#line default
#line hidden
this.Write(" != null;\r\n");
- #line 331 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 340 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
}
}
@@ -1031,7 +1065,7 @@ public override void GetObjectData(System.Runtime.Serialization.SerializationInf
#line hidden
this.Write(" }\r\n\r\n");
- #line 337 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 346 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
}
@@ -1045,7 +1079,7 @@ public override void GetObjectData(System.Runtime.Serialization.SerializationInf
" /// \r\n /// A signer for this request.\r\n " +
" override protected AbstractAWSSigner CreateSigner()\r\n {\r\n");
- #line 349 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 358 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
switch (this.Operation.AuthType.Value)
{
@@ -1056,7 +1090,7 @@ public override void GetObjectData(System.Runtime.Serialization.SerializationInf
#line hidden
this.Write(" return new NullSigner();\r\n");
- #line 355 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 364 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
break;
case OperationAuthType.V4:
@@ -1066,7 +1100,7 @@ public override void GetObjectData(System.Runtime.Serialization.SerializationInf
#line hidden
this.Write(" return new AWS4Signer();\r\n");
- #line 360 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 369 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
break;
case OperationAuthType.V4UnsignedBody:
@@ -1076,7 +1110,7 @@ public override void GetObjectData(System.Runtime.Serialization.SerializationInf
#line hidden
this.Write(" return new AWS4Signer(false);\r\n");
- #line 365 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 374 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
break;
case OperationAuthType.Bearer:
@@ -1086,7 +1120,7 @@ public override void GetObjectData(System.Runtime.Serialization.SerializationInf
#line hidden
this.Write(" return new BearerTokenSigner();\r\n");
- #line 370 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 379 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
break;
default:
@@ -1098,7 +1132,7 @@ public override void GetObjectData(System.Runtime.Serialization.SerializationInf
#line hidden
this.Write(" }\r\n");
- #line 377 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 386 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
}
// Flexible checksum overrides to allow response validation configuration on the request
@@ -1119,7 +1153,7 @@ protected override CoreChecksumResponseBehavior CoreChecksumMode
{
if (IsSet");
- #line 391 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 400 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Operation.ChecksumConfiguration.RequestValidationModeMember));
#line default
@@ -1127,7 +1161,7 @@ protected override CoreChecksumResponseBehavior CoreChecksumMode
this.Write("())\r\n {\r\n return (CoreChecksumResponseBehavior)" +
"Enum.Parse(typeof(CoreChecksumResponseBehavior), this.");
- #line 393 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 402 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Operation.ChecksumConfiguration.RequestValidationModeMember));
#line default
@@ -1137,7 +1171,7 @@ protected override CoreChecksumResponseBehavior CoreChecksumMode
"ithm> _supportedChecksumAlgorithms = new List\r\n {\r" +
"\n ");
- #line 402 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 411 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(string.Join(", ", Operation.ChecksumConfiguration?.ResponseAlgorithms?.Select(s => $"CoreChecksumAlgorithm.{s}").ToArray())));
#line default
@@ -1152,10 +1186,261 @@ protected override CoreChecksumResponseBehavior CoreChecksumMode
#endregion
");
- #line 410 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 419 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
}
+ if (this.Structure.Members.Any(m => !m.IsExcluded && m.IsBackwardsCompatibleDateTimeProperty))
+ {
+
+
+ #line default
+ #line hidden
+ this.Write("#region Backwards compatible properties\r\n");
+
+ #line 426 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+
+ foreach(var member in this.Structure.Members)
+ {
+ if (member.IsExcluded || !member.IsBackwardsCompatibleDateTimeProperty)
+ continue;
+
+
+ #line default
+ #line hidden
+ this.Write(" private ");
+
+ #line 432 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(member.DetermineType()));
+
+ #line default
+ #line hidden
+ this.Write(" ");
+
+ #line 432 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(member.BackwardCompatibilityVariableName));
+
+ #line default
+ #line hidden
+
+ #line 432 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(member.IsCollection ? string.Format(" = AWSConfigs.InitializeCollections ? new {0}() : null;", member.DetermineType()) : ";"));
+
+ #line default
+ #line hidden
+ this.Write("\r\n");
+
+ #line 433 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+
+ }
+
+
+ #line default
+ #line hidden
+ this.Write("\r\n");
+
+ #line 437 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+
+ foreach(var member in this.Structure.Members)
+ {
+ if (member.IsExcluded || !member.IsBackwardsCompatibleDateTimeProperty)
+ continue;
+
+
+ #line default
+ #line hidden
+
+ #line 443 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ this.FormatPropertyDocumentation(member, "This property is deprecated. Setting this property results in non-UTC DateTimes " +
+ "not being marshalled correctly. Use " + member.PropertyName + " instead. Setting either " + member.BackwardCompatibilityPropertyName +
+ " or " + member.PropertyName + " results in both " + member.BackwardCompatibilityPropertyName + " and " +
+ member.PropertyName + " being assigned, the latest assignment to either one of the two property is reflected in " +
+ "the value of both. " + member.BackwardCompatibilityPropertyName + " is provided for backwards compatibility only " +
+ "and assigning a non-Utc DateTime to it results in the wrong timestamp being passed to the service.");
+
+ #line default
+ #line hidden
+ this.Write(" [Obsolete(\"Setting this property results in non-UTC DateTimes not being m" +
+ "arshalled correctly. \" +\r\n \"Use ");
+
+ #line 450 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName));
+
+ #line default
+ #line hidden
+ this.Write(" instead. Setting either ");
+
+ #line 450 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(member.BackwardCompatibilityPropertyName));
+
+ #line default
+ #line hidden
+ this.Write(" or ");
+
+ #line 450 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName));
+
+ #line default
+ #line hidden
+ this.Write(" results in both ");
+
+ #line 450 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(member.BackwardCompatibilityPropertyName));
+
+ #line default
+ #line hidden
+ this.Write(" and \" +\r\n \"");
+
+ #line 451 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName));
+
+ #line default
+ #line hidden
+ this.Write(" being assigned, the latest assignment to either one of the two property is \" + \r" +
+ "\n \"reflected in the value of both. ");
+
+ #line 452 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(member.BackwardCompatibilityPropertyName));
+
+ #line default
+ #line hidden
+ this.Write(" is provided for backwards compatibility only and \" +\r\n \"assigning a n" +
+ "on-Utc DateTime to it results in the wrong timestamp being passed to the service" +
+ ".\", false)]\r\n ");
+
+ #line 454 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(member.AccessModifier));
+
+ #line default
+ #line hidden
+ this.Write(" ");
+
+ #line 454 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(member.DetermineType()));
+
+ #line default
+ #line hidden
+
+ #line 454 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(member.UseNullable ? "?" : ""));
+
+ #line default
+ #line hidden
+ this.Write(" ");
+
+ #line 454 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(member.BackwardCompatibilityPropertyName));
+
+ #line default
+ #line hidden
+ this.Write("\r\n {\r\n get { return this.");
+
+ #line 456 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(member.BackwardCompatibilityVariableName));
+
+ #line default
+ #line hidden
+ this.Write(".GetValueOrDefault(); }\r\n set\r\n {\r\n this.");
+
+ #line 459 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(member.BackwardCompatibilityVariableName));
+
+ #line default
+ #line hidden
+ this.Write(" = value;\r\n if (value != null)\r\n {\r\n " +
+ " this.");
+
+ #line 462 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(member.VariableName));
+
+ #line default
+ #line hidden
+ this.Write(" = new DateTime(value.Value.Ticks, DateTimeKind.Utc);\r\n }\r\n " +
+ " else\r\n {\r\n this.");
+
+ #line 466 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(member.VariableName));
+
+ #line default
+ #line hidden
+ this.Write(" = null;\r\n }\r\n }\r\n }\r\n");
+
+ #line 470 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+
+ if (member.EmitIsSetProperties)
+ {
+
+
+ #line default
+ #line hidden
+ this.Write(" /// \r\n /// This property is set to true if the property <" +
+ "seealso cref=\"");
+
+ #line 475 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(member.BackwardCompatibilityPropertyName));
+
+ #line default
+ #line hidden
+ this.Write(@"""/>
+ /// is set; false otherwise.
+ /// This property can be used to determine if the related property
+ /// was returned by a service response or if the related property
+ /// should be sent to the service during a service call.
+ ///
+ ///
+ /// True if the related property was set or will be sent to a service; false otherwise.
+ ///
+ [Obsolete(""Setting ");
+
+ #line 484 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(member.BackwardCompatibilityPropertyName));
+
+ #line default
+ #line hidden
+ this.Write(" results in non-UTC DateTimes not being marshalled correctly. Use ");
+
+ #line 484 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName));
+
+ #line default
+ #line hidden
+ this.Write(" instead.\", false)]\r\n public bool Is");
+
+ #line 485 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(member.BackwardCompatibilityPropertyName));
+
+ #line default
+ #line hidden
+ this.Write("Set\r\n {\r\n get\r\n {\r\n return this.Is");
+
+ #line 489 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName));
+
+ #line default
+ #line hidden
+ this.Write("Set;\r\n }\r\n set\r\n {\r\n this.Is");
+
+ #line 493 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName));
+
+ #line default
+ #line hidden
+ this.Write("Set = value;;\r\n }\r\n }\r\n");
+
+ #line 496 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+
+ }
+ }
+
+
+
+ #line default
+ #line hidden
+ this.Write("#endregion\r\n");
+
+ #line 502 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+
+ }
if (this.Structure is ExceptionShape)
{
var exceptionShape = (ExceptionShape)this.Structure;
@@ -1178,7 +1463,7 @@ public override RetryableDetails Retryable
}
");
- #line 430 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 521 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
}
}
@@ -1193,7 +1478,7 @@ public override RetryableDetails Retryable
#line hidden
this.Write("\r\n");
- #line 440 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 531 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
}
if (this.StructureType == StructureType.Response && hasStreamingMember)
@@ -1227,7 +1512,7 @@ protected virtual void Dispose(bool disposing)
{
");
- #line 468 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 559 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
if (this.Structure != null)
{
@@ -1241,21 +1526,21 @@ protected virtual void Dispose(bool disposing)
#line hidden
this.Write(" this.");
- #line 476 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 567 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.VariableName));
#line default
#line hidden
this.Write("?.Dispose();\r\n this.");
- #line 477 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 568 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.VariableName));
#line default
#line hidden
this.Write(" = null;\r\n");
- #line 478 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 569 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
}
}
@@ -1267,7 +1552,7 @@ protected virtual void Dispose(bool disposing)
this.Write(" }\r\n\r\n this._disposed = true;\r\n }\r\n\r\n #endr" +
"egion\r\n");
- #line 489 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 580 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
}
@@ -1278,7 +1563,7 @@ protected virtual void Dispose(bool disposing)
return this.GenerationEnvironment.ToString();
}
- #line 495 "C:\Dev\worktrees\fixdatetimes\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
+ #line 586 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\SourceFiles\StructureGenerator.tt"
// Set to true when the service model specifies a shape that should be wrapped in a response. ElastiCache CreateCacheCluster is an example of this.
public bool IsWrapped { get; set; }
diff --git a/generator/ServiceClientGeneratorLib/Generators/SourceFiles/StructureGenerator.tt b/generator/ServiceClientGeneratorLib/Generators/SourceFiles/StructureGenerator.tt
index 1798cf27ebfd..3389116870cc 100644
--- a/generator/ServiceClientGeneratorLib/Generators/SourceFiles/StructureGenerator.tt
+++ b/generator/ServiceClientGeneratorLib/Generators/SourceFiles/StructureGenerator.tt
@@ -35,6 +35,7 @@ using Amazon.Runtime.EventStreams;
using Amazon.Runtime.EventStreams.Internal;
using <#=this.Config.Namespace#>.Model.Internal.MarshallTransformations;
using Amazon.Runtime.EventStreams.Utils;
+using Amazon.Runtime.Internal.Util;
<#
}
#>
diff --git a/generator/ServiceClientGeneratorLib/Member.cs b/generator/ServiceClientGeneratorLib/Member.cs
index 8098ef115b11..134dcd48320b 100644
--- a/generator/ServiceClientGeneratorLib/Member.cs
+++ b/generator/ServiceClientGeneratorLib/Member.cs
@@ -631,16 +631,26 @@ string GetTypeUnmarshallerName(JsonData extendedData, bool useNullable = true)
var keyTypeUnmarshaller = GetTypeUnmarshallerName(memberShape[Shape.KeyKey], useNullable);
var valueType = DetermineType(memberShape[Shape.ValueKey], true, useNullable);
var valueTypeUnmarshaller = GetTypeUnmarshallerName(memberShape[Shape.ValueKey], useNullable);
-
- return string.Format("DictionaryUnmarshaller<{0}, {1}, {2}, {3}>",
- keyType, valueType, keyTypeUnmarshaller, valueTypeUnmarshaller);
+ if (this.model.Type == ServiceType.Json || this.model.Type == ServiceType.Rest_Json)
+ return string.Format("JsonDictionaryUnmarshaller<{0}, {1}, {2}, {3}>",
+ keyType, valueType, keyTypeUnmarshaller, valueTypeUnmarshaller);
+ else if (this.model.Type == ServiceType.Query || this.model.Type == ServiceType.Rest_Xml)
+ return string.Format("XmlDictionaryUnmarshaller<{0}, {1}, {2}, {3}>",
+ keyType, valueType, keyTypeUnmarshaller, valueTypeUnmarshaller);
+ else
+ throw new Exception("Unknown protocol type");
case "list":
var listType = DetermineType(memberShape[Member.MemberKey], true, useNullable);
var listTypeUnmarshaller = GetTypeUnmarshallerName(memberShape[Member.MemberKey], useNullable);
-
- return string.Format("ListUnmarshaller<{0}, {1}>",
+ if (this.model.Type == ServiceType.Json || this.model.Type == ServiceType.Rest_Json)
+ return string.Format("JsonListUnmarshaller<{0},{1}>",listType, listTypeUnmarshaller);
+ if (this.model.Type == ServiceType.Rest_Xml || this.model.Type == ServiceType.Query)
+ return string.Format("XmlListUnmarshaller<{0}, {1}>",
listType, listTypeUnmarshaller);
-
+ else
+ {
+ throw new Exception("Unknown protocol type");
+ }
case "decimal":
throw new Exception(UnhandledTypeDecimalErrorMessage);
@@ -726,13 +736,14 @@ public string DetermineTypeUnmarshallerInstantiate(JsonData extendedData, string
isFlat = false;
}
- if (this.model.Type == ServiceType.Json
- || this.model.Type == ServiceType.Rest_Json
- || (this.model.Type == ServiceType.Rest_Xml && !isFlat))
- return string.Format("new DictionaryUnmarshaller<{0}, {1}, {2}, {3}>(StringUnmarshaller.Instance, {5})",
+ if (this.model.Type == ServiceType.Json || this.model.Type == ServiceType.Rest_Json)
+ return string.Format("new JsonDictionaryUnmarshaller<{0}, {1}, {2}, {3}>(StringUnmarshaller.Instance, {5})",
+ keyType, valueType, keyTypeUnmarshaller, valueTypeUnmarshaller, keyTypeUnmarshallerInstantiate, valueTypeUnmarshallerInstantiate);
+ else if (this.model.Type == ServiceType.Rest_Xml && !isFlat)
+ return string.Format("new XmlDictionaryUnmarshaller<{0}, {1}, {2}, {3}>(StringUnmarshaller.Instance, {5})",
keyType, valueType, keyTypeUnmarshaller, valueTypeUnmarshaller, keyTypeUnmarshallerInstantiate, valueTypeUnmarshallerInstantiate);
else
- return string.Format("new KeyValueUnmarshaller<{0}, {1}, {2}, {3}>(StringUnmarshaller.Instance, {5})",
+ return string.Format("new XmlKeyValueUnmarshaller<{0}, {1}, {2}, {3}>(StringUnmarshaller.Instance, {5})",
keyType, valueType, keyTypeUnmarshaller, valueTypeUnmarshaller, keyTypeUnmarshallerInstantiate, valueTypeUnmarshallerInstantiate);
case "list":
var listType = DetermineType(memberShape[Shape.MemberKey], true, false);
@@ -740,7 +751,7 @@ public string DetermineTypeUnmarshallerInstantiate(JsonData extendedData, string
var listTypeUnmarshallerInstantiate = DetermineTypeUnmarshallerInstantiate(memberShape[Shape.MemberKey], typeNode.ToString(), false);
if (this.model.Type == ServiceType.Json || this.model.Type == ServiceType.Rest_Json)
- return string.Format("new ListUnmarshaller<{0}, {1}>({2})",
+ return string.Format("new JsonListUnmarshaller<{0}, {1}>({2})",
listType, listTypeUnmarshaller, listTypeUnmarshallerInstantiate);
else if ((this.model.Type == ServiceType.Query || this.model.Type == ServiceType.Rest_Xml) && $"{listTypeUnmarshaller}.Instance" != listTypeUnmarshallerInstantiate)
return $"new {listTypeUnmarshaller}({listTypeUnmarshallerInstantiate})";
diff --git a/sdk/src/Core/AWSConfigs.cs b/sdk/src/Core/AWSConfigs.cs
index 8cd2f44b68b7..11802ed7313d 100644
--- a/sdk/src/Core/AWSConfigs.cs
+++ b/sdk/src/Core/AWSConfigs.cs
@@ -243,14 +243,34 @@ public static string AWSProfilesLocation
}
#endregion
+ #region StreamingUtf8JsonReaderBufferSize
-
- #region SDK Cache
+ ///
+ /// Key for the StreamingUtf8JsonReaderBufferSize property.
+ /// "/>
+ ///
+ public const string StreamingUtf8JsonReaderBufferSizeKey = "StreamingUtf8JsonReaderBufferSize";
///
- /// Key for the UseSdkCache property.
- ///
+ /// Configures the default buffer size for the the StreamingUtf8JsonReader/>
+ /// used for buffering data from the stream passed into its constructor. If this isn't set, the SDK will default to 4096 bytes.
+ ///
+ /// Setting this property is not thread safe and should only be set at application startup.
///
+ public static int? StreamingUtf8JsonReaderBufferSize
+ {
+ get { return _rootConfig.StreamingUtf8JsonReaderBufferSize; }
+ set { _rootConfig.StreamingUtf8JsonReaderBufferSize = value; }
+ }
+
+ #endregion
+
+ #region SDK Cache
+
+ ///
+ /// Key for the UseSdkCache property.
+ ///
+ ///
public const string UseSdkCacheKey = "AWSCache";
///
diff --git a/sdk/src/Core/AWSSDK.Core.NetFramework.csproj b/sdk/src/Core/AWSSDK.Core.NetFramework.csproj
index 607c7a130b66..d6481420e5c9 100644
--- a/sdk/src/Core/AWSSDK.Core.NetFramework.csproj
+++ b/sdk/src/Core/AWSSDK.Core.NetFramework.csproj
@@ -71,10 +71,6 @@
-
diff --git a/sdk/src/Core/AWSSDK.Core.NetStandard.csproj b/sdk/src/Core/AWSSDK.Core.NetStandard.csproj
index 6e3f4ee951de..efc193a0877e 100644
--- a/sdk/src/Core/AWSSDK.Core.NetStandard.csproj
+++ b/sdk/src/Core/AWSSDK.Core.NetStandard.csproj
@@ -83,9 +83,6 @@
-
diff --git a/sdk/src/Core/Amazon.Runtime/Documents/Internal/Transform/DocumentUnmarshaller.cs b/sdk/src/Core/Amazon.Runtime/Documents/Internal/Transform/DocumentUnmarshaller.cs
index cdc85503b461..0463ee245144 100644
--- a/sdk/src/Core/Amazon.Runtime/Documents/Internal/Transform/DocumentUnmarshaller.cs
+++ b/sdk/src/Core/Amazon.Runtime/Documents/Internal/Transform/DocumentUnmarshaller.cs
@@ -18,77 +18,80 @@
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
+using System.Text.Json;
using Amazon.Runtime.Internal.Transform;
-using ThirdParty.Json.LitJson;
+using Amazon.Runtime.Internal.Util;
namespace Amazon.Runtime.Documents.Internal.Transform
{
///
- /// Dedicated for .
+ /// Dedicated for .
///
///
/// Per the Document Spec, Xml is not supported.
///
- public class DocumentUnmarshaller : IUnmarshaller, IUnmarshaller
+ public class DocumentUnmarshaller : IJsonUnmarshaller
{
public static DocumentUnmarshaller Instance { get; } = new DocumentUnmarshaller();
private DocumentUnmarshaller() { }
- public Document Unmarshall(JsonUnmarshallerContext context)
+ public Document Unmarshall(JsonUnmarshallerContext context, ref StreamingUtf8JsonReader reader)
{
- context.Read();
+ context.Read(ref reader);
switch (context.CurrentTokenType)
{
- case JsonToken.Null:
- case JsonToken.None:
+ case JsonTokenType.Null:
+ case JsonTokenType.None:
return new Document();
- case JsonToken.Boolean:
- return new Document(bool.Parse(context.ReadText()));
- case JsonToken.Double:
- return new Document(double.Parse(context.ReadText()));
- case JsonToken.Int:
- return new Document(int.Parse(context.ReadText()));
- case JsonToken.Long:
- return new Document(long.Parse(context.ReadText()));
- case JsonToken.String:
- return new Document(context.ReadText());
- case JsonToken.ArrayStart:
+ case JsonTokenType.True:
+ case JsonTokenType.False:
+ return new Document(reader.Reader.GetBoolean());
+ case JsonTokenType.Number:
+ if (reader.Reader.TryGetInt32(out int intValue))
+ {
+ return new Document(intValue);
+ }
+ else if (reader.Reader.TryGetInt64(out long longValue))
+ {
+ return new Document(longValue);
+ }
+ else if (reader.Reader.TryGetDouble(out double doubleValue))
+ {
+ return new Document(doubleValue);
+ }
+ else
+ {
+ throw new JsonException("Unsupported number type.");
+ }
+ case JsonTokenType.String:
+ return new Document(reader.Reader.GetString());
+ case JsonTokenType.StartArray:
var list = new List();
- while (!context.Peek(JsonToken.ArrayEnd))
- list.Add(Unmarshall(context));
+ while (!context.Peek(JsonTokenType.EndArray, ref reader))
+ list.Add(Unmarshall(context, ref reader));
- context.Read(); // Read ArrayEnd
+ context.Read(ref reader); // Read ArrayEnd
return new Document(list);
- case JsonToken.ObjectStart:
+ case JsonTokenType.StartObject:
var dict = new Dictionary();
- while (!context.Peek(JsonToken.ObjectEnd))
+ while (!context.Peek(JsonTokenType.EndObject, ref reader))
{
// Only supported Object is Dictionary
- var key = StringUnmarshaller.Instance.Unmarshall(context);
- var value = Unmarshall(context);
+ var key = StringUnmarshaller.Instance.Unmarshall(context, ref reader);
+ var value = Unmarshall(context, ref reader);
dict.Add(key, value);
}
- context.Read(); // Read ObjectEnd
+ context.Read(ref reader); // Read ObjectEnd
return new Document(dict);
default:
throw new ArgumentException($"Unknown JSON type: {context.CurrentTokenType}");
}
}
-
- ///
- /// Document Types does not support xml. However, Generic Type constraints for
- /// require implementing both
- /// json and xml unmarshalling support.
- ///
- Document IUnmarshaller.Unmarshall(XmlUnmarshallerContext input)
- {
- throw new NotImplementedException("Document is not supported in Xml Protocol");
- }
}
}
\ No newline at end of file
diff --git a/sdk/src/Core/Amazon.Runtime/EventStreams/Internal/EventStreamUtils.cs b/sdk/src/Core/Amazon.Runtime/EventStreams/Internal/EventStreamUtils.cs
index 3087cec1a4d2..25196919639a 100644
--- a/sdk/src/Core/Amazon.Runtime/EventStreams/Internal/EventStreamUtils.cs
+++ b/sdk/src/Core/Amazon.Runtime/EventStreams/Internal/EventStreamUtils.cs
@@ -15,6 +15,7 @@
using Amazon.Runtime.EventStreams.Internal;
using Amazon.Runtime.Internal.Transform;
+using Amazon.Runtime.Internal.Util;
using System;
using System.Collections.Generic;
using System.IO;
diff --git a/sdk/src/Core/Amazon.Runtime/Internal/Transform/IJsonErrorResponseUnmarshaller.cs b/sdk/src/Core/Amazon.Runtime/Internal/Transform/IJsonErrorResponseUnmarshaller.cs
new file mode 100644
index 000000000000..7d6a1cef8ad8
--- /dev/null
+++ b/sdk/src/Core/Amazon.Runtime/Internal/Transform/IJsonErrorResponseUnmarshaller.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Text.Json;
+using System.Threading.Tasks;
+using Amazon.Runtime.Internal.Util;
+
+namespace Amazon.Runtime.Internal.Transform
+{
+ ///
+ /// The interface for unmarshalling a json error response.
+ ///
+ /// The type to unmarshall.
+ /// The json unmarshaller context
+ public interface IJsonErrorResponseUnmarshaller
+ {
+ ///
+ /// The unmarshall method accepts a context, the error response and a StreamingUTf8JsonReader and returns the modeled exception.
+ ///
+ /// The JSON Unmarshaller context
+ /// The error response
+ /// The JSON reader
+ /// T, the error shape that is unmarshalled from the JSON context
+ T Unmarshall(TJsonUnmarshallerContext context, ErrorResponse errorResponse, ref StreamingUtf8JsonReader reader);
+ }
+}
diff --git a/sdk/src/Core/Amazon.Runtime/Internal/Transform/IJsonUnmarshaller.cs b/sdk/src/Core/Amazon.Runtime/Internal/Transform/IJsonUnmarshaller.cs
new file mode 100644
index 000000000000..74d8d5584587
--- /dev/null
+++ b/sdk/src/Core/Amazon.Runtime/Internal/Transform/IJsonUnmarshaller.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Text.Json;
+using System.Threading.Tasks;
+using Amazon.Runtime.Internal.Util;
+
+namespace Amazon.Runtime.Internal.Transform
+{
+ ///
+ /// Interface for JSON unmarshallers which unmarshall objects from response data.
+ /// The Unmarshallers are stateless, and only encode the rules for what data in
+ /// the JSON stream goes into what members of an object.
+ ///
+ /// The type of object the unmarshaller returns
+ /// The type of the Unmarshaller context. This can be any context that
+ /// inherits from JsonUnmarshallerContext or JsonUnmarshallerContext itself. The context contains the
+ /// state during parsing of the JSON stream.
+ public interface IJsonUnmarshaller
+ {
+ ///
+ /// Given the current position in the JSON stream, extract a T.
+ ///
+ /// The JSON parsing context
+ /// The Utf8JsonReader in the System Text JSON namespace
+ /// An object of type T populated with data from the JSON stream.
+ T Unmarshall(TJsonUnmarshallerContext input, ref StreamingUtf8JsonReader reader);
+ }
+}
\ No newline at end of file
diff --git a/sdk/src/Core/Amazon.Runtime/Internal/Transform/IResponseUnmarshaller.cs b/sdk/src/Core/Amazon.Runtime/Internal/Transform/IResponseUnmarshaller.cs
index 675bd3122e16..78554f70d486 100644
--- a/sdk/src/Core/Amazon.Runtime/Internal/Transform/IResponseUnmarshaller.cs
+++ b/sdk/src/Core/Amazon.Runtime/Internal/Transform/IResponseUnmarshaller.cs
@@ -26,19 +26,26 @@ namespace Amazon.Runtime.Internal.Transform
/// in the XML stream goes into what members of an object.
///
/// The type of object the unmarshaller returns
- /// The type of the XML unmashaller context, which contains the
- /// state of parsing the XML stream. Uaually an instance of
+ /// The type of the unmashaller context, which contains the
+ /// state of parsing the stream. Usually an instance of
/// Amazon.Runtime.Internal.Transform.UnmarshallerContext.
- public interface IResponseUnmarshaller : IUnmarshaller
+ public interface IResponseUnmarshaller
{
///
/// Extracts an exeption with data from an ErrorResponse.
///
- /// The XML parsing context.
+ /// The parsing context.
/// An inner exception to be included with the returned exception
/// The HttpStatusCode from the ErrorResponse
/// Either an exception based on the ErrorCode from the ErrorResponse, or the
/// general service exception for the service in question.
AmazonServiceException UnmarshallException(R input, Exception innerException, HttpStatusCode statusCode);
+
+ ///
+ /// Given the current position in the stream, extract a T
+ ///
+ /// The parsing context
+ /// An object of type T populated with data from the XML stream.
+ T Unmarshall(R input);
}
}
diff --git a/sdk/src/Core/Amazon.Runtime/Internal/Transform/IErrorResponseUnmarshaller.cs b/sdk/src/Core/Amazon.Runtime/Internal/Transform/IXmlErrorResponseUnmarshaller.cs
similarity index 72%
rename from sdk/src/Core/Amazon.Runtime/Internal/Transform/IErrorResponseUnmarshaller.cs
rename to sdk/src/Core/Amazon.Runtime/Internal/Transform/IXmlErrorResponseUnmarshaller.cs
index 1592260b481d..b39973ca38f9 100644
--- a/sdk/src/Core/Amazon.Runtime/Internal/Transform/IErrorResponseUnmarshaller.cs
+++ b/sdk/src/Core/Amazon.Runtime/Internal/Transform/IXmlErrorResponseUnmarshaller.cs
@@ -29,17 +29,16 @@ namespace Amazon.Runtime.Internal.Transform
/// in the XML stream goes into what members of an object.
///
/// The type of object the unmarshaller returns
- /// The type of the XML unmashaller context, which contains the
- /// state during parsing of the XML stream. Usually an instance of
- /// Amazon.Runtime.Internal.Transform.UnmarshallerContext.
- public interface IErrorResponseUnmarshaller : IUnmarshaller
+ /// The type of the XML unmashaller context, which contains the
+ /// state during parsing of the XML stream.
+ public interface IXmlErrorResponseUnmarshaller : IXmlUnmarshaller
{
///
/// Given the current position in the XML stream, extract a T.
///
/// The XML parsing context
- ///
+ /// The error response
/// An object of type T populated with data from the XML stream.
- TUnmarshaller Unmarshall(TUnmarshalleContext input, ErrorResponse errorResponse);
+ TUnmarshaller Unmarshall(XmlUnmarshallerContext input, ErrorResponse errorResponse);
}
}
\ No newline at end of file
diff --git a/sdk/src/Core/Amazon.Runtime/Internal/Transform/IUnmarshaller.cs b/sdk/src/Core/Amazon.Runtime/Internal/Transform/IXmlUnmarshaller.cs
similarity index 65%
rename from sdk/src/Core/Amazon.Runtime/Internal/Transform/IUnmarshaller.cs
rename to sdk/src/Core/Amazon.Runtime/Internal/Transform/IXmlUnmarshaller.cs
index 7f5e2b95187b..02bce06686cb 100644
--- a/sdk/src/Core/Amazon.Runtime/Internal/Transform/IUnmarshaller.cs
+++ b/sdk/src/Core/Amazon.Runtime/Internal/Transform/IXmlUnmarshaller.cs
@@ -29,16 +29,10 @@ namespace Amazon.Runtime.Internal.Transform
/// in the XML stream goes into what members of an object.
///
/// The type of object the unmarshaller returns
- /// The type of the XML unmashaller context, which contains the
- /// state during parsing of the XML stream. Usually an instance of
- /// Amazon.Runtime.Internal.Transform.UnmarshallerContext.
- public interface IUnmarshaller
+ /// The type of the XML unmashaller context, which contains the
+ /// state during parsing of the XML stream.
+ public interface IXmlUnmarshaller
{
- ///
- /// Given the current position in the XML stream, extract a T.
- ///
- /// The XML parsing context
- /// An object of type T populated with data from the XML stream.
- T Unmarshall(R input);
+ T Unmarshall(TXmlUnmarshallerContext input);
}
}
diff --git a/sdk/src/Core/Amazon.Runtime/Internal/Transform/JsonErrorResponseUnmarshaller.cs b/sdk/src/Core/Amazon.Runtime/Internal/Transform/JsonErrorResponseUnmarshaller.cs
index fbc42fbcf0bf..f6625714d171 100644
--- a/sdk/src/Core/Amazon.Runtime/Internal/Transform/JsonErrorResponseUnmarshaller.cs
+++ b/sdk/src/Core/Amazon.Runtime/Internal/Transform/JsonErrorResponseUnmarshaller.cs
@@ -14,115 +14,129 @@
*/
using Amazon.Runtime.Internal;
+using Amazon.Runtime.Internal.Util;
using System;
using Amazon.Util;
using System.Xml;
-using ThirdParty.Json.LitJson;
using System.Text;
using System.IO;
+using System.Text.Json;
namespace Amazon.Runtime.Internal.Transform
{
///
- /// First-pass unmarshaller for all errors
+ /// First-pass unmarshaller for all errors
///
- public class JsonErrorResponseUnmarshaller : IUnmarshaller
+ public class JsonErrorResponseUnmarshaller : IJsonUnmarshaller
{
///
/// Build an ErrorResponse from json
///
/// The json parsing context.
+ /// The Utf8JsonReader
/// Usually an Amazon.Runtime.Internal.JsonUnmarshallerContext.
/// An ErrorResponse object.
- public ErrorResponse Unmarshall(JsonUnmarshallerContext context)
+ public ErrorResponse Unmarshall(JsonUnmarshallerContext context, ref StreamingUtf8JsonReader reader)
{
ErrorResponse response;
- if (context.Peek() == 60) //starts with '<' so assuming XML.
+ // we cannot use context.Peek() because the stream used by streamreader has been read to completion by the
+ // streamingutf8jsonreader. Since responseBody will be populated, we use that instead.
+ for (int i = 0; i < context.ResponseBody.Length; i++)
{
- ErrorResponseUnmarshaller xmlUnmarshaller = new ErrorResponseUnmarshaller();
- using (var stream = new MemoryStream(context.GetResponseBodyBytes()))
- {
- XmlUnmarshallerContext xmlContext = new XmlUnmarshallerContext(stream, false, null);
- response = xmlUnmarshaller.Unmarshall(xmlContext);
- }
- }
- else
- {
- string type;
- string message;
- string code;
- string requestId = null;
- GetValuesFromJsonIfPossible(context, out type, out message, out code);
-
- // If an error code was not found, check for the x-amzn-ErrorType header.
- // This header is returned by rest-json services.
- if (string.IsNullOrEmpty(type) &&
- context.ResponseData.IsHeaderPresent(HeaderKeys.XAmzErrorType))
+ if (context.ResponseBody[i] == 32) // skip whitespace
+ continue;
+ else
{
- var errorType = context.ResponseData.GetHeaderValue(HeaderKeys.XAmzErrorType);
- if (!string.IsNullOrEmpty(errorType))
+ if (context.ResponseBody[i] == 60) //starts with '<' so assuming XML.
{
- // The error type can contain additional information, with ":" as a delimiter
- // We are only interested in the initial part which is the error type
- type = ParseType(errorType);
+ XmlErrorResponseUnmarshaller xmlUnmarshaller = new XmlErrorResponseUnmarshaller();
+ using (var stream = new MemoryStream(context.GetResponseBodyBytes()))
+ {
+ XmlUnmarshallerContext xmlContext = new XmlUnmarshallerContext(stream, false, null);
+ response = xmlUnmarshaller.Unmarshall(xmlContext);
+ return response;
+ }
}
+ else
+ break;
}
+ }
- // Check for the x-amzn-error-message header. This header is returned by rest-json services.
- // If the header is present it is preferred over any value provided in the response body.
- if (context.ResponseData.IsHeaderPresent(HeaderKeys.XAmznErrorMessage))
- {
- var errorMessage = context.ResponseData.GetHeaderValue(HeaderKeys.XAmznErrorMessage);
- if (!string.IsNullOrEmpty(errorMessage))
- message = errorMessage;
- }
+ string type;
+ string message;
+ string code;
+ string requestId = null;
+ GetValuesFromJsonIfPossible(context, ref reader, out type, out message, out code);
- // if both "__type" and HeaderKeys.XAmzErrorType were not specified, use "code" as type
- // this impacts Glacier
- if (string.IsNullOrEmpty(type) &&
- !string.IsNullOrEmpty(code))
+ // If an error code was not found, check for the x-amzn-ErrorType header.
+ // This header is returned by rest-json services.
+ if (string.IsNullOrEmpty(type) &&
+ context.ResponseData.IsHeaderPresent(HeaderKeys.XAmzErrorType))
+ {
+ var errorType = context.ResponseData.GetHeaderValue(HeaderKeys.XAmzErrorType);
+ if (!string.IsNullOrEmpty(errorType))
{
- type = code;
+ // The error type can contain additional information, with ":" as a delimiter
+ // We are only interested in the initial part which is the error type
+ type = ParseType(errorType);
}
+ }
+
+ // Check for the x-amzn-error-message header. This header is returned by rest-json services.
+ // If the header is present it is preferred over any value provided in the response body.
+ if (context.ResponseData.IsHeaderPresent(HeaderKeys.XAmznErrorMessage))
+ {
+ var errorMessage = context.ResponseData.GetHeaderValue(HeaderKeys.XAmznErrorMessage);
+ if (!string.IsNullOrEmpty(errorMessage))
+ message = errorMessage;
+ }
+
+ // if both "__type" and HeaderKeys.XAmzErrorType were not specified, use "code" as type
+ // this impacts Glacier
+ if (string.IsNullOrEmpty(type) &&
+ !string.IsNullOrEmpty(code))
+ {
+ type = code;
+ }
- // strip extra data from type, leaving only the exception type name
- type = type == null ? null : ParseType(type.Substring(type.LastIndexOf("#", StringComparison.Ordinal) + 1));
- // if no message was found create a generic message
- if (string.IsNullOrEmpty(message))
+ // strip extra data from type, leaving only the exception type name
+ type = type == null ? null : ParseType(type.Substring(type.LastIndexOf("#", StringComparison.Ordinal) + 1));
+ // if no message was found create a generic message
+ if (string.IsNullOrEmpty(message))
+ {
+ if (string.IsNullOrEmpty(type))
{
- if (string.IsNullOrEmpty(type))
- {
- if (string.IsNullOrEmpty(context.ResponseBody))
- message = "The service returned an error. See inner exception for details.";
- else
- message = "The service returned an error with HTTP Body: " + context.ResponseBody;
- }
+ if (string.IsNullOrEmpty(context.ResponseBody))
+ message = "The service returned an error. See inner exception for details.";
else
- {
- if (string.IsNullOrEmpty(context.ResponseBody))
- message = "The service returned an error with Error Code " + type + ".";
- else
- message = "The service returned an error with Error Code " + type + " and HTTP Body: " + context.ResponseBody;
- }
+ message = "The service returned an error with HTTP Body: " + context.ResponseBody;
}
-
- // Check for the x-amzn-RequestId header. This header is returned by rest-json services.
- // If the header is present it is preferred over any value provided in the response body.
- if (context.ResponseData.IsHeaderPresent(HeaderKeys.RequestIdHeader))
+ else
{
- requestId = context.ResponseData.GetHeaderValue(HeaderKeys.RequestIdHeader);
+ if (string.IsNullOrEmpty(context.ResponseBody))
+ message = "The service returned an error with Error Code " + type + ".";
+ else
+ message = "The service returned an error with Error Code " + type + " and HTTP Body: " + context.ResponseBody;
}
+ }
- response = new ErrorResponse
- {
- Code = type,
- Message = message,
- // type is not applicable to JSON services, setting to Unknown
- Type = ErrorType.Unknown,
- RequestId = requestId
- };
+ // Check for the x-amzn-RequestId header. This header is returned by rest-json services.
+ // If the header is present it is preferred over any value provided in the response body.
+ if (context.ResponseData.IsHeaderPresent(HeaderKeys.RequestIdHeader))
+ {
+ requestId = context.ResponseData.GetHeaderValue(HeaderKeys.RequestIdHeader);
}
+
+ response = new ErrorResponse
+ {
+ Code = type,
+ Message = message,
+ // type is not applicable to JSON services, setting to Unknown
+ Type = ErrorType.Unknown,
+ RequestId = requestId
+ };
+
return response;
}
@@ -140,37 +154,37 @@ private static string ParseType(string type)
}
- private static void GetValuesFromJsonIfPossible(JsonUnmarshallerContext context, out string type, out string message, out string code)
+ private static void GetValuesFromJsonIfPossible(JsonUnmarshallerContext context, ref StreamingUtf8JsonReader reader, out string type, out string message, out string code)
{
code = null;
type = null;
message = null;
- while (TryReadContext(context))
+ while (TryReadContext(context, ref reader))
{
if (context.TestExpression("__type"))
{
- type = StringUnmarshaller.GetInstance().Unmarshall(context);
+ type = StringUnmarshaller.GetInstance().Unmarshall(context, ref reader);
continue;
}
if (context.TestExpression("message"))
{
- message = StringUnmarshaller.GetInstance().Unmarshall(context);
+ message = StringUnmarshaller.GetInstance().Unmarshall(context, ref reader);
continue;
}
if (context.TestExpression("code"))
{
- code = StringUnmarshaller.GetInstance().Unmarshall(context);
+ code = StringUnmarshaller.GetInstance().Unmarshall(context, ref reader);
continue;
}
}
}
- private static bool TryReadContext(JsonUnmarshallerContext context)
+ private static bool TryReadContext(JsonUnmarshallerContext context, ref StreamingUtf8JsonReader reader)
{
try
{
- return context.Read();
+ return context.Read(ref reader);
}
catch (JsonException)
{
diff --git a/sdk/src/Core/Amazon.Runtime/Internal/Transform/JsonUnmarshallerContext.cs b/sdk/src/Core/Amazon.Runtime/Internal/Transform/JsonUnmarshallerContext.cs
index 1f1fda7c4293..b22da8f4d5c0 100644
--- a/sdk/src/Core/Amazon.Runtime/Internal/Transform/JsonUnmarshallerContext.cs
+++ b/sdk/src/Core/Amazon.Runtime/Internal/Transform/JsonUnmarshallerContext.cs
@@ -19,6 +19,7 @@
using System.Text;
using ThirdParty.Json.LitJson;
using Amazon.Runtime.Internal.Util;
+using System.Text.Json;
namespace Amazon.Runtime.Internal.Transform
{
@@ -49,9 +50,8 @@ public class JsonUnmarshallerContext : UnmarshallerContext
#region Private members
private StreamReader streamReader = null;
- private JsonReader jsonReader = null;
private JsonPathStack stack = new JsonPathStack();
- private JsonToken? currentToken = null;
+ private JsonTokenType? currentToken = null;
private bool disposed = false;
private bool wasPeeked = false;
#endregion
@@ -129,17 +129,28 @@ public JsonUnmarshallerContext(
base.SetupFlexibleChecksumStream(responseData, CrcStream ?? responseStream, contentLength, requestContext);
}
}
-
+
if (this.FlexibleChecksumStream != null) // either just flexible checksum, or flexible checksum wrapping the older CRC stream
streamReader = new StreamReader(this.FlexibleChecksumStream);
else if (this.CrcStream != null)
streamReader = new StreamReader(this.CrcStream);
else
streamReader = new StreamReader(responseStream);
-
- jsonReader = new JsonReader(streamReader);
}
+ #endregion
+ #region Public Methods
+
+ ///
+ /// Reads the next token at depth greater than or equal to target depth.
+ ///
+ /// Tokens are read at depth greater than or equal to target depth.
+ /// The Utf8JsonReader used to read the document
+ /// True if a token was read and current depth is greater than or equal to target depth.
+ public bool ReadAtDepth(int targetDepth, ref StreamingUtf8JsonReader reader)
+ {
+ return Read(ref reader) && this.CurrentDepth >= targetDepth;
+ }
#endregion
#region Overrides
@@ -151,7 +162,7 @@ public override bool IsStartOfDocument
{
get
{
- return (CurrentTokenType == JsonToken.None) && (!streamReader.EndOfStream);
+ return (CurrentTokenType == JsonTokenType.None) && (!streamReader.EndOfStream);
}
}
@@ -160,7 +171,7 @@ public override bool IsStartOfDocument
///
public override bool IsEndElement
{
- get { return CurrentTokenType == JsonToken.ObjectEnd; }
+ get { return CurrentTokenType == JsonTokenType.EndObject; }
}
///
@@ -168,7 +179,7 @@ public override bool IsEndElement
///
public override bool IsStartElement
{
- get { return CurrentTokenType == JsonToken.ObjectStart; }
+ get { return CurrentTokenType == JsonTokenType.StartObject; }
}
///
@@ -201,7 +212,7 @@ public override string CurrentPath
///
/// True if a token was read, false if there are no more tokens to read.
///
- public override bool Read()
+ public bool Read(ref StreamingUtf8JsonReader reader)
{
if (wasPeeked)
{
@@ -209,11 +220,11 @@ public override bool Read()
return currentToken == null;
}
- bool result = jsonReader.Read();
+ bool result = reader.Read();
if (result)
{
- currentToken = jsonReader.Token;
- UpdateContext();
+ currentToken = reader.Reader.TokenType;
+ UpdateContext(ref reader);
}
else
{
@@ -231,13 +242,14 @@ public override bool Read()
/// will return the same data until a Read() call is made.
///
/// Token to peek.
+ /// The Utf8JsonReader
/// Returns true if the peeked token matches given token.
- public bool Peek(JsonToken token)
+ public bool Peek(JsonTokenType token, ref StreamingUtf8JsonReader reader)
{
if (wasPeeked)
return currentToken != null && currentToken == token;
- if (Read())
+ if (Read(ref reader))
{
wasPeeked = true;
return currentToken == token;
@@ -245,46 +257,34 @@ public bool Peek(JsonToken token)
return false;
}
- ///
- /// Returns the text contents of the current token being parsed.
- ///
- ///
- /// The text contents of the current token being parsed.
- ///
- public override string ReadText()
+ public string ReadText(ref StreamingUtf8JsonReader reader)
{
- object data = jsonReader.Value;
- string text;
+ string text = string.Empty;
switch (currentToken)
{
- case JsonToken.Null:
+ case JsonTokenType.Null:
text = null;
break;
- case JsonToken.String:
- case JsonToken.PropertyName:
- text = data as string;
+ case JsonTokenType.String:
+ text = reader.Reader.GetString();
+ break;
+ case JsonTokenType.Number:
+ if (reader.Reader.TryGetInt64(out long longValue))
+ text = longValue.ToString(CultureInfo.InvariantCulture);
+ else if (reader.Reader.TryGetDouble(out double doubleValue))
+ text = doubleValue.ToString(CultureInfo.InvariantCulture);
+ else if (reader.Reader.TryGetInt32(out int intValue))
+ text = intValue.ToString(CultureInfo.InvariantCulture);
break;
- case JsonToken.Boolean:
- case JsonToken.Int:
- case JsonToken.UInt:
- case JsonToken.Long:
- case JsonToken.ULong:
- IFormattable iformattable = data as IFormattable;
- if (iformattable != null)
- text = iformattable.ToString(null, CultureInfo.InvariantCulture);
- else
- text = data.ToString();
+ case JsonTokenType.PropertyName:
+ text = reader.Reader.GetString();
break;
- case JsonToken.Double:
- var formattable = data as IFormattable;
- if (formattable != null)
- text = formattable.ToString("R", CultureInfo.InvariantCulture);
- else
- text = data.ToString();
+ case JsonTokenType.True:
+ case JsonTokenType.False:
+ text = reader.Reader.GetBoolean().ToString();
break;
default:
- throw new AmazonClientException(
- "We expected a VALUE token but got: " + currentToken);
+ throw new AmazonClientException($"Unexpected token: {currentToken}");
}
return text;
}
@@ -296,9 +296,9 @@ public override string ReadText()
///
/// The type of the current token
///
- public JsonToken CurrentTokenType
+ public JsonTokenType? CurrentTokenType
{
- get { return currentToken.Value; }
+ get { return currentToken; }
}
#endregion
@@ -353,11 +353,11 @@ private int StreamPeek()
return peek;
}
- private void UpdateContext()
+ private void UpdateContext(ref StreamingUtf8JsonReader reader)
{
if (!currentToken.HasValue) return;
- if (currentToken.Value == JsonToken.ObjectStart || currentToken.Value == JsonToken.ArrayStart)
+ if (currentToken.Value == JsonTokenType.StartObject || currentToken.Value == JsonTokenType.StartArray)
{
// Push '/' for object start and array start.
stack.Push(new PathSegment
@@ -366,7 +366,7 @@ private void UpdateContext()
Value = DELIMITER
});
}
- else if (currentToken.Value == JsonToken.ObjectEnd || currentToken.Value == JsonToken.ArrayEnd)
+ else if (currentToken.Value == JsonTokenType.EndObject || currentToken.Value == JsonTokenType.EndArray)
{
if (stack.Peek().SegmentType == PathSegmentType.Delimiter)
{
@@ -384,9 +384,9 @@ private void UpdateContext()
// if the stack is empty and the token type is a string, then the document is a raw string with no opening or
// closing delimeter. Per smithy spec https://smithy.io/2.0/spec/simple-types.html#document this is allowed
// so we should just push the value so that it can be retrieved later.
- else if (currentToken.Value == JsonToken.PropertyName || (stack.Count == 0 && currentToken == JsonToken.String))
+ else if (currentToken.Value == JsonTokenType.PropertyName || (stack.Count == 0 && currentToken == JsonTokenType.String))
{
- string t = ReadText();
+ string t = ReadText(ref reader);
// Push property name, it's appended to the stack's CurrentPath,
// it this does not affect the depth.
@@ -396,7 +396,7 @@ private void UpdateContext()
Value = t
});
}
- else if (currentToken.Value != JsonToken.None && stack.Peek().SegmentType != PathSegmentType.Delimiter)
+ else if (currentToken.Value != JsonTokenType.None && stack.Peek().SegmentType != PathSegmentType.Delimiter)
{
// Pop if you encounter a simple data type or null
// This will pop the property name associated with it in cases like {"a":"b"}.
@@ -408,17 +408,6 @@ private void UpdateContext()
}
#endregion
-
- public JsonData ToJsonData()
- {
- var data = JsonMapper.ToObject(jsonReader);
-
- if (stack.Count > 0)
- stack.Pop();
-
- return data;
- }
-
protected override void Dispose(bool disposing)
{
if (!disposed)
diff --git a/sdk/src/Core/Amazon.Runtime/Internal/Transform/ResponseUnmarshallers.cs b/sdk/src/Core/Amazon.Runtime/Internal/Transform/ResponseUnmarshallers.cs
index 0be45973d44e..df1005130ed9 100644
--- a/sdk/src/Core/Amazon.Runtime/Internal/Transform/ResponseUnmarshallers.cs
+++ b/sdk/src/Core/Amazon.Runtime/Internal/Transform/ResponseUnmarshallers.cs
@@ -22,6 +22,7 @@
using Amazon.Util;
using Amazon.Runtime.Internal.Util;
using System.Globalization;
+using System.Text.Json;
namespace Amazon.Runtime.Internal.Transform
{
@@ -95,7 +96,7 @@ public AmazonWebServiceResponse UnmarshallResponse(UnmarshallerContext context)
public abstract AmazonWebServiceResponse Unmarshall(UnmarshallerContext input);
-#endregion
+ #endregion
public static string GetDefaultErrorMessage() where T : Exception
{
@@ -154,7 +155,7 @@ public override AmazonServiceException UnmarshallException(UnmarshallerContext i
}
public abstract AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext input);
-
+
public abstract AmazonServiceException UnmarshallException(XmlUnmarshallerContext input, Exception innerException, HttpStatusCode statusCode);
protected override UnmarshallerContext ConstructUnmarshallerContext(Stream responseStream, bool maintainResponseBody, IWebResponseData response, bool isException)
@@ -227,19 +228,17 @@ public override AmazonWebServiceResponse Unmarshall(UnmarshallerContext input)
throw new AmazonUnmarshallingException(requestId, context.CurrentPath, e, context.ResponseData.StatusCode);
}
}
+
public override AmazonServiceException UnmarshallException(UnmarshallerContext input, Exception innerException, HttpStatusCode statusCode)
{
JsonUnmarshallerContext context = input as JsonUnmarshallerContext;
if (context == null)
throw new InvalidOperationException("Unsupported UnmarshallerContext");
-
var responseException = this.UnmarshallException(context, innerException, statusCode);
responseException.RequestId = context.ResponseData.GetHeaderValue(HeaderKeys.RequestIdHeader);
return responseException;
}
- public abstract AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext input);
-
public abstract AmazonServiceException UnmarshallException(JsonUnmarshallerContext input, Exception innerException, HttpStatusCode statusCode);
protected override UnmarshallerContext ConstructUnmarshallerContext(Stream responseStream, bool maintainResponseBody, IWebResponseData response, bool isException)
diff --git a/sdk/src/Core/Amazon.Runtime/Internal/Transform/SimpleTypeUnmarshaller.cs b/sdk/src/Core/Amazon.Runtime/Internal/Transform/SimpleTypeUnmarshaller.cs
index 7a75f894fb4f..e4aea164fceb 100644
--- a/sdk/src/Core/Amazon.Runtime/Internal/Transform/SimpleTypeUnmarshaller.cs
+++ b/sdk/src/Core/Amazon.Runtime/Internal/Transform/SimpleTypeUnmarshaller.cs
@@ -17,7 +17,7 @@
using System.Collections.Generic;
using System.Globalization;
using System.IO;
-
+using System.Text.Json;
using Amazon.Runtime.Internal.Util;
using Amazon.Util;
using ThirdParty.Json.LitJson;
@@ -32,10 +32,10 @@ public static T Unmarshall(XmlUnmarshallerContext context)
return (T)Convert.ChangeType(text, typeof(T), CultureInfo.InvariantCulture);
}
- public static T Unmarshall(JsonUnmarshallerContext context)
+ public static T Unmarshall(JsonUnmarshallerContext context, ref StreamingUtf8JsonReader reader)
{
- context.Read();
- string text = context.ReadText();
+ context.Read(ref reader);
+ string text = context.ReadText(ref reader);
if (text == null)
return default(T);
@@ -46,7 +46,7 @@ public static T Unmarshall(JsonUnmarshallerContext context)
///
/// Unmarshaller for int fields
///
- public class IntUnmarshaller : IUnmarshaller, IUnmarshaller
+ public class IntUnmarshaller : IXmlUnmarshaller, IJsonUnmarshaller
{
private IntUnmarshaller() { }
@@ -69,9 +69,9 @@ public int Unmarshall(XmlUnmarshallerContext context)
{
return SimpleTypeUnmarshaller.Unmarshall(context);
}
- public int Unmarshall(JsonUnmarshallerContext context)
+ public int Unmarshall(JsonUnmarshallerContext context, ref StreamingUtf8JsonReader reader)
{
- return SimpleTypeUnmarshaller.Unmarshall(context);
+ return SimpleTypeUnmarshaller.Unmarshall(context, ref reader);
}
}
@@ -81,7 +81,7 @@ public int Unmarshall(JsonUnmarshallerContext context)
/// This unmarshaller is not implemented for XML context, as XML responses
/// will null elements (xsi:nil='true') will be skipped by the XML parser.
///
- public class NullableIntUnmarshaller : IUnmarshaller, IUnmarshaller
+ public class NullableIntUnmarshaller : IXmlUnmarshaller, IJsonUnmarshaller
{
private NullableIntUnmarshaller() { }
@@ -112,10 +112,10 @@ public static NullableIntUnmarshaller GetInstance()
return int.Parse(text, CultureInfo.InvariantCulture);
}
- public int? Unmarshall(JsonUnmarshallerContext context)
+ public int? Unmarshall(JsonUnmarshallerContext context, ref StreamingUtf8JsonReader reader)
{
- context.Read();
- string text = context.ReadText();
+ context.Read(ref reader);
+ string text = context.ReadText(ref reader);
if (text == null)
{
@@ -128,7 +128,7 @@ public static NullableIntUnmarshaller GetInstance()
///
/// Unmarshaller for long fields
///
- public class LongUnmarshaller : IUnmarshaller, IUnmarshaller
+ public class LongUnmarshaller : IXmlUnmarshaller, IJsonUnmarshaller
{
private LongUnmarshaller() { }
@@ -151,13 +151,13 @@ public long Unmarshall(XmlUnmarshallerContext context)
{
return SimpleTypeUnmarshaller.Unmarshall(context);
}
- public long Unmarshall(JsonUnmarshallerContext context)
+ public long Unmarshall(JsonUnmarshallerContext context, ref StreamingUtf8JsonReader reader)
{
- return SimpleTypeUnmarshaller.Unmarshall(context);
+ return SimpleTypeUnmarshaller.Unmarshall(context, ref reader);
}
}
- public class NullableLongUnmarshaller : IUnmarshaller, IUnmarshaller
+ public class NullableLongUnmarshaller : IXmlUnmarshaller, IJsonUnmarshaller
{
private NullableLongUnmarshaller() { }
@@ -183,10 +183,10 @@ public static NullableLongUnmarshaller Instance
return long.Parse(text, CultureInfo.InvariantCulture);
}
- public long? Unmarshall(JsonUnmarshallerContext context)
+ public long? Unmarshall(JsonUnmarshallerContext context, ref StreamingUtf8JsonReader reader)
{
- context.Read();
- string text = context.ReadText();
+ context.Read(ref reader);
+ string text = context.ReadText(ref reader);
if (text == null)
{
@@ -199,7 +199,7 @@ public static NullableLongUnmarshaller Instance
///
/// Unmarshaller for float fields
///
- public class FloatUnmarshaller : IUnmarshaller, IUnmarshaller
+ public class FloatUnmarshaller : IXmlUnmarshaller, IJsonUnmarshaller
{
private FloatUnmarshaller() { }
@@ -222,16 +222,16 @@ public float Unmarshall(XmlUnmarshallerContext context)
{
return SimpleTypeUnmarshaller.Unmarshall(context);
}
- public float Unmarshall(JsonUnmarshallerContext context)
+ public float Unmarshall(JsonUnmarshallerContext context, ref StreamingUtf8JsonReader reader)
{
- return SimpleTypeUnmarshaller.Unmarshall(context);
+ return SimpleTypeUnmarshaller.Unmarshall(context, ref reader);
}
}
///
/// Unmarshaller for float fields
///
- public class NullableFloatUnmarshaller : IUnmarshaller, IUnmarshaller
+ public class NullableFloatUnmarshaller : IXmlUnmarshaller, IJsonUnmarshaller
{
private NullableFloatUnmarshaller() { }
@@ -257,10 +257,10 @@ public static NullableFloatUnmarshaller Instance
return float.Parse(text, CultureInfo.InvariantCulture);
}
- public float? Unmarshall(JsonUnmarshallerContext context)
+ public float? Unmarshall(JsonUnmarshallerContext context, ref StreamingUtf8JsonReader reader)
{
- context.Read();
- string text = context.ReadText();
+ context.Read(ref reader);
+ string text = context.ReadText(ref reader);
if (text == null)
{
@@ -274,7 +274,7 @@ public static NullableFloatUnmarshaller Instance
///
/// Unmarshaller for double fields
///
- public class DoubleUnmarshaller : IUnmarshaller, IUnmarshaller
+ public class DoubleUnmarshaller : IXmlUnmarshaller, IJsonUnmarshaller
{
private DoubleUnmarshaller() { }
@@ -298,16 +298,16 @@ public double Unmarshall(XmlUnmarshallerContext context)
{
return SimpleTypeUnmarshaller.Unmarshall(context);
}
- public double Unmarshall(JsonUnmarshallerContext context)
+ public double Unmarshall(JsonUnmarshallerContext context, ref StreamingUtf8JsonReader reader)
{
- return SimpleTypeUnmarshaller.Unmarshall(context);
+ return SimpleTypeUnmarshaller.Unmarshall(context, ref reader);
}
}
///
/// Unmarshaller for double fields
///
- public class NullableDoubleUnmarshaller : IUnmarshaller, IUnmarshaller
+ public class NullableDoubleUnmarshaller : IXmlUnmarshaller, IJsonUnmarshaller
{
private NullableDoubleUnmarshaller() { }
@@ -333,10 +333,10 @@ public static NullableDoubleUnmarshaller Instance
return double.Parse(text, CultureInfo.InvariantCulture);
}
- public double? Unmarshall(JsonUnmarshallerContext context)
+ public double? Unmarshall(JsonUnmarshallerContext context, ref StreamingUtf8JsonReader reader)
{
- context.Read();
- string text = context.ReadText();
+ context.Read(ref reader);
+ string text = context.ReadText(ref reader);
if (text == null)
{
@@ -349,7 +349,7 @@ public static NullableDoubleUnmarshaller Instance
///
/// Unmarshaller for decimal fields
///
- public class DecimalUnmarshaller : IUnmarshaller, IUnmarshaller
+ public class DecimalUnmarshaller : IXmlUnmarshaller, IJsonUnmarshaller
{
private DecimalUnmarshaller() { }
@@ -372,16 +372,16 @@ public decimal Unmarshall(XmlUnmarshallerContext context)
{
return SimpleTypeUnmarshaller.Unmarshall(context);
}
- public decimal Unmarshall(JsonUnmarshallerContext context)
+ public decimal Unmarshall(JsonUnmarshallerContext context, ref StreamingUtf8JsonReader reader)
{
- return SimpleTypeUnmarshaller.Unmarshall(context);
+ return SimpleTypeUnmarshaller.Unmarshall(context, ref reader);
}
}
///
/// Unmarshaller for decimal fields
///
- public class NullableDecimalUnmarshaller : IUnmarshaller, IUnmarshaller
+ public class NullableDecimalUnmarshaller : IXmlUnmarshaller, IJsonUnmarshaller
{
private NullableDecimalUnmarshaller() { }
@@ -407,10 +407,10 @@ public static NullableDecimalUnmarshaller Instance
return decimal.Parse(text, CultureInfo.InvariantCulture);
}
- public decimal? Unmarshall(JsonUnmarshallerContext context)
+ public decimal? Unmarshall(JsonUnmarshallerContext context, ref StreamingUtf8JsonReader reader)
{
- context.Read();
- string text = context.ReadText();
+ context.Read(ref reader);
+ string text = context.ReadText(ref reader);
if (text == null)
{
@@ -423,7 +423,7 @@ public static NullableDecimalUnmarshaller Instance
///
/// Unmarshaller for bool fields
///
- public class BoolUnmarshaller : IUnmarshaller, IUnmarshaller
+ public class BoolUnmarshaller : IXmlUnmarshaller, IJsonUnmarshaller
{
private BoolUnmarshaller() { }
@@ -446,16 +446,16 @@ public bool Unmarshall(XmlUnmarshallerContext context)
{
return SimpleTypeUnmarshaller.Unmarshall(context);
}
- public bool Unmarshall(JsonUnmarshallerContext context)
+ public bool Unmarshall(JsonUnmarshallerContext context, ref StreamingUtf8JsonReader reader)
{
- return SimpleTypeUnmarshaller.Unmarshall(context);
+ return SimpleTypeUnmarshaller.Unmarshall(context, ref reader);
}
}
///
/// Unmarshaller for bool fields
///
- public class NullableBoolUnmarshaller : IUnmarshaller, IUnmarshaller
+ public class NullableBoolUnmarshaller : IXmlUnmarshaller, IJsonUnmarshaller
{
private NullableBoolUnmarshaller() { }
@@ -481,10 +481,10 @@ public static NullableBoolUnmarshaller Instance
return bool.Parse(text);
}
- public bool? Unmarshall(JsonUnmarshallerContext context)
+ public bool? Unmarshall(JsonUnmarshallerContext context, ref StreamingUtf8JsonReader reader)
{
- context.Read();
- string text = context.ReadText();
+ context.Read(ref reader);
+ string text = context.ReadText(ref reader);
if(string.IsNullOrEmpty(text))
{
return null;
@@ -497,7 +497,7 @@ public static NullableBoolUnmarshaller Instance
///
/// Unmarshaller for string fields
///
- public class StringUnmarshaller : IUnmarshaller, IUnmarshaller
+ public class StringUnmarshaller : IXmlUnmarshaller, IJsonUnmarshaller
{
private StringUnmarshaller() { }
@@ -520,16 +520,16 @@ public string Unmarshall(XmlUnmarshallerContext context)
{
return SimpleTypeUnmarshaller.Unmarshall(context);
}
- public string Unmarshall(JsonUnmarshallerContext context)
+ public string Unmarshall(JsonUnmarshallerContext context, ref StreamingUtf8JsonReader reader)
{
- return SimpleTypeUnmarshaller.Unmarshall(context);
+ return SimpleTypeUnmarshaller.Unmarshall(context, ref reader);
}
}
///
/// Unmarshaller for byte fields
///
- public class ByteUnmarshaller : IUnmarshaller, IUnmarshaller
+ public class ByteUnmarshaller : IXmlUnmarshaller, IJsonUnmarshaller
{
private ByteUnmarshaller() { }
@@ -552,16 +552,16 @@ public byte Unmarshall(XmlUnmarshallerContext context)
{
return SimpleTypeUnmarshaller.Unmarshall(context);
}
- public byte Unmarshall(JsonUnmarshallerContext context)
+ public byte Unmarshall(JsonUnmarshallerContext context, ref StreamingUtf8JsonReader reader)
{
- return SimpleTypeUnmarshaller.Unmarshall(context);
+ return SimpleTypeUnmarshaller.Unmarshall(context, ref reader);
}
}
///
/// Unmarshaller for DateTime fields
///
- public class DateTimeUnmarshaller : IUnmarshaller, IUnmarshaller
+ public class DateTimeUnmarshaller : IXmlUnmarshaller, IJsonUnmarshaller
{
private DateTimeUnmarshaller() { }
@@ -586,10 +586,10 @@ public DateTime Unmarshall(XmlUnmarshallerContext context)
return UnmarshallInternal(text, treatAsNullable: false).Value;
}
- public DateTime Unmarshall(JsonUnmarshallerContext context)
+ public DateTime Unmarshall(JsonUnmarshallerContext context, ref StreamingUtf8JsonReader reader)
{
- context.Read();
- string text = context.ReadText();
+ context.Read(ref reader);
+ string text = context.ReadText(ref reader);
return UnmarshallInternal(text, treatAsNullable: false).Value;
}
@@ -627,7 +627,7 @@ public DateTime Unmarshall(JsonUnmarshallerContext context)
/// This unmarshaller is not implemented for XML context, as XML responses
/// will null elements (xsi:nil='true') will be skipped by the XML parser.
///
- public class NullableDateTimeUnmarshaller : IUnmarshaller, IUnmarshaller
+ public class NullableDateTimeUnmarshaller : IXmlUnmarshaller, IJsonUnmarshaller
{
private NullableDateTimeUnmarshaller() { }
@@ -652,15 +652,15 @@ public static NullableDateTimeUnmarshaller GetInstance()
return DateTimeUnmarshaller.UnmarshallInternal(text, treatAsNullable: true);
}
- public DateTime? Unmarshall(JsonUnmarshallerContext context)
+ public DateTime? Unmarshall(JsonUnmarshallerContext context, ref StreamingUtf8JsonReader reader)
{
- context.Read();
- string text = context.ReadText();
+ context.Read(ref reader);
+ string text = context.ReadText(ref reader);
return DateTimeUnmarshaller.UnmarshallInternal(text, treatAsNullable: true);
}
}
- public class DateTimeEpochLongMillisecondsUnmarshaller : IUnmarshaller, IUnmarshaller
+ public class DateTimeEpochLongMillisecondsUnmarshaller : IXmlUnmarshaller, IJsonUnmarshaller
{
private DateTimeEpochLongMillisecondsUnmarshaller() { }
@@ -683,15 +683,15 @@ public DateTime Unmarshall(XmlUnmarshallerContext context)
{
return SimpleTypeUnmarshaller.Unmarshall(context);
}
- public DateTime Unmarshall(JsonUnmarshallerContext context)
+ public DateTime Unmarshall(JsonUnmarshallerContext context, ref StreamingUtf8JsonReader reader)
{
- long millseconds = LongUnmarshaller.Instance.Unmarshall(context);
+ long millseconds = LongUnmarshaller.Instance.Unmarshall(context, ref reader);
var ret = Amazon.Util.AWSSDKUtils.EPOCH_START.AddMilliseconds(millseconds);
return ret;
}
}
- public class NullableDateTimeEpochLongMillisecondsUnmarshaller : IUnmarshaller, IUnmarshaller
+ public class NullableDateTimeEpochLongMillisecondsUnmarshaller : IXmlUnmarshaller, IJsonUnmarshaller
{
private NullableDateTimeEpochLongMillisecondsUnmarshaller() { }
@@ -720,10 +720,10 @@ public static NullableDateTimeEpochLongMillisecondsUnmarshaller Instance
return ret;
}
- public DateTime? Unmarshall(JsonUnmarshallerContext context)
+ public DateTime? Unmarshall(JsonUnmarshallerContext context, ref StreamingUtf8JsonReader reader)
{
- context.Read();
- string text = context.ReadText();
+ context.Read(ref reader);
+ string text = context.ReadText(ref reader);
if (text == null)
{
@@ -739,7 +739,7 @@ public static NullableDateTimeEpochLongMillisecondsUnmarshaller Instance
///
/// Unmarshaller for MemoryStream fields
///
- public class MemoryStreamUnmarshaller : IUnmarshaller, IUnmarshaller
+ public class MemoryStreamUnmarshaller : IXmlUnmarshaller, IJsonUnmarshaller
{
private MemoryStreamUnmarshaller() { }
@@ -765,13 +765,13 @@ public MemoryStream Unmarshall(XmlUnmarshallerContext context)
return stream;
}
- public MemoryStream Unmarshall(JsonUnmarshallerContext context)
+ public MemoryStream Unmarshall(JsonUnmarshallerContext context, ref StreamingUtf8JsonReader reader)
{
- context.Read();
- if (context.CurrentTokenType == JsonToken.Null)
+ context.Read(ref reader);
+ if (context.CurrentTokenType == JsonTokenType.Null)
return null;
- byte[] bytes = Convert.FromBase64String(context.ReadText());
+ byte[] bytes = Convert.FromBase64String(context.ReadText(ref reader));
MemoryStream stream = new MemoryStream(bytes, 0, bytes.Length, true, true);
return stream;
}
@@ -780,7 +780,7 @@ public MemoryStream Unmarshall(JsonUnmarshallerContext context)
///
/// Unmarshaller for ResponseMetadata
///
- public class ResponseMetadataUnmarshaller : IUnmarshaller, IUnmarshaller
+ public class ResponseMetadataUnmarshaller : IXmlUnmarshaller, IJsonUnmarshaller
{
private ResponseMetadataUnmarshaller() { }
@@ -819,17 +819,17 @@ public ResponseMetadata Unmarshall(XmlUnmarshallerContext context)
return metadata;
}
- public ResponseMetadata Unmarshall(JsonUnmarshallerContext context)
+ public ResponseMetadata Unmarshall(JsonUnmarshallerContext context, ref StreamingUtf8JsonReader reader)
{
ResponseMetadata metadata = new ResponseMetadata();
int depth = context.CurrentDepth;
while (context.CurrentDepth >= depth)
{
- context.Read();
+ context.Read(ref reader);
if (context.TestExpression("ResponseMetadata/RequestId"))
{
- metadata.RequestId = StringUnmarshaller.GetInstance().Unmarshall(context);
+ metadata.RequestId = StringUnmarshaller.GetInstance().Unmarshall(context, ref reader);
}
}
@@ -837,16 +837,15 @@ public ResponseMetadata Unmarshall(JsonUnmarshallerContext context)
}
}
- public class KeyValueUnmarshaller :
- IUnmarshaller, XmlUnmarshallerContext>,
- IUnmarshaller, JsonUnmarshallerContext>
- where KUnmarshaller : IUnmarshaller, IUnmarshaller
- where VUnmarshaller : IUnmarshaller, IUnmarshaller
+ public class XmlKeyValueUnmarshaller :
+ IXmlUnmarshaller, XmlUnmarshallerContext>
+ where KUnmarshaller : IXmlUnmarshaller
+ where VUnmarshaller : IXmlUnmarshaller
{
private KUnmarshaller keyUnmarshaller;
private VUnmarshaller valueUnmarshaller;
- public KeyValueUnmarshaller(KUnmarshaller keyUnmarshaller, VUnmarshaller valueUnmarshaller)
+ public XmlKeyValueUnmarshaller(KUnmarshaller keyUnmarshaller, VUnmarshaller valueUnmarshaller)
{
this.keyUnmarshaller = keyUnmarshaller;
this.valueUnmarshaller = valueUnmarshaller;
@@ -883,31 +882,47 @@ public KeyValuePair Unmarshall(XmlUnmarshallerContext context)
return new KeyValuePair(key, value);
}
- public KeyValuePair Unmarshall(JsonUnmarshallerContext context)
+ }
+
+ public class JsonKeyValueUnmarshaller :
+ IJsonUnmarshaller, JsonUnmarshallerContext>
+ where KUnmarshaller : IJsonUnmarshaller
+ where VUnmarshaller : IJsonUnmarshaller
+ {
+ private KUnmarshaller keyUnmarshaller;
+ private VUnmarshaller valueUnmarshaller;
+
+ public JsonKeyValueUnmarshaller(KUnmarshaller keyUnmarshaller, VUnmarshaller valueUnmarshaller)
{
- K key = this.keyUnmarshaller.Unmarshall(context);
- V value = this.valueUnmarshaller.Unmarshall(context);
+ this.keyUnmarshaller = keyUnmarshaller;
+ this.valueUnmarshaller = valueUnmarshaller;
+ }
+
+ public KeyValuePair Unmarshall(JsonUnmarshallerContext context, ref StreamingUtf8JsonReader reader)
+ {
+ K key = this.keyUnmarshaller.Unmarshall(context, ref reader);
+ V value = this.valueUnmarshaller.Unmarshall(context, ref reader);
return new KeyValuePair(key, value);
}
}
- public class ListUnmarshaller : IUnmarshaller, XmlUnmarshallerContext>, IUnmarshaller, JsonUnmarshallerContext>
- where IUnmarshaller : IUnmarshaller, IUnmarshaller
+ public class XmlListUnmarshaller : IXmlUnmarshaller, XmlUnmarshallerContext>
+ where TUnmarshaller : IXmlUnmarshaller
{
- private IUnmarshaller iUnmarshaller;
+ private TUnmarshaller iUnmarshaller;
- public ListUnmarshaller(IUnmarshaller iUnmarshaller)
+ public XmlListUnmarshaller(TUnmarshaller iUnmarshaller)
{
this.iUnmarshaller = iUnmarshaller;
}
-
- public List Unmarshall(XmlUnmarshallerContext context)
+
+ public List Unmarshall(XmlUnmarshallerContext context)
{
int originalDepth = context.CurrentDepth;
int targetDepth = originalDepth + 1;
- var list = new List();
+ var list = new List();
// If the list is nested, we don't want the current depth to be less than the original depth
// because then, context.Read() will return true if there are more elements and all the
// list's elements will be unmarshalled as one list instead of multiple nested lists.
@@ -924,40 +939,52 @@ public List Unmarshall(XmlUnmarshallerContext context)
}
return list;
}
- public List Unmarshall(JsonUnmarshallerContext context)
+ }
+
+ public class JsonListUnmarshaller : IJsonUnmarshaller, JsonUnmarshallerContext>
+ where TUnmarshaller : IJsonUnmarshaller
+ {
+ private TUnmarshaller iUnmarshaller;
+
+ public JsonListUnmarshaller(TUnmarshaller iUnmarshaller)
+ {
+ this.iUnmarshaller = iUnmarshaller;
+ }
+
+ public List Unmarshall(JsonUnmarshallerContext context, ref StreamingUtf8JsonReader reader)
{
- context.Read(); // Read [ or null
- if (context.CurrentTokenType == JsonToken.Null)
+ context.Read(ref reader); // Read [ or null
+ if (context.CurrentTokenType == JsonTokenType.Null)
{
if (AWSConfigs.InitializeCollections)
- return new List();
+ return new List();
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
// end up sending the same empty collection back.
- List list = new AlwaysSendList();
- while (!context.Peek(JsonToken.ArrayEnd)) // Peek for ]
+ List list = new AlwaysSendList();
+ while (!context.Peek(JsonTokenType.EndArray, ref reader)) // Peek for ]
{
- list.Add(iUnmarshaller.Unmarshall(context));
+ list.Add(iUnmarshaller.Unmarshall(context, ref reader));
}
- context.Read(); // Read ]
+ context.Read(ref reader); // Read ]
return list;
}
}
- public class DictionaryUnmarshaller : IUnmarshaller, XmlUnmarshallerContext>, IUnmarshaller, JsonUnmarshallerContext>
- where TKeyUnmarshaller : IUnmarshaller, IUnmarshaller
- where TValueUnmarshaller : IUnmarshaller, IUnmarshaller
+
+ public class XmlDictionaryUnmarshaller : IXmlUnmarshaller, XmlUnmarshallerContext>
+ where TKeyUnmarshaller : IXmlUnmarshaller
+ where TValueUnmarshaller : IXmlUnmarshaller
{
- private KeyValueUnmarshaller KVUnmarshaller;
+ private XmlKeyValueUnmarshaller KVUnmarshaller;
- public DictionaryUnmarshaller(TKeyUnmarshaller kUnmarshaller, TValueUnmarshaller vUnmarshaller)
+ public XmlDictionaryUnmarshaller(TKeyUnmarshaller kUnmarshaller, TValueUnmarshaller vUnmarshaller)
{
- KVUnmarshaller = new KeyValueUnmarshaller(kUnmarshaller, vUnmarshaller);
+ KVUnmarshaller = new XmlKeyValueUnmarshaller(kUnmarshaller, vUnmarshaller);
}
public Dictionary Unmarshall(XmlUnmarshallerContext context)
@@ -983,11 +1010,23 @@ public Dictionary Unmarshall(XmlUnmarshallerContext context)
return dictionary;
}
+ }
+
+ public class JsonDictionaryUnmarshaller : IJsonUnmarshaller, JsonUnmarshallerContext>
+ where TKeyUnmarshaller :IJsonUnmarshaller
+ where TValueUnmarshaller : IJsonUnmarshaller
+ {
+ private JsonKeyValueUnmarshaller KVUnmarshaller;
+
+ public JsonDictionaryUnmarshaller(TKeyUnmarshaller kUnmarshaller, TValueUnmarshaller vUnmarshaller)
+ {
+ KVUnmarshaller = new JsonKeyValueUnmarshaller(kUnmarshaller, vUnmarshaller);
+ }
- public Dictionary Unmarshall(JsonUnmarshallerContext context)
+ public Dictionary Unmarshall(JsonUnmarshallerContext context, ref StreamingUtf8JsonReader reader)
{
- context.Read(); // Read { or null
- if (context.CurrentTokenType == JsonToken.Null)
+ context.Read(ref reader); // Read { or null
+ if (context.CurrentTokenType == JsonTokenType.Null)
{
if (AWSConfigs.InitializeCollections)
return new Dictionary();
@@ -1000,12 +1039,12 @@ public Dictionary Unmarshall(JsonUnmarshallerContext context)
// so if the response was empty, reusing the object in the request we will
// end up sending the same empty collection back.
Dictionary dictionary = new AlwaysSendDictionary();
- while (!context.Peek(JsonToken.ObjectEnd)) // Peek }
+ while (!context.Peek(JsonTokenType.EndObject, ref reader)) // Peek }
{
- KeyValuePair item = KVUnmarshaller.Unmarshall(context);
+ KeyValuePair item = KVUnmarshaller.Unmarshall(context, ref reader);
dictionary.Add(item.Key, item.Value);
}
- context.Read(); // Read }
+ context.Read(ref reader); // Read }
return dictionary;
}
diff --git a/sdk/src/Core/Amazon.Runtime/Internal/Transform/UnmarshallerContext.cs b/sdk/src/Core/Amazon.Runtime/Internal/Transform/UnmarshallerContext.cs
index 086faa6f2074..dacafbce1f9f 100644
--- a/sdk/src/Core/Amazon.Runtime/Internal/Transform/UnmarshallerContext.cs
+++ b/sdk/src/Core/Amazon.Runtime/Internal/Transform/UnmarshallerContext.cs
@@ -21,6 +21,7 @@
using System.IO;
using System.Xml;
using ThirdParty.Ionic.Zlib;
+using System.Text.Json;
namespace Amazon.Runtime.Internal.Transform
{
@@ -184,16 +185,6 @@ public bool TestExpression(string expression, int startingStackDepth)
return TestExpression(expression, startingStackDepth, CurrentPath, CurrentDepth);
}
- ///
- /// Reads the next token at depth greater than or equal to target depth.
- ///
- /// Tokens are read at depth greater than or equal to target depth.
- /// True if a token was read and current depth is greater than or equal to target depth.
- public bool ReadAtDepth(int targetDepth)
- {
- return Read() && this.CurrentDepth >= targetDepth;
- }
-
private static bool TestExpression(string expression, string currentPath)
{
if (expression.Equals("."))
@@ -235,22 +226,6 @@ private static bool TestExpression(string expression, int startingStackDepth, st
///
public abstract int CurrentDepth { get; }
- ///
- /// Reads to the next node in the document, and updates the context accordingly.
- ///
- ///
- /// True if a node was read, false if there are no more elements to read.
- ///
- public abstract bool Read();
-
- ///
- /// Returns the text contents of the current element being parsed.
- ///
- ///
- /// The text contents of the current element being parsed.
- ///
- public abstract string ReadText();
-
///
/// True if NodeType is Element.
///
@@ -307,404 +282,4 @@ public void Dispose()
#endregion
}
-
- ///
- /// Wrap an XmltextReader for simulating an event stream.
- ///
- /// Each Read() operation goes either to the next element or next attribute within
- /// the current element. TestExpression() is used to match the current event
- /// to an xpath expression. The general pattern looks like this:
- ///
- /// UnmarshallerContext context = new UnmarshallerContext(...);
- /// while (context.Read())
- /// {
- /// if (context.TestExpresion("path/to/element"))
- /// {
- /// myObject.stringMember = stringUnmarshaller.GetInstance().Unmarshall(context);
- /// continue;
- /// }
- /// if (context.TestExpression("path/to/@attribute"))
- /// myObject.MyComplexTypeMember = MyComplexTypeUnmarshaller.GetInstance().Unmarshall(context);
- /// }
- ///
- ///
- public class XmlUnmarshallerContext : UnmarshallerContext
- {
- #region Private members
-
- private static HashSet nodesToSkip = new HashSet
- {
- XmlNodeType.None,
- XmlNodeType.XmlDeclaration,
- XmlNodeType.Comment,
- XmlNodeType.DocumentType,
- XmlNodeType.CDATA,
- XmlNodeType.Whitespace
- };
-
- private StreamReader streamReader;
- private XmlTextReader _xmlTextReader;
- private Stack stack = new Stack();
- private string stackString = "";
- private Dictionary attributeValues;
- private List attributeNames;
- private IEnumerator attributeEnumerator;
- private XmlNodeType nodeType;
- private string nodeContent = String.Empty;
- private bool disposed = false;
- private bool currentlyProcessingEmptyElement;
-
- public Stream Stream
- {
- get
- {
- return streamReader.BaseStream;
- }
- }
-
- ///
- /// Despite Microsoft's recommendation to use XmlReader for .NET Framework 2.0 or greater
- /// (https://docs.microsoft.com/en-us/dotnet/api/system.xml.xmltextreader#remarks), this class
- /// intentionally uses XmlTextReader to handle the XML related object key constraints
- /// for S3 (https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-keys.html).
- ///
- private XmlTextReader XmlReader
- {
- get
- {
- if (_xmlTextReader == null)
- {
- _xmlTextReader = new XmlTextReader(streamReader);
- _xmlTextReader.WhitespaceHandling = WhitespaceHandling.All;
- _xmlTextReader.DtdProcessing = DtdProcessing.Ignore;
- }
- return _xmlTextReader;
- }
- }
-
- #endregion
-
- #region Constructors
-
- ///
- /// Wrap an XmlTextReader with state for event-based parsing of an XML stream.
- ///
- /// Stream with the XML from a service response.
- /// If set to true, maintains a copy of the complete response body constraint to log response size as the stream is being read.
- /// Response data coming back from the request
- /// If set to true, maintains a copy of the complete response body as the stream is being read.
- public XmlUnmarshallerContext(Stream responseStream, bool maintainResponseBody, IWebResponseData responseData, bool isException = false)
- : this(responseStream, maintainResponseBody, responseData, isException, null)
- {
- }
-
- ///
- /// Wrap an XmlTextReader with state for event-based parsing of an XML stream.
- ///
- /// Stream with the XML from a service response.
- /// If set to true, maintains a copy of the complete response body constraint to log response size as the stream is being read.
- /// Response data coming back from the request
- /// If set to true, maintains a copy of the complete response body as the stream is being read.
- /// Context for the request that produced this response
- public XmlUnmarshallerContext(Stream responseStream, bool maintainResponseBody, IWebResponseData responseData, bool isException, IRequestContext requestContext)
- {
- if (isException)
- {
- this.WrappingStream = new CachingWrapperStream(responseStream);
- }
- else if (maintainResponseBody)
- {
- this.WrappingStream = new CachingWrapperStream(responseStream, AWSConfigs.LoggingConfig.LogResponsesSizeLimit);
- }
-
- if (isException || maintainResponseBody)
- {
- responseStream = this.WrappingStream;
- }
- // If the unmarshaller context is being called internally without there being a http response then the response data would be null
- if (responseData != null)
- {
- long contentLength;
- bool parsedContentLengthHeader = long.TryParse(responseData.GetHeaderValue("Content-Length"), out contentLength);
-
- if (parsedContentLengthHeader && contentLength == 0)
- {
- IsEmptyResponse = true;
- }
- // Validate flexible checksums if we know the content length and the behavior was opted in to on the request
- if (parsedContentLengthHeader && responseData.ContentLength == contentLength &&
- string.IsNullOrEmpty(responseData.GetHeaderValue("Content-Encoding")) &&
- requestContext?.OriginalRequest?.CoreChecksumMode == CoreChecksumResponseBehavior.ENABLED)
- {
- SetupFlexibleChecksumStream(responseData, responseStream, contentLength, requestContext);
- }
- }
-
- streamReader = new StreamReader(this.FlexibleChecksumStream ?? responseStream);
-
- this.WebResponseData = responseData;
- this.MaintainResponseBody = maintainResponseBody;
- this.IsException = isException;
- }
-
- #endregion
-
- #region Overrides
-
- ///
- /// The current XML path that is being unmarshalled.
- ///
- public override string CurrentPath
- {
- get { return this.stackString; }
- }
-
- ///
- /// Returns the element depth of the parser's current position in the XML
- /// document being parsed.
- ///
- public override int CurrentDepth
- {
- get { return stack.Count; }
- }
-
- ///
- /// Reads to the next node in the XML document, and updates the context accordingly.
- ///
- ///
- /// True if a node was read, false if there are no more elements to read./
- ///
- public override bool Read()
- {
- if (attributeEnumerator != null && attributeEnumerator.MoveNext())
- {
- this.nodeType = XmlNodeType.Attribute;
- stackString = string.Format(CultureInfo.InvariantCulture, "{0}/@{1}", StackToPath(stack), attributeEnumerator.Current);
- }
- else
- {
- // Skip some nodes
- if (nodesToSkip.Contains(XmlReader.NodeType))
- XmlReader.Read();
-
- if (currentlyProcessingEmptyElement)
- {
- nodeType = XmlNodeType.EndElement;
- stack.Pop();
- stackString = StackToPath(stack);
- XmlReader.Read();
- currentlyProcessingEmptyElement = false;
- }
- else if(XmlReader.IsEmptyElement)
- {
- //This is a shorthand form of an empty element and we want to allow it
- nodeType = XmlNodeType.Element;
- stack.Push(XmlReader.LocalName);
- stackString = StackToPath(stack);
- currentlyProcessingEmptyElement = true;
- nodeContent = String.Empty;
-
- //Defer reading so that on next pass we can treat this same element as the end element.
- }
- else
- {
- switch (XmlReader.NodeType)
- {
- case XmlNodeType.EndElement:
- this.nodeType = XmlNodeType.EndElement;
- stack.Pop();
- stackString = StackToPath(stack);
- XmlReader.Read();
- break;
- case XmlNodeType.Element:
- nodeType = XmlNodeType.Element;
- stack.Push(XmlReader.LocalName);
- stackString = StackToPath(stack);
- this.ReadElement();
- break;
- }
- }
- }
-
- bool moreDataAvailable =
- XmlReader.ReadState != ReadState.EndOfFile &&
- XmlReader.ReadState != ReadState.Error &&
- XmlReader.ReadState != ReadState.Closed;
- return moreDataAvailable;
- }
-
- ///
- /// Returns the text contents of the current element being parsed.
- ///
- ///
- /// The text contents of the current element being parsed.
- ///
- public override string ReadText()
- {
- if (this.nodeType == XmlNodeType.Attribute)
- {
- return (attributeValues[attributeEnumerator.Current]);
- }
- else
- {
- return nodeContent;
- }
- }
-
- ///
- /// True if NodeType is Element.
- ///
- public override bool IsStartElement
- {
- get { return this.nodeType == XmlNodeType.Element; }
- }
-
- ///
- /// True if NodeType is EndElement.
- ///
- public override bool IsEndElement
- {
- get { return this.nodeType == XmlNodeType.EndElement; }
- }
-
- ///
- /// True if the context is at the start of the document.
- ///
- public override bool IsStartOfDocument
- {
- get { return XmlReader.ReadState == ReadState.Initial; }
- }
-
- #endregion
-
- #region Public methods
-
- ///
- /// True if NodeType is Attribute.
- ///
- public bool IsAttribute
- {
- get { return this.nodeType == XmlNodeType.Attribute; }
- }
-
- #endregion
-
- #region Private Methods
-
- private static string StackToPath(Stack stack)
- {
- string path = null;
- foreach (string s in stack.ToArray())
- {
- path = null == path ? s : string.Format(CultureInfo.InvariantCulture, "{0}/{1}", s, path);
- }
- return "/" + path;
- }
-
- // Move to the next element, cache the attributes collection
- // and attempt to cache the inner text of the element if applicable.
- private void ReadElement()
- {
- if (XmlReader.HasAttributes)
- {
- attributeValues = new Dictionary();
- attributeNames = new List();
- while (XmlReader.MoveToNextAttribute())
- {
- attributeValues.Add(XmlReader.LocalName, XmlReader.Value);
- attributeNames.Add(XmlReader.LocalName);
- }
- attributeEnumerator = attributeNames.GetEnumerator();
- }
- XmlReader.MoveToElement();
- XmlReader.Read();
-
- if (XmlReader.NodeType == XmlNodeType.Text || XmlReader.NodeType == XmlNodeType.Whitespace)
- nodeContent = XmlReader.ReadContentAsString();
- else
- nodeContent = String.Empty;
- }
-
- #endregion
-
- protected override void Dispose(bool disposing)
- {
- if (!this.disposed)
- {
- if (disposing)
- {
- if (streamReader != null)
- {
- streamReader.Dispose();
- streamReader = null;
- }
- if (_xmlTextReader != null)
- {
-#if NETSTANDARD
- _xmlTextReader.Dispose();
-#else
- _xmlTextReader.Close();
-#endif
- _xmlTextReader = null;
- }
- }
- disposed = true;
- }
- base.Dispose(disposing);
- }
- }
-
- public class EC2UnmarshallerContext : XmlUnmarshallerContext
- {
- ///
- /// Wrap an XmlTextReader with state for event-based parsing of an XML stream.
- ///
- /// Stream with the XML from a service response.
- /// If set to true, maintains a copy of the complete response body constraint to log response size as the stream is being read.
- /// Response data coming back from the request
- /// If set to true, maintains a copy of the complete response body as the stream is being read.
- public EC2UnmarshallerContext(Stream responseStream, bool maintainResponseBody, IWebResponseData responseData, bool isException = false)
- : base(responseStream, maintainResponseBody, responseData, isException)
- {
- }
-
- ///
- /// Wrap an XmlTextReader with state for event-based parsing of an XML stream.
- ///
- /// Stream with the XML from a service response.
- /// If set to true, maintains a copy of the complete response body constraint to log response size as the stream is being read.
- /// Response data coming back from the request
- /// If set to true, maintains a copy of the complete response body as the stream is being read.
- /// Context for the request that produced this response
- public EC2UnmarshallerContext(Stream responseStream, bool maintainResponseBody, IWebResponseData responseData, bool isException, IRequestContext requestContext)
- : base(responseStream, maintainResponseBody, responseData, isException, requestContext)
- {
- }
-
- ///
- /// RequestId value, if found in response
- ///
- public string RequestId { get; private set; }
-
- ///
- /// Reads to the next node in the XML document, and updates the context accordingly.
- /// If node is RequestId, reads the contents and stores in RequestId property.
- ///
- ///
- /// True if a node was read, false if there are no more elements to read./
- ///
- public override bool Read()
- {
- bool result = base.Read();
- if (RequestId == null)
- {
- if (IsStartElement && TestExpression("RequestId", 2))
- {
- RequestId = StringUnmarshaller.GetInstance().Unmarshall(this);
- }
- }
- return result;
- }
- }
-
}
diff --git a/sdk/src/Core/Amazon.Runtime/Internal/Transform/ErrorResponseUnmarshaller.cs b/sdk/src/Core/Amazon.Runtime/Internal/Transform/XmlErrorResponseUnmarshaller.cs
similarity index 90%
rename from sdk/src/Core/Amazon.Runtime/Internal/Transform/ErrorResponseUnmarshaller.cs
rename to sdk/src/Core/Amazon.Runtime/Internal/Transform/XmlErrorResponseUnmarshaller.cs
index 24c99ec6fd15..6af0180ee1c2 100644
--- a/sdk/src/Core/Amazon.Runtime/Internal/Transform/ErrorResponseUnmarshaller.cs
+++ b/sdk/src/Core/Amazon.Runtime/Internal/Transform/XmlErrorResponseUnmarshaller.cs
@@ -23,7 +23,7 @@ namespace Amazon.Runtime.Internal.Transform
///
/// Response Unmarshaller for all Errors
///
- public class ErrorResponseUnmarshaller : IUnmarshaller
+ public class XmlErrorResponseUnmarshaller : IXmlUnmarshaller
{
///
/// Build an ErrorResponse from XML
@@ -108,18 +108,20 @@ private static bool TryReadContext(XmlUnmarshallerContext context)
}
}
- private static ErrorResponseUnmarshaller instance;
+ private static XmlErrorResponseUnmarshaller instance;
+#pragma warning disable CA1024 // Use properties where appropriate
///
/// Return an instance of and ErrorResponseUnmarshaller.
///
///
- public static ErrorResponseUnmarshaller GetInstance()
+ public static XmlErrorResponseUnmarshaller GetInstance()
{
if (instance == null)
- instance = new ErrorResponseUnmarshaller();
+ instance = new XmlErrorResponseUnmarshaller();
return instance;
}
}
+#pragma warning restore CA1024 // Use properties where appropriate
}
diff --git a/sdk/src/Core/Amazon.Runtime/Internal/Transform/XmlUnmarshallerContext.cs b/sdk/src/Core/Amazon.Runtime/Internal/Transform/XmlUnmarshallerContext.cs
new file mode 100644
index 000000000000..39b3b7cbd9df
--- /dev/null
+++ b/sdk/src/Core/Amazon.Runtime/Internal/Transform/XmlUnmarshallerContext.cs
@@ -0,0 +1,420 @@
+using Amazon.Runtime.Internal.Util;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml;
+
+namespace Amazon.Runtime.Internal.Transform
+{
+ ///
+ /// Wrap an XmltextReader for simulating an event stream.
+ ///
+ /// Each Read() operation goes either to the next element or next attribute within
+ /// the current element. TestExpression() is used to match the current event
+ /// to an xpath expression. The general pattern looks like this:
+ ///
+ /// UnmarshallerContext context = new UnmarshallerContext(...);
+ /// while (context.Read())
+ /// {
+ /// if (context.TestExpresion("path/to/element"))
+ /// {
+ /// myObject.stringMember = stringUnmarshaller.GetInstance().Unmarshall(context);
+ /// continue;
+ /// }
+ /// if (context.TestExpression("path/to/@attribute"))
+ /// myObject.MyComplexTypeMember = MyComplexTypeUnmarshaller.GetInstance().Unmarshall(context);
+ /// }
+ ///
+ ///
+ public class XmlUnmarshallerContext : UnmarshallerContext
+ {
+ #region Private members
+
+ private static HashSet nodesToSkip = new HashSet
+ {
+ XmlNodeType.None,
+ XmlNodeType.XmlDeclaration,
+ XmlNodeType.Comment,
+ XmlNodeType.DocumentType,
+ XmlNodeType.CDATA,
+ XmlNodeType.Whitespace
+ };
+
+ private StreamReader streamReader;
+ private XmlTextReader _xmlTextReader;
+ private Stack stack = new Stack();
+ private string stackString = "";
+ private Dictionary attributeValues;
+ private List attributeNames;
+ private IEnumerator attributeEnumerator;
+ private XmlNodeType nodeType;
+ private string nodeContent = String.Empty;
+ private bool disposed = false;
+ private bool currentlyProcessingEmptyElement;
+
+ public Stream Stream
+ {
+ get
+ {
+ return streamReader.BaseStream;
+ }
+ }
+
+ ///
+ /// Despite Microsoft's recommendation to use XmlReader for .NET Framework 2.0 or greater
+ /// (https://docs.microsoft.com/en-us/dotnet/api/system.xml.xmltextreader#remarks), this class
+ /// intentionally uses XmlTextReader to handle the XML related object key constraints
+ /// for S3 (https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-keys.html).
+ ///
+ private XmlTextReader XmlReader
+ {
+ get
+ {
+ if (_xmlTextReader == null)
+ {
+ _xmlTextReader = new XmlTextReader(streamReader);
+ _xmlTextReader.WhitespaceHandling = WhitespaceHandling.All;
+ _xmlTextReader.DtdProcessing = DtdProcessing.Ignore;
+ }
+ return _xmlTextReader;
+ }
+ }
+
+ #endregion
+
+ #region Constructors
+
+ ///
+ /// Wrap an XmlTextReader with state for event-based parsing of an XML stream.
+ ///
+ /// Stream with the XML from a service response.
+ /// If set to true, maintains a copy of the complete response body constraint to log response size as the stream is being read.
+ /// Response data coming back from the request
+ /// If set to true, maintains a copy of the complete response body as the stream is being read.
+ public XmlUnmarshallerContext(Stream responseStream, bool maintainResponseBody, IWebResponseData responseData, bool isException = false)
+ : this(responseStream, maintainResponseBody, responseData, isException, null)
+ {
+ }
+
+ ///
+ /// Wrap an XmlTextReader with state for event-based parsing of an XML stream.
+ ///
+ /// Stream with the XML from a service response.
+ /// If set to true, maintains a copy of the complete response body constraint to log response size as the stream is being read.
+ /// Response data coming back from the request
+ /// If set to true, maintains a copy of the complete response body as the stream is being read.
+ /// Context for the request that produced this response
+ public XmlUnmarshallerContext(Stream responseStream, bool maintainResponseBody, IWebResponseData responseData, bool isException, IRequestContext requestContext)
+ {
+ if (isException)
+ {
+ this.WrappingStream = new CachingWrapperStream(responseStream);
+ }
+ else if (maintainResponseBody)
+ {
+ this.WrappingStream = new CachingWrapperStream(responseStream, AWSConfigs.LoggingConfig.LogResponsesSizeLimit);
+ }
+
+ if (isException || maintainResponseBody)
+ {
+ responseStream = this.WrappingStream;
+ }
+ // If the unmarshaller context is being called internally without there being a http response then the response data would be null
+ if (responseData != null)
+ {
+ long contentLength;
+ bool parsedContentLengthHeader = long.TryParse(responseData.GetHeaderValue("Content-Length"), out contentLength);
+
+ if (parsedContentLengthHeader && contentLength == 0)
+ {
+ IsEmptyResponse = true;
+ }
+ // Validate flexible checksums if we know the content length and the behavior was opted in to on the request
+ if (parsedContentLengthHeader && responseData.ContentLength == contentLength &&
+ string.IsNullOrEmpty(responseData.GetHeaderValue("Content-Encoding")) &&
+ requestContext?.OriginalRequest?.CoreChecksumMode == CoreChecksumResponseBehavior.ENABLED)
+ {
+ SetupFlexibleChecksumStream(responseData, responseStream, contentLength, requestContext);
+ }
+ }
+
+ streamReader = new StreamReader(this.FlexibleChecksumStream ?? responseStream);
+
+ this.WebResponseData = responseData;
+ this.MaintainResponseBody = maintainResponseBody;
+ this.IsException = isException;
+ }
+
+ #endregion
+
+ #region Overrides
+
+ ///
+ /// The current XML path that is being unmarshalled.
+ ///
+ public override string CurrentPath
+ {
+ get { return this.stackString; }
+ }
+
+ ///
+ /// Returns the element depth of the parser's current position in the XML
+ /// document being parsed.
+ ///
+ public override int CurrentDepth
+ {
+ get { return stack.Count; }
+ }
+
+ ///
+ /// True if NodeType is Element.
+ ///
+ public override bool IsStartElement
+ {
+ get { return this.nodeType == XmlNodeType.Element; }
+ }
+
+ ///
+ /// True if NodeType is EndElement.
+ ///
+ public override bool IsEndElement
+ {
+ get { return this.nodeType == XmlNodeType.EndElement; }
+ }
+
+ ///
+ /// True if the context is at the start of the document.
+ ///
+ public override bool IsStartOfDocument
+ {
+ get { return XmlReader.ReadState == ReadState.Initial; }
+ }
+
+ #endregion
+
+ #region Public methods
+
+ ///
+ /// Returns the text contents of the current element being parsed.
+ ///
+ ///
+ /// The text contents of the current element being parsed.
+ ///
+ public string ReadText()
+ {
+ if (this.nodeType == XmlNodeType.Attribute)
+ {
+ return (attributeValues[attributeEnumerator.Current]);
+ }
+ else
+ {
+ return nodeContent;
+ }
+ }
+
+ ///
+ /// Reads the next token at depth greater than or equal to target depth.
+ ///
+ /// Tokens are read at depth greater than or equal to target depth.
+ /// True if a token was read and current depth is greater than or equal to target depth.
+ public bool ReadAtDepth(int targetDepth)
+ {
+ return Read() && this.CurrentDepth >= targetDepth;
+ }
+
+ ///
+ /// Reads to the next node in the XML document, and updates the context accordingly.
+ ///
+ ///
+ /// True if a node was read, false if there are no more elements to read./
+ ///
+ public virtual bool Read()
+ {
+ if (attributeEnumerator != null && attributeEnumerator.MoveNext())
+ {
+ this.nodeType = XmlNodeType.Attribute;
+ stackString = string.Format(CultureInfo.InvariantCulture, "{0}/@{1}", StackToPath(stack), attributeEnumerator.Current);
+ }
+ else
+ {
+ // Skip some nodes
+ if (nodesToSkip.Contains(XmlReader.NodeType))
+ XmlReader.Read();
+
+ if (currentlyProcessingEmptyElement)
+ {
+ nodeType = XmlNodeType.EndElement;
+ stack.Pop();
+ stackString = StackToPath(stack);
+ XmlReader.Read();
+ currentlyProcessingEmptyElement = false;
+ }
+ else if (XmlReader.IsEmptyElement)
+ {
+ //This is a shorthand form of an empty element and we want to allow it
+ nodeType = XmlNodeType.Element;
+ stack.Push(XmlReader.LocalName);
+ stackString = StackToPath(stack);
+ currentlyProcessingEmptyElement = true;
+ nodeContent = String.Empty;
+
+ //Defer reading so that on next pass we can treat this same element as the end element.
+ }
+ else
+ {
+ switch (XmlReader.NodeType)
+ {
+ case XmlNodeType.EndElement:
+ this.nodeType = XmlNodeType.EndElement;
+ stack.Pop();
+ stackString = StackToPath(stack);
+ XmlReader.Read();
+ break;
+ case XmlNodeType.Element:
+ nodeType = XmlNodeType.Element;
+ stack.Push(XmlReader.LocalName);
+ stackString = StackToPath(stack);
+ this.ReadElement();
+ break;
+ }
+ }
+ }
+
+ bool moreDataAvailable =
+ XmlReader.ReadState != ReadState.EndOfFile &&
+ XmlReader.ReadState != ReadState.Error &&
+ XmlReader.ReadState != ReadState.Closed;
+ return moreDataAvailable;
+ }
+ ///
+ /// True if NodeType is Attribute.
+ ///
+ public bool IsAttribute
+ {
+ get { return this.nodeType == XmlNodeType.Attribute; }
+ }
+
+ #endregion
+
+ #region Private Methods
+
+ private static string StackToPath(Stack stack)
+ {
+ string path = null;
+ foreach (string s in stack.ToArray())
+ {
+ path = null == path ? s : string.Format(CultureInfo.InvariantCulture, "{0}/{1}", s, path);
+ }
+ return "/" + path;
+ }
+
+ // Move to the next element, cache the attributes collection
+ // and attempt to cache the inner text of the element if applicable.
+ private void ReadElement()
+ {
+ if (XmlReader.HasAttributes)
+ {
+ attributeValues = new Dictionary();
+ attributeNames = new List();
+ while (XmlReader.MoveToNextAttribute())
+ {
+ attributeValues.Add(XmlReader.LocalName, XmlReader.Value);
+ attributeNames.Add(XmlReader.LocalName);
+ }
+ attributeEnumerator = attributeNames.GetEnumerator();
+ }
+ XmlReader.MoveToElement();
+ XmlReader.Read();
+
+ if (XmlReader.NodeType == XmlNodeType.Text || XmlReader.NodeType == XmlNodeType.Whitespace)
+ nodeContent = XmlReader.ReadContentAsString();
+ else
+ nodeContent = String.Empty;
+ }
+
+ #endregion
+
+ protected override void Dispose(bool disposing)
+ {
+ if (!this.disposed)
+ {
+ if (disposing)
+ {
+ if (streamReader != null)
+ {
+ streamReader.Dispose();
+ streamReader = null;
+ }
+ if (_xmlTextReader != null)
+ {
+#if NETSTANDARD
+ _xmlTextReader.Dispose();
+#else
+ _xmlTextReader.Close();
+#endif
+ _xmlTextReader = null;
+ }
+ }
+ disposed = true;
+ }
+ base.Dispose(disposing);
+ }
+ }
+
+ public class EC2UnmarshallerContext : XmlUnmarshallerContext
+ {
+ ///
+ /// Wrap an XmlTextReader with state for event-based parsing of an XML stream.
+ ///
+ /// Stream with the XML from a service response.
+ /// If set to true, maintains a copy of the complete response body constraint to log response size as the stream is being read.
+ /// Response data coming back from the request
+ /// If set to true, maintains a copy of the complete response body as the stream is being read.
+ public EC2UnmarshallerContext(Stream responseStream, bool maintainResponseBody, IWebResponseData responseData, bool isException = false)
+ : base(responseStream, maintainResponseBody, responseData, isException)
+ {
+ }
+
+ ///
+ /// Wrap an XmlTextReader with state for event-based parsing of an XML stream.
+ ///
+ /// Stream with the XML from a service response.
+ /// If set to true, maintains a copy of the complete response body constraint to log response size as the stream is being read.
+ /// Response data coming back from the request
+ /// If set to true, maintains a copy of the complete response body as the stream is being read.
+ /// Context for the request that produced this response
+ public EC2UnmarshallerContext(Stream responseStream, bool maintainResponseBody, IWebResponseData responseData, bool isException, IRequestContext requestContext)
+ : base(responseStream, maintainResponseBody, responseData, isException, requestContext)
+ {
+ }
+
+ ///
+ /// RequestId value, if found in response
+ ///
+ public string RequestId { get; private set; }
+
+ ///
+ /// Reads to the next node in the XML document, and updates the context accordingly.
+ /// If node is RequestId, reads the contents and stores in RequestId property.
+ ///
+ ///
+ /// True if a node was read, false if there are no more elements to read./
+ ///
+ public override bool Read()
+ {
+ bool result = base.Read();
+ if (RequestId == null)
+ {
+ if (IsStartElement && TestExpression("RequestId", 2))
+ {
+ RequestId = StringUnmarshaller.GetInstance().Unmarshall(this);
+ }
+ }
+ return result;
+ }
+ }
+}
diff --git a/sdk/src/Core/Amazon.Runtime/Internal/Util/JsonConstants.cs b/sdk/src/Core/Amazon.Runtime/Internal/Util/JsonConstants.cs
new file mode 100644
index 000000000000..f1470b5e3cc2
--- /dev/null
+++ b/sdk/src/Core/Amazon.Runtime/Internal/Util/JsonConstants.cs
@@ -0,0 +1,29 @@
+/*
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License").
+ * You may not use this file except in compliance with the License.
+ * A copy of the License is located at
+ *
+ * http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Amazon.Runtime.Internal.Util
+{
+ ///
+ /// Constants used in JSON unmarshalling.
+ ///
+ public static class JsonConstants
+ {
+ private static byte[] _utf8BomBytes = new byte[] { 0xEF, 0xBB, 0xBF };
+ public static ReadOnlySpan Utf8Bom => _utf8BomBytes;
+ }
+}
diff --git a/sdk/src/Core/Amazon.Runtime/Internal/Util/StreamingUtf8JsonReader.cs b/sdk/src/Core/Amazon.Runtime/Internal/Util/StreamingUtf8JsonReader.cs
new file mode 100644
index 000000000000..27a7d50536b7
--- /dev/null
+++ b/sdk/src/Core/Amazon.Runtime/Internal/Util/StreamingUtf8JsonReader.cs
@@ -0,0 +1,181 @@
+/*
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License").
+ * You may not use this file except in compliance with the License.
+ * A copy of the License is located at
+ *
+ * http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+using System;
+using System.Buffers;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Text;
+using System.Text.Json;
+using System.Threading.Tasks;
+
+namespace Amazon.Runtime.Internal.Util
+{
+ ///
+ /// A wrapper around Utf8JsonReader that can handle reading from a stream.
+ ///
+ public ref struct StreamingUtf8JsonReader
+ {
+ private Utf8JsonReader _reader;
+ private static JsonReaderOptions _jsonOptions = new JsonReaderOptions
+ {
+ AllowTrailingCommas = true
+ };
+ ///
+ /// The UTF8JsonReader attached to the instance.
+ ///
+ public Utf8JsonReader Reader
+ {
+ get
+ {
+ return _reader;
+ }
+ }
+
+ private Stream _stream;
+ private byte[] _buffer;
+
+ ///
+ /// Initializes a new instance of the StreamingUtf8JsonReader. Upon initialization the reader will read from the stream and fill the buffer.
+ /// If a UTF8 BOM is present in the stream, it will be skipped. Unless is set, the default
+ /// buffer size for buffering data from the stream will be 4096. You can also use the constructor that accepts bufferSize to change this value.
+ ///
+ /// the stream containing the data
+ public StreamingUtf8JsonReader(Stream stream) : this(stream, AWSConfigs.StreamingUtf8JsonReaderBufferSize ?? 4096)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the StreamingUtf8JsonReader. Upon initialization the reader will read from the stream and fill the buffer.
+ /// If a UTF8 BOM is present in the stream, it will be skipped.
+ ///
+ /// the stream containing the data
+ /// the size of the buffer when reading data from the stream
+ ///
+ public StreamingUtf8JsonReader(Stream stream, int bufferSize)
+ {
+ if (stream is null)
+ throw new ArgumentException("Stream must not be null. Please initialize a stream and pass it into the constructor.");
+
+ _stream = stream;
+ _buffer = ArrayPool.Shared.Rent(bufferSize);
+ int utf8BomLength = JsonConstants.Utf8Bom.Length;
+ Debug.Assert(_buffer.Length >= utf8BomLength);
+
+ int bytesRead = _stream.Read(_buffer, 0, _buffer.Length);
+ int start = 0;
+ if (_buffer.AsSpan().StartsWith(JsonConstants.Utf8Bom))
+ {
+ start += utf8BomLength;
+ bytesRead -= utf8BomLength;
+ }
+
+ _reader = new Utf8JsonReader(_buffer.AsSpan(start, bytesRead), isFinalBlock: bytesRead == 0, new JsonReaderState(_jsonOptions));
+ }
+
+ ///
+ /// Reads data from the buffer and fetches more data from the stream to fill the buffer it more data exists.
+ ///
+ /// true if there is more data, false otherwise.
+ public bool Read()
+ {
+ // hasMoreData can return false if the value starts in one buffer and leaks into the next buffer
+ bool hasMoreData = _reader.Read();
+
+ while (!hasMoreData)
+ {
+ if (_reader.IsFinalBlock)
+ {
+ ArrayPool.Shared.Return(_buffer);
+ break;
+ }
+
+ GetMoreBytesFromStream(_stream, ref _buffer, ref _reader);
+
+ hasMoreData = _reader.Read();
+ }
+
+ return hasMoreData;
+ }
+
+ private static void GetMoreBytesFromStream(Stream stream, ref byte[] buffer, ref Utf8JsonReader reader)
+ {
+ int bytesRead = 0;
+ ReadOnlySpan leftover = buffer.AsSpan().Slice((int)reader.BytesConsumed);
+ if (reader.BytesConsumed < buffer.Length)
+ {
+ // If BytesConsumed is 0 that means that the previous Read failed because the JSON token was too large to fit in the buffer.
+ // In that case we need to resize the buffer and try again to read the JSON token.
+ if (reader.BytesConsumed == 0)
+ {
+ var resizedBuffer = ArrayPool.Shared.Rent(Math.Min(int.MaxValue, (buffer.Length * 2)));
+ Logger.GetLogger(typeof(StreamingUtf8JsonReader)).DebugFormat("Resizing buffer from {0} to {1}", buffer.Length, resizedBuffer.Length);
+ // copy over the data from the previous read's buffer to the newly resized buffer.
+ buffer.AsSpan().CopyTo(resizedBuffer);
+ // return the previous buffer to the pool and set the new buffer to equal the resized buffer.
+ ArrayPool.Shared.Return(buffer);
+ buffer = resizedBuffer;
+ // fill the new resized buffer with data from the stream. the offset MUST be leftover.Length
+ // so we don't overwrite the data that was copied from the previous buffer, and the number of bytes
+ // we read must be buffer.Length - leftover.Length which is just the second half of the buffer.
+ bytesRead = FillBuffer(stream, ref buffer, leftover.Length, buffer.Length - leftover.Length);
+ var resizedSpan = buffer.AsSpan(0, bytesRead + leftover.Length);
+ reader = new Utf8JsonReader(resizedSpan, isFinalBlock: bytesRead == 0, reader.CurrentState);
+ // early return since we have a reader
+ return;
+ }
+ else
+ {
+ // Move the unprocessed data from the buffer to the start and fill
+ // remaining space in the buffer with new content from the stream.
+ leftover.CopyTo(buffer);
+ bytesRead = FillBuffer(stream, ref buffer, leftover.Length, buffer.Length - leftover.Length);
+ }
+ }
+ else
+ {
+ bytesRead = FillBuffer(stream, ref buffer, 0, buffer.Length);
+ }
+
+ if (bytesRead == 0)
+ {
+ // empty buffer will be returned
+ reader = new Utf8JsonReader(buffer.AsSpan(0, bytesRead), isFinalBlock: true, reader.CurrentState);
+ return;
+ }
+
+ // passing in 0 for the start position and bytesRead + leftover.Length as the span length is safe here because even if we are on the last buffer block,
+ // and leftover is junk, that means bytesRead would've been zero and control would flow through the if block above.
+ reader = new Utf8JsonReader(buffer.AsSpan(0, bytesRead + leftover.Length), isFinalBlock: ((bytesRead + leftover.Length) != buffer.Length || bytesRead == 0), reader.CurrentState);
+ }
+
+ private static int FillBuffer(Stream stream, ref byte[] buffer, int offset, int bytesToRead)
+ {
+ if (stream is null)
+ throw new ArgumentNullException("stream must be populated.");
+ int bytesRead = 0;
+ while (bytesToRead > 0)
+ {
+ int read = stream.Read(buffer, offset, bytesToRead);
+ if (read == 0) break; // End of stream
+ offset += read;
+ bytesToRead -= read;
+ bytesRead += read;
+ }
+
+ return bytesRead;
+ }
+ }
+}
diff --git a/sdk/src/Core/Amazon.Util/AWSSDKUtils.cs b/sdk/src/Core/Amazon.Util/AWSSDKUtils.cs
index 2d38a6a47936..6d27ee6e3578 100644
--- a/sdk/src/Core/Amazon.Util/AWSSDKUtils.cs
+++ b/sdk/src/Core/Amazon.Util/AWSSDKUtils.cs
@@ -848,6 +848,13 @@ public static void CopyStream(Stream source, Stream destination, int bufferSize)
{
source.CopyTo(destination, bufferSize);
}
+
+ public static void CopyStreamAndSetPositionToZero(Stream source, Stream destination)
+ {
+ source.CopyTo(destination);
+ source.Position = 0;
+ destination.Position = 0;
+ }
#endregion
#region Public Methods and Properties
diff --git a/sdk/src/Core/Amazon.Util/Internal/RootConfig.cs b/sdk/src/Core/Amazon.Util/Internal/RootConfig.cs
index 2550fe805fa6..3c3b17a4ac8d 100644
--- a/sdk/src/Core/Amazon.Util/Internal/RootConfig.cs
+++ b/sdk/src/Core/Amazon.Util/Internal/RootConfig.cs
@@ -47,6 +47,7 @@ public RegionEndpoint RegionEndpoint
public bool? CSMEnabled { get; set; }
public string CSMClientId { get; set; }
public int? CSMPort { get; set; }
+ public int? StreamingUtf8JsonReaderBufferSize { get; set; }
#if NET8_0_OR_GREATER
public bool DisableDangerousDisablePathAndQueryCanonicalization { get; set; }
diff --git a/sdk/src/Core/GlobalSuppressions.cs b/sdk/src/Core/GlobalSuppressions.cs
index 359bd1bc2926..69264c720658 100644
--- a/sdk/src/Core/GlobalSuppressions.cs
+++ b/sdk/src/Core/GlobalSuppressions.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
@@ -41,11 +41,14 @@
[module: SuppressMessage("Microsoft.Naming", "CA1715:IdentifiersShouldHaveCorrectPrefix", Scope = "type", Target = "Amazon.Runtime.Internal.Transform.IUnmarshaller`2", MessageId = "T")]
[module: SuppressMessage("Microsoft.Naming", "CA1715:IdentifiersShouldHaveCorrectPrefix", Scope = "type", Target = "Amazon.Runtime.Internal.Transform.DictionaryUnmarshaller`4", MessageId = "T")]
[module: SuppressMessage("Microsoft.Naming", "CA1715:IdentifiersShouldHaveCorrectPrefix", Scope = "type", Target = "Amazon.Runtime.Internal.Transform.IMarshaller`2", MessageId = "T")]
-[module: SuppressMessage("Microsoft.Naming", "CA1715:IdentifiersShouldHaveCorrectPrefix", Scope = "type", Target = "Amazon.Runtime.Internal.Transform.ListUnmarshaller`2", MessageId = "T")]
-[module: SuppressMessage("Microsoft.Naming", "CA1715:IdentifiersShouldHaveCorrectPrefix", Scope = "type", Target = "Amazon.Runtime.Internal.Transform.KeyValueUnmarshaller`4", MessageId = "T")]
[module: SuppressMessage("Microsoft.Naming", "CA1715:IdentifiersShouldHaveCorrectPrefix", Scope = "type", Target = "Amazon.Runtime.Internal.Transform.IRequestMarshaller`2", MessageId = "T")]
[module: SuppressMessage("Microsoft.Naming", "CA1715:IdentifiersShouldHaveCorrectPrefix", Scope = "type", Target = "Amazon.Runtime.Internal.AutoConstructedDictionary`2", MessageId = "T")]
-
+[module: SuppressMessage("Microsoft.Naming", "CA1715:IdentifiersShouldHaveCorrectPrefix", Scope = "type", Target = "Amazon.Runtime.Internal.Transform.XmlKeyValueUnmarshaller`4", MessageId = "T")]
+[module: SuppressMessage("Microsoft.Naming", "CA1715:IdentifiersShouldHaveCorrectPrefix", Scope = "type", Target = "Amazon.Runtime.Internal.Transform.JsonKeyValueUnmarshaller`4", MessageId = "T")]
+[module: SuppressMessage("Microsoft.Naming", "CA1715:IdentifiersShouldHaveCorrectPrefix", Scope = "type", Target = "Amazon.Runtime.Internal.Transform.XmlDictionaryUnmarshaller`2", MessageId = "T")]
+[module: SuppressMessage("Microsoft.Naming", "CA1715:IdentifiersShouldHaveCorrectPrefix", Scope = "type", Target = "Amazon.Runtime.Internal.Transform.JsonDictionaryUnmarshaller`2", MessageId = "T")]
+[module: SuppressMessage("Microsoft.Naming", "CA1715:IdentifiersShouldHaveCorrectPrefix", Scope = "type", Target = "Amazon.Runtime.Internal.Transform.XmlListUnmarshaller`2", MessageId = "T")]
+[module: SuppressMessage("Microsoft.Naming", "CA1715:IdentifiersShouldHaveCorrectPrefix", Scope = "type", Target = "Amazon.Runtime.Internal.Transform.JsonListUnmarshaller`2", MessageId = "T")]
// Identifiers should not contain type names
[module: SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", Scope = "member", Target = "Amazon.Runtime.Internal.Auth.AWS4PreSignedUrlSigner.#MaxAWS4PreSignedUrlExpiry", MessageId = "signed")]
[module: SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", Scope = "member", Target = "Amazon.Runtime.Internal.Auth.AWS4Signer.#FormatDateTime(System.DateTime,System.String)", MessageId = "string")]
@@ -426,6 +429,8 @@
// Amazon.Runtime.Internal.Signer type conflicts with Amazon.Signer service namespace.
[module: SuppressMessage("Microsoft.Naming", "CA1724:TypeNamesShouldNotMatchNamespaces", Scope = "type", Target = "Amazon.Runtime.Internal.Signer")]
+// Override Equals and operator equals on value types
+[module: SuppressMessage("Performance","CA1815:Override equals and operator equals on value types",Scope = "type",Target = "T:Amazon.Runtime.Internal.Util.StreamingUtf8JsonReader")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1720:Identifier contains type name", Scope = "type", Target = "~T:ThirdParty.Json.LitJson.JsonType")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1010:Collections should implement generic interface", Scope = "type", Target = "~T:Amazon.MissingTypes.IOrderedDictionary")]
diff --git a/sdk/src/Core/ThirdParty/RuntimeBackports/ArrayPoolExtensions.cs b/sdk/src/Core/ThirdParty/RuntimeBackports/ArrayPoolExtensions.cs
new file mode 100644
index 000000000000..fd67c7dc785a
--- /dev/null
+++ b/sdk/src/Core/ThirdParty/RuntimeBackports/ArrayPoolExtensions.cs
@@ -0,0 +1,100 @@
+// Taken from https://raw.githubusercontent.com/CommunityToolkit/dotnet/refs/heads/main/src/CommunityToolkit.HighPerformance/Extensions/ArrayPoolExtensions.cs
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Buffers;
+using System.Diagnostics.CodeAnalysis;
+#nullable enable
+namespace ThirdParty.RuntimeBackports
+{
+ ///
+ /// Helpers for working with the type.
+ ///
+ public static class ArrayPoolExtensions
+ {
+ ///
+ /// Changes the number of elements of a rented one-dimensional array to the specified new size.
+ ///
+ /// The type of items into the target array to resize.
+ /// The target instance to use to resize the array.
+ /// The rented array to resize, or to create a new array.
+ /// The size of the new array.
+ /// Indicates whether the contents of the array should be cleared before reuse.
+ /// Thrown when is less than 0.
+ /// When this method returns, the caller must not use any references to the old array anymore.
+ public static void Resize(this ArrayPool pool, ref T[]? array, int newSize, bool clearArray = false)
+ {
+ // If the old array is null, just create a new one with the requested size
+ if (array is null)
+ {
+ array = pool.Rent(newSize);
+
+ return;
+ }
+
+ // If the new size is the same as the current size, do nothing
+ if (array.Length == newSize)
+ {
+ return;
+ }
+
+ // Rent a new array with the specified size, and copy as many items from the current array
+ // as possible to the new array. This mirrors the behavior of the Array.Resize API from
+ // the BCL: if the new size is greater than the length of the current array, copy all the
+ // items from the original array into the new one. Otherwise, copy as many items as possible,
+ // until the new array is completely filled, and ignore the remaining items in the first array.
+ T[] newArray = pool.Rent(newSize);
+ int itemsToCopy = Math.Min(array.Length, newSize);
+
+ Array.Copy(array, 0, newArray, 0, itemsToCopy);
+
+ pool.Return(array, clearArray);
+
+ array = newArray;
+ }
+
+ ///
+ /// Ensures that when the method returns is not null and is at least in length.
+ /// Contents of are not copied if a new array is rented.
+ ///
+ /// The type of items into the target array given as input.
+ /// The target instance used to rent and/or return the array.
+ /// The rented array to ensure capacity for, or to rent a new array.
+ /// The minimum length of when the method returns.
+ /// Indicates whether the contents of the array should be cleared if returned to the pool.
+ /// Thrown when is less than 0.
+ /// When this method returns, the caller must not use any references to the old array anymore.
+ public static void EnsureCapacity(this ArrayPool pool, ref T[]? array, int capacity, bool clearArray = false)
+ {
+ if (capacity < 0)
+ {
+ ThrowArgumentOutOfRangeExceptionForNegativeArrayCapacity();
+ }
+
+ if (array is null)
+ {
+ array = pool.Rent(capacity);
+ }
+ else if (array.Length < capacity)
+ {
+ // Ensure rent succeeds before returning the original array to the pool
+ T[] newArray = pool.Rent(capacity);
+
+ pool.Return(array, clearArray);
+
+ array = newArray;
+ }
+ }
+
+ ///
+ /// Throws an when the "capacity" parameter is negative.
+ ///
+ private static void ThrowArgumentOutOfRangeExceptionForNegativeArrayCapacity()
+ {
+ throw new ArgumentOutOfRangeException("capacity", "The array capacity must be a positive number.");
+ }
+ }
+}
+
diff --git a/sdk/src/Core/ThirdParty/RuntimeBackports/BitOperations.cs b/sdk/src/Core/ThirdParty/RuntimeBackports/BitOperations.cs
new file mode 100644
index 000000000000..58612b9c820b
--- /dev/null
+++ b/sdk/src/Core/ThirdParty/RuntimeBackports/BitOperations.cs
@@ -0,0 +1,37 @@
+// Taken from https://raw.githubusercontent.com/CommunityToolkit/dotnet/refs/heads/main/src/CommunityToolkit.HighPerformance/Helpers/Internals/BitOperations.cs
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Collections.Generic;
+using System.Runtime.CompilerServices;
+using System.Text;
+
+namespace ThirdParty.RuntimeBackports
+{
+ internal static class BitOperations
+ {
+ ///
+ /// Round the given integral value up to a power of 2.
+ ///
+ /// The value.
+ ///
+ /// The smallest power of 2 which is greater than or equal to .
+ /// If is 0 or the result overflows, returns 0.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static unsafe uint RoundUpToPowerOf2(uint value)
+ {
+ // Based on https://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
+ --value;
+ value |= value >> 1;
+ value |= value >> 2;
+ value |= value >> 4;
+ value |= value >> 8;
+ value |= value >> 16;
+
+ return value + 1;
+ }
+ }
+}
diff --git a/sdk/src/Core/ThirdParty/RuntimeBackports/_netstandard/ArrayPoolBufferWriter.cs b/sdk/src/Core/ThirdParty/RuntimeBackports/_netstandard/ArrayPoolBufferWriter.cs
new file mode 100644
index 000000000000..84de68665d8e
--- /dev/null
+++ b/sdk/src/Core/ThirdParty/RuntimeBackports/_netstandard/ArrayPoolBufferWriter.cs
@@ -0,0 +1,385 @@
+// partially adapted from https://raw.githubusercontent.com/CommunityToolkit/dotnet/refs/heads/main/src/CommunityToolkit.HighPerformance/Buffers/ArrayPoolBufferWriter%7BT%7D.cs
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Buffers;
+using System.Diagnostics;
+using System.Numerics;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using ThirdParty.RuntimeBackports;
+#if NET8_0_OR_GREATER
+using BitOperations = System.Numerics.BitOperations;
+#else
+using BitOperations = ThirdParty.RuntimeBackports.BitOperations;
+#endif
+#nullable enable
+namespace ThirdParty.RuntimeBackports
+{
+ ///
+ /// Represents a heap-based, array-backed output sink into which data can be written.
+ ///
+ /// The type of items to write to the current instance.
+ ///
+ /// This is a custom implementation that replicates the
+ /// functionality and API surface of the array-based buffer writer available in
+ /// .NET Standard 2.1, with the main difference being the fact that in this case
+ /// the arrays in use are rented from the shared instance,
+ /// and that is also available on .NET Standard 2.0.
+ ///
+ public sealed class ArrayPoolBufferWriter : IBufferWriter, IMemoryOwner
+ {
+ ///
+ /// The default buffer size to use to expand empty arrays.
+ ///
+ private const int DefaultInitialBufferSize = 256;
+
+ ///
+ /// The instance used to rent .
+ ///
+ private readonly ArrayPool pool;
+
+ ///
+ /// The underlying array.
+ ///
+ private T[]? array;
+
+#pragma warning disable IDE0032 // Use field over auto-property (clearer and faster)
+ ///
+ /// The starting offset within .
+ ///
+ private int index;
+#pragma warning restore IDE0032
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public ArrayPoolBufferWriter()
+ : this(ArrayPool.Shared, DefaultInitialBufferSize)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The instance to use.
+ public ArrayPoolBufferWriter(ArrayPool pool)
+ : this(pool, DefaultInitialBufferSize)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The minimum capacity with which to initialize the underlying buffer.
+ /// Thrown when is not valid.
+ public ArrayPoolBufferWriter(int initialCapacity)
+ : this(ArrayPool.Shared, initialCapacity)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The instance to use.
+ /// The minimum capacity with which to initialize the underlying buffer.
+ /// Thrown when is not valid.
+ public ArrayPoolBufferWriter(ArrayPool pool, int initialCapacity)
+ {
+ // Since we're using pooled arrays, we can rent the buffer with the
+ // default size immediately, we don't need to use lazy initialization
+ // to save unnecessary memory allocations in this case.
+ // Additionally, we don't need to manually throw the exception if
+ // the requested size is not valid, as that'll be thrown automatically
+ // by the array pool in use when we try to rent an array with that size.
+ this.pool = pool;
+ array = pool.Rent(initialCapacity);
+ index = 0;
+ }
+
+ ///
+ Memory IMemoryOwner.Memory
+ {
+ // This property is explicitly implemented so that it's hidden
+ // under normal usage, as the name could be confusing when
+ // displayed besides WrittenMemory and GetMemory().
+ // The IMemoryOwner interface is implemented primarily
+ // so that the AsStream() extension can be used on this type,
+ // allowing users to first create a ArrayPoolBufferWriter
+ // instance to write data to, then get a stream through the
+ // extension and let it take care of returning the underlying
+ // buffer to the shared pool when it's no longer necessary.
+ // Inlining is not needed here since this will always be a callvirt.
+ get => MemoryMarshal.AsMemory(WrittenMemory);
+ }
+
+ ///