Diagnostic code · ARA0400
NativeAOT unsafe API
The module uses an API that needs runtime code generation, dynamic loading or reflection unavailable or unsafe under NativeAOT and trimming. This is a compilation error even when developing with the JIT; the last good code keeps running.
Common causes
- Calling
Assembly.Load, usingAssemblyLoadContextorReflection.Emit, or compiling expression trees. - Looking up types or members by name, invoking methods reflectively, constructing runtime generic types, or using
Activator.CreateInstance(Type). - Using
dynamicinvocation, member access or construction.
Fixes
Replace runtime discovery and invocation with generated registration, serialization and direct typed calls.
Use statically referenced types and explicit factories instead of loading or constructing code dynamically.
Code:
ARA0400Constant:
cs::AOT_UNSAFEReported by: Ara.Analyzers