-
Notifications
You must be signed in to change notification settings - Fork 841
Open
Labels
Milestone
Description
We have the following trimming suppression:
extensions/src/Libraries/Microsoft.Extensions.AI.Abstractions/Utilities/AIJsonUtilities.Schema.cs
Lines 193 to 198 in 6487428
| #if !NET9_0_OR_GREATER | |
| [UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access", | |
| Justification = "Pre STJ-9 schema extraction can fail with a runtime exception if certain reflection metadata have been trimmed. " + | |
| "The exception message will guide users to turn off 'IlcTrimMetadata' which resolves all issues.")] | |
| #endif | |
| private static JsonElement GetJsonSchemaCore(JsonSerializerOptions options, FunctionParameterKey key) |
This is an incorrect way to address trimming warnings. The intention of the warnings is so developers now upfront what does and what doesn't work when the build and publish a trimmed or native AOT'd app. Suppressing warnings like this minimizes the principle of "if you don't get warnings during publish, your app is guaranteed to work the same as before you published".
We should remove this suppression and either make the underlying code trim-compatible, or we should annotate this method as RequiresUnreferencedCode.