aws-samples / serverless-dotnet-demo

MIT No Attribution
142 stars 37 forks source link

NET6TopLevelStatements: Wrong JSON serializer declaration? #3

Closed bjorg closed 2 years ago

bjorg commented 2 years ago

In the NET6TopLevelStatements sample, the function for PutProduct there seems to confusion on selecting the correct JSON serializer.

On line 15, the assembly attribute declares SourceGeneratorLambdaJsonSerializer<ApiGatewayProxyJsonSerializerContext> as the JSON serializer.

[assembly: LambdaSerializer(typeof(SourceGeneratorLambdaJsonSerializer<ApiGatewayProxyJsonSerializerContext>))]

But then on line 66-68, the sample passes in an instance of DefaultLambdaJsonSerializer to initialize the Lambda runtime.

await LambdaBootstrapBuilder.Create(handler, new DefaultLambdaJsonSerializer())
    .Build()
    .RunAsync();

Shouldn't this instead be:

await LambdaBootstrapBuilder.Create(handler, new SourceGeneratorLambdaJsonSerializer<ApiGatewayProxyJsonSerializerContext>())
    .Build()
    .RunAsync();

Since the JSON serializer is explicitly provided to the Lambda runtime, is line 15 really needed?

jeastham1993 commented 2 years ago

Hey @bjorg, apologies for missing this! I didn't get a notification from GitHub. You make a really valid point, updating it now.

jeastham1993 commented 2 years ago

Updated