Skip to main content
Source: AL0044AotSafeViolationAnalyzer.cs

Description

Code marked with [AotSafe] guarantees it will work correctly in AOT-compiled applications. Calling methods with [RequiresDynamicCode] violates this guarantee because those methods rely on runtime code generation which is not available in AOT scenarios.

Bad Code

Good Code

Properties

  • Category: Reliability
  • Severity: Warning
  • Enabled by default: True
  • Code fix available: False

Configuration

Notes

  • AOT (Ahead-of-Time) compilation generates native code at build time
  • Dynamic code generation (Reflection.Emit, Expression.Compile) is not available
  • Use concrete types and source generators for AOT-compatible code