Repository navigation
[release/5.0] Remove obsolete attribute from IgnoreNullValues - #41538
Conversation
* Update IgnoreNullValues obsoletion message * Add attributes to ref file
| public System.Text.Encodings.Web.JavaScriptEncoder? Encoder { get { throw null; } set { } } | ||
| [System.ObsoleteAttribute("To ignore null values when serializing, set DefaultIgnoreCondition to JsonIgnoreCondition.WhenWritingNull.", false)] | ||
| [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] | ||
| public bool IgnoreNullValues { get { throw null; } set { } } |
There was a problem hiding this comment.
This is going to impact folks who target net5.0 and use this API. Prior to this change, only folks using the package will have seen the obsolete attribute. Have you identified all the places upstack that will need to change as a result of this and made sure folks are ready to react to the change?
There was a problem hiding this comment.
Looks like a few in aspnetcore, blazor, lots of docs that need updates: https://github.com/search?p=3&q=JsonSerializerOptions+IgnoreNullValues+user%3Adotnet+user%3Amicrrosoft+user%3Aazure+extension%3Acs&type=Code
There was a problem hiding this comment.
I'll collate a list and send out a broadcast message to folks, with a target of getting this change in on Tuesday. Will be sure to follow up on doc changes.
There was a problem hiding this comment.
I think we should defer marking this API as obsolete to early in 6.0, given the state of the 5.0 release and upstream impact. It isn't a security, perf, or correctness issue, so to me, not worth the trade-off.
If we really want to mark it as EditorBrowsableState.Never, that is fine. Doing that doesn't require upstack code changes.
There was a problem hiding this comment.
The issue now is that it is inconsistently obsolete. When using the package folks get the obsolete warning but not when targeting ‘net5.0’ without the package. So we need to do something to make it consistent.
We could remove it from impl in 5.0 if the risk is too high.
We have rejected other new obsoletions at this point due to risk to the product.
There was a problem hiding this comment.
We could remove it from impl in 5.0 if the risk is too high.
+1
It makes sense to remove the obsolete from both ref and src (certainly for 5.0, and maybe even master). To me, it doesn't meet the bar for an obsoletion.
There was a problem hiding this comment.
The reason I had for obsoleting IgnoreNullValues was that we added a better API (DefaultIgnoreCondition) to provide the desired semantics. Also, IgnoreNullValues applies to both serialization and deserialization which is not desired (we don't think there's a good reason to ignore null values when deserializing).
There's logic ensuring that IgnoreNullValues and DefaultIgnoreCondition cannot both be used in the same options instance, so there is technically not much value in obsoleting the type at this late stage in the the release.
I'm fine with removing the obsolete attribute for 5.0. I'll make the change in this PR. I think we need to discuss whether to remove it in 6.0 as well - I'll bring this up offline.
Ports #41141 to release/5.0.- We want to have an accurate message here so that users don't have bugs due to value-type defaults being unintentionally ignored on serialization.- Also places theObsoleteandEditorBrowsableattributes on the property in the System.Text.Json ref file.The attribute was not added to the ref file earlier in the release (so the obsoletion had little visibility), and at this point it is rather late to do so given the risk and disruption to upstack callers.