Skip to content

refactor(aws-lambda): enhance DefaultLambdaHostJsonSerializer and replace ILambdaSerializer dependency#129

Merged
j-d-ha merged 9 commits into
feature/add-APIGatewayEvents-payloadfrom
feature/update-lambda-serializer
Nov 12, 2025
Merged

refactor(aws-lambda): enhance DefaultLambdaHostJsonSerializer and replace ILambdaSerializer dependency#129
j-d-ha merged 9 commits into
feature/add-APIGatewayEvents-payloadfrom
feature/update-lambda-serializer

Conversation

@j-d-ha

@j-d-ha j-d-ha commented Nov 12, 2025

Copy link
Copy Markdown
Collaborator

🚀 Pull Request

📋 Summary

This PR refactors the serializer implementation across the Lambda host to improve configuration flexibility and maintainability. The key changes include:

  • Replaces direct ILambdaSerializer dependency in LambdaHandlerComposer with a constructor parameter instead of configuration-based lookup
  • Introduces DefaultLambdaHostJsonSerializer class that uses configurable JsonSerializerOptions and JsonWriterOptions for enhanced customization
  • Replaces LambdaHostOptions.LambdaSerializer property with JsonSerializerOptions and JsonWriterOptions properties
  • Updates example applications to use the new configuration approach
  • Simplifies serializer registration and ensures proper AwsNamingPolicy wrapping of naming policies
  • Adds comprehensive XML documentation for the new serializer implementation
  • Updates README documentation to reflect the new serializer configuration approach

✅ Checklist

  • My changes build cleanly
  • I've added/updated relevant tests
  • I've added/updated documentation or README
  • I've followed the coding style for this project
  • I've tested the changes locally (if applicable)

📚 Documentation Updates

The following documentation files have been updated to align with the serializer refactoring:

AwsLambda.Host README

  • AOT Support Section: Updated example to use options.JsonSerializerOptions.TypeInfoResolverChain.Add() instead of the deprecated SourceGeneratorLambdaJsonSerializer pattern
  • Configuration Section: Added comprehensive examples showing JSON serialization customization through JsonSerializerOptions and JsonWriterOptions
  • Added clarity that DefaultLambdaHostJsonSerializer is automatically registered by the framework

🧪 Related Issues or PRs

Relates to serializer refactoring and configuration improvements.

💬 Notes for Reviewers

  • The LambdaHandlerComposer constructor signature has changed to use ILambdaSerializer directly instead of IOptions<LambdaHostOptions>
  • The JsonSerializerOptions property is automatically wrapped with AwsNamingPolicy if needed to maintain AWS compatibility
  • All example configurations have been updated to reflect the new approach
  • Tests have been updated to pass the serializer directly to the composer
  • Documentation has been comprehensively updated with correct AOT and configuration examples

…ions

- Replaced `ILambdaSerializer` with `JsonSerializerOptions` for Lambda JSON serialization
- Added configurable default `JsonSerializerOptions` with AWS-specific conventions
- Introduced `JsonWriterOptions` for improved control over JSON escaping
- Registered custom converters to support AWS conventions (e.g., `DateTimeConverter`, etc.)
- Provided flexibility to customize serialization behavior through new properties
- Introduced `DefaultLambdaHostJsonSerializer` implementing `ILambdaSerializer` interface
- Added support for configurable `JsonSerializerOptions` and `JsonWriterOptions`
- Enhanced serialization error handling with custom exception messages
- Updated `LambdaApplicationBuilder` to ensure property naming policy aligns with AWS naming rules
- Registered `DefaultLambdaHostJsonSerializer` as the default `ILambdaSerializer` if not already set
… LambdaHandlerComposer

- Removed `LambdaHostOptions` dependency in `LambdaHandlerComposer` constructor
- Introduced `ILambdaSerializer` dependency for handling request and response serialization
- Updated `_settings.LambdaSerializer` usage to `_lambdaSerializer` for serialization logic
- Enhanced null checks to include `lambdaSerializer` in constructor
- Improved code readability and alignment with AWS Lambda serialization standards
…zer tests in LambdaHandlerComposerTest

- Eliminated outdated `LambdaHostOptions` references in `LambdaHandlerComposer` unit tests.
- Added initialization and validation tests for the new `ILambdaSerializer` dependency.
- Updated test cases to reflect changes in constructor parameters.
- Improved test readability and ensured full coverage for `ILambdaSerializer` null checks.
…related classes

- Renamed `LambdaJsonSerializerOptions` to `JsonSerializerOptions` in `LambdaHostOptions`
- Renamed `LambdaJsonWriterOptions` to `JsonWriterOptions` for consistency
- Updated references in `DefaultLambdaHostJsonSerializer` and `LambdaApplicationBuilder`
- Improved documentation to use fully-qualified names for clarity
…uplicate handlers

- Replaced outdated `LambdaSerializer` assignment with `TypeInfoResolverChain` customization
- Commented out duplicate SQS event handlers to address compilation issues
- Improved examples to align with updated JSON serialization approach in `LambdaHostOptions`
…ed documentation

- Added XML documentation for `DefaultLambdaHostJsonSerializer` class and its methods.
- Included <summary> and <remarks> to explain configurable serialization options.
- Detailed parameters, return types, and exceptions for constructors and methods.
- Improved clarity on customization using `LambdaHostOptions`.
@github-actions github-actions Bot added the type: refactor Code refactoring label Nov 12, 2025
- Replaced outdated `LambdaSerializer` registration with `JsonSerializerOptions` configuration
- Documented new serialization customization using `TypeInfoResolverChain` and options
- Added details on `DefaultLambdaHostJsonSerializer` automatic registration and usage
- Included AOT-related project settings like `JsonSerializerIsReflectionEnabledByDefault`
- Refined available options section to highlight JSON serialization improvements
…orldAot example

- Set `JsonSerializerIsReflectionEnabledByDefault` to `false` in the project configuration.
- Enhanced trimming settings by explicitly disabling reflection-based JSON serialization.
- Improved AOT compliance by aligning with recommended .NET serialization practices.
@j-d-ha
j-d-ha merged commit 5816dff into feature/add-APIGatewayEvents-payload Nov 12, 2025
3 checks passed
@j-d-ha
j-d-ha deleted the feature/update-lambda-serializer branch November 12, 2025 16:49
j-d-ha added a commit that referenced this pull request Nov 15, 2025
#131)

