JsonValueNotTrimmable<TValue>
Not trim-safe since it calls JsonSerializer.Serialize(JsonSerializerOptions).
using System.Diagnostics.CodeAnalysis;
namespace System.Text.Json.Nodes
{
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("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.")]
internal sealed class JsonValueNotTrimmable<TValue> : JsonValue<TValue>
{
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("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.")]
public JsonValueNotTrimmable(TValue value, JsonNodeOptions? options = default(JsonNodeOptions?))
: base(value, options)
{
}
[System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "The ctor is marked RequiresUnreferencedCode.")]
public override void WriteTo(Utf8JsonWriter writer, JsonSerializerOptions options = null)
{
if (writer == null)
ThrowHelper.ThrowArgumentNullException("writer");
JsonSerializer.Serialize<TValue>(writer, _value, options);
}
}
}