dotnet-aot-compat

Convert reflection-unfriendly .NET code into trimmer-safe patterns for Native AOT.

1|Updated May 21, 2026
One-click install
npx skills add https://github.com/1k-off/umbraco-observability-playground --skill dotnet-aot-compat-1k-off
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dotnet-aot-compat
Source: https://github.com/1k-off/umbraco-observability-playground/tree/main/.agents/skills/dotnet-aot-compat
Command: npx skills add https://github.com/1k-off/umbraco-observability-playground --skill dotnet-aot-compat-1k-off

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It helps you remove IL trim and Native AOT analyzer warnings so your .NET application can publish and run safely without reflection-related surprises.

Core Features & Use Cases

  • Resolve IL trim/AOT analyzer warnings by following a warning-first workflow (build → fix → rebuild) to eliminate common IL2026/IL3050 and IL207x issues.
  • Apply correct trimming annotations using IsAotCompatible, [DynamicallyAccessedMembers], and related attributes so the trimmer can prove code reachability.
  • Handle JSON AOT compatibility by switching reflection-based JsonSerializer usage to source-generated JsonSerializerContext where appropriate.
  • Guard against unsafe suppression by avoiding pragma disable and UnconditionalSuppressMessage, and instead propagating requirements via RequiresUnreferencedCode / RequiresDynamicCode when needed.

Use case: You upgrade to net8.0+ and your build starts failing (or warning flooding) with IL2070/IL2067/IL2026/IL3050 during trimming/AOT analysis; this skill guides you to systematically annotate/refactor the code and rerun builds until warnings are gone.

Quick Start

Ask the AI to fix your Native AOT/trimming analyzer warnings for a net8.0+ project by enabling AOT analysis, rebuilding to collect ILXXXX warnings, and iteratively applying the correct annotation or JSON source-generation strategy until you reach zero IL warnings.

Frequently Asked Questions about dotnet-aot-compat

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix IL2026 and IL3050 warnings for .NET Native AOT?

Eliminate IL2026 and IL3050 warnings by enabling IsAotCompatible, applying DynamicallyAccessedMembers annotations, and propagating requirements via RequiresUnreferencedCode or RequiresDynamicCode attributes.

What causes IL2070 trim warnings when publishing .NET applications?

IL2070 trim warnings occur when .NET reflection-based patterns prevent the trimmer from proving code reachability. Resolve them by applying DynamicallyAccessedMembers annotations or switching to source-generated JSON serializers.

How do I make System.Text.Json compatible with Native AOT?

Make System.Text.Json compatible with Native AOT by replacing reflection-based JsonSerializer calls with source-generated JsonSerializerContext to satisfy the AOT trimmer's static analysis requirements.

Can I use DynamicallyAccessedMembers to fix .NET trimming analyzer warnings?

Yes, apply DynamicallyAccessedMembers attributes to explicitly declare required members for reflection, allowing the .NET trimmer to prove code reachability and eliminate IL2067 and IL2070 warnings.

Should I suppress IL2026 warnings with UnconditionalSuppressMessage?

Avoid using UnconditionalSuppressMessage or pragma disable to suppress IL2026 warnings. Instead, propagate trimming requirements via RequiresUnreferencedCode or RequiresDynamicCode attributes to maintain Native AOT safety.

Does this Native AOT compatibility workflow support multi-targeting projects?

Yes, the Native AOT compatibility workflow supports multi-targeting projects targeting net8.0+ alongside netstandard2.0 or net472, applying trimming annotations and source-generated JSON strategies across all targeted frameworks.