* feat(aws-lambda): add abstractions for Lambda request and response serialization

- Introduced `ILambdaRequest` to define a deserialization contract for Lambda requests
- Introduced `ILambdaResponse` to define a serialization contract for Lambda responses

* feat(aws-lambda): add support for API Gateway Events

- Added `AwsLambda.Host.APIGatewayEvents` project to the solution
- Configured project to support multiple frameworks including `net8.0`, `net9.0`, and `net10.0`
- Included `Amazon.Lambda.AP

* feat(aws-lambda): implement strongly-typed API Gateway request and response support

- Added `APIGatewayProxyRequest<T>` for typed deserialization of API Gateway requests
- Added `APIGatewayProxyResponse<T>` for typed serialization of API Gateway responses
- Enhanced flexibility with `JsonSerializerOptions` for request/response body handling

* feat(aws-lambda): enhance Lambda request and response type detection

- Added `IsILambdaRequest` to `ParameterInfo` for better request type recognition
- Added `IsResponseILambdaResponse` to `DelegateInfo` for response type validation
- Introduced helper methods for detecting `ILambdaRequest` and `ILambdaResponse` interfaces

* feat(source-generators): add and test support for request and response handling

- Added reference to `AwsLambda.Host.APIGatewayEvents` project in test project
- Introduced `VerifyTests/IRequestAndIResponseVerifyTests` for validating request/response mappings
- Enhanced `GeneratorTestHelpers` to support `APIGatewayProxyResponse<>` in metadata references
- Refactored `WithFeatures` usage for improved readability and maintainability

* feat(source-generators): add support for JSON options in Lambda handlers

- Utilize `IOptions<JsonSerializerOptions>` for request/response serialization customization
- Update template to conditionally handle `ILambdaRequest` and `ILambdaResponse` types
- Enhance context-building with optional JSON options for event deserialization and serialization
- Add helper logic to determine when JSON options are required based on type detection

* feat(tests): add metadata reference for `APIGatewayProxyResponse` in unit tests

- Included `APIGatewayProxyResponse` type in metadata references within `GeneratorTestHelpers`
- Added missing `using Amazon.Lambda.APIGatewayEvents` for required type definitions

* feat(tests): add generated snapshot tests for Lambda handler request/response handling

- Introduced `IRequestAndIResponseVerifyTests` to validate Lambda handler mapping logic
- Added snapshot testing for `MapHandlerInterceptor` ensuring correct request/response serialization
- Verified usage of `ILambdaApplication`, `ILambdaHostContext`, and JSON options for customization

* feat(examples): add new example project for Lambda API Gateway events

- Introduced `AwsLambda.Host.Example.Events` project to demonstrate event handling
- Configured project for `net8.0` with support for Lambda execution and testing
- Set up `launchSettings.json` with environment variables for local debugging
- Included `appsettings.json` with logging configuration and Lambda-specific settings

* feat(aws-lambda): add support for SQS events with strongly-typed deserialization and response handling

- Added `AwsLambda.Host.SQSEvent` project to the solution targeting `net8.0`, `net9.0`, and `net10.0`
- Implemented `SQSBatchResponse` inheriting from `Amazon.Lambda.SQSEvents.SQSBatchResponse`
- Introduced `SQSEvent<T>` for strongly-typed deserialization of SQS events with custom message types
- Configured references to `Amazon.Lambda.SQSEvents` and `Amazon.Lambda.Core` packages
- Updated solution and package properties to include SQS events configuration

* chore(commitlint): update config to disable header and body line length rules

- Set `header-max-length` rule to [0] to disable validation for commit header length
- Set `body-max-line-length` rule to [0] to disable validation for commit body line length

* feat(aws-lambda): enhance APIGatewayProxyResponse with strongly-typed body support

- Added new `Body` property to `APIGatewayProxyResponse<T>` class for strongly-typed responses
- Included `<inheritdoc>` and `<summary>` for better documentation and maintainability
- Added `System.Runtime.Serialization` namespace for potential serialization extensions

* feat(examples): add example handling SQS events in Lambda project

- Updated `AwsLambda.Host.Example.Events` to include `AwsLambda.Host.SQSEvent` project reference
- Demonstrated SQS event processing with deserialization and batch response handling
- Showcased logging and failure case simulation in the new handler examples in `Program.cs`

* feat(aws-lambda): add IJsonSerializable interface for custom JSON serialization

- Introduced `IJsonSerializable` interface to support registering type-specific JSON converters
- Defined `RegisterTypeInfo` method for declaring custom `JsonConverter` implementations
- Enabled automatic discovery and invocation of `RegisterTypeInfo` in Lambda host for serialization

* feat(aws-lambda): add SqsEnvelope and custom JSON converter for SQS events

- Introduced `SqsEnvelope<T>` extending `SQSEvent` to enable strongly-typed SQS event handling
- Implemented `SqsEnvelopeJsonConverter<T>` for custom serialization and deserialization logic
- Enabled seamless integration with type-specific JSON serialization via `RegisterTypeInfo` method

* feat(aws-lambda): remove SQSBatchResponse and SQSEvent for simpler event handling

- Deleted `SQSBatchResponse` and `SQSEvent` classes to streamline the library and reduce duplication
- Rely directly on `Amazon.Lambda.SQSEvents` for SQS event and batch response handling

* feat(solution): update project structure and add new envelopes for event handling

- Renamed `AwsLambda.Host.SQSEvent` to `AwsLambda.Host.SQSEnvelopes` for clarity
- Added `AwsLambda.Host.APIGatewayEnvelopes` project to the solution
- Removed `AwsLambda.Host.APIGatewayEvents` project reference for a cleaner structure
- Updated build configurations and nested project settings accordingly

* feat(solution): restructure and rename SQS project with new envelopes structure

- Renamed `AwsLambda.Host.SQSEnvelopes` to `AwsLambda.Host.Envelopes.SQS` for consistency
- Added new solution folder `Envelopes` to organize related projects better
- Updated namespace references in SQS-related files to match the new project name
- Adjusted solution and project configurations for the changes

* feat(solution): rename and refactor APIGateway project with new envelopes design

- Deleted `AwsLambda.Host.APIGatewayEvents` project and its associated classes
- Introduced `AwsLambda.Host.Envelopes.APIGateway` project for envelope-based approach
- Added `ApiGatewayRequestEnvelope<T>` and `ApiGatewayResponseEnvelope<T>` with custom converters
- Updated solution file to reflect project restructuring under the `Envelopes` folder
- Improved consistency by renaming namespaces and classes to align with `Envelopes` conventions

* feat(aws-lambda): add `<inheritdoc>` and Body summary in SqsEnvelope

- Added `<inheritdoc>` to `SqsEnvelope` and `SqsMessageEnvelope` for consistent documentation
- Introduced `<summary>` for the `Body` property in `SqsMessageEnvelope` to improve clarity

* feat(examples): update examples to use new envelopes structure

- Replaced `APIGatewayProxyRequest` and `APIGatewayProxyResponse` with `ApiGatewayRequestEnvelope`
  and `ApiGatewayResponseEnvelope` for API Gateway events
- Updated SQS event handlers to utilize `SqsEnvelope` for event deserialization and processing
- Added support for multiple Lambda handlers with updated envelope-based approach
- Adjusted JSON serializer configuration to register custom converters for envelopes
- Updated project references to reflect renamed envelope projects

* refactor(models): add type info and extraction improvements (#128)

* feat(models): introduce TypeInfo for type metadata representation

- Added `TypeInfo` record struct to encapsulate type-related information like generic status and interfaces
- Implemented `Create` method to initialize `TypeInfo` from `ITypeSymbol` and optional `TypeSyntax`
- Added extension methods for tasks and ValueTask to unwrap types for detailed type analysis

* feat(models): add ReturnTypeInfo to DelegateInfo

- Introduced optional `ReturnTypeInfo` property to `DelegateInfo` for capturing return type metadata
- Updated default initialization of `DelegateInfo` to include the new property

* refactor(testing, templates): remove unused references and clean up dependencies

- Removed the unused `AwsLambda.Host.APIGatewayEvents` namespace in `GeneratorTestHelpers.cs`
- Commented out metadata reference for generic `APIGatewayProxyResponse<>` in favor of non-generic reference
- Removed the unused `System.Text.Json` and `Microsoft.Extensions.Options` namespaces in `MapHandler.scriban` template

* feat(models): enhance DelegateInfo with detailed return type metadata

- Updated `DelegateInfo` to require `ReturnTypeInfo` instead of making it optional
- Refactored logic in `DelegateInfoExtractorExtensions` to handle `TypeInfo` creation for return types
- Improved type analysis by leveraging `TypeInfo` for unwrapped and global type representation
- Adjusted existing methods to retrieve and utilize detailed return type metadata more effectively

* refactor(syntax-providers): replace `FullResponseType` with `ReturnTypeInfo`

- Updated all references from `FullResponseType` to `ReturnTypeInfo.FullyQualifiedType`
  for consistent return type handling.
- Enhanced `TypeInfo` with factory methods for creating common types like `Void` and `Task`.
- Refactored `DelegateInfo` to remove `FullResponseType` and use `ReturnTypeInfo` uniformly.
- Adjusted logic in `DelegateInfoExtractorExtensions` to calculate and populate `ReturnTypeInfo`
  accurately.
- Simplified and cleaned up type analysis logic in affected syntax providers and output generators.

* refactor(models, syntax-providers): replace `Type` with `TypeInfo` for parameter and return types

- Replaced `Type` with `TypeInfo` in `ParameterInfo` and `DelegateInfo` to improve type metadata.
- Updated all references and logic to utilize `TypeInfo.FullyQualifiedType` for consistency.
- Simplified type analysis and removed obsolete methods for type unwrapping.
- Refactored syntax providers and output generators to adapt to the new `TypeInfo` structure.
- Consolidated extension methods for task and ValueTask type checks.
- Removed unused properties like `IsResponseILambdaResponse` and `IsILambdaRequest`.

* refactor(syntax-providers): replace method names with constants

- Replaced hardcoded method names `"OnInit"` and `"MapHandler"` with constants from `GeneratorConstants`.
- Improved maintainability and consistency by centralizing method name definitions.

* refactor(templates): remove unused `JsonSerializerOptions` dependency from `MapHandler.scriban`

- Eliminated unused logic for resolving `JsonSerializerOptions` to simplify the template.
- Removed conditional checks for `is_json_options_needed`, `is_lambda_request`, and `is_lambda_response`.
- Cleaned up redundant code for event deserialization and response serialization to improve clarity.

* refactor(models): remove unused `AttributeInfo` and `GenericInfo` structs

- Deleted `AttributeInfo` and `GenericInfo` from the `Models` namespace as they are no longer used.
- Improved codebase maintainability by removing dead code.

* feat(aws-lambda): remove ILambdaRequest and ILambdaResponse interfaces

- Deleted `ILambdaRequest` and `ILambdaResponse` interfaces from `AwsLambda.Host.Abstractions`
- Removed related dependencies such as `Stream` and `JsonSerializerOptions`
- Simplified the codebase by eliminating unused abstractions

* refactor(aws-lambda): enhance DefaultLambdaHostJsonSerializer and replace ILambdaSerializer dependency (#129)

* feat(aws-lambda): enhance JSON serialization options in LambdaHostOptions

- Replaced `ILambdaSerializer` with `JsonSerializerOptions` for Lambda JSON serialization
- Added configurable default `JsonSerializerOptions` with AWS-specific conventions
- Introduced `JsonWriterOptions` for improved control over JSON escaping
- Registered custom converters to support AWS conventions (e.g., `DateTimeConverter`, etc.)
- Provided flexibility to customize serialization behavior through new properties

* feat(aws-lambda): add default JSON serializer for Lambda host

- Introduced `DefaultLambdaHostJsonSerializer` implementing `ILambdaSerializer` interface
- Added support for configurable `JsonSerializerOptions` and `JsonWriterOptions`
- Enhanced serialization error handling with custom exception messages
- Updated `LambdaApplicationBuilder` to ensure property naming policy aligns with AWS naming rules
- Registered `DefaultLambdaHostJsonSerializer` as the default `ILambdaSerializer` if not already set

* feat(aws-lambda): replace LambdaHostOptions with ILambdaSerializer in LambdaHandlerComposer

- Removed `LambdaHostOptions` dependency in `LambdaHandlerComposer` constructor
- Introduced `ILambdaSerializer` dependency for handling request and response serialization
- Updated `_settings.LambdaSerializer` usage to `_lambdaSerializer` for serialization logic
- Enhanced null checks to include `lambdaSerializer` in constructor
- Improved code readability and alignment with AWS Lambda serialization standards

* refactor(unit-tests): remove LambdaHostOptions and add ILambdaSerializer tests in LambdaHandlerComposerTest

- Eliminated outdated `LambdaHostOptions` references in `LambdaHandlerComposer` unit tests.
- Added initialization and validation tests for the new `ILambdaSerializer` dependency.
- Updated test cases to reflect changes in constructor parameters.
- Improved test readability and ensured full coverage for `ILambdaSerializer` null checks.

* refactor(aws-lambda): update property names in LambdaHostOptions and related classes

- Renamed `LambdaJsonSerializerOptions` to `JsonSerializerOptions` in `LambdaHostOptions`
- Renamed `LambdaJsonWriterOptions` to `JsonWriterOptions` for consistency
- Updated references in `DefaultLambdaHostJsonSerializer` and `LambdaApplicationBuilder`
- Improved documentation to use fully-qualified names for clarity

* refactor(examples): update serializer configuration and comment out duplicate handlers

- Replaced outdated `LambdaSerializer` assignment with `TypeInfoResolverChain` customization
- Commented out duplicate SQS event handlers to address compilation issues
- Improved examples to align with updated JSON serialization approach in `LambdaHostOptions`

* feat(aws-lambda): enhance DefaultLambdaHostJsonSerializer with detailed documentation

- Added XML documentation for `DefaultLambdaHostJsonSerializer` class and its methods.
- Included <summary> and <remarks> to explain configurable serialization options.
- Detailed parameters, return types, and exceptions for constructors and methods.
- Improved clarity on customization using `LambdaHostOptions`.

* feat(docs): update README with enhanced JSON serialization guidelines

- Replaced outdated `LambdaSerializer` registration with `JsonSerializerOptions` configuration
- Documented new serialization customization using `TypeInfoResolverChain` and options
- Added details on `DefaultLambdaHostJsonSerializer` automatic registration and usage
- Included AOT-related project settings like `JsonSerializerIsReflectionEnabledByDefault`
- Refined available options section to highlight JSON serialization improvements

* feat(examples): disable reflection-based JSON serialization in HelloWorldAot example

- Set `JsonSerializerIsReflectionEnabledByDefault` to `false` in the project configuration.
- Enhanced trimming settings by explicitly disabling reflection-based JSON serialization.
- Improved AOT compliance by aligning with recommended .NET serialization practices.

* feat(aws-lambda): enhance envelope design with deserialization improvements

- Added `[JsonIgnore]` to `Body` property in `ApiGatewayRequestEnvelope` and `ApiGatewayResponseEnvelope`
  to prevent serialization of deserialized payload.
- Refactored `RegisterTypeInfo` to `RegisterConverter` for better clarity on purpose.
- Modified `ApiGatewayRequestEnvelopeJsonConverter` to optimize deserialization logic with override methods.
- Updated Scriban template to inject `LambdaHostOptions` and register serializers dynamically.

* feat(aws-lambda): ensure support for JSON serialization of IJsonSerializable types

- Added logic to collect and process parameters and return types implementing `IJsonSerializable`
- Updated Scriban model to include `SerializableItems` for template generation
- Enhanced `MapHandlerSources` for improved serialization support with minimal code adjustment

* refactor(aws-lambda): rename `RegisterTypeInfo` to `RegisterConverter`

- Updated method name in `IJsonSerializable` interface to better reflect its functionality.
- Maintains consistency with recent changes in serialization logic and conventions.

* feat(aws-lambda): add `IJsonSerializable` to `GeneratorConstants`

- Introduced `IJsonSerializable` constant within `GeneratorConstants` class.
- Enhances support for consistent serialization logic throughout the codebase.

* feat(aws-lambda): introduce `EnvelopeJsonConverter` for custom serialization

- Added abstract `EnvelopeJsonConverter<TEnvelope>` for handling Lambda event envelope serialization.
- Enabled custom payload handling through `ReadPayload` and `WritePayload` abstract methods.
- Utilized dedicated `JsonSerializerOptions` to prevent naming policy conflicts.
- Provided safe removal of converters with `GetConverterInstance`.

* refactor(aws-lambda): simplify `ApiGatewayResponseJsonConverter`

- Refactored to inherit from `EnvelopeJsonConverter` for cleaner abstraction.
- Replaced `Read` and `Write` with `ReadPayload` and `WritePayload` for payload-specific logic.
- Improved documentation with `<summary>` and `<remarks>` for enhanced clarity.

* refactor(aws-lambda): enhance SQS envelope with converter improvements and deserialization updates

- Renamed `RegisterTypeInfo` to `RegisterConverter` to align with naming conventions.
- Added `[JsonIgnore]` to the `Body` property in `SqsMessageEnvelope` to optimize serialization.
- Updated `SqsEnvelopeJsonConverter` to inherit from `EnvelopeJsonConverter` for cleaner abstraction.
- Replaced `Read` and `Write` methods with `ReadPayload` and `WritePayload` for payload-specific logic.
- Enhanced documentation with `<summary>` and `<remarks>` for improved clarity.

* feat(examples): update API Gateway example with enhanced serialization and logging

- Added `ILogger` injection into the handler for improved logging support.
- Introduced `JsonSerializable` attributes for API Gateway request/response and custom types.
- Enhanced `LambdaHostOptions` configuration with `TypeInfoResolverChain` for custom serialization.
- Modified handler response to include `IsBase64Encoded` and adjusted status code to `201`.

* refactor(aws-lambda): fix generic type used in `RegisterConverter` for SQS envelope

- Updated the `RegisterConverter` method to use the correct generic type `T` in `SqsEnvelope`.
- Aligns implementation with the intended generic type handling for `SqsEnvelopeJsonConverter`.

* refactor(aws-lambda): update APIGateway envelope references and serialization logic

- Replaced `APIGatewayProxyRequest` and `APIGatewayProxyResponse` with `ApiGatewayRequestEnvelope`
  and `ApiGatewayResponseEnvelope` in tests.
- Registered converters for `ApiGatewayRequestEnvelope` and `ApiGatewayResponseEnvelope` in
  `LambdaHostOptions.JsonSerializerOptions`.
- Adjusted test project references to include the new `Envelopes.APIGateway` module.
- Removed redundant references such as `System.Text.Json` in generated files for better clarity.

* refactor(docs): improve parameter documentation in `LambdaHandlerComposer`

- Reformatted XML documentation for better readability and consistency.
- Enhanced clarity of parameter descriptions by splitting long lines.

* refactor(envelopes): restructure AWS envelope modules and improve organization

- Moved `APIGateway` and `SQS` envelopes into a new `Envelopes` folder for better modularity.
- Updated solution file to reflect new folder structure and adjusted project references accordingly.
- Applied namespace adjustments to match the new folder and organization structure.

* refactor(envelopes): standardize class and property naming for SQS envelopes

- Renamed `SqsEnvelope` to `SQSEnvelope` for consistent casing with AWS terminology.
- Updated `SqsMessageEnvelope` to `SQSMessageEnvelope` for uniformity with parent class renaming.
- Modified references in `RegisterConverter` and JSON converter methods accordingly.
- Adjusted XML documentation to match the new class and property names.

* refactor(envelopes): standardize naming for APIGateway envelopes and converters

- Renamed `ApiGatewayRequestEnvelope` to `APIGatewayRequestEnvelope` for consistent casing with AWS terminology.
- Updated `ApiGatewayResponseEnvelope` to `APIGatewayResponseEnvelope` for uniformity in class names.
- Adjusted JSON converter classes to align with the updated envelope class names.
- Updated related references and namespaces for consistency.
- Refined XML documentation to reflect the new naming conventions.

* refactor(tests): add `Microsoft.Extensions.Options` using directive in generated snapshots

- Included `using Microsoft.Extensions.Options` across all unit test snapshots for consistency.
- Ensures compatibility with DI configuration options in Lambda Host generation tests.
- Updated relevant unit test files to align with the changes in generated code structure.
- Maintained formatting and alignment with existing snapshot conventions.

refactor(envelopes): fix inconsistent namespaces for APIGateway envelopes in tests

- Adjusted namespace from `AwsLambda.Host.APIGatewayEnvelops` to `AwsLambda.Host.Envelopes.APIGateway`.
- Updated references to `APIGatewayRequestEnvelope` and `APIGatewayResponseEnvelope` in tests.
- Ensured XML documentation, serializer references, and related logic match the renamed namespace.
- Verified snapshots after the namespace change for correctness across all related scenarios.

* feat(envelopes): add new `AwsLambda.Host.Envelopes` project for modular envelope support

- Introduced `AwsLambda.Host.Envelopes` with support for multi-targeting `net8.0`, `net9.0`, and `net10.0`.
- Enabled features like nullable reference types, implicit usings, and documentation generation.
- Updated `EnvelopeJsonConverter` namespace to `AwsLambda.Host.Envelopes` for better organization.
- Added project references to the solution file with appropriate configuration for build and release.
- Ensured proper nesting and alignment in the solution structure for better modularity.

* refactor(projects): update project references and standardize envelope usage

- Removed outdated `AwsLambda.Host.APIGatewayEnvelops` and SQS project references.
- Added updated `AwsLambda.Host.Envelopes` project references across affected projects.
- Updated example usage for `APIGatewayEnvelope` and `SQSEnvelope` with correct naming conventions.
- Adjusted JSON serialization attributes to align with renamed envelope classes.
- Ensured modularity improvements through clean project structure and consistent references.

* feat(unit-tests): add unit tests for `EnvelopeJsonConverter`

- Introduced comprehensive unit tests for `EnvelopeJsonConverter` in `AwsLambda.Host.Envelopes.UnitTests`.
- Added coverage for constructor, read, write, naming policy, and round-trip serialization scenarios.
- Verified edge cases like empty JSON, consecutive writes, and special character handling.
- Ensured tests cover serialization compatibility with custom naming policies and complex objects.
- Integrated new test project into the solution file with proper configuration.
- Updated `xunit.v3` package to `3.2.0` for test compatibility and stability enhancements.

* feat(tests): add unit tests for `APIGatewayRequestEnvelopeJsonConverter`

- Added comprehensive unit tests for `APIGatewayRequestEnvelopeJsonConverter` in `AwsLambda.Host.Envelopes.UnitTests`.
- Verified serialization and deserialization with naming policies, null/empty bodies, and type errors.
- Ensured round-trip consistency and support for multiple payload types in the envelope structure.
- Integrated tests with updated project targeting `net8.0`, `net9.0`, and `net10.0`.
- Added `AutoFixture` and updated project references to include `AwsLambda.Host.Envelopes.APIGateway`.

* refactor(tests): consolidate assertions in `APIGatewayRequestEnvelopeJsonConverterTests`

- Replaced redundant assertions with `AssertEnvelopeEquivalentToRequest` for consistency.
- Added helper method to centralize envelope and request comparison logic.
- Removed duplicate assertion blocks and ensured uniform test structure.
- Enhanced maintainability by simplifying assertion logic across test cases.

* feat(abstractions): add `IModelBinder` interface for model binding operations

- Introduced `IModelBinder` interface in `AwsLambda.Host` namespace.
- Added `BindModel` and `UnbindModel` methods with `JsonSerializerOptions` parameter.
- Enables extensibility for custom model binding logic in AWS Lambda handlers.

* feat(envelopes): replace `IJsonSerializable` with `IModelBinder` in APIGateway envelopes

- Updated `APIGatewayRequestEnvelope` and `APIGatewayResponseEnvelope` to implement `IModelBinder`.
- Replaced `RegisterConverter` methods with `BindModel` and `UnbindModel` using `JsonSerializerOptions`.
- Improved extensibility and consistency for model binding in API Gateway envelope classes.

* feat(source-generators): replace `RegisterConverter` logic with `IModelBinder` operations

- Updated generated `MapHandler` template to use `BindModel` and `UnbindModel` methods with `JsonSerializerOptions`.
- Removed `RegisterConverter` loops, improving model binding extensibility.
- Improved alignment with the `IModelBinder` abstraction for consistent model handling.

* feat(tests): update snapshots to include `IModelBinder` operations in generated code

- Added `BindModel` and `UnbindModel` invocations for request and response in generated methods.
- Removed `RegisterConverter` calls, improving testing alignment with `IModelBinder` abstraction.
- Enhanced extensibility and consistency in model binding for unit test snapshots.

* refactor(abstractions): replace `IModelBinder` with `IEnvelope` for payload operations

- Removed `IModelBinder` interface and introduced `IEnvelope` in `AwsLambda.Host` namespace.
- Replaced `BindModel` and `UnbindModel` methods with `ExtractPayload` and `PackPayload` respectively.
- Updated `APIGatewayRequestEnvelope` and `APIGatewayResponseEnvelope` to implement `IEnvelope`.
- Refactored `MapHandler` template logic to use `IEnvelope` for serialization/deserialization.
- Improved clarity and alignment with core naming conventions for envelope operations.

* refactor(tests): update snapshots to replace `IModelBinder` with `IEnvelope`

- Replaced `IModelBinder` interface with `IEnvelope` in generated code for request and response.
- Updated methods to use `ExtractPayload` and `PackPayload` for payload handling.
- Ensured consistency with recent abstraction changes and improved clarity in test snapshots.

* refactor(envelopes): update `SQSEnvelope` to replace `IJsonSerializable` with `IEnvelope`

- Replaced `IJsonSerializable` with `IEnvelope` in `SQSEnvelope` to align with recent abstractions.
- Added `ExtractPayload` and `PackPayload` methods for payload serialization/deserialization.
- Removed `RegisterConverter` logic in favor of improved extensibility with `JsonSerializerOptions`.

* refactor(generator): remove `IEnvelope` payload operations from `MapHandler` template

- Removed `ExtractPayload` and `PackPayload` calls for request/response handling in `MapHandler`.
- Simplified template logic to eliminate dependency on serialization options (`JsonSerializerOptions`).
- Improved alignment with recent abstraction changes by decoupling envelope-specific operations.

* refactor(envelopes): remove custom JSON converters for API Gateway envelopes

- Deleted `APIGatewayRequestEnvelopeJsonConverter` and `APIGatewayResponseJsonConverter` for simplification.
- Updated `APIGatewayRequestEnvelope` and `APIGatewayResponseEnvelope` to use `EnvelopeOptions` for payload handling.
- Replaced direct `JsonSerializerOptions` with `EnvelopeOptions` to improve extensibility and consistency.
- Renamed `Body` to `BodyContent` to align with clarity and abstraction goals.

* refactor(tests): remove `EnvelopeJsonConverterTests` and related project

- Deleted `AwsLambda.Host.Envelopes.UnitTests` project and its test for `EnvelopeJsonConverter`.
- Removed dependency on `AwesomeAssertions`, `NSubstitute`, and other libraries in the project.
- Streamlined test structure by eliminating redundant tests for envelope JSON converters.

* refactor(envelopes): remove `SQSEnvelopeJsonConverter` and update `SQSEnvelope` payload handling

- Deleted `SQSEnvelopeJsonConverter` to simplify the codebase and reduce redundancy.
- Updated `SQSEnvelope` to use `EnvelopeOptions` instead of `JsonSerializerOptions`.
- Renamed `Body` to `BodyContent` in `SQSMessageEnvelope` for improved clarity.
- Adjusted serialization/deserialization logic to operate directly within `SQSEnvelope`.

* feat(envelopes): add `EnvelopeOptions` and `ConfigureEnvelopeOptions` extension

- Introduced `EnvelopeOptions` to encapsulate `JsonSerializerOptions` for envelopes.
- Added `ConfigureEnvelopeOptions` extension method to simplify configuration.
- Improved consistency and extensibility for envelope serialization options.

* refactor(abstractions): make `JsonOptions` in `EnvelopeOptions` a property

- Changed `JsonOptions` from a field to a property for improved encapsulation.
- Ensured consistency with coding standards and enhanced extensibility.

* refactor(abstractions): update `IEnvelope` to use `EnvelopeOptions` for payload operations

- Replaced `JsonSerializerOptions` with `EnvelopeOptions` in `ExtractPayload` and `PackPayload`.
- Improved extensibility and alignment with recent envelope abstraction changes.

* feat(middleware): add `UseExtractAndPackEnvelope` for payload operations

- Introduced `UseExtractAndPackEnvelope` middleware to handle envelope payload extraction and packing.
- Utilized `EnvelopeOptions` for serialization/deserialization.
- Enhanced extensibility and alignment with recent envelope abstraction updates.

* feat(application): add default middleware to the request pipeline on start

- Introduced `AddDefaultMiddleware` to enhance the Lambda application pipeline.
- Added `UseExtractAndPackEnvelope` middleware to handle envelope payload operations.
- Ensured middleware is appended prior to starting the host.

* refactor(builder): update default serializer to `DefaultLambdaJsonSerializer`

- Replaced `DefaultLambdaHostJsonSerializer` with `DefaultLambdaJsonSerializer`.
- Ensured consistency with updated naming conventions and improved clarity.

* feat(builder): add `AddLambdaSerializerWithContext` for custom serializers

- Introduced `AddLambdaSerializerWithContext` to register a source generator-based serializer.
- Enabled support for `JsonSerializerContext` for enhanced serialization customization.
- Ensured compatibility with Lambda's `ILambdaSerializer` interface.

* refactor(options): remove `JsonSerializerOptions` and `JsonWriterOptions` from `LambdaHostOptions`

- Deleted `JsonSerializerOptions` and `JsonWriterOptions` properties to simplify `LambdaHostOptions`.
- Removed default JSON serializer/writer option methods as they are no longer needed.
- Streamlined configuration to rely on existing extensibility through other abstractions.

* feat(example): enhance AWS Lambda example with updated options and serializer

- Added `LangVersion` as `preview` and disabled reflection for `JsonSerializer` in the project file.
- Introduced `ConfigureEnvelopeOptions` and registered serializer with context in the DI container.
- Updated handler to log the payload and use `BodyContent` for response processing.
- Added a project reference for `AwsLambda.Host.Envelopes.SQS`.
- Removed redundant `JsonSerializable` entries for `APIGatewayProxyRequest` and `APIGatewayProxyResponse`.

* refactor(serializer): remove `DefaultLambdaHostJsonSerializer`

- Deleted `DefaultLambdaHostJsonSerializer` as it is no longer in use.
- Ensured alignment with recent updates to serializer-related abstractions.
- Simplified the project by removing redundant code.

* refactor(solution): remove `AwsLambda.Host.Envelopes.UnitTests` project from solution

- Deleted `AwsLambda.Host.Envelopes.UnitTests` project from `AwsLambda.Host.sln`.
- Updated solution configuration to remove associated build and platform settings.
- Simplified the solution by removing unused test project references.

* refactor(tests): remove `IRequestAndIResponseVerifyTests` and associated snapshots

- Deleted `IRequestAndIResponseVerifyTests` test class as it is no longer relevant.
- Removed associated snapshot file `IRequestAndIResponseVerifyTests#LambdaHandler.g.verified.cs`.
- Simplified test project by eliminating unused and obsolete test cases.

