diff --git a/extensions/AWSSDK.Extensions.sln b/extensions/AWSSDK.Extensions.sln index 3b45806eb294..c2d06ce0e53b 100644 --- a/extensions/AWSSDK.Extensions.sln +++ b/extensions/AWSSDK.Extensions.sln @@ -74,6 +74,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AWSSDK.CommonTest", "..\sdk EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AWSSDK.S3.NetFramework", "..\sdk\src\Services\S3\AWSSDK.S3.NetFramework.csproj", "{1A313326-988F-4FF2-992E-6D7E50DCF598}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AWSSDK.Extensions.CborProtocol.NetFramework", "src\AWSSDK.Extensions.CborProtocol\AWSSDK.Extensions.CborProtocol.NetFramework.csproj", "{4FCCBD72-8E9B-D74B-6538-D8684D181230}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AWSSDK.Extensions.CborProtocol.NetStandard", "src\AWSSDK.Extensions.CborProtocol\AWSSDK.Extensions.CborProtocol.NetStandard.csproj", "{24CBBC97-409E-BAC8-0553-D260AB0B8C6A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CborProtocol.Tests.NetFramework", "test\CborProtocol.Tests\CborProtocol.Tests.NetFramework.csproj", "{9FFDECAB-94D6-7EB1-1A5B-487492600755}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -204,6 +210,18 @@ Global {1A313326-988F-4FF2-992E-6D7E50DCF598}.Debug|Any CPU.Build.0 = Debug|Any CPU {1A313326-988F-4FF2-992E-6D7E50DCF598}.Release|Any CPU.ActiveCfg = Release|Any CPU {1A313326-988F-4FF2-992E-6D7E50DCF598}.Release|Any CPU.Build.0 = Release|Any CPU + {4FCCBD72-8E9B-D74B-6538-D8684D181230}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4FCCBD72-8E9B-D74B-6538-D8684D181230}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4FCCBD72-8E9B-D74B-6538-D8684D181230}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4FCCBD72-8E9B-D74B-6538-D8684D181230}.Release|Any CPU.Build.0 = Release|Any CPU + {24CBBC97-409E-BAC8-0553-D260AB0B8C6A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {24CBBC97-409E-BAC8-0553-D260AB0B8C6A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {24CBBC97-409E-BAC8-0553-D260AB0B8C6A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {24CBBC97-409E-BAC8-0553-D260AB0B8C6A}.Release|Any CPU.Build.0 = Release|Any CPU + {9FFDECAB-94D6-7EB1-1A5B-487492600755}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9FFDECAB-94D6-7EB1-1A5B-487492600755}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9FFDECAB-94D6-7EB1-1A5B-487492600755}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9FFDECAB-94D6-7EB1-1A5B-487492600755}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -240,6 +258,9 @@ Global {58BD3C7A-087C-4ECB-87C6-A3445025BEF5} = {A960D001-40B3-4B1A-A890-D1049FB7586E} {AF5B5402-7C9A-4E5E-B0C2-9278BAE0435C} = {A960D001-40B3-4B1A-A890-D1049FB7586E} {1A313326-988F-4FF2-992E-6D7E50DCF598} = {0BA39F07-84D6-420B-82D3-6DC3AF016C65} + {4FCCBD72-8E9B-D74B-6538-D8684D181230} = {3D822DC2-ED2E-4434-BC4F-CE7FCD846B02} + {24CBBC97-409E-BAC8-0553-D260AB0B8C6A} = {3D822DC2-ED2E-4434-BC4F-CE7FCD846B02} + {9FFDECAB-94D6-7EB1-1A5B-487492600755} = {A960D001-40B3-4B1A-A890-D1049FB7586E} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {949367A4-5683-4FD3-93F4-A2CEA6EECB21} diff --git a/extensions/test/CborProtocol.Tests/CborProtocol.Tests.NetFramework.csproj b/extensions/test/CborProtocol.Tests/CborProtocol.Tests.NetFramework.csproj new file mode 100644 index 000000000000..c32accb1f826 --- /dev/null +++ b/extensions/test/CborProtocol.Tests/CborProtocol.Tests.NetFramework.csproj @@ -0,0 +1,30 @@ + + + net472 + CborProtocol.Tests + CborProtocol.Tests + false + false + false + false + false + false + false + false + true + Latest + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + \ No newline at end of file diff --git a/extensions/test/CborProtocol.Tests/WriteDateTimeTests.cs b/extensions/test/CborProtocol.Tests/WriteDateTimeTests.cs new file mode 100644 index 000000000000..4df476f4849f --- /dev/null +++ b/extensions/test/CborProtocol.Tests/WriteDateTimeTests.cs @@ -0,0 +1,45 @@ +using System; +using System.Formats.Cbor; +using Xunit; +using AWSSDK.Extensions.CborProtocol; + +namespace Amazon.CborProtocol.Tests; + +public class WriteDateTimeTests +{ + [Theory] + [InlineData("1969-12-31T23:59:59Z", -1.0, CborReaderState.NegativeInteger, 2)] + [InlineData("1970-01-01T00:00:01Z", 1.0, CborReaderState.UnsignedInteger, 2)] + [InlineData("1970-01-01T00:00:00.500Z", 0.5, CborReaderState.SinglePrecisionFloat, 6)] + [InlineData("2025-01-01T00:00:00Z", 1735689600.0, CborReaderState.UnsignedInteger, 6)] + [InlineData("2025-06-19T20:15:28.468Z", 1750364128.468, CborReaderState.DoublePrecisionFloat, 10)] + public void WriteDateTime_EncodesCorrectly(string isoDate, double expectedUnixEpoch, CborReaderState expectedState, int expectedTotalBytes) + { + var dt = DateTime.Parse(isoDate); + var writer = new CborWriter(); + writer.WriteDateTime(dt); + + var encoded = writer.Encode(); + var reader = new CborReader(encoded); + var tag = reader.ReadTag(); + + Assert.Equal(CborTag.UnixTimeSeconds, tag); + Assert.Equal(expectedState, reader.PeekState()); + + double value = 0; + + if (expectedState == CborReaderState.SinglePrecisionFloat) + value = reader.ReadSingle(); + else if (expectedState == CborReaderState.DoublePrecisionFloat) + value = reader.ReadDouble(); + else if (expectedState == CborReaderState.UnsignedInteger) + value = reader.ReadUInt64(); + else if (expectedState == CborReaderState.NegativeInteger) + value = reader.ReadInt64(); + else + Assert.Fail($"CBOR state not found: ${reader.PeekState()}"); + + Assert.Equal(expectedUnixEpoch, value); + Assert.Equal(expectedTotalBytes, encoded.Length); + } +} diff --git a/extensions/test/CborProtocol.Tests/WriteOptimizedNumberTests.cs b/extensions/test/CborProtocol.Tests/WriteOptimizedNumberTests.cs new file mode 100644 index 000000000000..dec08da0cb49 --- /dev/null +++ b/extensions/test/CborProtocol.Tests/WriteOptimizedNumberTests.cs @@ -0,0 +1,55 @@ +using System.Formats.Cbor; +using Xunit; +using AWSSDK.Extensions.CborProtocol; + +namespace Amazon.CborProtocol.Tests; + +public class WriteOptimizedNumberTests +{ + [Theory] + [InlineData(0, 1)] // Fits in initial byte (major type + value) + [InlineData(23, 1)] // Still in initial byte + [InlineData(24, 2)] // One additional byte for UInt8 + [InlineData(255, 2)] // UInt8 + [InlineData(256, 3)] // UInt16 + [InlineData(65535, 3)] // UInt16 max + [InlineData(65536, 5)] // UInt32 + [InlineData(uint.MaxValue, 5)] // UInt32 + [InlineData((long)uint.MaxValue + 1, 9)] // UInt64 + public void WriteOptimizedNumber_UsesExpectedEncodingLength_ForUInt64(double value, int expectedBytes) + { + var writer = new CborWriter(); + writer.WriteOptimizedNumber((double)value); + var encoded = writer.Encode(); + + Assert.Equal(expectedBytes, encoded.Length); + } + + [Theory] + [InlineData(-1, 1)] // Negative integers encoded compactly + [InlineData(-24, 1)] + [InlineData(-25, 2)] // Beyond negative byte range + [InlineData(int.MinValue, 5)] // Should require full 32 bits + [InlineData(long.MinValue, 9)] // Full 64-bit negative integer + public void WriteOptimizedNumber_UsesExpectedEncodingLength_ForNegativeIntegers(long value, int expectedBytes) + { + var writer = new CborWriter(); + writer.WriteOptimizedNumber((double)value); + var encoded = writer.Encode(); + + Assert.Equal(expectedBytes, encoded.Length); + } + + [Theory] + [InlineData(1.5, 5, 0xFA)] // float32 marker + 4 bytes + [InlineData(123456789.12345, 9, 0xFB)] // Doesn't fit in float32 + public void WriteOptimizedNumber_Float32_IsManuallyEncodedAsFiveBytes(double value, int expectedBytes, byte floatMarker) + { + var writer = new CborWriter(); + writer.WriteOptimizedNumber(value); + var encoded = writer.Encode(); + + Assert.Equal(expectedBytes, encoded.Length); + Assert.Equal(floatMarker, encoded[0]); // Check float32 CBOR marker + } +} diff --git a/generator/.DevConfigs/6a90e4df-251e-45f8-808a-1a088cf0b25e.json b/generator/.DevConfigs/6a90e4df-251e-45f8-808a-1a088cf0b25e.json new file mode 100644 index 000000000000..0dc87396474b --- /dev/null +++ b/generator/.DevConfigs/6a90e4df-251e-45f8-808a-1a088cf0b25e.json @@ -0,0 +1,10 @@ + +{ + "core": { + "changeLogMessages": [ + "Cbor protocol temp message" + ], + "type": "patch", + "updateMinimum": true + } +} \ No newline at end of file diff --git a/generator/ProtocolTestsGenerator/settings.gradle.kts b/generator/ProtocolTestsGenerator/settings.gradle.kts index 0c14cf8100c8..f57af9125985 100644 --- a/generator/ProtocolTestsGenerator/settings.gradle.kts +++ b/generator/ProtocolTestsGenerator/settings.gradle.kts @@ -12,8 +12,9 @@ pluginManagement { dependencyResolutionManagement { versionCatalogs { create("codegen") { - version("smithy", "1.54.0") - library("protocol-tests", "software.amazon.smithy", "smithy-aws-protocol-tests").versionRef("smithy") + version("smithy", "1.58.0") + library("protocol-tests", "software.amazon.smithy", "smithy-protocol-tests").versionRef("smithy") + library("protocol-aws-tests", "software.amazon.smithy", "smithy-aws-protocol-tests").versionRef("smithy") library("codegen-core", "software.amazon.smithy", "smithy-codegen-core").versionRef("smithy") library("protocol-tests-traits", "software.amazon.smithy", "smithy-protocol-test-traits").versionRef("smithy") library("aws-traits", "software.amazon.smithy", "smithy-aws-traits").versionRef("smithy") diff --git a/generator/ProtocolTestsGenerator/smithy-dotnet-codegen/src/main/java/software/amazon/smithy/dotnet/codegen/HttpProtocolTestGenerator.java b/generator/ProtocolTestsGenerator/smithy-dotnet-codegen/src/main/java/software/amazon/smithy/dotnet/codegen/HttpProtocolTestGenerator.java index c8e4315db0b5..d9a879e88045 100644 --- a/generator/ProtocolTestsGenerator/smithy-dotnet-codegen/src/main/java/software/amazon/smithy/dotnet/codegen/HttpProtocolTestGenerator.java +++ b/generator/ProtocolTestsGenerator/smithy-dotnet-codegen/src/main/java/software/amazon/smithy/dotnet/codegen/HttpProtocolTestGenerator.java @@ -16,6 +16,7 @@ package software.amazon.smithy.dotnet.codegen; import software.amazon.smithy.aws.traits.ServiceTrait; +import software.amazon.smithy.model.traits.TitleTrait; import software.amazon.smithy.codegen.core.CodegenException; import software.amazon.smithy.dotnet.codegen.utils.ProtocolTestUtils; import software.amazon.smithy.model.Model; @@ -51,7 +52,14 @@ public HttpProtocolTestGenerator( this.model = context.model(); this.service = settings.getService(model); this.context = context; - this.serviceNamespace = service.getTrait(ServiceTrait.class).get().getSdkId().replace(" ", ""); + + String serviceNamespace = null; + if (service.getTrait(ServiceTrait.class).isPresent()) + serviceNamespace = service.getTrait(ServiceTrait.class).get().getSdkId(); + else if (service.getTrait(TitleTrait.class).isPresent()) + serviceNamespace = service.getTrait(TitleTrait.class).get().getValue().replace("Service", ""); + + this.serviceNamespace = serviceNamespace.replace(" ", ""); } @Override @@ -60,6 +68,8 @@ public void run() { OperationIndex operationIndex = OperationIndex.of(model); for (OperationShape operation : new TreeSet<>(topDownIndex.getContainedOperations(service))) { var operationName = operation.getId().getName(); + if (ProtocolTestCustomizations.OperationsToSkip.contains(operationName)) + continue; context.writerDelegator().useFileWriter(operationName + ".cs", serviceName, writer -> { this.writer = writer; addServiceProtocolSpecificImports(); @@ -87,6 +97,8 @@ private void addServiceProtocolSpecificImports() { } else if (this.serviceName.toLowerCase().contains("xml")) { writer.addImport(serviceName, "System.Xml"); writer.addImport(serviceName, "System.Xml.Linq"); + } else if (this.serviceName.toLowerCase().contains("rpcv2")) { + writer.addImport(serviceName, "AWSSDK.Extensions.CborProtocol.Internal"); } } @@ -94,7 +106,8 @@ private void generateErrorResponseTests(OperationShape operation, OperationIndex for (StructureShape error : index.getErrors(operation, service)) { error.getTrait(HttpResponseTestsTrait.class).ifPresent(trait -> { for (HttpResponseTestCase httpResponseTestCase : trait.getTestCasesFor(AppliesTo.CLIENT)) { - generateErrorResponseTest(operation, error, httpResponseTestCase); + if (!trait.getTestCasesFor(AppliesTo.CLIENT).getFirst().getProtocol().getName().toLowerCase().contains("cbor")) // Skip CBOR response tests until the unmarshallers are ready + generateErrorResponseTest(operation, error, httpResponseTestCase); } }); } @@ -283,6 +296,9 @@ private void assertRequestBody(HttpRequestTestCase httpRequestTestCase) { } else if (httpRequestTestCase.getProtocol().getName().equals("restXml")) { writer.write("var expectedBody = $S;", httpRequestTestCase.getBody()); writer.write("XmlTestUtils.AssertBody(marshalledRequest,expectedBody);"); + } else if (this.marshallerType.equals("Cbor")) { + writer.write("var expectedBody = $S;", httpRequestTestCase.getBody()); + writer.write("CborProtocolUtils.AssertBody(marshalledRequest, expectedBody);"); } else { throw new CodegenException("Unsupported protocol detected while generating request test block."); } @@ -294,7 +310,8 @@ private void generateResponseTests(OperationShape operation) { setMarshallerType(trait.getTestCasesFor(AppliesTo.CLIENT).getFirst().getProtocol().getName()); } for (HttpResponseTestCase httpResponseTestCase : trait.getTestCasesFor(AppliesTo.CLIENT)) { - if (ProtocolTestCustomizations.TestsToSkip.contains(httpResponseTestCase.getId()) || httpResponseTestCase.hasTag("defaults")) + if (ProtocolTestCustomizations.TestsToSkip.contains(httpResponseTestCase.getId()) || httpResponseTestCase.hasTag("defaults") + || trait.getTestCasesFor(AppliesTo.CLIENT).getFirst().getProtocol().getName().toLowerCase().contains("cbor")) // Skip CBOR response tests until the unmarshallers are ready continue; generateResponseTest(operation, httpResponseTestCase); } @@ -343,6 +360,8 @@ private void setMarshallerType(String protocol) { this.marshallerType = "Json"; } else if (protocol.toLowerCase().contains("xml") || protocol.toLowerCase().contains("query")) { this.marshallerType = "Xml"; + } else if (protocol.toLowerCase().contains("cbor")) { + this.marshallerType = "Cbor"; } } diff --git a/generator/ProtocolTestsGenerator/smithy-dotnet-codegen/src/main/java/software/amazon/smithy/dotnet/codegen/customizations/ProtocolTestCustomizations.java b/generator/ProtocolTestsGenerator/smithy-dotnet-codegen/src/main/java/software/amazon/smithy/dotnet/codegen/customizations/ProtocolTestCustomizations.java index 0cc7a2df9fd3..e8a7438727cf 100644 --- a/generator/ProtocolTestsGenerator/smithy-dotnet-codegen/src/main/java/software/amazon/smithy/dotnet/codegen/customizations/ProtocolTestCustomizations.java +++ b/generator/ProtocolTestsGenerator/smithy-dotnet-codegen/src/main/java/software/amazon/smithy/dotnet/codegen/customizations/ProtocolTestCustomizations.java @@ -20,6 +20,14 @@ private ProtocolTestCustomizations() { "SparseBooleanMap", "SparseNumberMap" ); + + // These operations don't exist in C2J + public static final List OperationsToSkip = Arrays.asList( + "RpcV2CborSparseMaps", + "OperationWithDefaults", + "SparseNullsOperation" + ); + //The rename is written in smithy and since we're generating from the C2J structures we will skip this test. public static final List TestsToSkip = Arrays.asList( "RestJsonSerializeRenamedStructureUnionValue", diff --git a/generator/ProtocolTestsGenerator/smithy-dotnet-protocol-test/build.gradle.kts b/generator/ProtocolTestsGenerator/smithy-dotnet-protocol-test/build.gradle.kts index 5ae891f3ea15..874b34ae93b3 100644 --- a/generator/ProtocolTestsGenerator/smithy-dotnet-protocol-test/build.gradle.kts +++ b/generator/ProtocolTestsGenerator/smithy-dotnet-protocol-test/build.gradle.kts @@ -27,6 +27,7 @@ repositories { dependencies { implementation(project(":smithy-dotnet-codegen")) + implementation(codegen.protocol.aws.tests) implementation(codegen.protocol.tests) } diff --git a/generator/ProtocolTestsGenerator/smithy-dotnet-protocol-test/smithy-build.json b/generator/ProtocolTestsGenerator/smithy-dotnet-protocol-test/smithy-build.json index 520ca34ea199..bdd22d6e4a06 100644 --- a/generator/ProtocolTestsGenerator/smithy-dotnet-protocol-test/smithy-build.json +++ b/generator/ProtocolTestsGenerator/smithy-dotnet-protocol-test/smithy-build.json @@ -127,6 +127,24 @@ "packageVersion": "0.0.1" } } + }, + "RpcV2Protocol": { + "transforms": [ + { + "name": "includeServices", + "args": { + "services": [ + "smithy.protocoltests.rpcv2Cbor#RpcV2Protocol" + ] + } + } + ], + "plugins": { + "dotnet-protocol-test-codegen": { + "service": "smithy.protocoltests.rpcv2Cbor#RpcV2Protocol", + "packageVersion": "0.0.1" + } + } } } } \ No newline at end of file diff --git a/generator/ServiceClientGeneratorLib/Generators/Marshallers/CborExceptionUnmarshaller.cs b/generator/ServiceClientGeneratorLib/Generators/Marshallers/CborExceptionUnmarshaller.cs new file mode 100644 index 000000000000..4b43859b25e2 --- /dev/null +++ b/generator/ServiceClientGeneratorLib/Generators/Marshallers/CborExceptionUnmarshaller.cs @@ -0,0 +1,238 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version: 17.0.0.0 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ +namespace ServiceClientGenerator.Generators.Marshallers +{ + using System.Linq; + using System.Text; + using System.Collections.Generic; + using System; + + /// + /// Class to produce the template output + /// + + #line 1 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborExceptionUnmarshaller.tt" + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")] + public partial class CborExceptionUnmarshaller : BaseResponseUnmarshaller + { +#line hidden + /// + /// Create the template output + /// + public override string TransformText() + { + + #line 6 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborExceptionUnmarshaller.tt" + + AddLicenseHeader(); + + AddCommonUsingStatements(); + + + #line default + #line hidden + this.Write("using System.Text.Json;\r\nusing Amazon.Util;\r\n#pragma warning disable CS0612,CS061" + + "8\r\nnamespace "); + + #line 14 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborExceptionUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(this.Config.Namespace)); + + #line default + #line hidden + this.Write(".Model.Internal.MarshallTransformations\r\n{\r\n /// \r\n /// Response U" + + "nmarshaller for "); + + #line 17 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborExceptionUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName)); + + #line default + #line hidden + this.Write(" Object\r\n /// \r\n public class "); + + #line 19 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborExceptionUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName)); + + #line default + #line hidden + this.Write("Unmarshaller : IJsonErrorResponseUnmarshaller<"); + + #line 19 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborExceptionUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName)); + + #line default + #line hidden + this.Write(@", JsonUnmarshallerContext> + { + /// + /// Unmarshaller the response from the service to the response class. + /// + /// + /// + /// + public "); + + #line 27 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborExceptionUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName)); + + #line default + #line hidden + this.Write(@" Unmarshall(JsonUnmarshallerContext context, ref StreamingUtf8JsonReader reader) + { + return this.Unmarshall(context, new Amazon.Runtime.Internal.ErrorResponse(), ref reader); + } + + /// + /// Unmarshaller the response from the service to the response class. + /// + /// + /// + /// + /// + public "); + + #line 39 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborExceptionUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName)); + + #line default + #line hidden + this.Write(@" Unmarshall(JsonUnmarshallerContext context, Amazon.Runtime.Internal.ErrorResponse errorResponse, ref StreamingUtf8JsonReader reader) + { + if (context.Stream.Length > 0) + { + context.Read(ref reader); + } + +"); + + #line 46 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborExceptionUnmarshaller.tt" + + if (this.Config.ServiceModel.IsAwsQueryCompatible) + { + GenerateAWSQueryCompatibleBlock(); + + + #line default + #line hidden + this.Write(" "); + + #line 51 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborExceptionUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName)); + + #line default + #line hidden + this.Write(" unmarshalledObject = new "); + + #line 51 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborExceptionUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName)); + + #line default + #line hidden + this.Write("(errorResponse.Message, errorResponse.InnerException,\r\n errorType," + + " errorCode, errorResponse.RequestId, errorResponse.StatusCode);\r\n"); + + #line 53 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborExceptionUnmarshaller.tt" + + } + else + { + + + #line default + #line hidden + this.Write(" "); + + #line 58 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborExceptionUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName)); + + #line default + #line hidden + this.Write(" unmarshalledObject = new "); + + #line 58 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborExceptionUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName)); + + #line default + #line hidden + this.Write("(errorResponse.Message, errorResponse.InnerException,\r\n errorRespo" + + "nse.Type, errorResponse.Code, errorResponse.RequestId, errorResponse.StatusCode)" + + ";\r\n"); + + #line 60 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborExceptionUnmarshaller.tt" + + } + + + #line default + #line hidden + this.Write(" \r\n int targetDepth = context.CurrentDepth;\r\n if (co" + + "ntext.Stream.Length > 0)\r\n {\r\n while (context.ReadAtDe" + + "pth(targetDepth, ref reader))\r\n {\r\n"); + + #line 69 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborExceptionUnmarshaller.tt" + + if(this.Structure != null) + { + foreach (var member in this.Structure.Members) + { + + + #line default + #line hidden + this.Write(" if (context.TestExpression(\""); + + #line 75 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborExceptionUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallName)); + + #line default + #line hidden + this.Write("\", targetDepth))\r\n {\r\n var unmarshaller" + + " = "); + + #line 77 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborExceptionUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(member.DetermineTypeUnmarshallerInstantiate())); + + #line default + #line hidden + this.Write(";\r\n unmarshalledObject."); + + #line 78 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborExceptionUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName)); + + #line default + #line hidden + this.Write(" = unmarshaller.Unmarshall(context, ref reader);\r\n continu" + + "e;\r\n }\r\n"); + + #line 81 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborExceptionUnmarshaller.tt" + + } + } + + + #line default + #line hidden + this.Write(" }\r\n }\r\n \r\n return unmarshalledObje" + + "ct;\r\n }\r\n\r\n"); + + #line 91 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborExceptionUnmarshaller.tt" + + this.AddStructureSingletonMethod(); + + + #line default + #line hidden + this.Write(" }\r\n}"); + return this.GenerationEnvironment.ToString(); + } + } + + #line default + #line hidden +} diff --git a/generator/ServiceClientGeneratorLib/Generators/Marshallers/CborExceptionUnmarshaller.tt b/generator/ServiceClientGeneratorLib/Generators/Marshallers/CborExceptionUnmarshaller.tt new file mode 100644 index 000000000000..fc262f8ce25f --- /dev/null +++ b/generator/ServiceClientGeneratorLib/Generators/Marshallers/CborExceptionUnmarshaller.tt @@ -0,0 +1,95 @@ +<#@ template language="C#" inherits="BaseResponseUnmarshaller"#> +<#@ assembly name="System.Core" #> +<#@ import namespace="System.Linq" #> +<#@ import namespace="System.Text" #> +<#@ import namespace="System.Collections.Generic" #> +<# + AddLicenseHeader(); + + AddCommonUsingStatements(); +#> +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 : IJsonErrorResponseUnmarshaller<<#=this.UnmarshallerBaseName #>, JsonUnmarshallerContext> + { + /// + /// Unmarshaller the response from the service to the response class. + /// + /// + /// + /// + public <#=this.UnmarshallerBaseName #> Unmarshall(JsonUnmarshallerContext context, ref StreamingUtf8JsonReader reader) + { + return this.Unmarshall(context, new Amazon.Runtime.Internal.ErrorResponse(), ref reader); + } + + /// + /// Unmarshaller the response from the service to the response class. + /// + /// + /// + /// + /// + public <#=this.UnmarshallerBaseName #> Unmarshall(JsonUnmarshallerContext context, Amazon.Runtime.Internal.ErrorResponse errorResponse, ref StreamingUtf8JsonReader reader) + { + if (context.Stream.Length > 0) + { + context.Read(ref reader); + } + +<# + if (this.Config.ServiceModel.IsAwsQueryCompatible) + { + GenerateAWSQueryCompatibleBlock(); +#> + <#=this.UnmarshallerBaseName #> unmarshalledObject = new <#=this.UnmarshallerBaseName #>(errorResponse.Message, errorResponse.InnerException, + errorType, errorCode, errorResponse.RequestId, errorResponse.StatusCode); +<# + } + else + { +#> + <#=this.UnmarshallerBaseName #> unmarshalledObject = new <#=this.UnmarshallerBaseName #>(errorResponse.Message, errorResponse.InnerException, + errorResponse.Type, errorResponse.Code, errorResponse.RequestId, errorResponse.StatusCode); +<# + } +#> + + int targetDepth = context.CurrentDepth; + if (context.Stream.Length > 0) + { + while (context.ReadAtDepth(targetDepth, ref reader)) + { +<# + if(this.Structure != null) + { + foreach (var member in this.Structure.Members) + { +#> + if (context.TestExpression("<#=member.MarshallName#>", targetDepth)) + { + var unmarshaller = <#= member.DetermineTypeUnmarshallerInstantiate() #>; + unmarshalledObject.<#=member.PropertyName#> = unmarshaller.Unmarshall(context, ref reader); + continue; + } +<# + } + } +#> + } + } + + return unmarshalledObject; + } + +<# + this.AddStructureSingletonMethod(); +#> + } +} \ No newline at end of file diff --git a/generator/ServiceClientGeneratorLib/Generators/Marshallers/CborResponseUnmarshaller.cs b/generator/ServiceClientGeneratorLib/Generators/Marshallers/CborResponseUnmarshaller.cs new file mode 100644 index 000000000000..0b40a4eff320 --- /dev/null +++ b/generator/ServiceClientGeneratorLib/Generators/Marshallers/CborResponseUnmarshaller.cs @@ -0,0 +1,533 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version: 17.0.0.0 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ +namespace ServiceClientGenerator.Generators.Marshallers +{ + using System.Linq; + using System.Text; + using System.Collections.Generic; + using System; + + /// + /// Class to produce the template output + /// + + #line 1 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")] + public partial class CborResponseUnmarshaller : BaseResponseUnmarshaller + { +#line hidden + /// + /// Create the template output + /// + public override string TransformText() + { + + #line 6 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + + AddLicenseHeader(); + + AddCommonUsingStatements(); + + + #line default + #line hidden + this.Write("using System.Text.Json;\r\nusing Amazon.Util;\r\n#pragma warning disable CS0612,CS061" + + "8\r\nnamespace "); + + #line 14 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(this.Config.Namespace)); + + #line default + #line hidden + this.Write(".Model.Internal.MarshallTransformations\r\n{\r\n /// \r\n /// Response U" + + "nmarshaller for "); + + #line 17 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName)); + + #line default + #line hidden + this.Write(" operation\r\n /// \r\n public class "); + + #line 19 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName)); + + #line default + #line hidden + this.Write(@"ResponseUnmarshaller : JsonResponseUnmarshaller + { + /// + /// Unmarshaller the response from the service to the response class. + /// + /// + /// + public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) + { + "); + + #line 28 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName)); + + #line default + #line hidden + this.Write("Response response = new "); + + #line 28 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(this.Operation.Name)); + + #line default + #line hidden + this.Write("Response();\r\n"); + + #line 29 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + + var payload = this.Operation.ResponsePayloadMember; + var unmarshallPayload = payload != null && payload.IsStructure; + var payloadIsStream = payload != null && !unmarshallPayload; + bool isEventStreamOutput = this.Operation.IsEventStreamOutput; + if (this.Operation.ResponseHasBodyMembers || payload != null) + { + if (this.Operation.AllowEmptyResult) + { + throw new NotImplementedException("AllowEmptyResult is not implemented for JSON unmarshallers"); + } + if (isEventStreamOutput) + { + if(payload == null) + { + payload = this.Structure.Members.Where(m => m.ModelShape.IsEventStream).FirstOrDefault(); + //if payload is still null after we search for a member that is of eventStream then the operation is not modeled correctly + + if(payload == null) + throw new InvalidOperationException("An eventstream operation's response must have at least one member that is marked with the eventStream trait"); + } + + + #line default + #line hidden + this.Write(" response."); + + #line 51 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(payload.PropertyName)); + + #line default + #line hidden + this.Write(" = new "); + + #line 51 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(payload.Shape.Name)); + + #line default + #line hidden + this.Write("(context.Stream);\r\n"); + + #line 52 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + + } + else if (payloadIsStream) + { + if (payload.Shape.IsStreaming) + { + + + #line default + #line hidden + this.Write(" response."); + + #line 59 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(payload.PropertyName)); + + #line default + #line hidden + this.Write(" = context.Stream;\r\n"); + + #line 60 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + + } + else if (payload.ModelShape.IsString) + { + + + #line default + #line hidden + this.Write(" using (var sr = new StreamReader(context.Stream))\r\n {\r\n " + + " response."); + + #line 67 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(payload.PropertyName)); + + #line default + #line hidden + this.Write(" = sr.ReadToEnd();\r\n }\r\n"); + + #line 69 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + + } + else if (payload.ModelShape.IsMemoryStream) + { + + + #line default + #line hidden + this.Write(" var ms = new MemoryStream();\r\n Amazon.Util.AWSSDKUtils.Cop" + + "yStream(context.Stream, ms);\r\n ms.Seek(0, SeekOrigin.Begin);\r\n " + + " if (ms.Length > 0)\r\n response."); + + #line 78 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(payload.PropertyName)); + + #line default + #line hidden + this.Write(" = ms;\r\n"); + + #line 79 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + + } + else + { + // At this point, all valid configurations have been handled. Valid use of payload is defined: + // https://awslabs.github.io/smithy/1.0/spec/core/http-traits.html#httppayload-trait + throw new Exception( + $"{payload.PropertyName} can not be a Payload as Type {payload.Shape.Type} is not a valid target for the httpPayload trait. " + + "The httpPayload trait can be applied to structure members that target a string, blob, structure, union, document, set, map, or list."); + } + } + else if (unmarshallPayload) + { + + + #line default + #line hidden + this.Write(" StreamingUtf8JsonReader reader = new StreamingUtf8JsonReader(context." + + "Stream);\r\n var unmarshaller = "); + + #line 94 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(payload.DetermineTypeUnmarshallerInstantiate())); + + #line default + #line hidden + this.Write(";\r\n response."); + + #line 95 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(payload.PropertyName)); + + #line default + #line hidden + this.Write(" = unmarshaller.Unmarshall(context, ref reader);\r\n"); + + #line 96 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + + } + else if (this.IsWrapped) + { + + + #line default + #line hidden + this.Write(" StreamingUtf8JsonReader reader = new StreamingUtf8JsonReader(context." + + "Stream);\r\n\t\t\tresponse."); + + #line 102 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(this.WrappedResultMember)); + + #line default + #line hidden + this.Write(" = "); + + #line 102 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(this.Structure.Name)); + + #line default + #line hidden + this.Write("Unmarshaller.Instance.Unmarshall(context, ref reader);\r\n"); + + #line 103 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + + } + else + { + + + #line default + #line hidden + this.Write(@" StreamingUtf8JsonReader reader = new StreamingUtf8JsonReader(context.Stream); + context.Read(ref reader); + int targetDepth = context.CurrentDepth; + while (context.ReadAtDepth(targetDepth, ref reader)) + { +"); + + #line 113 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + + + foreach (var member in this.Operation.ResponseBodyMembers) + { + + + #line default + #line hidden + this.Write(" if (context.TestExpression(\""); + + #line 118 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallName)); + + #line default + #line hidden + this.Write("\", targetDepth))\r\n {\r\n var unmarshaller = "); + + #line 120 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(member.DetermineTypeUnmarshallerInstantiate())); + + #line default + #line hidden + this.Write(";\r\n response."); + + #line 121 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName)); + + #line default + #line hidden + this.Write(" = unmarshaller.Unmarshall(context, ref reader);\r\n continue;\r\n" + + " }\r\n"); + + #line 124 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + + } + + + #line default + #line hidden + this.Write(" }\r\n"); + + #line 128 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + + } + } + UnmarshallHeaders(); + ProcessStatusCode(); + + + #line default + #line hidden + this.Write(@" + return response; + } + + /// + /// Unmarshaller error response to exception. + /// + /// + /// + /// + /// + public override AmazonServiceException UnmarshallException(JsonUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode) + { + StreamingUtf8JsonReader reader = new StreamingUtf8JsonReader(context.Stream); + var errorResponse = JsonErrorResponseUnmarshaller.GetInstance().Unmarshall(context, ref reader); + errorResponse.InnerException = innerException; + errorResponse.StatusCode = statusCode; + + var responseBodyBytes = context.GetResponseBodyBytes(); + + using (var streamCopy = new MemoryStream(responseBodyBytes)) +"); + + #line 155 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + + if (this.Config.ServiceModel.IsAwsQueryCompatible) + { + + + #line default + #line hidden + + #line 159 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + // Create a copy of context with headers in the response + + + + #line default + #line hidden + this.Write(" using (var contextCopy = new JsonUnmarshallerContext(streamCopy, true" + + ", context.ResponseData))\r\n"); + + #line 163 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + + } + else + { + + + #line default + #line hidden + this.Write(" using (var contextCopy = new JsonUnmarshallerContext(streamCopy, fals" + + "e, context.ResponseData))\r\n"); + + #line 169 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + + // Create a new reader because the stream has been read already in the original context + } + + + #line default + #line hidden + this.Write(" {\r\n StreamingUtf8JsonReader readerCopy = new Streaming" + + "Utf8JsonReader(streamCopy);\r\n"); + + #line 175 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + + foreach (var exception in this.Operation.Exceptions) + { + + + #line default + #line hidden + this.Write(" if (errorResponse.Code != null && errorResponse.Code.Equals(\""); + + #line 179 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(exception.Code)); + + #line default + #line hidden + this.Write("\"))\r\n {\r\n return "); + + #line 181 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(exception.Name)); + + #line default + #line hidden + this.Write("Unmarshaller.Instance.Unmarshall(contextCopy, errorResponse, ref readerCopy);\r\n " + + " }\r\n"); + + #line 183 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + + } + + + #line default + #line hidden + this.Write(" }\r\n"); + + #line 187 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + + if (this.Config.ServiceModel.IsAwsQueryCompatible) + { + GenerateAWSQueryCompatibleBlock(); + + + #line default + #line hidden + this.Write(" return new "); + + #line 192 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(this.BaseException)); + + #line default + #line hidden + this.Write("(errorResponse.Message, errorResponse.InnerException, errorType, errorCode, error" + + "Response.RequestId, errorResponse.StatusCode);\r\n"); + + #line 193 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + + } + else + { + + + #line default + #line hidden + this.Write(" return new "); + + #line 198 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(this.BaseException)); + + #line default + #line hidden + this.Write("(errorResponse.Message, errorResponse.InnerException, errorResponse.Type, errorRe" + + "sponse.Code, errorResponse.RequestId, errorResponse.StatusCode);\r\n"); + + #line 199 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + + } + + + #line default + #line hidden + this.Write(" }\r\n\r\n"); + + #line 204 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + + if (payload != null && payload.Shape.IsStreaming) + { + + + #line default + #line hidden + this.Write(@" /// + /// Overriden to return true indicating the response contains streaming data. + /// + public override bool HasStreamingProperty + { + get + { + return true; + } + } + +"); + + #line 219 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + + } + this.AddResponseSingletonMethod(); + + + #line default + #line hidden + + #line 223 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + + if(isEventStreamOutput) + { + + + #line default + #line hidden + this.Write(@" /// + /// Return false for reading the entire response + /// + /// + /// + /// + protected override bool ShouldReadEntireResponse(IWebResponseData response, bool readEntireResponse) + { + return false; + } + /// + /// Specifies that the response should be streamed + /// + public override bool HasStreamingProperty => true; +"); + + #line 241 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborResponseUnmarshaller.tt" + + } + + + #line default + #line hidden + this.Write(" }\r\n}"); + return this.GenerationEnvironment.ToString(); + } + } + + #line default + #line hidden +} diff --git a/generator/ServiceClientGeneratorLib/Generators/Marshallers/CborResponseUnmarshaller.tt b/generator/ServiceClientGeneratorLib/Generators/Marshallers/CborResponseUnmarshaller.tt new file mode 100644 index 000000000000..0b6fa34d8f41 --- /dev/null +++ b/generator/ServiceClientGeneratorLib/Generators/Marshallers/CborResponseUnmarshaller.tt @@ -0,0 +1,245 @@ +<#@ template language="C#" inherits="BaseResponseUnmarshaller"#> +<#@ assembly name="System.Core" #> +<#@ import namespace="System.Linq" #> +<#@ import namespace="System.Text" #> +<#@ import namespace="System.Collections.Generic" #> +<# + AddLicenseHeader(); + + AddCommonUsingStatements(); +#> +using System.Text.Json; +using Amazon.Util; +#pragma warning disable CS0612,CS0618 +namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations +{ + /// + /// Response Unmarshaller for <#=this.UnmarshallerBaseName #> operation + /// + public class <#=this.UnmarshallerBaseName #>ResponseUnmarshaller : JsonResponseUnmarshaller + { + /// + /// Unmarshaller the response from the service to the response class. + /// + /// + /// + 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; + var payloadIsStream = payload != null && !unmarshallPayload; + bool isEventStreamOutput = this.Operation.IsEventStreamOutput; + if (this.Operation.ResponseHasBodyMembers || payload != null) + { + if (this.Operation.AllowEmptyResult) + { + throw new NotImplementedException("AllowEmptyResult is not implemented for JSON unmarshallers"); + } + if (isEventStreamOutput) + { + if(payload == null) + { + payload = this.Structure.Members.Where(m => m.ModelShape.IsEventStream).FirstOrDefault(); + //if payload is still null after we search for a member that is of eventStream then the operation is not modeled correctly + + if(payload == null) + throw new InvalidOperationException("An eventstream operation's response must have at least one member that is marked with the eventStream trait"); + } +#> + response.<#=payload.PropertyName#> = new <#=payload.Shape.Name#>(context.Stream); +<# + } + else if (payloadIsStream) + { + if (payload.Shape.IsStreaming) + { +#> + response.<#=payload.PropertyName#> = context.Stream; +<# + } + else if (payload.ModelShape.IsString) + { +#> + using (var sr = new StreamReader(context.Stream)) + { + response.<#=payload.PropertyName#> = sr.ReadToEnd(); + } +<# + } + else if (payload.ModelShape.IsMemoryStream) + { +#> + var ms = new MemoryStream(); + Amazon.Util.AWSSDKUtils.CopyStream(context.Stream, ms); + ms.Seek(0, SeekOrigin.Begin); + if (ms.Length > 0) + response.<#=payload.PropertyName#> = ms; +<# + } + else + { + // At this point, all valid configurations have been handled. Valid use of payload is defined: + // https://awslabs.github.io/smithy/1.0/spec/core/http-traits.html#httppayload-trait + throw new Exception( + $"{payload.PropertyName} can not be a Payload as Type {payload.Shape.Type} is not a valid target for the httpPayload trait. " + + "The httpPayload trait can be applied to structure members that target a string, blob, structure, union, document, set, map, or list."); + } + } + else if (unmarshallPayload) + { +#> + StreamingUtf8JsonReader reader = new StreamingUtf8JsonReader(context.Stream); + var unmarshaller = <#= payload.DetermineTypeUnmarshallerInstantiate() #>; + response.<#=payload.PropertyName#> = unmarshaller.Unmarshall(context, ref reader); +<# + } + else if (this.IsWrapped) + { +#> + StreamingUtf8JsonReader reader = new StreamingUtf8JsonReader(context.Stream); + response.<#=this.WrappedResultMember#> = <#=this.Structure.Name#>Unmarshaller.Instance.Unmarshall(context, ref reader); +<# + } + else + { +#> + StreamingUtf8JsonReader reader = new StreamingUtf8JsonReader(context.Stream); + context.Read(ref reader); + int targetDepth = context.CurrentDepth; + while (context.ReadAtDepth(targetDepth, ref reader)) + { +<# + + foreach (var member in this.Operation.ResponseBodyMembers) + { +#> + if (context.TestExpression("<#=member.MarshallName#>", targetDepth)) + { + var unmarshaller = <#= member.DetermineTypeUnmarshallerInstantiate() #>; + response.<#=member.PropertyName#> = unmarshaller.Unmarshall(context, ref reader); + continue; + } +<# + } +#> + } +<# + } + } + UnmarshallHeaders(); + ProcessStatusCode(); +#> + + return response; + } + + /// + /// Unmarshaller error response to exception. + /// + /// + /// + /// + /// + public override AmazonServiceException UnmarshallException(JsonUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode) + { + StreamingUtf8JsonReader reader = new StreamingUtf8JsonReader(context.Stream); + var errorResponse = JsonErrorResponseUnmarshaller.GetInstance().Unmarshall(context, ref reader); + errorResponse.InnerException = innerException; + errorResponse.StatusCode = statusCode; + + var responseBodyBytes = context.GetResponseBodyBytes(); + + using (var streamCopy = new MemoryStream(responseBodyBytes)) +<# + if (this.Config.ServiceModel.IsAwsQueryCompatible) + { +#> +<# // 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, context.ResponseData)) +<# + // 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, ref readerCopy); + } +<# + } +#> + } +<# + if (this.Config.ServiceModel.IsAwsQueryCompatible) + { + GenerateAWSQueryCompatibleBlock(); +#> + return new <#=this.BaseException#>(errorResponse.Message, errorResponse.InnerException, errorType, errorCode, errorResponse.RequestId, errorResponse.StatusCode); +<# + } + else + { +#> + return new <#=this.BaseException#>(errorResponse.Message, errorResponse.InnerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, errorResponse.StatusCode); +<# + } +#> + } + +<# + if (payload != null && payload.Shape.IsStreaming) + { +#> + /// + /// Overriden to return true indicating the response contains streaming data. + /// + public override bool HasStreamingProperty + { + get + { + return true; + } + } + +<# + } + this.AddResponseSingletonMethod(); +#> +<# + if(isEventStreamOutput) + { +#> + /// + /// Return false for reading the entire response + /// + /// + /// + /// + protected override bool ShouldReadEntireResponse(IWebResponseData response, bool readEntireResponse) + { + return false; + } + /// + /// Specifies that the response should be streamed + /// + public override bool HasStreamingProperty => true; +<# + } +#> + } +} \ No newline at end of file diff --git a/generator/ServiceClientGeneratorLib/Generators/Marshallers/CborStructureUnmarshaller.cs b/generator/ServiceClientGeneratorLib/Generators/Marshallers/CborStructureUnmarshaller.cs new file mode 100644 index 000000000000..e88fe2577d0c --- /dev/null +++ b/generator/ServiceClientGeneratorLib/Generators/Marshallers/CborStructureUnmarshaller.cs @@ -0,0 +1,266 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version: 17.0.0.0 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ +namespace ServiceClientGenerator.Generators.Marshallers +{ + using System.Linq; + using System.Text; + using System.Collections.Generic; + using System; + + /// + /// Class to produce the template output + /// + + #line 1 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborStructureUnmarshaller.tt" + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")] + public partial class CborStructureUnmarshaller : BaseResponseUnmarshaller + { +#line hidden + /// + /// Create the template output + /// + public override string TransformText() + { + + #line 6 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborStructureUnmarshaller.tt" + + AddLicenseHeader(); + + AddCommonUsingStatements(); + + + #line default + #line hidden + this.Write("using System.Text.Json;\r\n#pragma warning disable CS0612,CS0618\r\nnamespace "); + + #line 13 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborStructureUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(this.Config.Namespace)); + + #line default + #line hidden + this.Write(".Model.Internal.MarshallTransformations\r\n{\r\n /// \r\n /// Response U" + + "nmarshaller for "); + + #line 16 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborStructureUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName)); + + #line default + #line hidden + this.Write(" Object\r\n /// \r\n public class "); + + #line 18 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborStructureUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName)); + + #line default + #line hidden + this.Write("Unmarshaller : IJsonUnmarshaller<"); + + #line 18 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborStructureUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName)); + + #line default + #line hidden + this.Write(@", JsonUnmarshallerContext> + { + /// + /// Unmarshaller the response from the service to the response class. + /// + /// + /// + /// The unmarshalled object + public "); + + #line 26 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborStructureUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName)); + + #line default + #line hidden + this.Write(" Unmarshall(JsonUnmarshallerContext context, ref StreamingUtf8JsonReader reader)\r" + + "\n {\r\n "); + + #line 28 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborStructureUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName)); + + #line default + #line hidden + this.Write(" unmarshalledObject = new "); + + #line 28 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborStructureUnmarshaller.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 31 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborStructureUnmarshaller.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()) + { + Member eventPayloadMember = this.Structure.GetExplicitEventPayloadMember(); + if(eventPayloadMember.ModelShape.IsString) + { + + + #line default + #line hidden + this.Write(" using (var sr = new StreamReader(context.Stream))\r\n {\r\n " + + " unmarshalledObject."); + + #line 41 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborStructureUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(eventPayloadMember.PropertyName)); + + #line default + #line hidden + this.Write(" = sr.ReadToEnd();\r\n }\r\n"); + + #line 43 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborStructureUnmarshaller.tt" + + } + + + #line default + #line hidden + + #line 46 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborStructureUnmarshaller.tt" + + else + { + + + #line default + #line hidden + this.Write(" unmarshalledObject."); + + #line 50 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborStructureUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(eventPayloadMember.PropertyName)); + + #line default + #line hidden + this.Write(" = context.Stream as MemoryStream;\r\n"); + + #line 51 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborStructureUnmarshaller.tt" + + } + + + #line default + #line hidden + + #line 54 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborStructureUnmarshaller.tt" + + } + + + #line default + #line hidden + + #line 57 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborStructureUnmarshaller.tt" + + if(this.Structure != null && (this.Structure.HasImplicitEventPayloadMembers() || !this.Structure.IsEvent)) + { + + + #line default + #line hidden + this.Write(@" context.Read(ref reader); + if (context.CurrentTokenType == JsonTokenType.Null) + return null; + + int targetDepth = context.CurrentDepth; + while (context.ReadAtDepth(targetDepth, ref reader)) + { +"); + + #line 68 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborStructureUnmarshaller.tt" + + } + + + #line default + #line hidden + + #line 71 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborStructureUnmarshaller.tt" + + if(this.Structure != null && (!this.Structure.IsEvent || this.Structure.HasImplicitEventPayloadMembers())) + { + foreach (var member in this.Structure.Members) + { + + + #line default + #line hidden + this.Write(" if (context.TestExpression(\""); + + #line 77 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborStructureUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallName)); + + #line default + #line hidden + this.Write("\", targetDepth))\r\n {\r\n var unmarshaller = "); + + #line 79 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborStructureUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(member.DetermineTypeUnmarshallerInstantiate())); + + #line default + #line hidden + this.Write(";\r\n unmarshalledObject."); + + #line 80 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborStructureUnmarshaller.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName)); + + #line default + #line hidden + this.Write(" = unmarshaller.Unmarshall(context, ref reader);\r\n continue;\r\n" + + " }\r\n"); + + #line 83 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborStructureUnmarshaller.tt" + + } + } + + + #line default + #line hidden + + #line 87 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborStructureUnmarshaller.tt" + + if(this.Structure != null && (!this.Structure.IsEvent || this.Structure.HasImplicitEventPayloadMembers())) + { + + + #line default + #line hidden + this.Write(" }\r\n"); + + #line 92 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborStructureUnmarshaller.tt" + + } + + + #line default + #line hidden + this.Write(" return unmarshalledObject;\r\n }\r\n\r\n\r\n"); + + #line 99 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\Marshallers\CborStructureUnmarshaller.tt" + + this.AddStructureSingletonMethod(); + + + #line default + #line hidden + this.Write(" }\r\n}"); + return this.GenerationEnvironment.ToString(); + } + } + + #line default + #line hidden +} diff --git a/generator/ServiceClientGeneratorLib/Generators/Marshallers/CborStructureUnmarshaller.tt b/generator/ServiceClientGeneratorLib/Generators/Marshallers/CborStructureUnmarshaller.tt new file mode 100644 index 000000000000..f46be03f43a3 --- /dev/null +++ b/generator/ServiceClientGeneratorLib/Generators/Marshallers/CborStructureUnmarshaller.tt @@ -0,0 +1,103 @@ +<#@ template language="C#" inherits="BaseResponseUnmarshaller"#> +<#@ assembly name="System.Core" #> +<#@ import namespace="System.Linq" #> +<#@ import namespace="System.Text" #> +<#@ import namespace="System.Collections.Generic" #> +<# + AddLicenseHeader(); + + AddCommonUsingStatements(); +#> +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 : IJsonUnmarshaller<<#=this.UnmarshallerBaseName #>, JsonUnmarshallerContext> + { + /// + /// Unmarshaller the response from the service to the response class. + /// + /// + /// + /// The unmarshalled object + public <#=this.UnmarshallerBaseName #> Unmarshall(JsonUnmarshallerContext context, ref StreamingUtf8JsonReader reader) + { + <#=this.UnmarshallerBaseName #> unmarshalledObject = new <#=this.UnmarshallerBaseName #>(); + if (context.IsEmptyResponse) + return null; +<# + //HasImplicitEventPayloadMembers means that the structure does not have a member with the EventPayload trait + if(this.Structure != null && this.Structure.IsEvent && !this.Structure.HasImplicitEventPayloadMembers()) + { + Member eventPayloadMember = this.Structure.GetExplicitEventPayloadMember(); + if(eventPayloadMember.ModelShape.IsString) + { +#> + using (var sr = new StreamReader(context.Stream)) + { + unmarshalledObject.<#=eventPayloadMember.PropertyName#> = sr.ReadToEnd(); + } +<# + } +#> +<# + else + { +#> + unmarshalledObject.<#=eventPayloadMember.PropertyName#> = context.Stream as MemoryStream; +<# + } +#> +<# + } +#> +<# + if(this.Structure != null && (this.Structure.HasImplicitEventPayloadMembers() || !this.Structure.IsEvent)) + { +#> + context.Read(ref reader); + if (context.CurrentTokenType == JsonTokenType.Null) + return null; + + int targetDepth = context.CurrentDepth; + while (context.ReadAtDepth(targetDepth, ref reader)) + { +<# + } +#> +<# + if(this.Structure != null && (!this.Structure.IsEvent || this.Structure.HasImplicitEventPayloadMembers())) + { + foreach (var member in this.Structure.Members) + { +#> + if (context.TestExpression("<#=member.MarshallName#>", targetDepth)) + { + var unmarshaller = <#= member.DetermineTypeUnmarshallerInstantiate() #>; + unmarshalledObject.<#=member.PropertyName#> = unmarshaller.Unmarshall(context, ref reader); + continue; + } +<# + } + } +#> +<# + if(this.Structure != null && (!this.Structure.IsEvent || this.Structure.HasImplicitEventPayloadMembers())) + { +#> + } +<# + } +#> + return unmarshalledObject; + } + + +<# + this.AddStructureSingletonMethod(); +#> + } +} \ No newline at end of file diff --git a/generator/ServiceClientGeneratorLib/Generators/SourceFiles/EventStreamOutputGenerator.cs b/generator/ServiceClientGeneratorLib/Generators/SourceFiles/EventStreamOutputGenerator.cs index 33c89b81345f..0d38dbc15d72 100644 --- a/generator/ServiceClientGeneratorLib/Generators/SourceFiles/EventStreamOutputGenerator.cs +++ b/generator/ServiceClientGeneratorLib/Generators/SourceFiles/EventStreamOutputGenerator.cs @@ -18,7 +18,7 @@ namespace ServiceClientGenerator.Generators.SourceFiles /// Class to produce the template output /// - #line 1 "C:\codebase\v4\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamOutputGenerator.tt" + #line 1 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamOutputGenerator.tt" [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")] public partial class EventStreamOutputGenerator : StructureGenerator { @@ -29,7 +29,7 @@ public partial class EventStreamOutputGenerator : StructureGenerator public override string TransformText() { - #line 6 "C:\codebase\v4\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamOutputGenerator.tt" + #line 6 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamOutputGenerator.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\v4\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamOutputGenerator.tt" + #line 10 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamOutputGenerator.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 IEventOutputStream. Users need to be able to call Dispose."")] public sealed class "); - #line 12 "C:\codebase\v4\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamOutputGenerator.tt" + #line 12 "C:\repos\aws-sdk-net-v4\generator\ServiceClientGeneratorLib\Generators\SourceFiles\EventStreamOutputGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(this.Structure.Name)); #line default #line hidden this.Write(" : EnumerableEventOutputStream