Description
Implement comprehensive AOT (Ahead-of-Time compilation) compatibility validation across all MinimalLambda packages to ensure reliable native AOT support for optimal Lambda cold start performance.
Problem Statement
While MinimalLambda advertises AOT support and includes a HelloWorldAot example, there's no systematic validation ensuring AOT compatibility across the library packages. This creates risks of:
- Runtime failures when users enable AOT compilation
- Trim warnings that become runtime errors
- Missing type metadata for JSON serialization
- Undiscovered reflection usage that breaks AOT
Proposed Solution
Implement comprehensive AOT validation through:
- Library package annotations
- Static analysis with AOT analyzers
- CI validation of AOT builds
- Trim annotations where needed
- Documentation of AOT requirements
Acceptance Criteria
1. Library Package Configuration
2. AOT Analyzer Integration
3. Trim Annotations
4. CI Validation
5. Documentation Updates
6. Testing Validation
Technical Considerations
Known Reflection Usage
src/MinimalLambda.Testing/HostFactoryResolver.cs - Uses Activator.CreateInstance, Type.GetType, etc.
- Testing package may be exempt from AOT requirements
- Consider adding
<IsAotCompatible>false</IsAotCompatible> if necessary
- Document why testing package isn't AOT-compatible
Dependencies
- Ensure all NuGet dependencies support AOT:
- Amazon.Lambda.Core
- Amazon.Lambda.RuntimeSupport
- Amazon.Lambda.Serialization.SystemTextJson
- Microsoft.Extensions.Hosting
- OpenTelemetry packages
Breaking Changes
- Adding
IsAotCompatible shouldn't break existing code
- May discover APIs that need
[RequiresUnreferencedCode] annotation
- Document any newly discovered limitations
Implementation Tasks
Phase 1: Analysis
Phase 2: Annotations
Phase 3: CI Integration
Phase 4: Validation
Phase 5: Documentation
Success Metrics
- ✅ All library packages marked with
IsAotCompatible=true
- ✅ Zero AOT/trim analyzer warnings in library code
- ✅ CI builds validate AOT compatibility
- ✅ At least 2 working AOT examples (HelloWorldAot + one envelope)
- ✅ Documentation clearly explains AOT requirements
References
Related Issues
None
Type
Story / Enhancement
Description
Implement comprehensive AOT (Ahead-of-Time compilation) compatibility validation across all MinimalLambda packages to ensure reliable native AOT support for optimal Lambda cold start performance.
Problem Statement
While MinimalLambda advertises AOT support and includes a HelloWorldAot example, there's no systematic validation ensuring AOT compatibility across the library packages. This creates risks of:
Proposed Solution
Implement comprehensive AOT validation through:
Acceptance Criteria
1. Library Package Configuration
<IsAotCompatible>true</IsAotCompatible>to all library projects:MinimalLambda.csprojMinimalLambda.Abstractions.csprojMinimalLambda.OpenTelemetry.csprojMinimalLambda.Envelopes.*)2. AOT Analyzer Integration
Directory.Build.propsor individual project files:3. Trim Annotations
[DynamicallyAccessedMembers][RequiresUnreferencedCode][UnconditionalSuppressMessage]where safeHostFactoryResolver.cs(identified as using reflection)4. CI Validation
5. Documentation Updates
JsonSerializerContextfor common scenarios6. Testing Validation
Technical Considerations
Known Reflection Usage
src/MinimalLambda.Testing/HostFactoryResolver.cs- UsesActivator.CreateInstance,Type.GetType, etc.<IsAotCompatible>false</IsAotCompatible>if necessaryDependencies
Breaking Changes
IsAotCompatibleshouldn't break existing code[RequiresUnreferencedCode]annotationImplementation Tasks
Phase 1: Analysis
Phase 2: Annotations
IsAotCompatibleto project filesRequiresUnreferencedCodewhere neededPhase 3: CI Integration
Phase 4: Validation
Phase 5: Documentation
Success Metrics
IsAotCompatible=trueReferences
Related Issues
None
Type
Story / Enhancement