* refactor(builder): remove AwsNamingPolicy enforcement in `LambdaApplicationBuilder`

- Deleted redundant code enforcing `AwsNamingPolicy` for `JsonSerializerOptions`.
- Simplified `LambdaApplicationBuilder` configuration.

* refactor(example): simplify serializer registration in HelloWorldAot example

- Replaced `ConfigureLambdaHostOptions` with `AddLambdaSerializerWithContext`.
- Streamlined DI container setup for serializer configuration.

* refactor(sqs-envelope): remove `required` modifier from `BodyContent` property

- Made `BodyContent` optional by removing the `required` modifier in `SQSEnvelope`.

* feat(example): add SQS handler and serialization support in AWS Lambda example

- Added SQS handler implementation to process SQS events within Lambda.
- Updated `SerializerContext` to include serialization support for `SQSEnvelope<Request>` and `SQSBatchResponse`.
- Enhanced the example to demonstrate handling and logging of SQS messages.
- Retained APIGateway handler as commented-out code for reference.

* refactor(map-handler): remove `IJsonSerializable` items processing from source generator

- Deleted unused processing logic for `IJsonSerializable` items in `MapHandlerSources.cs`.
- Removed `SerializableItems` from the code generation model and updated template accordingly.
- Simplified source generator by eliminating redundant logic for JSON serialization.

