Description
Code marked with[TrimSafe] guarantees it will work correctly in trimmed applications. Calling methods with [RequiresUnreferencedCode] violates this guarantee because those methods may fail at runtime when types are trimmed.
Bad Code
Good Code
Properties
- Category: Reliability
- Severity: Warning
- Enabled by default: True
- Code fix available: False
Configuration
Notes
- Trimming removes unused code to reduce binary size
- Reflection-based code may fail when referenced types are trimmed
- Use source generators instead of reflection for trim-safe code
