dotnet-aot-compat

Resolve IL trim and AOT analyzer warnings for .NET Native AOT compatibility.

2|Updated Mar 17, 2026
One-click install
npx skills add https://github.com/sayedihashimi/copilot-skill-eval --skill dotnet-aot-compat-sayedihashimi
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dotnet-aot-compat
Source: https://github.com/sayedihashimi/copilot-skill-eval/tree/main/examples/aspnet-razor-pages/plugins/dotnet-skills/dotnet-upgrade/skills/dotnet-aot-compat
Command: npx skills add https://github.com/sayedihashimi/copilot-skill-eval --skill dotnet-aot-compat-sayedihashimi

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Make .NET projects compatible with Native AOT by systematically addressing IL trim/AOT analyzer warnings, enabling smoother ahead-of-time compilation and safer trimming.

Core Features & Use Cases

  • Annotate reflection usage with DynamicallyAccessedMembers to preserve type information during trimming.
  • Enable IsAotCompatible and adjust project TFMs to net8.0+ where necessary.
  • Apply a strategy to migrate JSON serialization to source generation and minimize reflective dependencies.

Quick Start

Enable AOT analysis for net8.0+ projects and begin iterative fixes of IL trim/AOT 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 resolve IL2026 and IL2070 warnings in .NET Native AOT projects?

Resolve IL2026 and IL2070 warnings by annotating reflection usage with DynamicallyAccessedMembers to preserve type information during trimming. This strategy enables iterative, warning-driven fixes without relying on unsafe suppressions, ensuring your .NET projects are Native AOT-compatible.

What is the best way to make a .NET project trimming-safe for AOT compilation?

Making a .NET project trimming-safe involves enabling AOT analyzers for net8.0+ projects and iteratively fixing IL trim warnings. You must annotate reflection code flow with DynamicallyAccessedMembers and migrate JSON serialization to source generation to minimize reflective dependencies.

Does Native AOT compatibility require upgrading my .NET project to net8.0?

Yes, Native AOT compatibility requires upgrading your project target frameworks to net8.0+. You must enable IsAotCompatible in your project file and begin iterative fixes of IL trim warnings to ensure ahead-of-time compilation succeeds safely.

Why do I get IL2072 and IL2067 warnings when enabling AOT analysis?

IL2072 and IL2067 warnings occur during AOT analysis because the trimmer cannot statically guarantee type members are preserved through reflection code flow. You fix these by applying DynamicallyAccessedMembers annotations to refactor the flow and satisfy the analyzer requirements.

Can I suppress IL3050 warnings instead of refactoring code for AOT compatibility?

Suppressing IL3050 warnings is discouraged for AOT compatibility. The recommended approach is to follow iterative, warning-driven fixes by annotating DynamicallyAccessedMembers and refactoring annotation flow, avoiding unsafe suppressions to maintain trimming safety.

How to migrate JSON serialization to make .NET projects AOT-compatible?

Migrate JSON serialization to source generation to make .NET projects AOT-compatible. This minimizes reflective dependencies by providing compile-time type information, which works alongside DynamicallyAccessedMembers annotations to resolve IL trim warnings.