# trim-analyzer > Run `dotnet publish` with Native AOT enabled and analyze trim/linker warnings (IL2xxx/IL3xxx). - Author: Claude - Repository: psklarkins/claude-tools - Version: 20260108102420 - Stars: 0 - Forks: 0 - Last Updated: 2026-02-06 - Source: https://github.com/psklarkins/claude-tools - Web: https://mule.run/skillshub/@@psklarkins/claude-tools~trim-analyzer:20260108102420 --- # Trim Analyzer Skill Run `dotnet publish` with Native AOT enabled and analyze trim/linker warnings (IL2xxx/IL3xxx). ## When to Use This Skill - Before Native AOT deployment to identify compatibility issues - "Run trim analysis on this project" - "Check for AOT linker warnings" - "What IL2xxx warnings does this project have?" - After modifying code that uses reflection or dynamic types - To validate AOT readiness of a specific project ## What This Skill Does 1. **Runs `dotnet publish`** with `/p:PublishAot=true` 2. **Captures IL warnings** from the build output: - **IL2xxx** - Trim warnings (reflection, dynamic types) - **IL3xxx** - AOT warnings (code generation, P/Invoke) 3. **Parses and categorizes** warnings by code and severity 4. **Provides fix guidance** for common warning codes ## Usage ```bash # Analyze a project trim-analyzer ./src/MyApp/MyApp.csproj # Specify configuration trim-analyzer ./src/MyApp/MyApp.csproj -c Debug # Different runtime trim-analyzer ./src/MyApp/MyApp.csproj -r linux-x64 # Extended timeout (for large projects) trim-analyzer ./src/MyApp/MyApp.csproj --timeout 600 ``` ## Options | Option | Description | Default | |--------|-------------|---------| | `--configuration, -c` | Build configuration | Release | | `--runtime, -r` | Runtime identifier | win-x64 | | `--timeout` | Publish timeout in seconds | 300 | ## Output Example ``` === TRIM/AOT WARNINGS FOUND === Publish: SUCCESS Total warnings: 5 IL2xxx (Trim): 3 IL3xxx (AOT): 2 === WARNINGS === File: src/Services/TypeFactory.cs [IL2026] (line 45) Member: 'CreateInstance' Using member 'System.Activator.CreateInstance(Type)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. [IL3050] (line 67) Member: 'GetGenericMethod' Using member 'MethodInfo.MakeGenericMethod' which requires dynamic code generation. === COMMON FIXES === IL2026 (RequiresUnreferencedCode): - Add [DynamicallyAccessedMembers] to type parameters - Use source generators instead of reflection ``` ## Common Warning Codes ### Trim Warnings (IL2xxx) | Code | Description | |------|-------------| | IL2026 | Method with RequiresUnreferencedCode is called | | IL2046 | 'RequiresUnreferencedCode' annotations don't match | | IL2067 | Type passed to a generic parameter doesn't satisfy DynamicallyAccessedMembersAttribute | | IL2072 | Return value doesn't satisfy DynamicallyAccessedMembersAttribute | | IL2075 | Argument passed to a parameter doesn't satisfy DynamicallyAccessedMembersAttribute | ### AOT Warnings (IL3xxx) | Code | Description | |------|-------------| | IL3050 | Method with RequiresDynamicCode is called | | IL3051 | 'RequiresDynamicCode' annotations don't match | | IL3053 | Generic parameter doesn't satisfy DAM requirements for AOT | ## Integration with Other Skills **AOT readiness workflow:** ``` 1. aot-analyzer → Static analysis of reflection patterns 2. json-context-validator → Verify JSON serialization contexts 3. trim-analyzer → Run actual publish and collect warnings ``` ## Notes - **Requires project to compile** - Won't run on broken projects - **Can be slow** - AOT publish can take several minutes for large projects - **Creates publish artifacts** - Check your `bin/Release/net10.0/publish` folder - **Runtime-specific** - Some warnings only appear for specific RIDs - **Works with any .NET 7+ project** - But most useful for AOT-targeted projects ## Prerequisites - .NET 10 SDK installed - Project configured for AOT (`true` or via CLI) - All NuGet packages restored (`dotnet restore`)