* refactor(solution): remove `AwsLambda.Host.Envelopes` project from solution

- Deleted `AwsLambda.Host.Envelopes` project and its related files.
- Removed project references to `AwsLambda.Host.Envelopes` in dependent projects.
- Updated solution file to exclude `AwsLambda.Host.Envelopes` project and related configurations.
- Simplified the solution by eliminating an unused and redundant project.

* feat(api-gateway-envelope): add strongly typed `BodyContent` and improve serialization support

- Added `<remarks>` documentation to describe the use of `BodyContent` in request/response envelopes.
- Enhanced serialization/deserialization by introducing a strongly typed `BodyContent` property.
- Improved maintainability and readability with updated inline comments for `APIGatewayRequestEnvelope` and `APIGatewayResponseEnvelope`.

* feat(envelopes): improve documentation for serialized `Body` content in envelopes

- Updated `<summary>` for `BodyContent` to reference serialized content of `Body` in requests/responses.
- Added `<remarks>` to `SQSEnvelope` to enhance clarity on typed `SQSMessageEnvelope` serialization.
- Improved readability and consistency of XML comments across envelope classes.

* refactor(envelopes): rename envelope classes for consistent naming conventions

- Renamed `APIGatewayRequestEnvelope` to `ApiGatewayRequestEnvelope`.
- Renamed `APIGatewayResponseEnvelope` to `ApiGatewayResponseEnvelope`.
- Renamed `SQSEnvelope` to `SqsEnvelope`.
- Renamed `SQSMessageEnvelope` to `SqsMessageEnvelope`.
- Updated examples and serializers to reflect new naming conventions.

