-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Overview
This issue tracks the resolution of AOT compilation warnings discovered during Native AOT compatibility testing. Currently, the AOT test app produces 56 warnings and fails at runtime.
Related Epic: #7246
Current Status
- Warning Count: 56 (Target: 0)
- Runtime Status: ❌ Fails with
ConfigurationExceptionfor actor provider type resolution
Error Categories
1. Trim Analysis Warnings - Type.GetType() (IL2057)
These occur when using Type.GetType(string) with dynamic type names from configuration, making it impossible for the trimmer to guarantee type availability.
Affected Files:
-
ActorSystemImpl.cs:300- LoadExtensions() -
ActorSystemImpl.cs:285- ConfigureScheduler() -
ActorSystemImpl.cs:447- ConfigureProvider() -
Mailboxes.cs:66- Constructor -
Serialization.cs:183- Constructor (serializers) -
Serialization.cs:210- Constructor (serialization bindings) -
Settings.cs:104- Constructor (LoggerType) -
Settings.cs:142- Constructor (StdoutLogger) -
Settings.cs:174- Constructor (LoggerStartTimeout) -
Dispatchers.cs:607- ConfiguratorFrom() -
Serializer.cs:200- GetSerializerIdentifierFromConfig() -
AbstractDispatcher.cs:343- MessageDispatcherConfigurator.ConfigureExecutor()
2. Trim Analysis Warnings - Activator.CreateInstance (IL2067, IL2087)
These occur when creating instances without proper DynamicallyAccessedMembers annotations.
Affected Files:
-
Props.cs:587- CreateProducer() - Missing PublicConstructors annotation -
Extensions.cs:136- WithExtension<T,TI>() - Missing PublicParameterlessConstructor annotation -
Extensions.cs:116- WithExtension() - Missing PublicParameterlessConstructor annotation
3. AOT Analysis Warnings - System.Linq.Expressions (IL3050)
These are from BCL code using Type.MakeGenericType() which requires dynamic code generation. These may be acceptable if expression compilation isn't used in AOT scenarios.
Files: DelegateHelpers.Generated.cs (40 warnings in BCL code)
Action Items
High Priority
- Add
DynamicDependencyandUnconditionalSuppressMessageattributes for known-safe type resolutions - Implement AOT-compatible type registration system (potentially using source generators)
- Add
DynamicallyAccessedMembersannotations toProps.CreateProducer()parameter - Add
DynamicallyAccessedMembersannotations to extension methods inExtensions.cs - Fix runtime error:
ConfigurationExceptionfor 'Akka.Actor.LocalActorRefProvider'
Medium Priority
- Investigate expression compilation usage - determine if we can avoid it in AOT scenarios
- Create AOT-specific configuration validator to catch type resolution issues at build time
- Document which Akka.NET features are/aren't AOT compatible
Low Priority
- Evaluate if System.Linq.Expressions warnings can be suppressed (if not used in AOT paths)
- Add AOT compatibility tests to CI pipeline
Runtime Error Details
Unhandled Exception: Akka.Configuration.ConfigurationException:
'akka.actor.provider' is not a valid type name : 'Akka.Actor.LocalActorRefProvider'
at Akka.Actor.Settings..ctor(ActorSystem, Config, ActorSystemSetup)
This suggests the type resolution mechanism fails completely in AOT scenarios. The provider type cannot be loaded dynamically.
Technical Approach
Option 1: Source Generator for Type Registration
- Create a source generator that scans configuration and generates static type mappings
- Eliminates runtime
Type.GetType()calls
Option 2: Explicit Type Registration API
- Add
ActorSystemSetupbuilders that accept concrete types instead of type names - Provides AOT-friendly configuration path
Option 3: Hybrid Approach
- Keep existing API for non-AOT scenarios
- Add AOT-specific setup path with compile-time type registration
- Use
#ifdirectives or feature detection
Success Criteria
- All 56 warnings resolved or properly suppressed with justification
- AOT test app runs successfully without runtime exceptions
- Core actor system functionality works in AOT scenarios
- Documentation updated with AOT compatibility guidelines