Improve obsoletion message for IgnoreNullValues (#36886)
authorLayomi Akinrinade <laakinri@microsoft.com>
Fri, 22 May 2020 21:49:34 +0000 (17:49 -0400)
committerGitHub <noreply@github.com>
Fri, 22 May 2020 21:49:34 +0000 (14:49 -0700)
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.cs

index 27dc1fe..05b2aec 100644 (file)
@@ -199,7 +199,7 @@ namespace System.Text.Json
         /// Thrown if this property is set after serialization or deserialization has occurred.
         /// or <see cref="DefaultIgnoreCondition"/> has been set to a non-default value. These properties cannot be used together.
         /// </exception>
-        [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 @@ namespace System.Text.Json
             {
                 VerifyMutable();
 
-                if (value == true && _defaultIgnoreCondition != JsonIgnoreCondition.Never)
+                if (value && _defaultIgnoreCondition != JsonIgnoreCondition.Never)
                 {
                     Debug.Assert(_defaultIgnoreCondition == JsonIgnoreCondition.WhenWritingDefault);
                     throw new InvalidOperationException(SR.DefaultIgnoreConditionAlreadySpecified);