* refactor(envelopes): update namespaces and project references for better consistency

- Renamed `APIGateway` to `ApiGateway` and `SQS` to `Sqs` in namespaces and project file paths.
- Updated affected project references and imports in unit tests and examples.
- Adjusted `RootNamespace` values in related `.csproj` files for consistency.
- Corrected solution file to align with renamed project paths.

* feat(docs): add guidelines for C# 14 extension members and syntax clarification

- Documented correct usage of C# 14 `extension` blocks with examples.
- Highlighted differences between old and new extension syntax with rules.
- Clarified valid scenarios for extension blocks and discouraged unnecessary conversions.
- Updated release notes workflow section for better clarity.

* feat(di): add extension methods for envelope options and JSON serializer with context

- Added `ConfigureEnvelopeOptions` extension method to simplify configuration of `EnvelopeOptions` in DI.
- Introduced `AddLambdaSerializerWithContext` extension method for registering source-generated JSON serializers.
- Improved XML documentation to enhance clarity and usability of the new methods.

* refactor(host-abstractions): remove `IJsonSerializable` interface

- Deleted unused `IJsonSerializable` interface and its associated XML documentation.
- Simplified the codebase by removing redundant abstractions for JSON serialization.

* refactor(envelopes): split `IEnvelope` into `IRequestEnvelope` and `IResponseEnvelope`

