aws-lambda-dotnet icon indicating copy to clipboard operation
aws-lambda-dotnet copied to clipboard

Use SourceGeneratorLambdaJsonSerializer for AspNetCoreServer functions

Open Dreamescaper opened this issue 1 year ago • 1 comments

Describe the feature

Currently reflection-based DefaultLambdaJsonSerializer is used for AspNetCore functions. But since we know for sure which types (HttpApi/RestApi/LoadBalancer) are going to be used there, probably it makes sense to use source-generated SourceGeneratorLambdaJsonSerializer.

Use Case

Improved performance (especially cold-start) and better AOT compatibility.

Acknowledgements

  • [X] I may be able to implement this feature request
  • [ ] This feature might incur a breaking change

Dreamescaper avatar Apr 09 '24 12:04 Dreamescaper

Needs review with the team.

ashishdhingra avatar Apr 09 '24 16:04 ashishdhingra

This can be done using the AddAWSLambdaHosting override that takes in a SourceGeneratorLambdaJsonSerializer<T>. There are no plans to put a SourceGeneratorLambdaJsonSerializer<T> in the package automatically because we would have to do that for all supported Lambda event types and that would bloat the package. As I recall when I look into this in the past I would even have to make each request/response event pairing be separate SourceGeneratorLambdaJsonSerializer<T> because the types cause interference if I add them all to the same type of SourceGeneratorLambdaJsonSerializer<T>

normj avatar Mar 02 '25 23:03 normj

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

github-actions[bot] avatar Mar 02 '25 23:03 github-actions[bot]