Skip to main content
Source: Al0094AvoidDynamicKeywordAnalyzer.cs

Description

The dynamic keyword relies on Reflection.Emit which is unavailable in Native AOT. Use strongly-typed alternatives.

Bad Code

dynamic obj = GetResponse();
Console.WriteLine(obj.Name);

Good Code

var obj = GetResponse();
Console.WriteLine(obj.Name);
// Or use JsonElement / strongly-typed deserialization

Properties

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

Configuration

dotnet_diagnostic.AL0094.severity = warning