- Replaced `IEnvelope` interface with two new interfaces: `IRequestEnvelope` and `IResponseEnvelope`.
- Updated `ApiGateway` envelopes to implement appropriate interfaces.
- Refactored `Middleware/EnvelopeMiddleware` to use new interfaces for better separation of concerns.
- Removed redundant `PackPayload` method from `SqsEnvelope`.

* feat(middleware): add XML documentation for `UseExtractAndPackEnvelope`

- Added `<summary>`, `<remarks>`, and `<seealso>` tags to improve clarity and usability of the method.
- Documented the behavior of `IRequestEnvelope` and `IResponseEnvelope` processing in middleware.
- Included exception details and return value for enhanced developer guidance.

* refactor(envelopes): standardize namespaces and improve consistency

- Renamed namespaces from `ApiGateway2` to `ApiGateway` and `Sqs2` to `Sqs` for better clarity.
- Removed `NoWarn` settings and unused `RootNamespace` from project files.
- Updated references in examples and dependent files to match new namespaces.
- Enhanced XML documentation for exception handling and property definitions.

* feat(envelopes): add XML documentation for `EnvelopeOptions` properties

- Documented `JsonOptions` property in `EnvelopeOptions` with `<summary>` and `<remarks>` tags.
- Included descriptions for configuring JSON serialization settings via `IRequestEnvelope` and `IResponseEnvelope`.
- Improved clarity by specifying default behavior and usage scenarios.

