diff --git a/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Amazon.Lambda.Annotations.SourceGenerator.csproj b/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Amazon.Lambda.Annotations.SourceGenerator.csproj
index 842688f81..21abfd558 100644
--- a/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Amazon.Lambda.Annotations.SourceGenerator.csproj
+++ b/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Amazon.Lambda.Annotations.SourceGenerator.csproj
@@ -48,6 +48,10 @@
TextTemplatingFilePreprocessor
FieldsAndConstructor.cs
+
+ TextTemplatingFilePreprocessor
+ JsonSerializerContextTemplate.cs
+
TextTemplatingFilePreprocessor
LambdaFunctionTemplate.cs
@@ -78,6 +82,11 @@
True
FieldsAndConstructor.tt
+
+ True
+ True
+ JsonSerializerContextTemplate.tt
+
LambdaFunctionTemplate.tt
True
diff --git a/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Generator.cs b/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Generator.cs
index 4ff503042..73d17672f 100644
--- a/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Generator.cs
+++ b/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Generator.cs
@@ -11,7 +11,9 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
+using System.IO;
using System.Linq;
+using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
@@ -50,16 +52,17 @@ public class Generator : ISourceGenerator
public Generator()
{
#if DEBUG
- // if (!Debugger.IsAttached)
- // {
- // Debugger.Launch();
- // }
+ //if (!Debugger.IsAttached)
+ //{
+ // Debugger.Launch();
+ //}
#endif
}
public void Execute(GeneratorExecutionContext context)
{
var diagnosticReporter = new DiagnosticReporter(context);
+ var sourceGeneratedSerializableTypes = new HashSet();
try
{
@@ -225,12 +228,18 @@ public void Execute(GeneratorExecutionContext context)
continue;
}
+
var template = new LambdaFunctionTemplate(model);
string sourceText;
try
{
sourceText = template.TransformText().ToEnvironmentLineEndings();
+ var filePath = $"C:\\codebase\\V3\\snapshots\\{model.GeneratedMethod.ContainingType.Name}.g.cs";
+ using (StreamWriter writer = new StreamWriter(filePath))
+ {
+ writer.Write(sourceText);
+ }
context.AddSource($"{model.GeneratedMethod.ContainingType.Name}.g.cs", SourceText.From(sourceText, Encoding.UTF8, SourceHashAlgorithm.Sha256));
}
catch (Exception e) when (e is NotSupportedException || e is InvalidOperationException)
@@ -242,10 +251,20 @@ public void Execute(GeneratorExecutionContext context)
// report every generated file to build output
diagnosticReporter.Report(Diagnostic.Create(DiagnosticDescriptors.CodeGeneration, Location.None, $"{model.GeneratedMethod.ContainingType.Name}.g.cs", sourceText));
+ AddSourceGeneratedSerializableTypes(sourceGeneratedSerializableTypes, model);
lambdaModels.Add(model);
annotationReport.LambdaFunctions.Add(model);
}
+ if (sourceGeneratedSerializableTypes.Any())
+ {
+ var jsonSerializerContextTemplate = new JsonSerializerContextTemplate(context.Compilation.AssemblyName, sourceGeneratedSerializableTypes);
+ var sourceText = jsonSerializerContextTemplate.TransformText().ToEnvironmentLineEndings();
+ context.AddSource("ApiGatewayResponseJsonSerializerContext.g.cs", SourceText.From(sourceText, Encoding.UTF8, SourceHashAlgorithm.Sha256));
+ diagnosticReporter.Report(Diagnostic.Create(DiagnosticDescriptors.CodeGeneration, Location.None, "ApiGatewayResponseJsonSerializerContext.g.cs", sourceText));
+ Execute(context);
+ }
+
if (isExecutable)
{
var executableAssembly = GenerateExecutableAssemblySource(
@@ -297,6 +316,25 @@ public void Execute(GeneratorExecutionContext context)
}
}
+ private static void AddSourceGeneratedSerializableTypes(HashSet sourceGeneratedSerializableTypes, LambdaFunctionModel model)
+ {
+ var restApiAttribute = model.LambdaMethod.Attributes.FirstOrDefault(att => att.Type.FullName == TypeFullNames.RestApiAttribute) as AttributeModel;
+ var httpApiAttribute = model.LambdaMethod.Attributes.FirstOrDefault(att => att.Type.FullName == TypeFullNames.HttpApiAttribute) as AttributeModel;
+
+ if (restApiAttribute is null && httpApiAttribute is null)
+ {
+ return;
+ }
+ if (model.LambdaMethod.ReturnsIHttpResults)
+ {
+ return;
+ }
+
+ var useHttpV2Response = httpApiAttribute?.Data.Version == APIGateway.HttpApiVersion.V2;
+ var apiGatewayResponseType = useHttpV2Response ? TypeFullNames.APIGatewayHttpApiV2ProxyResponse : TypeFullNames.APIGatewayProxyResponse;
+ sourceGeneratedSerializableTypes.Add(apiGatewayResponseType);
+ }
+
private static ExecutableAssembly GenerateExecutableAssemblySource(
GeneratorExecutionContext context,
DiagnosticReporter diagnosticReporter,
diff --git a/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Models/GeneratedMethodModelBuilder.cs b/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Models/GeneratedMethodModelBuilder.cs
index 5a0460beb..d2788799e 100644
--- a/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Models/GeneratedMethodModelBuilder.cs
+++ b/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Models/GeneratedMethodModelBuilder.cs
@@ -53,6 +53,10 @@ private static IList BuildUsings(LambdaMethodModel lambdaMethodModel,
{
namespaces.Add("Amazon.Lambda.Annotations.APIGateway");
}
+ if (lambdaMethodModel.Events.Contains(EventType.API))
+ {
+ namespaces.Add("System.Text.Json");
+ }
return namespaces;
}
@@ -60,54 +64,33 @@ private static IList BuildUsings(LambdaMethodModel lambdaMethodModel,
private static TypeModel BuildResponseType(IMethodSymbol lambdaMethodSymbol,
LambdaMethodModel lambdaMethodModel, GeneratorExecutionContext context)
{
- var task = context.Compilation.GetTypeByMetadataName(TypeFullNames.Task1);
-
- if (lambdaMethodModel.ReturnsIHttpResults)
- {
- var typeStream = context.Compilation.GetTypeByMetadataName(TypeFullNames.Stream);
- if (lambdaMethodModel.ReturnsGenericTask)
- {
- var genericTask = task.Construct(typeStream);
- return TypeModelBuilder.Build(genericTask, context);
- }
- return TypeModelBuilder.Build(typeStream, context);
- }
-
-
- if (lambdaMethodSymbol.HasAttribute(context, TypeFullNames.RestApiAttribute))
+ if (lambdaMethodModel.Events.Contains(EventType.API))
{
- var symbol = lambdaMethodModel.ReturnsVoidOrGenericTask ?
- task.Construct(context.Compilation.GetTypeByMetadataName(TypeFullNames.APIGatewayProxyResponse)):
- context.Compilation.GetTypeByMetadataName(TypeFullNames.APIGatewayProxyResponse);
- return TypeModelBuilder.Build(symbol, context);
- }
- else if (lambdaMethodSymbol.HasAttribute(context, TypeFullNames.HttpApiAttribute))
- {
- var version = GetHttpApiVersion(lambdaMethodSymbol, context);
- switch (version)
+ if (lambdaMethodSymbol.HasAttribute(context, TypeFullNames.HttpApiAttribute))
{
- case HttpApiVersion.V1:
+ var version = GetHttpApiVersion(lambdaMethodSymbol, context);
+ if (version != HttpApiVersion.V1 && version != HttpApiVersion.V2)
{
- var symbol = lambdaMethodModel.ReturnsVoidOrGenericTask ?
- task.Construct(context.Compilation.GetTypeByMetadataName(TypeFullNames.APIGatewayProxyResponse)):
- context.Compilation.GetTypeByMetadataName(TypeFullNames.APIGatewayProxyResponse);
- return TypeModelBuilder.Build(symbol, context);
- }
- case HttpApiVersion.V2:
- {
- var symbol = lambdaMethodModel.ReturnsVoidOrGenericTask ?
- task.Construct(context.Compilation.GetTypeByMetadataName(TypeFullNames.APIGatewayHttpApiV2ProxyResponse)):
- context.Compilation.GetTypeByMetadataName(TypeFullNames.APIGatewayHttpApiV2ProxyResponse);
- return TypeModelBuilder.Build(symbol, context);
- }
- default:
throw new ArgumentOutOfRangeException();
+ };
}
+
+ return CreateStreamTypeModel(context, lambdaMethodModel);
}
- else
+
+ return lambdaMethodModel.ReturnType;
+ }
+
+ private static TypeModel CreateStreamTypeModel(GeneratorExecutionContext context, LambdaMethodModel lambdaMethodModel)
+ {
+ var task = context.Compilation.GetTypeByMetadataName(TypeFullNames.Task1);
+ var typeStream = context.Compilation.GetTypeByMetadataName(TypeFullNames.Stream);
+ if (lambdaMethodModel.ReturnsVoidOrGenericTask)
{
- return lambdaMethodModel.ReturnType;
+ var genericTask = task.Construct(typeStream);
+ return TypeModelBuilder.Build(genericTask, context);
}
+ return TypeModelBuilder.Build(typeStream, context);
}
private static HttpApiVersion GetHttpApiVersion(IMethodSymbol lambdaMethodSymbol, GeneratorExecutionContext context)
diff --git a/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Models/LambdaMethodModel.cs b/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Models/LambdaMethodModel.cs
index 9a81ee95c..c57908cc2 100644
--- a/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Models/LambdaMethodModel.cs
+++ b/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Models/LambdaMethodModel.cs
@@ -54,11 +54,34 @@ public bool ReturnsIHttpResults
{
return true;
}
- if(ReturnsGenericTask && ReturnType.TypeArguments.Count == 1 && ReturnType.TypeArguments[0].FullName == TypeFullNames.IHttpResult)
+
+ return ReturnsGenericTask && ReturnType.TypeArguments.Count == 1 && ReturnType.TypeArguments[0].FullName == TypeFullNames.IHttpResult;
+ }
+ }
+
+ ///
+ /// Returns true if the Lambda function returns either of the following types
+ /// 1. APIGatewayProxyResponse or Task
+ /// 2. APIGatewayHttpApiV2ProxyResponse or Task
+ ///
+ public bool ReturnsApiGatewayResponse
+ {
+ get
+ {
+ if(ReturnsVoid)
{
- return true;
+ return false;
}
+ if(ReturnType.FullName == TypeFullNames.APIGatewayProxyResponse || ReturnType.FullName == TypeFullNames.APIGatewayHttpApiV2ProxyResponse)
+ {
+ return true;
+ }
+ if(ReturnsGenericTask && ReturnType.TypeArguments.Count == 1)
+ {
+ return ReturnType.TypeArguments[0].FullName == TypeFullNames.APIGatewayProxyResponse
+ || ReturnType.TypeArguments[0].FullName == TypeFullNames.APIGatewayHttpApiV2ProxyResponse;
+ }
return false;
}
diff --git a/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Templates/APIGatewayInvoke.cs b/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Templates/APIGatewayInvoke.cs
index 36dff2f66..3976bded1 100644
--- a/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Templates/APIGatewayInvoke.cs
+++ b/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Templates/APIGatewayInvoke.cs
@@ -22,7 +22,7 @@ namespace Amazon.Lambda.Annotations.SourceGenerator.Templates
/// Class to produce the template output
///
- #line 1 "C:\codebase\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
+ #line 1 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")]
public partial class APIGatewayInvoke : APIGatewayInvokeBase
{
@@ -33,10 +33,12 @@ public partial class APIGatewayInvoke : APIGatewayInvokeBase
public virtual string TransformText()
{
- #line 10 "C:\codebase\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
+ #line 10 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
var restApiAttribute = _model.LambdaMethod.Attributes.FirstOrDefault(att => att.Type.FullName == TypeFullNames.RestApiAttribute) as AttributeModel;
var httpApiAttribute = _model.LambdaMethod.Attributes.FirstOrDefault(att => att.Type.FullName == TypeFullNames.HttpApiAttribute) as AttributeModel;
+ var useHttpV2Response = httpApiAttribute?.Data.Version == Amazon.Lambda.Annotations.APIGateway.HttpApiVersion.V2;
+ var apiGatewayResponseType = useHttpV2Response ? TypeFullNames.APIGatewayHttpApiV2ProxyResponse : TypeFullNames.APIGatewayProxyResponse;
if (_model.LambdaMethod.ReturnsIHttpResults)
{
@@ -46,27 +48,27 @@ public virtual string TransformText()
#line hidden
this.Write(" var httpResults = ");
- #line 17 "C:\codebase\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
+ #line 19 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(_model.LambdaMethod.ReturnsGenericTask ? "await " : ""));
#line default
#line hidden
- #line 17 "C:\codebase\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
+ #line 19 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(_model.LambdaMethod.ContainingType.Name.ToCamelCase()));
#line default
#line hidden
this.Write(".");
- #line 17 "C:\codebase\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
+ #line 19 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(_model.LambdaMethod.Name));
#line default
#line hidden
this.Write("(");
- #line 17 "C:\codebase\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
+ #line 19 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(_parameterSignature));
#line default
@@ -74,7 +76,7 @@ public virtual string TransformText()
this.Write(");\r\n HttpResultSerializationOptions.ProtocolFormat serializationFormat" +
" = ");
- #line 18 "C:\codebase\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
+ #line 20 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(restApiAttribute != null ? "HttpResultSerializationOptions.ProtocolFormat.RestApi" : "HttpResultSerializationOptions.ProtocolFormat.HttpApi"));
#line default
@@ -82,7 +84,7 @@ public virtual string TransformText()
this.Write(";\r\n HttpResultSerializationOptions.ProtocolVersion serializationVersio" +
"n = ");
- #line 19 "C:\codebase\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
+ #line 21 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(restApiAttribute != null || httpApiAttribute?.Data.Version == Amazon.Lambda.Annotations.APIGateway.HttpApiVersion.V1 ? "HttpResultSerializationOptions.ProtocolVersion.V1" : "HttpResultSerializationOptions.ProtocolVersion.V2"));
#line default
@@ -90,20 +92,22 @@ public virtual string TransformText()
this.Write(";\r\n System.Text.Json.Serialization.JsonSerializerContext jsonContext =" +
" ");
- #line 20 "C:\codebase\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
+ #line 22 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(_model.SerializerInfo.SerializerJsonContextName != null ? _model.SerializerInfo.SerializerJsonContextName + ".Default" : "null"));
#line default
#line hidden
- this.Write(";\r\n var serializationOptions = new HttpResultSerializationOptions { Fo" +
- "rmat = serializationFormat, Version = serializationVersion, JsonContext = jsonCo" +
- "ntext };\r\n var response = httpResults.Serialize(serializationOptions)" +
- ";\r\n");
+ this.Write(@";
+ var serializationOptions = new HttpResultSerializationOptions { Format = serializationFormat, Version = serializationVersion, JsonContext = jsonContext };
+ var response = httpResults.Serialize(serializationOptions);
+ return response;
+");
- #line 23 "C:\codebase\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
-
+ #line 26 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
+ return this.GenerationEnvironment.ToString();
}
- else if (_model.LambdaMethod.ReturnsVoid)
+
+ if (_model.LambdaMethod.ReturnsVoid || _model.LambdaMethod.ReturnsVoidTask)
{
@@ -111,204 +115,208 @@ public virtual string TransformText()
#line hidden
this.Write(" ");
- #line 28 "C:\codebase\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
+ #line 32 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(_model.LambdaMethod.ReturnsVoidTask ? "await " : ""));
+
+ #line default
+ #line hidden
+
+ #line 32 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(_model.LambdaMethod.ContainingType.Name.ToCamelCase()));
#line default
#line hidden
this.Write(".");
- #line 28 "C:\codebase\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
+ #line 32 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(_model.LambdaMethod.Name));
#line default
#line hidden
this.Write("(");
- #line 28 "C:\codebase\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
+ #line 32 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(_parameterSignature));
#line default
#line hidden
- this.Write(");\r\n");
+ this.Write(");\r\n var response = new ");
- #line 29 "C:\codebase\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
-
+ #line 33 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(apiGatewayResponseType));
+
+ #line default
+ #line hidden
+ this.Write("\r\n {\r\n StatusCode = 200\r\n };\r\n\r\n " +
+ "var responseStream = new MemoryStream();\r\n JsonSerializer.Serialize(r" +
+ "esponseStream, response, typeof(");
+
+ #line 39 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(apiGatewayResponseType));
+
+ #line default
+ #line hidden
+ this.Write("));\r\n responseStream.Position = 0;\r\n return responseStream;" +
+ "\r\n");
+
+ #line 42 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
+ return this.GenerationEnvironment.ToString();
}
- else if (_model.LambdaMethod.ReturnsVoidTask)
- {
+
+ if (_model.LambdaMethod.ReturnsApiGatewayResponse)
+ {
+ // If the customer's Lambda method returns an APIGateway response type
+ // we just use the JsonSerializer to convert it to a stream and return it.
#line default
#line hidden
- this.Write(" await ");
+ this.Write(" var response = ");
- #line 34 "C:\codebase\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
+ #line 50 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(_model.LambdaMethod.ReturnsGenericTask ? "await " : ""));
+
+ #line default
+ #line hidden
+
+ #line 50 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(_model.LambdaMethod.ContainingType.Name.ToCamelCase()));
#line default
#line hidden
this.Write(".");
- #line 34 "C:\codebase\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
+ #line 50 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(_model.LambdaMethod.Name));
#line default
#line hidden
this.Write("(");
- #line 34 "C:\codebase\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
+ #line 50 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(_parameterSignature));
#line default
#line hidden
- this.Write(");\r\n");
+ this.Write(");\r\n var responseStream = new MemoryStream();\r\n JsonSeriali" +
+ "zer.Serialize(responseStream, response, typeof(");
- #line 35 "C:\codebase\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
-
+ #line 52 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(apiGatewayResponseType));
+
+ #line default
+ #line hidden
+ this.Write("));\r\n responseStream.Position = 0;\r\n return responseStream;" +
+ "\r\n");
+
+ #line 55 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
+ return this.GenerationEnvironment.ToString();
}
- else
- {
#line default
#line hidden
- this.Write(" var response = ");
+ this.Write(" var result = ");
- #line 40 "C:\codebase\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
+ #line 58 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(_model.LambdaMethod.ReturnsGenericTask ? "await " : ""));
#line default
#line hidden
- #line 40 "C:\codebase\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
+ #line 58 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(_model.LambdaMethod.ContainingType.Name.ToCamelCase()));
#line default
#line hidden
this.Write(".");
- #line 40 "C:\codebase\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
+ #line 58 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(_model.LambdaMethod.Name));
#line default
#line hidden
this.Write("(");
- #line 40 "C:\codebase\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
+ #line 58 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(_parameterSignature));
#line default
#line hidden
this.Write(");\r\n");
- #line 41 "C:\codebase\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
-
- }
+ #line 59 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
- if (_model.GeneratedMethod.ReturnType.FullName == _model.LambdaMethod.ReturnType.FullName || _model.LambdaMethod.ReturnsIHttpResults)
+ if (_model.LambdaMethod.ReturnType.IsValueType)
{
#line default
#line hidden
- this.Write(" return response;\r\n");
+ this.Write(" var body = result.ToString();\r\n");
- #line 48 "C:\codebase\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
+ #line 64 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
}
+ else if (_model.LambdaMethod.ReturnType.IsString())
+ {
+ // no action
+ }
else
{
- if (!_model.LambdaMethod.ReturnsVoid && !_model.LambdaMethod.ReturnsVoidTask)
- {
- if (_model.LambdaMethod.ReturnType.IsValueType)
- {
-
-
- #line default
- #line hidden
- this.Write("\r\n var body = response.ToString();\r\n");
-
- #line 59 "C:\codebase\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
-
- }
- else if (_model.LambdaMethod.ReturnType.IsString())
- {
- // no action
- }
- else
- {
#line default
#line hidden
this.Write(@" var memoryStream = new MemoryStream();
- serializer.Serialize(response, memoryStream);
+ serializer.Serialize(result, memoryStream);
memoryStream.Position = 0;
// convert stream to string
- StreamReader reader = new StreamReader( memoryStream );
+ StreamReader reader = new StreamReader(memoryStream);
var body = reader.ReadToEnd();
");
- #line 75 "C:\codebase\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
+ #line 80 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
- }
- }
+ }
#line default
#line hidden
- this.Write("\r\n return new ");
+ this.Write(" var response = new ");
- #line 80 "C:\codebase\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
- this.Write(this.ToStringHelper.ToStringWithCulture(_model.LambdaMethod.ReturnsVoidOrGenericTask ? _model.GeneratedMethod.ReturnType.TaskTypeArgument : _model.GeneratedMethod.ReturnType.FullName));
+ #line 83 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(apiGatewayResponseType));
#line default
#line hidden
- this.Write("\r\n {\r\n");
+ this.Write("\r\n {\r\n Body = ");
- #line 82 "C:\codebase\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
-
- if (!_model.LambdaMethod.ReturnsVoid && !_model.LambdaMethod.ReturnsVoidTask)
- {
-
+ #line 85 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(_model.LambdaMethod.ReturnType.IsString() ? "result" : "body"));
#line default
#line hidden
- this.Write(" Body = ");
+ this.Write(",\r\n StatusCode = 200,\r\n Headers = new Dictionary\r\n {\r\n {\"Content-Type\", ");
- #line 86 "C:\codebase\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
- this.Write(this.ToStringHelper.ToStringWithCulture(_model.LambdaMethod.ReturnType.IsString() ? "response" : "body"));
-
- #line default
- #line hidden
- this.Write(",\r\n Headers = new Dictionary\r\n {\r\n " +
- " {\"Content-Type\", ");
-
- #line 89 "C:\codebase\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
+ #line 89 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(_model.LambdaMethod.ReturnType.IsString() ? "\"text/plain\"" : "\"application/json\""));
#line default
#line hidden
- this.Write("}\r\n },\r\n");
+ this.Write("}\r\n }\r\n };\r\n\r\n var responseStream = new Memo" +
+ "ryStream();\r\n JsonSerializer.Serialize(responseStream, response, type" +
+ "of(");
- #line 91 "C:\codebase\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
-
- }
-
-
- #line default
- #line hidden
- this.Write(" StatusCode = 200\r\n };\r\n");
-
- #line 96 "C:\codebase\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
-
- }
-
+ #line 94 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewayInvoke.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(apiGatewayResponseType));
#line default
#line hidden
+ this.Write("));\r\n responseStream.Position = 0;\r\n return responseStream;" +
+ "\r\n");
return this.GenerationEnvironment.ToString();
}
}
diff --git a/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Templates/APIGatewayInvoke.tt b/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Templates/APIGatewayInvoke.tt
index c7cc555a2..1db339235 100644
--- a/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Templates/APIGatewayInvoke.tt
+++ b/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Templates/APIGatewayInvoke.tt
@@ -10,6 +10,8 @@
<#
var restApiAttribute = _model.LambdaMethod.Attributes.FirstOrDefault(att => att.Type.FullName == TypeFullNames.RestApiAttribute) as AttributeModel;
var httpApiAttribute = _model.LambdaMethod.Attributes.FirstOrDefault(att => att.Type.FullName == TypeFullNames.HttpApiAttribute) as AttributeModel;
+ var useHttpV2Response = httpApiAttribute?.Data.Version == Amazon.Lambda.Annotations.APIGateway.HttpApiVersion.V2;
+ var apiGatewayResponseType = useHttpV2Response ? TypeFullNames.APIGatewayHttpApiV2ProxyResponse : TypeFullNames.APIGatewayProxyResponse;
if (_model.LambdaMethod.ReturnsIHttpResults)
{
@@ -20,79 +22,75 @@
System.Text.Json.Serialization.JsonSerializerContext jsonContext = <#= _model.SerializerInfo.SerializerJsonContextName != null ? _model.SerializerInfo.SerializerJsonContextName + ".Default" : "null"#>;
var serializationOptions = new HttpResultSerializationOptions { Format = serializationFormat, Version = serializationVersion, JsonContext = jsonContext };
var response = httpResults.Serialize(serializationOptions);
-<#
+ return response;
+<# return this.GenerationEnvironment.ToString();
}
- else if (_model.LambdaMethod.ReturnsVoid)
+
+ if (_model.LambdaMethod.ReturnsVoid || _model.LambdaMethod.ReturnsVoidTask)
{
#>
- <#= _model.LambdaMethod.ContainingType.Name.ToCamelCase() #>.<#= _model.LambdaMethod.Name #>(<#= _parameterSignature #>);
-<#
+ <#= _model.LambdaMethod.ReturnsVoidTask ? "await " : "" #><#= _model.LambdaMethod.ContainingType.Name.ToCamelCase() #>.<#= _model.LambdaMethod.Name #>(<#= _parameterSignature #>);
+ var response = new <#= apiGatewayResponseType #>
+ {
+ StatusCode = 200
+ };
+
+ var responseStream = new MemoryStream();
+ JsonSerializer.Serialize(responseStream, response, typeof(<#= apiGatewayResponseType #>));
+ responseStream.Position = 0;
+ return responseStream;
+<# return this.GenerationEnvironment.ToString();
}
- else if (_model.LambdaMethod.ReturnsVoidTask)
- {
+
+ if (_model.LambdaMethod.ReturnsApiGatewayResponse)
+ {
+ // If the customer's Lambda method returns an APIGateway response type
+ // we just use the JsonSerializer to convert it to a stream and return it.
#>
- await <#= _model.LambdaMethod.ContainingType.Name.ToCamelCase() #>.<#= _model.LambdaMethod.Name #>(<#= _parameterSignature #>);
-<#
+ var response = <#= _model.LambdaMethod.ReturnsGenericTask ? "await " : "" #><#= _model.LambdaMethod.ContainingType.Name.ToCamelCase() #>.<#= _model.LambdaMethod.Name #>(<#= _parameterSignature #>);
+ var responseStream = new MemoryStream();
+ JsonSerializer.Serialize(responseStream, response, typeof(<#= apiGatewayResponseType #>));
+ responseStream.Position = 0;
+ return responseStream;
+<# return this.GenerationEnvironment.ToString();
}
- else
- {
#>
- var response = <#= _model.LambdaMethod.ReturnsGenericTask ? "await " : "" #><#= _model.LambdaMethod.ContainingType.Name.ToCamelCase() #>.<#= _model.LambdaMethod.Name #>(<#= _parameterSignature #>);
+ var result = <#= _model.LambdaMethod.ReturnsGenericTask ? "await " : "" #><#= _model.LambdaMethod.ContainingType.Name.ToCamelCase() #>.<#= _model.LambdaMethod.Name #>(<#= _parameterSignature #>);
<#
- }
-
- if (_model.GeneratedMethod.ReturnType.FullName == _model.LambdaMethod.ReturnType.FullName || _model.LambdaMethod.ReturnsIHttpResults)
+ if (_model.LambdaMethod.ReturnType.IsValueType)
{
#>
- return response;
+ var body = result.ToString();
<#
}
+ else if (_model.LambdaMethod.ReturnType.IsString())
+ {
+ // no action
+ }
else
{
- if (!_model.LambdaMethod.ReturnsVoid && !_model.LambdaMethod.ReturnsVoidTask)
- {
- if (_model.LambdaMethod.ReturnType.IsValueType)
- {
-#>
-
- var body = response.ToString();
-<#
- }
- else if (_model.LambdaMethod.ReturnType.IsString())
- {
- // no action
- }
- else
- {
#>
var memoryStream = new MemoryStream();
- serializer.Serialize(response, memoryStream);
+ serializer.Serialize(result, memoryStream);
memoryStream.Position = 0;
// convert stream to string
- StreamReader reader = new StreamReader( memoryStream );
+ StreamReader reader = new StreamReader(memoryStream);
var body = reader.ReadToEnd();
<#
- }
- }
+ }
#>
-
- return new <#= _model.LambdaMethod.ReturnsVoidOrGenericTask ? _model.GeneratedMethod.ReturnType.TaskTypeArgument : _model.GeneratedMethod.ReturnType.FullName #>
+ var response = new <#= apiGatewayResponseType #>
{
-<#
- if (!_model.LambdaMethod.ReturnsVoid && !_model.LambdaMethod.ReturnsVoidTask)
- {
-#>
- Body = <#= _model.LambdaMethod.ReturnType.IsString() ? "response" : "body" #>,
+ Body = <#= _model.LambdaMethod.ReturnType.IsString() ? "result" : "body" #>,
+ StatusCode = 200,
Headers = new Dictionary
{
{"Content-Type", <#= _model.LambdaMethod.ReturnType.IsString() ? "\"text/plain\"" : "\"application/json\"" #>}
- },
-<#
- }
-#>
- StatusCode = 200
+ }
};
-<#
- }
-#>
\ No newline at end of file
+
+ var responseStream = new MemoryStream();
+ JsonSerializer.Serialize(responseStream, response, typeof(<#= apiGatewayResponseType #>));
+ responseStream.Position = 0;
+ return responseStream;
diff --git a/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Templates/APIGatewaySetupParameters.cs b/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Templates/APIGatewaySetupParameters.cs
index e9e577f06..b69bfb030 100644
--- a/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Templates/APIGatewaySetupParameters.cs
+++ b/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Templates/APIGatewaySetupParameters.cs
@@ -54,6 +54,8 @@ public virtual string TransformText()
}));
var restApiAttribute = _model.LambdaMethod.Attributes.FirstOrDefault(att => att.Type.FullName == TypeFullNames.RestApiAttribute) as AttributeModel;
var httpApiAttribute = _model.LambdaMethod.Attributes.FirstOrDefault(att => att.Type.FullName == TypeFullNames.HttpApiAttribute) as AttributeModel;
+ var useHttpV2Response = httpApiAttribute?.Data.Version == Amazon.Lambda.Annotations.APIGateway.HttpApiVersion.V2;
+ var apiGatewayResponseType = useHttpV2Response ? TypeFullNames.APIGatewayHttpApiV2ProxyResponse : TypeFullNames.APIGatewayProxyResponse;
if (restApiAttribute != null && httpApiAttribute != null)
{
@@ -77,7 +79,7 @@ public virtual string TransformText()
#line hidden
this.Write(" var validationErrors = new List();\r\n\r\n");
- #line 50 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 52 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
}
@@ -95,21 +97,21 @@ public virtual string TransformText()
#line hidden
this.Write(" var ");
- #line 62 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 64 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Name));
#line default
#line hidden
this.Write(" = scope.ServiceProvider.GetRequiredService<");
- #line 62 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 64 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Type.FullName));
#line default
#line hidden
this.Write(">();\r\n");
- #line 63 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 65 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
}
else if (parameter.Attributes.Any(att => att.Type.FullName == TypeFullNames.FromQueryAttribute))
@@ -127,21 +129,21 @@ public virtual string TransformText()
#line hidden
this.Write(" var ");
- #line 75 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 77 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Name));
#line default
#line hidden
this.Write(" = default(");
- #line 75 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 77 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Type.FullName));
#line default
#line hidden
this.Write(");\r\n");
- #line 76 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 78 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
if (parameter.Type.IsEnumerable && parameter.Type.IsGenericType)
@@ -175,42 +177,42 @@ public virtual string TransformText()
#line hidden
this.Write(" if (__request__.");
- #line 104 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 106 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(queryStringParameters));
#line default
#line hidden
this.Write("?.ContainsKey(\"");
- #line 104 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 106 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(parameterKey));
#line default
#line hidden
this.Write("\") == true)\r\n {\r\n ");
- #line 106 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 108 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Name));
#line default
#line hidden
this.Write(" = __request__.");
- #line 106 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 108 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(queryStringParameters));
#line default
#line hidden
this.Write("[\"");
- #line 106 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 108 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(parameterKey));
#line default
#line hidden
this.Write("\"]");
- #line 106 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 108 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(commaSplit));
#line default
@@ -218,14 +220,14 @@ public virtual string TransformText()
this.Write("\r\n .Select(q =>\r\n {\r\n " +
" try\r\n {\r\n return (");
- #line 111 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 113 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(typeArgument.FullName));
#line default
#line hidden
this.Write(")Convert.ChangeType(q, typeof(");
- #line 111 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 113 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(typeArgument.FullNameWithoutAnnotations));
#line default
@@ -236,7 +238,7 @@ public virtual string TransformText()
{
validationErrors.Add($""Value {q} at '");
- #line 115 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 117 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(parameterKey));
#line default
@@ -245,7 +247,7 @@ public virtual string TransformText()
"n default;\r\n }\r\n })\r\n " +
" .ToList();\r\n }\r\n\r\n");
- #line 122 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 124 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
}
else
@@ -257,14 +259,14 @@ public virtual string TransformText()
#line hidden
this.Write(" if (__request__.");
- #line 128 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 130 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(queryStringParameters));
#line default
#line hidden
this.Write("?.ContainsKey(\"");
- #line 128 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 130 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(parameterKey));
#line default
@@ -272,35 +274,35 @@ public virtual string TransformText()
this.Write("\") == true)\r\n {\r\n try\r\n {\r\n " +
" ");
- #line 132 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 134 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Name));
#line default
#line hidden
this.Write(" = (");
- #line 132 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 134 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Type.FullName));
#line default
#line hidden
this.Write(")Convert.ChangeType(__request__.");
- #line 132 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 134 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(queryStringParameters));
#line default
#line hidden
this.Write("[\"");
- #line 132 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 134 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(parameterKey));
#line default
#line hidden
this.Write("\"], typeof(");
- #line 132 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 134 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Type.FullNameWithoutAnnotations));
#line default
@@ -310,21 +312,21 @@ public virtual string TransformText()
"eption)\r\n {\r\n validationErrors.Add($\"Value {__" +
"request__.");
- #line 136 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 138 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(queryStringParameters));
#line default
#line hidden
this.Write("[\"");
- #line 136 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 138 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(parameterKey));
#line default
#line hidden
this.Write("\"]} at \'");
- #line 136 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 138 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(parameterKey));
#line default
@@ -332,7 +334,7 @@ public virtual string TransformText()
this.Write("\' failed to satisfy constraint: {e.Message}\");\r\n }\r\n }\r" +
"\n\r\n");
- #line 140 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 142 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
}
@@ -354,21 +356,21 @@ public virtual string TransformText()
#line hidden
this.Write(" var ");
- #line 156 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 158 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Name));
#line default
#line hidden
this.Write(" = default(");
- #line 156 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 158 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Type.FullName));
#line default
#line hidden
this.Write(");\r\n");
- #line 157 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 159 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
if (parameter.Type.IsEnumerable && parameter.Type.IsGenericType)
@@ -402,14 +404,14 @@ public virtual string TransformText()
#line hidden
this.Write(" if (__request__.");
- #line 185 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 187 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(headers));
#line default
#line hidden
this.Write("?.Any(x => string.Equals(x.Key, \"");
- #line 185 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 187 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(headerKey));
#line default
@@ -417,28 +419,28 @@ public virtual string TransformText()
this.Write("\", StringComparison.OrdinalIgnoreCase)) == true)\r\n {\r\n " +
"");
- #line 187 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 189 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Name));
#line default
#line hidden
this.Write(" = __request__.");
- #line 187 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 189 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(headers));
#line default
#line hidden
this.Write(".First(x => string.Equals(x.Key, \"");
- #line 187 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 189 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(headerKey));
#line default
#line hidden
this.Write("\", StringComparison.OrdinalIgnoreCase)).Value");
- #line 187 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 189 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(commaSplit));
#line default
@@ -446,14 +448,14 @@ public virtual string TransformText()
this.Write("\r\n .Select(q =>\r\n {\r\n " +
" try\r\n {\r\n return (");
- #line 192 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 194 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(typeArgument.FullName));
#line default
#line hidden
this.Write(")Convert.ChangeType(q, typeof(");
- #line 192 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 194 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(typeArgument.FullNameWithoutAnnotations));
#line default
@@ -464,7 +466,7 @@ public virtual string TransformText()
{
validationErrors.Add($""Value {q} at '");
- #line 196 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 198 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(headerKey));
#line default
@@ -473,7 +475,7 @@ public virtual string TransformText()
"n default;\r\n }\r\n })\r\n " +
" .ToList();\r\n }\r\n\r\n");
- #line 203 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 205 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
}
else
@@ -485,14 +487,14 @@ public virtual string TransformText()
#line hidden
this.Write(" if (__request__.");
- #line 209 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 211 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(headers));
#line default
#line hidden
this.Write("?.Any(x => string.Equals(x.Key, \"");
- #line 209 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 211 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(headerKey));
#line default
@@ -500,35 +502,35 @@ public virtual string TransformText()
this.Write("\", StringComparison.OrdinalIgnoreCase)) == true)\r\n {\r\n " +
"try\r\n {\r\n ");
- #line 213 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 215 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Name));
#line default
#line hidden
this.Write(" = (");
- #line 213 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 215 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Type.FullName));
#line default
#line hidden
this.Write(")Convert.ChangeType(__request__.");
- #line 213 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 215 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(headers));
#line default
#line hidden
this.Write(".First(x => string.Equals(x.Key, \"");
- #line 213 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 215 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(headerKey));
#line default
#line hidden
this.Write("\", StringComparison.OrdinalIgnoreCase)).Value, typeof(");
- #line 213 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 215 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Type.FullNameWithoutAnnotations));
#line default
@@ -538,21 +540,21 @@ public virtual string TransformText()
"eption)\r\n {\r\n validationErrors.Add($\"Value {__" +
"request__.");
- #line 217 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 219 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(headers));
#line default
#line hidden
this.Write(".First(x => string.Equals(x.Key, \"");
- #line 217 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 219 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(headerKey));
#line default
#line hidden
this.Write("\", StringComparison.OrdinalIgnoreCase)).Value} at \'");
- #line 217 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 219 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(headerKey));
#line default
@@ -560,7 +562,7 @@ public virtual string TransformText()
this.Write("\' failed to satisfy constraint: {e.Message}\");\r\n }\r\n }\r" +
"\n\r\n");
- #line 221 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 223 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
}
}
@@ -575,14 +577,14 @@ public virtual string TransformText()
#line hidden
this.Write(" var ");
- #line 230 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 232 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Name));
#line default
#line hidden
this.Write(" = __request__.Body;\r\n\r\n");
- #line 232 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 234 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
}
else
@@ -593,14 +595,14 @@ public virtual string TransformText()
#line hidden
this.Write(" var ");
- #line 237 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 239 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Name));
#line default
#line hidden
this.Write(" = default(");
- #line 237 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 239 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Type.FullName));
#line default
@@ -609,14 +611,14 @@ public virtual string TransformText()
" var byteArray = Encoding.ASCII.GetBytes(__request__.Body);\r\n " +
" var stream = new MemoryStream(byteArray);\r\n ");
- #line 243 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 245 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Name));
#line default
#line hidden
this.Write(" = serializer.Deserialize<");
- #line 243 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 245 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Type.FullName));
#line default
@@ -625,7 +627,7 @@ public virtual string TransformText()
" validationErrors.Add($\"Value {__request__.Body} at \'body\' failed to sa" +
"tisfy constraint: {e.Message}\");\r\n }\r\n\r\n");
- #line 250 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 252 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
}
}
@@ -641,21 +643,21 @@ public virtual string TransformText()
#line hidden
this.Write(" var ");
- #line 260 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 262 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Name));
#line default
#line hidden
this.Write(" = default(");
- #line 260 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 262 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Type.FullName));
#line default
#line hidden
this.Write(");\r\n if (__request__.PathParameters?.ContainsKey(\"");
- #line 261 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 263 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(routeKey));
#line default
@@ -663,28 +665,28 @@ public virtual string TransformText()
this.Write("\") == true)\r\n {\r\n try\r\n {\r\n " +
" ");
- #line 265 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 267 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Name));
#line default
#line hidden
this.Write(" = (");
- #line 265 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 267 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Type.FullName));
#line default
#line hidden
this.Write(")Convert.ChangeType(__request__.PathParameters[\"");
- #line 265 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 267 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(routeKey));
#line default
#line hidden
this.Write("\"], typeof(");
- #line 265 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 267 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Type.FullNameWithoutAnnotations));
#line default
@@ -695,14 +697,14 @@ public virtual string TransformText()
{
validationErrors.Add($""Value {__request__.PathParameters[""");
- #line 269 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 271 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(routeKey));
#line default
#line hidden
this.Write("\"]} at \'");
- #line 269 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 271 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(routeKey));
#line default
@@ -710,7 +712,7 @@ public virtual string TransformText()
this.Write("\' failed to satisfy constraint: {e.Message}\");\r\n }\r\n }\r" +
"\n\r\n");
- #line 273 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 275 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
}
else
@@ -729,8 +731,8 @@ public virtual string TransformText()
" if (validationErrors.Any())\r\n {\r\n var errorResult" +
" = new ");
- #line 287 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
- this.Write(this.ToStringHelper.ToStringWithCulture(restApiAttribute != null || httpApiAttribute?.Data.Version == Amazon.Lambda.Annotations.APIGateway.HttpApiVersion.V1 ? "Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse" : "Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyResponse"));
+ #line 289 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(apiGatewayResponseType));
#line default
#line hidden
@@ -744,41 +746,19 @@ public virtual string TransformText()
},
StatusCode = 400
};
-");
-
- #line 297 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
-
- if(_model.LambdaMethod.ReturnsIHttpResults)
- {
+ var errorStream = new MemoryStream();
+ JsonSerializer.Serialize(errorStream, errorResult, typeof(");
- #line default
- #line hidden
- this.Write(" var errorStream = new System.IO.MemoryStream();\r\n " +
- "serializer.Serialize(errorResult, errorStream);\r\n errorStream.Pos" +
- "ition = 0;\r\n return errorStream;\r\n");
-
- #line 305 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
-
- }
- else
- {
-
+ #line 301 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(apiGatewayResponseType));
#line default
#line hidden
- this.Write(" return errorResult;\r\n");
+ this.Write("));\r\n errorStream.Position = 0;\r\n return errorStrea" +
+ "m;\r\n }\r\n");
- #line 311 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
-
- }
-
-
- #line default
- #line hidden
- this.Write(" }\r\n\r\n");
-
- #line 316 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
+ #line 305 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\APIGatewaySetupParameters.tt"
}
diff --git a/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Templates/APIGatewaySetupParameters.tt b/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Templates/APIGatewaySetupParameters.tt
index 343bcbcab..88ab4cd45 100644
--- a/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Templates/APIGatewaySetupParameters.tt
+++ b/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Templates/APIGatewaySetupParameters.tt
@@ -27,6 +27,8 @@
}));
var restApiAttribute = _model.LambdaMethod.Attributes.FirstOrDefault(att => att.Type.FullName == TypeFullNames.RestApiAttribute) as AttributeModel;
var httpApiAttribute = _model.LambdaMethod.Attributes.FirstOrDefault(att => att.Type.FullName == TypeFullNames.HttpApiAttribute) as AttributeModel;
+ var useHttpV2Response = httpApiAttribute?.Data.Version == Amazon.Lambda.Annotations.APIGateway.HttpApiVersion.V2;
+ var apiGatewayResponseType = useHttpV2Response ? TypeFullNames.APIGatewayHttpApiV2ProxyResponse : TypeFullNames.APIGatewayProxyResponse;
if (restApiAttribute != null && httpApiAttribute != null)
{
@@ -284,7 +286,7 @@
// return 400 Bad Request if there exists a validation error
if (validationErrors.Any())
{
- var errorResult = new <#= restApiAttribute != null || httpApiAttribute?.Data.Version == Amazon.Lambda.Annotations.APIGateway.HttpApiVersion.V1 ? "Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse" : "Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyResponse" #>
+ var errorResult = new <#= apiGatewayResponseType #>
{
Body = @$"{{""message"": ""{validationErrors.Count} validation error(s) detected: {string.Join(",", validationErrors)}""}}",
Headers = new Dictionary
@@ -294,25 +296,12 @@
},
StatusCode = 400
};
-<#
- if(_model.LambdaMethod.ReturnsIHttpResults)
- {
-#>
- var errorStream = new System.IO.MemoryStream();
- serializer.Serialize(errorResult, errorStream);
+
+ var errorStream = new MemoryStream();
+ JsonSerializer.Serialize(errorStream, errorResult, typeof(<#= apiGatewayResponseType #>));
errorStream.Position = 0;
return errorStream;
-<#
- }
- else
- {
-#>
- return errorResult;
-<#
- }
-#>
}
-
<#
}
#>
\ No newline at end of file
diff --git a/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Templates/JsonSerializerContextTemplate.cs b/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Templates/JsonSerializerContextTemplate.cs
new file mode 100644
index 000000000..71e585536
--- /dev/null
+++ b/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Templates/JsonSerializerContextTemplate.cs
@@ -0,0 +1,346 @@
+// ------------------------------------------------------------------------------
+//
+// 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 Amazon.Lambda.Annotations.SourceGenerator.Templates
+{
+ using System.Linq;
+ using System.Threading.Tasks;
+ using System.Text;
+ using System.Collections.Generic;
+ using Microsoft.CodeAnalysis;
+ using System;
+
+ ///
+ /// Class to produce the template output
+ ///
+
+ #line 1 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\JsonSerializerContextTemplate.tt"
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")]
+ public partial class JsonSerializerContextTemplate : JsonSerializerContextTemplateBase
+ {
+#line hidden
+ ///
+ /// Create the template output
+ ///
+ public virtual string TransformText()
+ {
+ this.Write("\r\nusing System.Text.Json.Serialization;\r\n\r\nnamespace ");
+
+ #line 11 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\JsonSerializerContextTemplate.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(_containingNamespace));
+
+ #line default
+ #line hidden
+ this.Write("\r\n{\r\n#if !NETSTANDARD2_0\r\n");
+
+ #line 14 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\JsonSerializerContextTemplate.tt"
+
+ foreach (var serializableType in _serializableTypes)
+ {
+
+
+ #line default
+ #line hidden
+ this.Write(" [JsonSerializable(typeof(");
+
+ #line 18 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\JsonSerializerContextTemplate.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(serializableType));
+
+ #line default
+ #line hidden
+ this.Write("))]\r\n");
+
+ #line 19 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\JsonSerializerContextTemplate.tt"
+
+ }
+
+
+ #line default
+ #line hidden
+ this.Write(" internal partial class ApiGatewayResponseJsonSerializerContext : JsonSerializ" +
+ "erContext\r\n {\r\n }\r\n#endif\r\n}");
+ return this.GenerationEnvironment.ToString();
+ }
+ }
+
+ #line default
+ #line hidden
+ #region Base class
+ ///
+ /// Base class for this transformation
+ ///
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")]
+ public class JsonSerializerContextTemplateBase
+ {
+ #region Fields
+ private global::System.Text.StringBuilder generationEnvironmentField;
+ private global::System.CodeDom.Compiler.CompilerErrorCollection errorsField;
+ private global::System.Collections.Generic.List indentLengthsField;
+ private string currentIndentField = "";
+ private bool endsWithNewline;
+ private global::System.Collections.Generic.IDictionary sessionField;
+ #endregion
+ #region Properties
+ ///
+ /// The string builder that generation-time code is using to assemble generated output
+ ///
+ public System.Text.StringBuilder GenerationEnvironment
+ {
+ get
+ {
+ if ((this.generationEnvironmentField == null))
+ {
+ this.generationEnvironmentField = new global::System.Text.StringBuilder();
+ }
+ return this.generationEnvironmentField;
+ }
+ set
+ {
+ this.generationEnvironmentField = value;
+ }
+ }
+ ///
+ /// The error collection for the generation process
+ ///
+ public System.CodeDom.Compiler.CompilerErrorCollection Errors
+ {
+ get
+ {
+ if ((this.errorsField == null))
+ {
+ this.errorsField = new global::System.CodeDom.Compiler.CompilerErrorCollection();
+ }
+ return this.errorsField;
+ }
+ }
+ ///
+ /// A list of the lengths of each indent that was added with PushIndent
+ ///
+ private System.Collections.Generic.List indentLengths
+ {
+ get
+ {
+ if ((this.indentLengthsField == null))
+ {
+ this.indentLengthsField = new global::System.Collections.Generic.List();
+ }
+ return this.indentLengthsField;
+ }
+ }
+ ///
+ /// Gets the current indent we use when adding lines to the output
+ ///
+ public string CurrentIndent
+ {
+ get
+ {
+ return this.currentIndentField;
+ }
+ }
+ ///
+ /// Current transformation session
+ ///
+ public virtual global::System.Collections.Generic.IDictionary Session
+ {
+ get
+ {
+ return this.sessionField;
+ }
+ set
+ {
+ this.sessionField = value;
+ }
+ }
+ #endregion
+ #region Transform-time helpers
+ ///
+ /// Write text directly into the generated output
+ ///
+ public void Write(string textToAppend)
+ {
+ if (string.IsNullOrEmpty(textToAppend))
+ {
+ return;
+ }
+ // If we're starting off, or if the previous text ended with a newline,
+ // we have to append the current indent first.
+ if (((this.GenerationEnvironment.Length == 0)
+ || this.endsWithNewline))
+ {
+ this.GenerationEnvironment.Append(this.currentIndentField);
+ this.endsWithNewline = false;
+ }
+ // Check if the current text ends with a newline
+ if (textToAppend.EndsWith(global::System.Environment.NewLine, global::System.StringComparison.CurrentCulture))
+ {
+ this.endsWithNewline = true;
+ }
+ // This is an optimization. If the current indent is "", then we don't have to do any
+ // of the more complex stuff further down.
+ if ((this.currentIndentField.Length == 0))
+ {
+ this.GenerationEnvironment.Append(textToAppend);
+ return;
+ }
+ // Everywhere there is a newline in the text, add an indent after it
+ textToAppend = textToAppend.Replace(global::System.Environment.NewLine, (global::System.Environment.NewLine + this.currentIndentField));
+ // If the text ends with a newline, then we should strip off the indent added at the very end
+ // because the appropriate indent will be added when the next time Write() is called
+ if (this.endsWithNewline)
+ {
+ this.GenerationEnvironment.Append(textToAppend, 0, (textToAppend.Length - this.currentIndentField.Length));
+ }
+ else
+ {
+ this.GenerationEnvironment.Append(textToAppend);
+ }
+ }
+ ///
+ /// Write text directly into the generated output
+ ///
+ public void WriteLine(string textToAppend)
+ {
+ this.Write(textToAppend);
+ this.GenerationEnvironment.AppendLine();
+ this.endsWithNewline = true;
+ }
+ ///
+ /// Write formatted text directly into the generated output
+ ///
+ public void Write(string format, params object[] args)
+ {
+ this.Write(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args));
+ }
+ ///
+ /// Write formatted text directly into the generated output
+ ///
+ public void WriteLine(string format, params object[] args)
+ {
+ this.WriteLine(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args));
+ }
+ ///
+ /// Raise an error
+ ///
+ public void Error(string message)
+ {
+ System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError();
+ error.ErrorText = message;
+ this.Errors.Add(error);
+ }
+ ///
+ /// Raise a warning
+ ///
+ public void Warning(string message)
+ {
+ System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError();
+ error.ErrorText = message;
+ error.IsWarning = true;
+ this.Errors.Add(error);
+ }
+ ///
+ /// Increase the indent
+ ///
+ public void PushIndent(string indent)
+ {
+ if ((indent == null))
+ {
+ throw new global::System.ArgumentNullException("indent");
+ }
+ this.currentIndentField = (this.currentIndentField + indent);
+ this.indentLengths.Add(indent.Length);
+ }
+ ///
+ /// Remove the last indent that was added with PushIndent
+ ///
+ public string PopIndent()
+ {
+ string returnValue = "";
+ if ((this.indentLengths.Count > 0))
+ {
+ int indentLength = this.indentLengths[(this.indentLengths.Count - 1)];
+ this.indentLengths.RemoveAt((this.indentLengths.Count - 1));
+ if ((indentLength > 0))
+ {
+ returnValue = this.currentIndentField.Substring((this.currentIndentField.Length - indentLength));
+ this.currentIndentField = this.currentIndentField.Remove((this.currentIndentField.Length - indentLength));
+ }
+ }
+ return returnValue;
+ }
+ ///
+ /// Remove any indentation
+ ///
+ public void ClearIndent()
+ {
+ this.indentLengths.Clear();
+ this.currentIndentField = "";
+ }
+ #endregion
+ #region ToString Helpers
+ ///
+ /// Utility class to produce culture-oriented representation of an object as a string.
+ ///
+ public class ToStringInstanceHelper
+ {
+ private System.IFormatProvider formatProviderField = global::System.Globalization.CultureInfo.InvariantCulture;
+ ///
+ /// Gets or sets format provider to be used by ToStringWithCulture method.
+ ///
+ public System.IFormatProvider FormatProvider
+ {
+ get
+ {
+ return this.formatProviderField ;
+ }
+ set
+ {
+ if ((value != null))
+ {
+ this.formatProviderField = value;
+ }
+ }
+ }
+ ///
+ /// This is called from the compile/run appdomain to convert objects within an expression block to a string
+ ///
+ public string ToStringWithCulture(object objectToConvert)
+ {
+ if ((objectToConvert == null))
+ {
+ throw new global::System.ArgumentNullException("objectToConvert");
+ }
+ System.Type t = objectToConvert.GetType();
+ System.Reflection.MethodInfo method = t.GetMethod("ToString", new System.Type[] {
+ typeof(System.IFormatProvider)});
+ if ((method == null))
+ {
+ return objectToConvert.ToString();
+ }
+ else
+ {
+ return ((string)(method.Invoke(objectToConvert, new object[] {
+ this.formatProviderField })));
+ }
+ }
+ }
+ private ToStringInstanceHelper toStringHelperField = new ToStringInstanceHelper();
+ ///
+ /// Helper to produce culture-oriented representation of an object as a string
+ ///
+ public ToStringInstanceHelper ToStringHelper
+ {
+ get
+ {
+ return this.toStringHelperField;
+ }
+ }
+ #endregion
+ }
+ #endregion
+}
diff --git a/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Templates/JsonSerializerContextTemplate.tt b/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Templates/JsonSerializerContextTemplate.tt
new file mode 100644
index 000000000..60e679952
--- /dev/null
+++ b/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Templates/JsonSerializerContextTemplate.tt
@@ -0,0 +1,26 @@
+<#@ template language="C#" #>
+<#@ assembly name="System.Core" #>
+<#@ import namespace="System.Linq" #>
+<#@ import namespace="System.Threading.Tasks" #>
+<#@ import namespace="System.Text" #>
+<#@ import namespace="System.Collections.Generic" #>
+<#@ import namespace="Microsoft.CodeAnalysis" #>
+
+using System.Text.Json.Serialization;
+
+namespace <#= _containingNamespace #>
+{
+#if !NETSTANDARD2_0
+<#
+ foreach (var serializableType in _serializableTypes)
+ {
+#>
+ [JsonSerializable(typeof(<#= serializableType #>))]
+<#
+ }
+#>
+ internal partial class ApiGatewayResponseJsonSerializerContext : JsonSerializerContext
+ {
+ }
+#endif
+}
\ No newline at end of file
diff --git a/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Templates/JsonSerializerContextTemplateCode.cs b/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Templates/JsonSerializerContextTemplateCode.cs
new file mode 100644
index 000000000..0c43e2b6a
--- /dev/null
+++ b/Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Templates/JsonSerializerContextTemplateCode.cs
@@ -0,0 +1,17 @@
+using Amazon.Lambda.Annotations.SourceGenerator.Models;
+using System.Collections.Generic;
+
+namespace Amazon.Lambda.Annotations.SourceGenerator.Templates
+{
+ public partial class JsonSerializerContextTemplate
+ {
+ private readonly string _containingNamespace;
+ private readonly HashSet _serializableTypes;
+
+ public JsonSerializerContextTemplate(string containingNamespace, HashSet serializableTypes)
+ {
+ _containingNamespace = containingNamespace;
+ _serializableTypes = serializableTypes;
+ }
+ }
+}
diff --git a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/ComplexCalculator_Add_Generated.g.cs b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/ComplexCalculator_Add_Generated.g.cs
index 368ab6f97..5b550f803 100644
--- a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/ComplexCalculator_Add_Generated.g.cs
+++ b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/ComplexCalculator_Add_Generated.g.cs
@@ -1,10 +1,11 @@
-using System;
+using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using Amazon.Lambda.Core;
+using System.Text.Json;
namespace TestServerlessApp
{
@@ -20,28 +21,32 @@ public ComplexCalculator_Add_Generated()
serializer = new Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer();
}
- public Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyResponse Add(Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyRequest __request__, Amazon.Lambda.Core.ILambdaContext __context__)
+ public System.IO.Stream Add(Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyRequest __request__, Amazon.Lambda.Core.ILambdaContext __context__)
{
var complexNumbers = __request__.Body;
- var response = complexCalculator.Add(complexNumbers, __context__, __request__);
+ var result = complexCalculator.Add(complexNumbers, __context__, __request__);
var memoryStream = new MemoryStream();
- serializer.Serialize(response, memoryStream);
+ serializer.Serialize(result, memoryStream);
memoryStream.Position = 0;
// convert stream to string
- StreamReader reader = new StreamReader( memoryStream );
+ StreamReader reader = new StreamReader(memoryStream);
var body = reader.ReadToEnd();
-
- return new Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyResponse
+ var response = new Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyResponse
{
Body = body,
+ StatusCode = 200,
Headers = new Dictionary
{
{"Content-Type", "application/json"}
- },
- StatusCode = 200
+ }
};
+
+ var responseStream = new MemoryStream();
+ JsonSerializer.Serialize(responseStream, response, typeof(Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyResponse));
+ responseStream.Position = 0;
+ return responseStream;
}
private static void SetExecutionEnvironment()
diff --git a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/ComplexCalculator_Subtract_Generated.g.cs b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/ComplexCalculator_Subtract_Generated.g.cs
index b1a77978d..df310de53 100644
--- a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/ComplexCalculator_Subtract_Generated.g.cs
+++ b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/ComplexCalculator_Subtract_Generated.g.cs
@@ -1,10 +1,11 @@
-using System;
+using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using Amazon.Lambda.Core;
+using System.Text.Json;
namespace TestServerlessApp
{
@@ -20,7 +21,7 @@ public ComplexCalculator_Subtract_Generated()
serializer = new Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer();
}
- public Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyResponse Subtract(Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyRequest __request__, Amazon.Lambda.Core.ILambdaContext __context__)
+ public System.IO.Stream Subtract(Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyRequest __request__, Amazon.Lambda.Core.ILambdaContext __context__)
{
var validationErrors = new List();
@@ -50,27 +51,34 @@ public Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyResponse Subtract(
},
StatusCode = 400
};
- return errorResult;
- }
- var response = complexCalculator.Subtract(complexNumbers);
+ var errorStream = new MemoryStream();
+ JsonSerializer.Serialize(errorStream, errorResult, typeof(Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyResponse));
+ errorStream.Position = 0;
+ return errorStream;
+ }
+ var result = complexCalculator.Subtract(complexNumbers);
var memoryStream = new MemoryStream();
- serializer.Serialize(response, memoryStream);
+ serializer.Serialize(result, memoryStream);
memoryStream.Position = 0;
// convert stream to string
- StreamReader reader = new StreamReader( memoryStream );
+ StreamReader reader = new StreamReader(memoryStream);
var body = reader.ReadToEnd();
-
- return new Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyResponse
+ var response = new Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyResponse
{
Body = body,
+ StatusCode = 200,
Headers = new Dictionary
{
{"Content-Type", "application/json"}
- },
- StatusCode = 200
+ }
};
+
+ var responseStream = new MemoryStream();
+ JsonSerializer.Serialize(responseStream, response, typeof(Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyResponse));
+ responseStream.Position = 0;
+ return responseStream;
}
private static void SetExecutionEnvironment()
diff --git a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/CustomizeResponseExamples_NotFoundResponseWithHeaderV1Async_Generated.g.cs b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/CustomizeResponseExamples_NotFoundResponseWithHeaderV1Async_Generated.g.cs
index 66a9b2f4c..1de16d83c 100644
--- a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/CustomizeResponseExamples_NotFoundResponseWithHeaderV1Async_Generated.g.cs
+++ b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/CustomizeResponseExamples_NotFoundResponseWithHeaderV1Async_Generated.g.cs
@@ -6,6 +6,7 @@
using System.IO;
using Amazon.Lambda.Core;
using Amazon.Lambda.Annotations.APIGateway;
+using System.Text.Json;
namespace TestServerlessApp
{
@@ -51,12 +52,12 @@ public CustomizeResponseExamples_NotFoundResponseWithHeaderV1Async_Generated()
},
StatusCode = 400
};
- var errorStream = new System.IO.MemoryStream();
- serializer.Serialize(errorResult, errorStream);
+
+ var errorStream = new MemoryStream();
+ JsonSerializer.Serialize(errorStream, errorResult, typeof(Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse));
errorStream.Position = 0;
return errorStream;
}
-
var httpResults = await customizeResponseExamples.NotFoundResponseWithHeaderV1Async(x, __context__);
HttpResultSerializationOptions.ProtocolFormat serializationFormat = HttpResultSerializationOptions.ProtocolFormat.HttpApi;
HttpResultSerializationOptions.ProtocolVersion serializationVersion = HttpResultSerializationOptions.ProtocolVersion.V1;
diff --git a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/CustomizeResponseExamples_NotFoundResponseWithHeaderV1_Generated.g.cs b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/CustomizeResponseExamples_NotFoundResponseWithHeaderV1_Generated.g.cs
index dc9f19a6c..c627b3761 100644
--- a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/CustomizeResponseExamples_NotFoundResponseWithHeaderV1_Generated.g.cs
+++ b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/CustomizeResponseExamples_NotFoundResponseWithHeaderV1_Generated.g.cs
@@ -6,6 +6,7 @@
using System.IO;
using Amazon.Lambda.Core;
using Amazon.Lambda.Annotations.APIGateway;
+using System.Text.Json;
namespace TestServerlessApp
{
@@ -51,12 +52,12 @@ public System.IO.Stream NotFoundResponseWithHeaderV1(Amazon.Lambda.APIGatewayEve
},
StatusCode = 400
};
- var errorStream = new System.IO.MemoryStream();
- serializer.Serialize(errorResult, errorStream);
+
+ var errorStream = new MemoryStream();
+ JsonSerializer.Serialize(errorStream, errorResult, typeof(Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse));
errorStream.Position = 0;
return errorStream;
}
-
var httpResults = customizeResponseExamples.NotFoundResponseWithHeaderV1(x, __context__);
HttpResultSerializationOptions.ProtocolFormat serializationFormat = HttpResultSerializationOptions.ProtocolFormat.HttpApi;
HttpResultSerializationOptions.ProtocolVersion serializationVersion = HttpResultSerializationOptions.ProtocolVersion.V1;
diff --git a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/CustomizeResponseExamples_NotFoundResponseWithHeaderV2Async_Generated.g.cs b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/CustomizeResponseExamples_NotFoundResponseWithHeaderV2Async_Generated.g.cs
index 50cb6c472..d997962e9 100644
--- a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/CustomizeResponseExamples_NotFoundResponseWithHeaderV2Async_Generated.g.cs
+++ b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/CustomizeResponseExamples_NotFoundResponseWithHeaderV2Async_Generated.g.cs
@@ -6,6 +6,7 @@
using System.IO;
using Amazon.Lambda.Core;
using Amazon.Lambda.Annotations.APIGateway;
+using System.Text.Json;
namespace TestServerlessApp
{
@@ -51,12 +52,12 @@ public CustomizeResponseExamples_NotFoundResponseWithHeaderV2Async_Generated()
},
StatusCode = 400
};
- var errorStream = new System.IO.MemoryStream();
- serializer.Serialize(errorResult, errorStream);
+
+ var errorStream = new MemoryStream();
+ JsonSerializer.Serialize(errorStream, errorResult, typeof(Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyResponse));
errorStream.Position = 0;
return errorStream;
}
-
var httpResults = await customizeResponseExamples.NotFoundResponseWithHeaderV2Async(x, __context__);
HttpResultSerializationOptions.ProtocolFormat serializationFormat = HttpResultSerializationOptions.ProtocolFormat.HttpApi;
HttpResultSerializationOptions.ProtocolVersion serializationVersion = HttpResultSerializationOptions.ProtocolVersion.V2;
diff --git a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/CustomizeResponseExamples_NotFoundResponseWithHeaderV2_Generated.g.cs b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/CustomizeResponseExamples_NotFoundResponseWithHeaderV2_Generated.g.cs
index d809f6c9b..a7519c97e 100644
--- a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/CustomizeResponseExamples_NotFoundResponseWithHeaderV2_Generated.g.cs
+++ b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/CustomizeResponseExamples_NotFoundResponseWithHeaderV2_Generated.g.cs
@@ -6,6 +6,7 @@
using System.IO;
using Amazon.Lambda.Core;
using Amazon.Lambda.Annotations.APIGateway;
+using System.Text.Json;
namespace TestServerlessApp
{
@@ -51,12 +52,12 @@ public System.IO.Stream NotFoundResponseWithHeaderV2(Amazon.Lambda.APIGatewayEve
},
StatusCode = 400
};
- var errorStream = new System.IO.MemoryStream();
- serializer.Serialize(errorResult, errorStream);
+
+ var errorStream = new MemoryStream();
+ JsonSerializer.Serialize(errorStream, errorResult, typeof(Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyResponse));
errorStream.Position = 0;
return errorStream;
}
-
var httpResults = customizeResponseExamples.NotFoundResponseWithHeaderV2(x, __context__);
HttpResultSerializationOptions.ProtocolFormat serializationFormat = HttpResultSerializationOptions.ProtocolFormat.HttpApi;
HttpResultSerializationOptions.ProtocolVersion serializationVersion = HttpResultSerializationOptions.ProtocolVersion.V2;
diff --git a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/CustomizeResponseExamples_OkResponseWithHeaderAsync_Generated.g.cs b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/CustomizeResponseExamples_OkResponseWithHeaderAsync_Generated.g.cs
index 6f56db9fa..45524e0c4 100644
--- a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/CustomizeResponseExamples_OkResponseWithHeaderAsync_Generated.g.cs
+++ b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/CustomizeResponseExamples_OkResponseWithHeaderAsync_Generated.g.cs
@@ -6,6 +6,7 @@
using System.IO;
using Amazon.Lambda.Core;
using Amazon.Lambda.Annotations.APIGateway;
+using System.Text.Json;
namespace TestServerlessApp
{
@@ -51,12 +52,12 @@ public CustomizeResponseExamples_OkResponseWithHeaderAsync_Generated()
},
StatusCode = 400
};
- var errorStream = new System.IO.MemoryStream();
- serializer.Serialize(errorResult, errorStream);
+
+ var errorStream = new MemoryStream();
+ JsonSerializer.Serialize(errorStream, errorResult, typeof(Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse));
errorStream.Position = 0;
return errorStream;
}
-
var httpResults = await customizeResponseExamples.OkResponseWithHeaderAsync(x, __context__);
HttpResultSerializationOptions.ProtocolFormat serializationFormat = HttpResultSerializationOptions.ProtocolFormat.RestApi;
HttpResultSerializationOptions.ProtocolVersion serializationVersion = HttpResultSerializationOptions.ProtocolVersion.V1;
diff --git a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/CustomizeResponseExamples_OkResponseWithHeader_Generated.g.cs b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/CustomizeResponseExamples_OkResponseWithHeader_Generated.g.cs
index d56149923..fed7f09cd 100644
--- a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/CustomizeResponseExamples_OkResponseWithHeader_Generated.g.cs
+++ b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/CustomizeResponseExamples_OkResponseWithHeader_Generated.g.cs
@@ -6,6 +6,7 @@
using System.IO;
using Amazon.Lambda.Core;
using Amazon.Lambda.Annotations.APIGateway;
+using System.Text.Json;
namespace TestServerlessApp
{
@@ -51,12 +52,12 @@ public System.IO.Stream OkResponseWithHeader(Amazon.Lambda.APIGatewayEvents.APIG
},
StatusCode = 400
};
- var errorStream = new System.IO.MemoryStream();
- serializer.Serialize(errorResult, errorStream);
+
+ var errorStream = new MemoryStream();
+ JsonSerializer.Serialize(errorStream, errorResult, typeof(Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse));
errorStream.Position = 0;
return errorStream;
}
-
var httpResults = customizeResponseExamples.OkResponseWithHeader(x, __context__);
HttpResultSerializationOptions.ProtocolFormat serializationFormat = HttpResultSerializationOptions.ProtocolFormat.RestApi;
HttpResultSerializationOptions.ProtocolVersion serializationVersion = HttpResultSerializationOptions.ProtocolVersion.V1;
diff --git a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/GreeterExecutable_SayHelloAsync_Generated.g.cs b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/GreeterExecutable_SayHelloAsync_Generated.g.cs
index 29f4c59cf..b1234e974 100644
--- a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/GreeterExecutable_SayHelloAsync_Generated.g.cs
+++ b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/GreeterExecutable_SayHelloAsync_Generated.g.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
@@ -6,6 +6,7 @@
using System.IO;
using Microsoft.Extensions.DependencyInjection;
using Amazon.Lambda.Core;
+using System.Text.Json;
namespace TestServerlessApp
{
@@ -28,7 +29,7 @@ public Greeter_SayHelloAsync_Generated()
serviceProvider = services.BuildServiceProvider();
}
- public async System.Threading.Tasks.Task SayHelloAsync(Amazon.Lambda.APIGatewayEvents.APIGatewayProxyRequest __request__, Amazon.Lambda.Core.ILambdaContext __context__)
+ public async System.Threading.Tasks.Task SayHelloAsync(Amazon.Lambda.APIGatewayEvents.APIGatewayProxyRequest __request__, Amazon.Lambda.Core.ILambdaContext __context__)
{
// Create a scope for every request,
// this allows creating scoped dependencies without creating a scope manually.
@@ -70,15 +71,22 @@ public Greeter_SayHelloAsync_Generated()
},
StatusCode = 400
};
- return errorResult;
- }
+ var errorStream = new MemoryStream();
+ JsonSerializer.Serialize(errorStream, errorResult, typeof(Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse));
+ errorStream.Position = 0;
+ return errorStream;
+ }
await greeter.SayHelloAsync(firstNames);
-
- return new Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse
+ var response = new Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse
{
StatusCode = 200
};
+
+ var responseStream = new MemoryStream();
+ JsonSerializer.Serialize(responseStream, response, typeof(Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse));
+ responseStream.Position = 0;
+ return responseStream;
}
private static void SetExecutionEnvironment()
diff --git a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/GreeterExecutable_SayHello_Generated.g.cs b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/GreeterExecutable_SayHello_Generated.g.cs
index 6583888c0..521f3ea0b 100644
--- a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/GreeterExecutable_SayHello_Generated.g.cs
+++ b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/GreeterExecutable_SayHello_Generated.g.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
@@ -6,6 +6,7 @@
using System.IO;
using Microsoft.Extensions.DependencyInjection;
using Amazon.Lambda.Core;
+using System.Text.Json;
namespace TestServerlessApp
{
@@ -28,7 +29,7 @@ public Greeter_SayHello_Generated()
serviceProvider = services.BuildServiceProvider();
}
- public Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse SayHello(Amazon.Lambda.APIGatewayEvents.APIGatewayProxyRequest __request__, Amazon.Lambda.Core.ILambdaContext __context__)
+ public System.IO.Stream SayHello(Amazon.Lambda.APIGatewayEvents.APIGatewayProxyRequest __request__, Amazon.Lambda.Core.ILambdaContext __context__)
{
// Create a scope for every request,
// this allows creating scoped dependencies without creating a scope manually.
@@ -70,15 +71,22 @@ public Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse SayHello(Amazon.La
},
StatusCode = 400
};
- return errorResult;
- }
+ var errorStream = new MemoryStream();
+ JsonSerializer.Serialize(errorStream, errorResult, typeof(Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse));
+ errorStream.Position = 0;
+ return errorStream;
+ }
greeter.SayHello(firstNames, __request__, __context__);
-
- return new Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse
+ var response = new Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse
{
StatusCode = 200
};
+
+ var responseStream = new MemoryStream();
+ JsonSerializer.Serialize(responseStream, response, typeof(Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse));
+ responseStream.Position = 0;
+ return responseStream;
}
private static void SetExecutionEnvironment()
diff --git a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/Greeter_SayHelloAsync_Generated.g.cs b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/Greeter_SayHelloAsync_Generated.g.cs
index bf255b7df..4330e679c 100644
--- a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/Greeter_SayHelloAsync_Generated.g.cs
+++ b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/Greeter_SayHelloAsync_Generated.g.cs
@@ -1,10 +1,11 @@
-using System;
+using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using Amazon.Lambda.Core;
+using System.Text.Json;
namespace TestServerlessApp
{
@@ -20,7 +21,7 @@ public Greeter_SayHelloAsync_Generated()
serializer = new Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer();
}
- public async System.Threading.Tasks.Task SayHelloAsync(Amazon.Lambda.APIGatewayEvents.APIGatewayProxyRequest __request__, Amazon.Lambda.Core.ILambdaContext __context__)
+ public async System.Threading.Tasks.Task SayHelloAsync(Amazon.Lambda.APIGatewayEvents.APIGatewayProxyRequest __request__, Amazon.Lambda.Core.ILambdaContext __context__)
{
var validationErrors = new List();
@@ -56,15 +57,22 @@ public Greeter_SayHelloAsync_Generated()
},
StatusCode = 400
};
- return errorResult;
- }
+ var errorStream = new MemoryStream();
+ JsonSerializer.Serialize(errorStream, errorResult, typeof(Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse));
+ errorStream.Position = 0;
+ return errorStream;
+ }
await greeter.SayHelloAsync(firstNames);
-
- return new Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse
+ var response = new Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse
{
StatusCode = 200
};
+
+ var responseStream = new MemoryStream();
+ JsonSerializer.Serialize(responseStream, response, typeof(Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse));
+ responseStream.Position = 0;
+ return responseStream;
}
private static void SetExecutionEnvironment()
diff --git a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/Greeter_SayHello_Generated.g.cs b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/Greeter_SayHello_Generated.g.cs
index 186f814f9..66451d6f1 100644
--- a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/Greeter_SayHello_Generated.g.cs
+++ b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/Greeter_SayHello_Generated.g.cs
@@ -1,10 +1,11 @@
-using System;
+using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using Amazon.Lambda.Core;
+using System.Text.Json;
namespace TestServerlessApp
{
@@ -20,7 +21,7 @@ public Greeter_SayHello_Generated()
serializer = new Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer();
}
- public Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse SayHello(Amazon.Lambda.APIGatewayEvents.APIGatewayProxyRequest __request__, Amazon.Lambda.Core.ILambdaContext __context__)
+ public System.IO.Stream SayHello(Amazon.Lambda.APIGatewayEvents.APIGatewayProxyRequest __request__, Amazon.Lambda.Core.ILambdaContext __context__)
{
var validationErrors = new List();
@@ -56,15 +57,22 @@ public Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse SayHello(Amazon.La
},
StatusCode = 400
};
- return errorResult;
- }
+ var errorStream = new MemoryStream();
+ JsonSerializer.Serialize(errorStream, errorResult, typeof(Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse));
+ errorStream.Position = 0;
+ return errorStream;
+ }
greeter.SayHello(firstNames, __request__, __context__);
-
- return new Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse
+ var response = new Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse
{
StatusCode = 200
};
+
+ var responseStream = new MemoryStream();
+ JsonSerializer.Serialize(responseStream, response, typeof(Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse));
+ responseStream.Position = 0;
+ return responseStream;
}
private static void SetExecutionEnvironment()
diff --git a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/IntrinsicExample_HasIntrinsic_Generated.g.cs b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/IntrinsicExample_HasIntrinsic_Generated.g.cs
index a1c627ca1..442a1b06e 100644
--- a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/IntrinsicExample_HasIntrinsic_Generated.g.cs
+++ b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/IntrinsicExample_HasIntrinsic_Generated.g.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
diff --git a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/NullableReferenceTypeExample_NullableHeaderHttpApi_Generated.g.cs b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/NullableReferenceTypeExample_NullableHeaderHttpApi_Generated.g.cs
index 60da26f9d..20db41073 100644
--- a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/NullableReferenceTypeExample_NullableHeaderHttpApi_Generated.g.cs
+++ b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/NullableReferenceTypeExample_NullableHeaderHttpApi_Generated.g.cs
@@ -5,6 +5,7 @@
using System.Threading.Tasks;
using System.IO;
using Amazon.Lambda.Core;
+using System.Text.Json;
namespace TestServerlessApp
{
@@ -20,7 +21,7 @@ public NullableReferenceTypeExample_NullableHeaderHttpApi_Generated()
serializer = new Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer();
}
- public Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyResponse NullableHeaderHttpApi(Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyRequest __request__, Amazon.Lambda.Core.ILambdaContext __context__)
+ public System.IO.Stream NullableHeaderHttpApi(Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyRequest __request__, Amazon.Lambda.Core.ILambdaContext __context__)
{
var validationErrors = new List();
@@ -50,15 +51,22 @@ public Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyResponse NullableH
},
StatusCode = 400
};
- return errorResult;
- }
+ var errorStream = new MemoryStream();
+ JsonSerializer.Serialize(errorStream, errorResult, typeof(Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyResponse));
+ errorStream.Position = 0;
+ return errorStream;
+ }
nullableReferenceTypeExample.NullableHeaderHttpApi(text, __context__);
-
- return new Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyResponse
+ var response = new Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyResponse
{
StatusCode = 200
};
+
+ var responseStream = new MemoryStream();
+ JsonSerializer.Serialize(responseStream, response, typeof(Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyResponse));
+ responseStream.Position = 0;
+ return responseStream;
}
private static void SetExecutionEnvironment()
diff --git a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/ProgramMultiHandler.g.cs b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/ProgramMultiHandler.g.cs
index d3b7728d5..faf7c4f23 100644
--- a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/ProgramMultiHandler.g.cs
+++ b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/ProgramMultiHandler.g.cs
@@ -16,11 +16,11 @@ public static async Task Main(string[] args)
switch (Environment.GetEnvironmentVariable("ANNOTATIONS_HANDLER"))
{
case "SayHello":
- Func sayhello_handler = new TestServerlessApp.Greeter_SayHello_Generated().SayHello;
+ Func sayhello_handler = new TestServerlessApp.Greeter_SayHello_Generated().SayHello;
await Amazon.Lambda.RuntimeSupport.LambdaBootstrapBuilder.Create(sayhello_handler, new Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer()).Build().RunAsync();
break;
case "SayHelloAsync":
- Func> sayhelloasync_handler = new TestServerlessApp.Greeter_SayHelloAsync_Generated().SayHelloAsync;
+ Func> sayhelloasync_handler = new TestServerlessApp.Greeter_SayHelloAsync_Generated().SayHelloAsync;
await Amazon.Lambda.RuntimeSupport.LambdaBootstrapBuilder.Create(sayhelloasync_handler, new Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer()).Build().RunAsync();
break;
diff --git a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Add_Generated.g.cs b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Add_Generated.g.cs
index 4429228c8..280456f17 100644
--- a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Add_Generated.g.cs
+++ b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Add_Generated.g.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
@@ -6,6 +6,7 @@
using System.IO;
using Microsoft.Extensions.DependencyInjection;
using Amazon.Lambda.Core;
+using System.Text.Json;
namespace TestServerlessApp
{
@@ -28,7 +29,7 @@ public SimpleCalculator_Add_Generated()
serviceProvider = services.BuildServiceProvider();
}
- public Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse Add(Amazon.Lambda.APIGatewayEvents.APIGatewayProxyRequest __request__, Amazon.Lambda.Core.ILambdaContext __context__)
+ public System.IO.Stream Add(Amazon.Lambda.APIGatewayEvents.APIGatewayProxyRequest __request__, Amazon.Lambda.Core.ILambdaContext __context__)
{
// Create a scope for every request,
// this allows creating scoped dependencies without creating a scope manually.
@@ -77,22 +78,28 @@ public Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse Add(Amazon.Lambda.
},
StatusCode = 400
};
- return errorResult;
- }
-
- var response = simpleCalculator.Add(x, y);
-
- var body = response.ToString();
- return new Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse
+ var errorStream = new MemoryStream();
+ JsonSerializer.Serialize(errorStream, errorResult, typeof(Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse));
+ errorStream.Position = 0;
+ return errorStream;
+ }
+ var result = simpleCalculator.Add(x, y);
+ var body = result.ToString();
+ var response = new Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse
{
Body = body,
+ StatusCode = 200,
Headers = new Dictionary
{
{"Content-Type", "application/json"}
- },
- StatusCode = 200
+ }
};
+
+ var responseStream = new MemoryStream();
+ JsonSerializer.Serialize(responseStream, response, typeof(Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse));
+ responseStream.Position = 0;
+ return responseStream;
}
private static void SetExecutionEnvironment()
diff --git a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_DivideAsync_Generated.g.cs b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_DivideAsync_Generated.g.cs
index c89c25ba1..1c7d477a2 100644
--- a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_DivideAsync_Generated.g.cs
+++ b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_DivideAsync_Generated.g.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
@@ -6,6 +6,7 @@
using System.IO;
using Microsoft.Extensions.DependencyInjection;
using Amazon.Lambda.Core;
+using System.Text.Json;
namespace TestServerlessApp
{
@@ -28,7 +29,7 @@ public SimpleCalculator_DivideAsync_Generated()
serviceProvider = services.BuildServiceProvider();
}
- public async System.Threading.Tasks.Task DivideAsync(Amazon.Lambda.APIGatewayEvents.APIGatewayProxyRequest __request__, Amazon.Lambda.Core.ILambdaContext __context__)
+ public async System.Threading.Tasks.Task DivideAsync(Amazon.Lambda.APIGatewayEvents.APIGatewayProxyRequest __request__, Amazon.Lambda.Core.ILambdaContext __context__)
{
// Create a scope for every request,
// this allows creating scoped dependencies without creating a scope manually.
@@ -77,27 +78,34 @@ public SimpleCalculator_DivideAsync_Generated()
},
StatusCode = 400
};
- return errorResult;
- }
- var response = await simpleCalculator.DivideAsync(first, second);
+ var errorStream = new MemoryStream();
+ JsonSerializer.Serialize(errorStream, errorResult, typeof(Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse));
+ errorStream.Position = 0;
+ return errorStream;
+ }
+ var result = await simpleCalculator.DivideAsync(first, second);
var memoryStream = new MemoryStream();
- serializer.Serialize(response, memoryStream);
+ serializer.Serialize(result, memoryStream);
memoryStream.Position = 0;
// convert stream to string
- StreamReader reader = new StreamReader( memoryStream );
+ StreamReader reader = new StreamReader(memoryStream);
var body = reader.ReadToEnd();
-
- return new Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse
+ var response = new Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse
{
Body = body,
+ StatusCode = 200,
Headers = new Dictionary
{
{"Content-Type", "application/json"}
- },
- StatusCode = 200
+ }
};
+
+ var responseStream = new MemoryStream();
+ JsonSerializer.Serialize(responseStream, response, typeof(Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse));
+ responseStream.Position = 0;
+ return responseStream;
}
private static void SetExecutionEnvironment()
diff --git a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Multiply_Generated.g.cs b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Multiply_Generated.g.cs
index ba715c9e9..cae9f4764 100644
--- a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Multiply_Generated.g.cs
+++ b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Multiply_Generated.g.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
@@ -6,6 +6,7 @@
using System.IO;
using Microsoft.Extensions.DependencyInjection;
using Amazon.Lambda.Core;
+using System.Text.Json;
namespace TestServerlessApp
{
@@ -28,7 +29,7 @@ public SimpleCalculator_Multiply_Generated()
serviceProvider = services.BuildServiceProvider();
}
- public Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse Multiply(Amazon.Lambda.APIGatewayEvents.APIGatewayProxyRequest __request__, Amazon.Lambda.Core.ILambdaContext __context__)
+ public System.IO.Stream Multiply(Amazon.Lambda.APIGatewayEvents.APIGatewayProxyRequest __request__, Amazon.Lambda.Core.ILambdaContext __context__)
{
// Create a scope for every request,
// this allows creating scoped dependencies without creating a scope manually.
@@ -77,20 +78,27 @@ public Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse Multiply(Amazon.La
},
StatusCode = 400
};
- return errorResult;
- }
-
- var response = simpleCalculator.Multiply(x, y);
- return new Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse
+ var errorStream = new MemoryStream();
+ JsonSerializer.Serialize(errorStream, errorResult, typeof(Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse));
+ errorStream.Position = 0;
+ return errorStream;
+ }
+ var result = simpleCalculator.Multiply(x, y);
+ var response = new Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse
{
- Body = response,
+ Body = result,
+ StatusCode = 200,
Headers = new Dictionary
{
{"Content-Type", "text/plain"}
- },
- StatusCode = 200
+ }
};
+
+ var responseStream = new MemoryStream();
+ JsonSerializer.Serialize(responseStream, response, typeof(Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse));
+ responseStream.Position = 0;
+ return responseStream;
}
private static void SetExecutionEnvironment()
diff --git a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Pi_Generated.g.cs b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Pi_Generated.g.cs
index 3439eab52..7240d6f1d 100644
--- a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Pi_Generated.g.cs
+++ b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Pi_Generated.g.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
diff --git a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Random_Generated.g.cs b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Random_Generated.g.cs
index f6a99480b..f5ea5fb7b 100644
--- a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Random_Generated.g.cs
+++ b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Random_Generated.g.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
diff --git a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Randoms_Generated.g.cs b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Randoms_Generated.g.cs
index 6af86d1be..551970e39 100644
--- a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Randoms_Generated.g.cs
+++ b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Randoms_Generated.g.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
diff --git a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Subtract_Generated.g.cs b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Subtract_Generated.g.cs
index 8edda1d35..b936467b9 100644
--- a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Subtract_Generated.g.cs
+++ b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SimpleCalculator_Subtract_Generated.g.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
@@ -6,6 +6,7 @@
using System.IO;
using Microsoft.Extensions.DependencyInjection;
using Amazon.Lambda.Core;
+using System.Text.Json;
namespace TestServerlessApp
{
@@ -28,7 +29,7 @@ public SimpleCalculator_Subtract_Generated()
serviceProvider = services.BuildServiceProvider();
}
- public Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse Subtract(Amazon.Lambda.APIGatewayEvents.APIGatewayProxyRequest __request__, Amazon.Lambda.Core.ILambdaContext __context__)
+ public System.IO.Stream Subtract(Amazon.Lambda.APIGatewayEvents.APIGatewayProxyRequest __request__, Amazon.Lambda.Core.ILambdaContext __context__)
{
// Create a scope for every request,
// this allows creating scoped dependencies without creating a scope manually.
@@ -78,11 +79,17 @@ public Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse Subtract(Amazon.La
},
StatusCode = 400
};
- return errorResult;
- }
+ var errorStream = new MemoryStream();
+ JsonSerializer.Serialize(errorStream, errorResult, typeof(Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse));
+ errorStream.Position = 0;
+ return errorStream;
+ }
var response = simpleCalculator.Subtract(x, y, simpleCalculatorService);
- return response;
+ var responseStream = new MemoryStream();
+ JsonSerializer.Serialize(responseStream, response, typeof(Amazon.Lambda.APIGatewayEvents.APIGatewayProxyResponse));
+ responseStream.Position = 0;
+ return responseStream;
}
private static void SetExecutionEnvironment()
diff --git a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SourceGenerationSerializationExample_GetPerson_Generated.g.cs b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SourceGenerationSerializationExample_GetPerson_Generated.g.cs
index f23c50208..667ae0707 100644
--- a/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SourceGenerationSerializationExample_GetPerson_Generated.g.cs
+++ b/Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Snapshots/SourceGenerationSerializationExample_GetPerson_Generated.g.cs
@@ -6,6 +6,7 @@
using System.IO;
using Amazon.Lambda.Core;
using Amazon.Lambda.Annotations.APIGateway;
+using System.Text.Json;
namespace TestExecutableServerlessApp
{