Sign in Get 3 free credits

Try a job or a niche: tiktok captions, study notes, excel formulas. Press Esc to close.

.NET trimming and Native AOT

Fixes trimming and Native AOT warnings in your .NET code step by step, so your app publishes small and fast.

What we improved

SKILL.md now carries the working method on its own instead of pointing to the reference files for it. Added a six step workflow: scope the work, turn the analysis on, get the complete warning list, triage, apply the narrowest fix, verify. A

Improved by YourAISkill from the original by Aaronontheweb, under its MIT licence. The download includes the author's licence and a CHANGES.md listing every change. Both Claude reviews read the improved version.

Claude's review

9/10 Excellent .NET trimming and Native AOT workflow: warning triage table, attribute guidance, annotation chains, safe replacement patterns, suppression rules and gotchas.

We asked Claude the question you would ask: would I be glad I installed this? Two separate reviews, the second blind to the first, must both rate a skill 7 or higher before we sell it.

In detail

Guidelines for making .NET libraries and applications trimming-safe and Native AOT compatible. Covers the trimming/AOT model, the MSBuild properties that enable analysis (IsTrimmable, IsAotCompatible, PublishTrimmed, PublishAot), the trimming attributes (RequiresUnreferencedCode, RequiresDynamicCode, DynamicallyAccessedMembers, UnconditionalSuppressMessage), IL2xxx/IL3xxx warning codes, and a pattern playbook: source generators and UnsafeAccessor, generated-interception diagnostic suppressors, intentional runtime scanning boundaries, trimming-safe islands and feature switches, migration analyzers, and temporary warning-approval baselines. Use when introducing trimming/AOT support, resolving IL2xxx/IL3xxx warnings, or making reflection-heavy code trimming-safe in C# / .NET codebases. For System.Text.Json AOT scenarios, see also the serialization skill.

How you use it

  1. Add it to your pack, then download your pack (1 credit).
  2. In Claude, open Customize > Skills and upload the zip. Code execution needs to be on under Settings > Capabilities.
  3. Ask Claude for the job in your own words. It uses the skill when your request matches what it does. Step by step guide

Safety check

Nothing risky found: no hidden instructions, no download and run, no reading of saved passwords or keys.

An automated scan lowers risk but cannot promise zero risk. How we check skills

Preview

The first lines of SKILL.md
---
name: aot-trimming
description: "Make .NET libraries and apps trimming-safe and Native AOT compatible, and fix IL2xxx and IL3xxx warnings. Gives a step by step workflow (enable the analyzers, expand collapsed warnings, triage each warning code, fix, verify with a trimmed or AOT test app), the MSBuild properties, the attributes (RequiresUnreferencedCode, RequiresDynamicCode, DynamicallyAccessedMembers, UnconditionalSuppressMessage, DynamicDependency) and when each is right, and patterns that replace or contain reflection: source generated registration, generic overloads, UnsafeAccessor, System.Text.Json source generation, RuntimeFeature gated islands, feature switches and temporary warning baselines. Use when adding PublishTrimmed or PublishAot, when a build or publish shows IL2026, IL2070, IL3050 or similar warnings, when reviewing reflection heavy C# for trimming, or when designing public APIs that need trimming annotations."
version: 1.1.0
tags:
  - csharp
  - dotnet
  - aot
  - trimming
  - nativeaot
  - code-quality
---
<!-- Modified by YourAISkill (youraiskill.com) on 2 December 2026 from the original by Aaronontheweb. See CHANGES.md. -->

# .NET Trimming and Native AOT

## Core Model

- **Trimming** (`PublishTrimmed`) runs ILLink reachability analysis: only statically reachable code is kept. Reflection the analyzer cannot see gets trimmed away and produces warnings.
- **Native AOT** (`PublishAot`) makes trimming mandatory and removes the JIT. `Reflection.Emit` is unsupported, constructing *unknown* generic instantiations at runtime is not guaranteed, `Expression.Compile()` may fall back to interpretation, and reflection works only over members the linker preserved.
- Both run the same static analysis:
  - `IL2xxx`: trimming warnings (`RequiresUnreferencedCode` propagation and `DynamicallyAccessedMembers` dataflow).
  - `IL3xxx`: AOT and single-file warnings (`RequiresDynamicCode`, `RequiresAssemblyFiles`). An AOT publish reports both families.
- A library can be trimmable but **not** AOT-compatible (for example it uses `Reflection.Emit`, which trimming tolerates but AOT does not).

**Reflection is not the enemy.** It is fine in ordinary JIT apps, which need none of this. The attributes exist to *allow* reflection under trimming: annotate what reflection needs and the linker keeps it. Replace reflection (source generators, `[UnsafeAccessor]`, generic APIs) only where you want a reflective surface gone, such as a public registration API you do not want to ship with `[RequiresUnreferencedCode]`.

## Workflow

### 1. Scope

Confirm who publishes trimmed/AOT: the app itself, or consumers of your library. If nobody does, stop; there is nothing to fix.

### 2. Turn the analysis on

Library:

```xml
<PropertyGroup>
  <!-- Trim-compatible: enables trim warnings during the library build. -->
...

From Aaronontheweb's repository, MIT licence.

Related skills

  • Checked

    MAUI safe area layout

    Handles safe areas and edge to edge layouts in .NET MAUI, so content clears notches and the keyboard.

    by dotnet 6.4k
    7/101 credit
  • Checked

    Xamarin.Forms to .NET MAUI

    Moves your Xamarin.Forms app to .NET MAUI and keeps its store identity and user data, so nothing breaks quietly.

    by davidortinau 181
    8/101 credit
  • Checked

    Godot C# scripting

    Writes, ports and debugs C# scripts for Godot 4, so your game builds and runs without the common C# traps.

    by jame581 1k
    8/101 credit
  • Checked

    .NET Native Interop Helper

    Writes correct P/Invoke calls from .NET to C and C++ libraries, avoiding crashes, leaks and garbled text.

    by dotnet 6.4k
    8/101 credit
  • Checked

    Dotnet Performance Tracing

    Picks the right tool and commands to capture .NET performance data for a production slowdown.

    by dotnet 6.4k
    7/101 credit
  • Checked

    Godot C# Scripting

    Writes C# game code for Godot 4 that builds and runs, including signals, exports and calling GDScript.

    by gamedev-skills 13k
    8/101 credit

Secure checkout

Credits

AUD

  1. 1Choose
  2. 2Pay on Square
  3. 3Credits added