Repository navigation
Ignore From when serializing a JsonPatchDocument for add, remove, rep… - #64457
Conversation
…lace and test operations
|
Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime. |
mikekistler
left a comment
There was a problem hiding this comment.
I like this fix! @Youssef1313 what do you think?
| ~Microsoft.AspNetCore.JsonPatch.SystemTextJson.Operations.Operation<TModel>.Operation(string op, string path, string from, object value) -> void | ||
| ~Microsoft.AspNetCore.JsonPatch.SystemTextJson.Operations.Operation<TModel>.Operation(string op, string path, string from) -> void | ||
| ~Microsoft.AspNetCore.JsonPatch.SystemTextJson.Operations.OperationBase.from.get -> string | ||
| ~Microsoft.AspNetCore.JsonPatch.SystemTextJson.Operations.OperationBase.from.set -> void |
There was a problem hiding this comment.
This looks like a breaking change to the public API.
|
@akshay-zz Sorry for the delay reviewing this PR. This is something we're interested in taking though. Are you still interested in working on this PR? |
|
@halter73 yes, I'm interested in working in the PR. I will work this pr comment "Given the property is named in camelCase, it might be worth adding a test for the other one to ensure that ShouldSerializeFrom works correctly." Anything else you want me to take care? |
|
@akshay-zz There is also a breaking change, is that necessary for this PR? |
| { | ||
| // While ShouldSerializeValue appears unused. Be careful if you remove it. | ||
| // It decides whether or not the value property is serialized. | ||
| // It's used by STJ for deciding the JsonIgnore (WhenWritingDefault) |
There was a problem hiding this comment.
This comment doesn't make sense. It's used below at line 51. Unless STJ is doing something internally for properties named ShouldSerializeValue?
There was a problem hiding this comment.
Oh, the read at line 51 is actually always true.
If ShouldSerializeValue wasn't true, then we are always default, and we have already JsonIgnore for default.
There was a problem hiding this comment.
I deleted the condition at line 51. Actually if the condition was possible to be false, we would end up with syntactically invalid JSON altogether because STJ would have already written the property name and the colon, and then we would have skipped writing a value completely.
So I kept relying on the JsonIgnore with condition WhenWritingDefault.
| this.from = from; | ||
| } | ||
|
|
||
| public bool ShouldSerializeFrom() |
There was a problem hiding this comment.
We should add a comment here saying it's unused. Just kept around since it's public API. Maybe even mark it obsolete?
|
/backport to release/11.0-preview7 |
|
Started backporting to |
Ignore "From" when serializing a JsonPatchDocument for "add", "remove", "replace" and "test" operations
Summary of the changes (Less than 80 chars)
Description
Fixes #63862
Fixes #64123
#64031 Pr got closed mistakenly by @martincostello. Creating new one as we don't have the right to reopen it.