dotnet-aot-compat

Solid

Make .NET projects compatible with Native AOT and trimming by systematically resolving IL trim/AOT analyzer warnings. USE FOR: making projects AOT-compatible, fixing trimming warnings, resolving IL warnings (IL2026, IL2070, IL2067, IL2072, IL3050), adding DynamicallyAccessedMembers annotations, enabling IsAotCompatible. DO NOT USE FOR: publishing native AOT binaries, optimizing binary size, replacing reflection-heavy libraries with alternatives. INVOKES: no tools — pure knowledge skill.

Data & Documents 3,357 stars 247 forks Updated today MIT

Install

View on GitHub

Quality Score: 93/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# dotnet-aot-compat Make .NET projects compatible with Native AOT and trimming by systematically resolving all IL trim/AOT analyzer warnings. ## When to Use This Skill - **"Make this project AOT-compatible"** - **"Fix trimming warnings"** or **"fix IL warnings"** - **"Resolve IL2070 / IL2067 / IL2072 / IL2026 / IL3050 warnings"** - **"Add DynamicallyAccessedMembers annotations"** - **"Enable IsAotCompatible in my .csproj"** - **"My project has trim analyzer warnings after upgrading to net8.0"** - **"Annotate reflection code for the trimmer"** ## When Not to Use This Skill Do not use this skill when the project exclusively targets .NET Framework (net4x), which does not support the trim/AOT analyzers. ## Prerequisites An existing .NET project targeting net8.0 or later (or multi-targeting with at least one net8.0+ TFM) and the corresponding .NET SDK installed. ## Background: What AOT Compatibility Means Native AOT and the IL trimmer perform static analysis to determine what code is reachable. Reflection can break this analysis because the trimmer can't see what types/members are accessed at runtime. The `IsAotCompatible` property enables analyzers that flag these issues as build warnings (ILXXXX codes). ## Critical Rules ### ❌ Never suppress warnings incorrectly - **NEVER** use `#pragma warning disable` for IL warnings. It hides warnings from the Roslyn analyzer at build time, but the IL linker and AOT compiler still see the issue. The code will fail at trim/publish ...

Details

Author
dotnet
Repository
dotnet/skills
Created
4 months ago
Last Updated
today
Language
C#
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category