Repository navigation
Make MicroStack Native AOT compatible - #2
Merged
Merged
Conversation
Enable PublishAot=true with zero trim/AOT warnings and all 1,178 tests passing. Key changes: - Add MicroStackJsonContext (source-generated) and DictionaryObjectJsonConverter for AOT-safe Dictionary<string, object?> serialization - Change IServiceHandler.GetState()/RestoreState() from object to JsonElement for type-safe persistence round-trips - Update StatePersistence to use JsonElement directly (no reflection) - Replace all anonymous types in JSON response paths with Dictionary<string, object?> across STS, RDS Data, SES, CloudWatch, WAF, ECR handlers - Remove AOT-unsafe JsonResponse(object) overload from AwsResponseHelpers - Update all 39 service handlers for new interface signatures - Update all JsonSerializer calls to use source-generated context - Fix Lambda/ApiGateway response parsing for primitive types - Replace Program.cs anonymous types with named records - Update persistence tests for JsonElement-based assertions
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.
Summary
PublishAot=truewith zero trim/AOT warnings and all 1,178 tests passingMicroStackJsonContext(source-generated serializer context) andDictionaryObjectJsonConverterfor AOT-safeDictionary<string, object?>serialization — the core in-memory model used by all 39 service handlersIServiceHandler.GetState()/RestoreState()fromobjecttoJsonElementfor type-safe persistence round-trips without reflectionWhat changed
Infrastructure (new files)
MicroStackJsonContext.cs—[JsonSerializable]source-generated context registering all serialized types (persistence records, response types, dictionary variants)DictionaryObjectJsonConverter.cs— CustomJsonConverter<Dictionary<string, object?>>handling known primitive types (string, long, double, bool, null, nested dicts/lists, JsonElement, JsonNode) without reflectionInterface & persistence
IServiceHandler.GetState()returnsJsonElement?(wasobject?),RestoreState()takesJsonElement(wasobject)StatePersistencewritesJsonElement.GetRawText()directly, reads viaJsonDocument.Parse— noJsonSerializer.Serialize(object)callsAnonymous type elimination
JsonResponse(new { ... })calls replaced withDictionary<string, object?>across STS, RDS Data, SES, CloudWatch, WAF, ECRJsonResponse(object data)overload fromAwsResponseHelpersHealthResponse,ResetResponse,ConfigResponse)Serializer call audit
JsonSerializer.Serialize/Deserializecalls across StepFunctions, CloudFormation, Lambda, ApiGateway, KMS, SES, CloudWatch, and Program.cs now useMicroStackJsonContext.DefaultBug fixes discovered during migration
statusCodeandbodyextraction now handleslong/int/stringprimitives (not justJsonElement)DictionaryObjectJsonConverter.WriteValue: addedulong,uint,short,bytecases for CloudWatch CBOR valuesprop.Value[0].ToString()→prop.Value[0].GetString()(returns string value, not raw JSON token)Verification
dotnet build -c Release -p:IsAotCompatible=true→ 0 warnings, 0 errorsdotnet test→ 1,178 passed, 0 failed (1 pre-existing skip)