You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When analyzing the Microsoft.Extensions.Caching.Hybrid library, we get the following warnings
D:\git\extensions\src\Libraries\Microsoft.Extensions.Caching.Hybrid\Internal\DefaultJsonSerializerFactory.cs(26): Trim analysis error IL2026: Microsoft.Extensions.Caching.Hybrid.Internal.DefaultJsonSerializerFactory.DefaultJsonSerializer`1.Microsoft.Extensions.Caching.Hybrid.IHybridCacheSerializer<T>.Deserialize(ReadOnlySequence`1<Byte>): Using member 'System.Text.Json.JsonSerializer.Deserialize<T>(Utf8JsonReader&,JsonSerializerOptions)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved. [D:\git\extensions\test\Libraries\Microsoft.Extensions.AotCompatibility.TestApp\Microsoft.Extensions.AotCompatibility.TestApp.csproj]
D:\git\extensions\src\Libraries\Microsoft.Extensions.Caching.Hybrid\Internal\DefaultJsonSerializerFactory.cs(26): AOT analysis error IL3050: Microsoft.Extensions.Caching.Hybrid.Internal.DefaultJsonSerializerFactory.DefaultJsonSerializer`1.Microsoft.Extensions.Caching.Hybrid.IHybridCacheSerializer<T>.Deserialize(ReadOnlySequence`1<Byte>): Using member 'System.Text.Json.JsonSerializer.Deserialize<T>(Utf8JsonReader&,JsonSerializerOptions)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications. [D:\git\extensions\test\Libraries\Microsoft.Extensions.AotCompatibility.TestApp\Microsoft.Extensions.AotCompatibility.TestApp.csproj]
D:\git\extensions\src\Libraries\Microsoft.Extensions.Caching.Hybrid\Internal\DefaultJsonSerializerFactory.cs(36): Trim analysis error IL2026: Microsoft.Extensions.Caching.Hybrid.Internal.DefaultJsonSerializerFactory.DefaultJsonSerializer`1.Microsoft.Extensions.Caching.Hybrid.IHybridCacheSerializer<T>.Serialize(T,IBufferWriter`1<Byte>): Using member 'System.Text.Json.JsonSerializerOptions.Default.get' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved. [D:\git\extensions\test\Libraries\Microsoft.Extensions.AotCompatibility.TestApp\Microsoft.Extensions.AotCompatibility.TestApp.csproj]
D:\git\extensions\src\Libraries\Microsoft.Extensions.Caching.Hybrid\Internal\DefaultJsonSerializerFactory.cs(36): AOT analysis error IL3050: Microsoft.Extensions.Caching.Hybrid.Internal.DefaultJsonSerializerFactory.DefaultJsonSerializer`1.Microsoft.Extensions.Caching.Hybrid.IHybridCacheSerializer<T>.Serialize(T,IBufferWriter`1<Byte>): Using member 'System.Text.Json.JsonSerializerOptions.Default.get' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications. [D:\git\extensions\test\Libraries\Microsoft.Extensions.AotCompatibility.TestApp\Microsoft.Extensions.AotCompatibility.TestApp.csproj]
D:\git\extensions\src\Libraries\Microsoft.Extensions.Caching.Hybrid\Internal\DefaultJsonSerializerFactory.cs(36): Trim analysis error IL2026: Microsoft.Extensions.Caching.Hybrid.Internal.DefaultJsonSerializerFactory.DefaultJsonSerializer`1.Microsoft.Extensions.Caching.Hybrid.IHybridCacheSerializer<T>.Serialize(T,IBufferWriter`1<Byte>): Using member 'System.Text.Json.JsonSerializer.Serialize<T>(Utf8JsonWriter,T,JsonSerializerOptions)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved. [D:\git\extensions\test\Libraries\Microsoft.Extensions.AotCompatibility.TestApp\Microsoft.Extensions.AotCompatibility.TestApp.csproj]
D:\git\extensions\src\Libraries\Microsoft.Extensions.Caching.Hybrid\Internal\DefaultJsonSerializerFactory.cs(36): AOT analysis error IL3050: Microsoft.Extensions.Caching.Hybrid.Internal.DefaultJsonSerializerFactory.DefaultJsonSerializer`1.Microsoft.Extensions.Caching.Hybrid.IHybridCacheSerializer<T>.Serialize(T,IBufferWriter`1<Byte>): Using member 'System.Text.Json.JsonSerializer.Serialize<T>(Utf8JsonWriter,T,JsonSerializerOptions)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications. [D:\git\extensions\test\Libraries\Microsoft.Extensions.AotCompatibility.TestApp\Microsoft.Extensions.AotCompatibility.TestApp.csproj]
When analyzing the Microsoft.Extensions.Caching.Hybrid library, we get the following warnings
See
extensions/src/Libraries/Microsoft.Extensions.Caching.Hybrid/Internal/DefaultJsonSerializerFactory.cs
Lines 19 to 39 in d42d3e5
These suppressions are not valid. We need to ensure this library is trim/AOT compatible so people can use it in native AOT applications.
cc @mgravell
The text was updated successfully, but these errors were encountered: