IsAotCompatible, which means a trimmed or Native-AOT application can use them and the analysers will tell you if it cannot.
What makes it work
Every JSON call routes through a source-generatedJsonSerializerContext. The reflection-based serializer is what usually breaks under trimming - it discovers properties at run time, the trimmer removes what it cannot see being used, and the failure arrives as a runtime exception in production rather than a warning at build time. The source-generated context is resolved at compile time, so the trimmer keeps exactly what is used and the AOT compiler has real code to compile.
The one annotated exception
AddWestyxNexusSecrets<T> carries [RequiresUnreferencedCode] and [RequiresDynamicCode]:
- Read the secret directly.
client.GetSecret("database.password")involves no binding and is fully compatible. - Keep the binder and accept the warning, if the option type is simple enough that you can satisfy yourself the trimmer will keep it.
[DynamicDependency]on your own options type is the supported way to say so.
IConfiguration provider, feature management, the OpenFeature provider and the aws_iam credential source - publishes clean.
How it is proven
Not by declaring the property.IsAotCompatible turns the analysers on, but ILLink and the AOT compiler only see a library’s real reachability through an application that roots it - a library compiled on its own reports nothing.
The pipeline publishes a harness application that references all six packages, touches each one’s entry points, and roots every package as a TrimmerRootAssembly so the trimmer analyses all of each one rather than only what the harness happens to reach. The job fails on any IL2xxx or IL3xxx diagnostic from a Westyx package. It runs on every commit, so a change that quietly reintroduces reflection is caught where it is made.