<PackageReference Include="System.Text.Json" Version="7.0.0-preview.1.22076.8" />

DefaultValueHolder

sealed class DefaultValueHolder
using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; namespace System.Text.Json.Serialization.Metadata { internal sealed class DefaultValueHolder { public object DefaultValue { get; } [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2067:UnrecognizedReflectionPattern", Justification = "GetUninitializedObject is only called on a struct. You can always create an instance of a struct.")] private DefaultValueHolder(Type type) { if (type.IsValueType && Nullable.GetUnderlyingType(type) == (Type)null) DefaultValue = RuntimeHelpers.GetUninitializedObject(type); } public bool IsDefaultValue(object value) { if (DefaultValue != null) return DefaultValue.Equals(value); return value == null; } public static DefaultValueHolder CreateHolder(Type type) { return new DefaultValueHolder(type); } } }