refactor(abstractions): replace Lazy implementation with property for JSON options#199
Merged
j-d-ha merged 4 commits intoNov 29, 2025
Conversation
…or JSON options - Refactored `LambdaDefaultJsonOptions` from lazy initialization to a property with caching. - Improved clarity and maintainability of the code by simplifying access patterns.
…nfigured - Updated `PostConfigure` logic to conditionally assign `TypeInfoResolver` if not already set. - Clarified XML documentation regarding the behavior of `TypeInfoResolver` assignment.
…ccess - Updated `SqsSnsEnvelope` to use `LambdaDefaultJsonOptions` directly instead of `.Value`. - Updated `CloudWatchLogsEnvelopeBase` for consistent use of `LambdaDefaultJsonOptions`.
- Updated `CloudWatchLogsEnvelopeTests` to access `LambdaDefaultJsonOptions` directly. - Simplified `JsonSerializer.Serialize` calls for improved readability and maintainability.
|
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## main #199 +/- ##
==========================================
+ Coverage 90.65% 90.68% +0.02%
==========================================
Files 102 102
Lines 2237 2233 -4
Branches 252 254 +2
==========================================
- Hits 2028 2025 -3
+ Misses 116 115 -1
Partials 93 93
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
j-d-ha
deleted the
refactor/update-envelope-options-default-lambda-json-options
branch
November 29, 2025 18:45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



🚀 Pull Request
📋 Summary
This PR refactors the
EnvelopeOptions.LambdaDefaultJsonOptionsfield from aLazy<JsonSerializerOptions>to a regular property with lazy initialization using C# 14'sfieldkeyword. This simplifies the API surface by removing the need to access.Valuethroughout the codebase while maintaining the lazy initialization behavior.Changes:
LambdaDefaultJsonOptionsfromLazy<JsonSerializerOptions>to a property with lazy initializationEnvelopeOptionsPostConfigurationto use null-coalescing assignment, only settingTypeInfoResolverwhen not explicitly configured.Valueaccess throughout CloudWatchLogs and SQS envelope implementations✅ Checklist
🧪 Related Issues or PRs
Part of ongoing refactoring efforts to improve API ergonomics and leverage modern C# features.
💬 Notes for Reviewers
Key improvements:
.Valueto access JSON options??=instead of direct assignment)fieldkeyword for clean lazy initialization patternBreaking change consideration: While this changes the field type from
Lazy<T>toT, it's unlikely to be a breaking change since:.Valuein the codebaseLazy<>wrapper type