* feat(host): enhance XML documentation in `LambdaApplication`

- Added `<remarks>` to `StartAsync` to describe the application of default middleware.
- Improved clarity of `<see cref="ILoggerFactory" />` logging configuration in XML comments.
- Adjusted formatting of XML documentation for better readability and consistency.

* feat(docs): update README for new JSON serializer registration approach

- Replaced `JsonSerializerOptions.TypeInfoResolverChain` example with `AddLambdaSerializerWithContext`.
- Improved clarity and instructions for registering source-generated JSON serializers.
- Added explanation of compile-time serialization benefits and AOT configuration updates.

* refactor(source-generators): remove unused `Microsoft.Extensions.Options` imports

- Deleted redundant `using Microsoft.Extensions.Options` statements across multiple snapshot tests.
- Updated `MapHandler.scriban` template to exclude the unused import.
- Simplified generated files by ensuring only relevant dependencies are included.

* refactor(dependencies): reorder and categorize package references for clarity

- Grouped package references into logical categories: source generation, OTEL, and testing libraries.
- Reorganized library types to improve readability and maintainability in `Directory.Packages.props`.
- Removed duplicate and misplaced entries to streamline configuration.

* feat(tests): add multi-targeting and new unit tests for envelopes

- Updated `AwsLambda.Host.UnitTests` to support targeting `net8.0`, `net9.0`, and `net10.0`.
- Added a new test project `AwsLambda.Host.Envelopes.UnitTests` with initial test structure.
- Registered new test project in the solution and added necessary dependencies.
- Included a basic test for `ApiGatewayRequestEnvelope` to verify foundation setup.

