-
Notifications
You must be signed in to change notification settings - Fork 27
Description
Describe the bug
When enabling AOT, a trim analysis warning is logged even though I use the correct JsonSerializerContext overload.
Regression Issue
- Select this option if this issue appears to be a regression.
Expected Behavior
I expect no trim analysis warnings.
Current Behavior
I get the following warning:
Trim analysis warning IL2070: System.Text.Json.Serialization.Converters.EnumConverterFactory.Create(Type,EnumConverterOptions,JsonNamingPolicy,JsonSerializerOptions): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicParameterlessConstructor' in call to 'System.Type.MakeGenericType(Type[])'. The parameter 'enumType' of method 'System.Text.Json.Serialization.Converters.EnumConverterFactory.
Create(Type,EnumConverterOptions,JsonNamingPolicy,JsonSerializerOptions)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
Reproduction Steps
All you need is a call to AddAWSMessageBus with a JsonSerializerContext and an empty callback. I set the project property TrimmerSingleWarn to false in order to get the exact warning, and not a single generic one.
Possible Solution
After some digging, I found that SerializationOptions creates an instance of JsonStringEnumConverter, which causes the warning. I tried with a custom build of AWS.Messaging that did not create this instance, and the warning went away.
When you provide a JsonSerializerContext, this instance will never be used. But the warning does not seem to be depressed anywhere.
Additional Information/Context
No response
AWS.Messaging (or related) package versions
AWS.Messaging.Lambda 1.0.1
Targeted .NET Platform
.NET 8
Operating System and version
Windows 11