Skip to content

Latest commit

 

History

History
20 lines (14 loc) · 859 Bytes

File metadata and controls

20 lines (14 loc) · 859 Bytes

AL1408: Activator.CreateInstance is not AOT-safe

Property Value
Severity Warning
Category AOT Testing
Code fix No
Analyzer Al1408AvoidActivatorCreateInstanceAnalyzer
Enabled by default Yes

Description

Activator.CreateInstance uses reflection to create instances at runtime. In Native AOT, this requires the target type's constructor to be preserved. Use explicit construction, factory patterns, or annotate with [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructors)].

See also