From b04ec694212d1eb1a40919ec5ed3e7396adbff00 Mon Sep 17 00:00:00 2001 From: Layomi Akinrinade Date: Fri, 22 May 2020 10:19:15 -0700 Subject: [PATCH] Improve obsoletion message for IgnoreNullValues --- .../System/Text/Json/Serialization/JsonSerializerOptions.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.cs index 27dc1fe336964..05b2aec0a2faa 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.cs @@ -199,7 +199,7 @@ public JsonNamingPolicy? DictionaryKeyPolicy /// Thrown if this property is set after serialization or deserialization has occurred. /// or has been set to a non-default value. These properties cannot be used together. /// - [Obsolete("Use DefaultIgnoreCondition instead.", error: false)] + [Obsolete("To ignore null values when serializing, set DefaultIgnoreCondition to JsonIgnoreCondition.WhenWritingDefault.", error: false)] [EditorBrowsable(EditorBrowsableState.Never)] public bool IgnoreNullValues { @@ -211,7 +211,7 @@ public bool IgnoreNullValues { VerifyMutable(); - if (value == true && _defaultIgnoreCondition != JsonIgnoreCondition.Never) + if (value && _defaultIgnoreCondition != JsonIgnoreCondition.Never) { Debug.Assert(_defaultIgnoreCondition == JsonIgnoreCondition.WhenWritingDefault); throw new InvalidOperationException(SR.DefaultIgnoreConditionAlreadySpecified);