* feat(tests): expand unit tests for `ApiGatewayRequestEnvelope`

- Added comprehensive tests to validate `ExtractPayload` functionality under various scenarios:
  - Valid JSON, camelCase naming policy, null/empty body, invalid/malformed JSON.
- Verified behavior of inherited properties and `JsonIgnore` attribute on `BodyContent`.
- Ensured all deserialized values are preserved and exceptions are handled correctly.

* feat(tests): add unit tests for `ApiGatewayResponseEnvelope`

- Added comprehensive tests to validate `PackPayload` under various scenarios:
  - Valid payload, camelCase naming policy, null/empty body, and complex objects.
- Verified `BodyContent` serialization behavior with `JsonIgnore` attribute.
- Ensured proper inheritance from `APIGatewayProxyResponse` and dynamic updates to `Body`.

* feat(tests): add unit tests for `SqsEnvelope`

- Added comprehensive tests to validate `ExtractPayload` functionality:
  - Single/multiple records, camelCase naming policy, null/empty body, invalid/malformed JSON.
- Verified behavior of `BodyContent`, including `JsonIgnore` attribute and deserialization outcomes.
- Ensured proper inheritance of `SqsEnvelope` from `SQSEvent` and `SqsMessageEnvelope` from `SQSMessage`.
- Registered `AwsLambda.Host.Envelopes.Sqs` project reference in unit test project for coverage.

* feat(docs): add README for `AwsLambda.Host.Envelopes.Sqs`

- Introduced detailed documentation for `SqsEnvelope<T>` usage, including deserialization examples.
- Provided quick start guide and AOT configuration instructions for JSON serialization.
- Added badges for build status, code coverage, quality gate, and license.
- Linked relevant resources and example projects for further reference.

* feat(envelopes): add `ApiGatewayV2RequestEnvelope` and `ApiGatewayV2ResponseEnvelope`

- Introduced `ApiGatewayV2RequestEnvelope<T>` to simplify deserialization of request payloads.
- Added `ApiGatewayV2ResponseEnvelope<T>` to streamline serialization of response payloads.
- Enabled strongly-typed `BodyContent` for improved payload handling in API Gateway integrations.

* feat(tests): add unit tests for `ApiGatewayV2RequestEnvelope` and `ApiGatewayV2ResponseEnvelope`

- Added comprehensive tests for `ApiGatewayV2RequestEnvelope` to validate `ExtractPayload` functionality:
  - Scenarios include valid JSON, camelCase naming policy, null/empty body, invalid/malformed JSON.
  - Verified proper inheritance, `JsonIgnore` attribute, and deserialization correctness.
- Developed tests for `ApiGatewayV2ResponseEnvelope` to confirm `PackPayload` behavior:
  - Scenarios include valid payloads, camelCase naming policy, null/empty body, complex objects.
  - Ensured `BodyContent` serialization adheres to expected structure with proper updates and inheritance.

* feat(docs): add README for `AwsLambda.Host.Envelopes.ApiGateway`

- Detailed documentation for `AwsLambda.Host.Envelopes.ApiGateway`.
- Included usage, quick start examples, and AOT support for envelopes.
- Added badges for build status, code coverage, quality, and license.
- Linked relevant resources and example projects for reference.

* feat(docs): update README for `AwsLambda.Host.Envelopes.Sqs`

- Added a table describing envelope classes, base classes, and their use cases.
- Enhanced documentation to improve clarity and use case discovery.

* chore(docs): remove badges from `README` files

- Removed build, code coverage, quality gate, and license badges from `ApiGateway` and `Sqs` README files.
- Updated both `README` files to simplify the header section.

* feat: update `README` and project metadata for `ApiGateway` and `Sqs` envelopes

- Simplified links in `README` files for `ApiGateway` and `Sqs` envelopes.
- Added `PackageId`, `Description`, and `PackageReadmeFile` metadata to project files.
- Updated `Directory.Build.props` to set version as `1.0.0-beta.1`.

* feat(docs): update README for `AwsLambda.Host.Abstractions`

- Added documentation for envelope abstractions: `IRequestEnvelope` and `IResponseEnvelope`.
- Detailed their contracts for payload extraction and response packing in AWS Lambda contexts.
- Enhanced `README` to improve clarity on key features and abstractions.

* chore(docs): improve XML documentation formatting for `SqsEnvelope` and `LambdaApplication`

- Adjusted line breaks and indentation for better readability in XML documentation.
- Enhanced consistency in formatting for `<remarks>` and `<description>` tags.

* chore(ci): add `envelopes` to validate-pr-title workflow scopes

- Updated `validate-pr-title.yaml` to include `envelopes` as an allowed scope for PR title validation.

---------

Signed-off-by: Jonas Ha <61319894+j-d-ha@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: refactor Code refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant