-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Automatically port System.Text.Json.JsonSerializerOptions #2879
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
rpetrusha
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made a number of changes, if you'd like to review them, @carlossanlop. I'll merge when the build completes successfully.
Exception conditions were appearing multiple times in the file. Was there a change to your porting tool that might have caused this?
@rpetrusha I doubt it, unless you're seeing the same exceptions in all the PRs I submitted for Json yesterday. What was the error? Maybe it was an intermittent issue in the Docs build? Edit: I see what you mean. I thought you meant an exception thrown during the build process. Let me check the code. |
jozkee
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments.
|
@rpetrusha It's not my tool's fault, I ran it again and all the exceptions were added only once. |
Co-Authored-By: David Cantu <[email protected]>
|
I addressed the comments and fixed some missing values. The only thing blocking this from getting merged is the question to @ahsonkhan |
Co-Authored-By: Ahson Khan <[email protected]>
|
@rpetrusha the last comment in this PR has been addressed. If the build passes, I think we can get this merged. |
ahsonkhan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partially reviewed. Left some feedback.
Co-Authored-By: Ahson Khan <[email protected]>
|
I'll merge this PR now, @carlossanlop. |
| This property can be set to <xref:System.Text.Json.JsonNamingPolicy.CamelCase?displayProperty=nameWithType> to specify a camel-casing policy. | ||
| This property can be set to <xref:System.Text.Json.JsonNamingPolicy.CamelCase> to specify a camel-casing policy. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This remark got duplicated with the latest change.
| ## Remarks | ||
| Once serialization or deserialization occurs, the list cannot be modified. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should state, "should not be modified", not cannot. There is nothing preventing the caller from modifying the list. The changes just won't be reflected when (de)serializing.
cc @steveharter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The caller cannot modify the list. They will get an InvalidOperationException.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really? Interesting. We should document the exception then, no? Similar to other properties:
https://docs.microsoft.com/en-us/dotnet/api/system.text.json.jsonserializeroptions.allowtrailingcommas?view=netcore-3.0#exceptions
Verified, yep.
[Fact]
public static void ConverterWithCallback()
{
const string json = @"{""Name"":""MyName""}";
var options = new JsonSerializerOptions();
options.Converters.Add(new CustomerCallbackConverter());
Customer customer = JsonSerializer.Deserialize<Customer>(json, options);
Assert.Equal("MyNameHello!", customer.Name);
// Throws System.InvalidOperationException : Serializer options cannot be changed once serialization or deserialization has occurred.
options.Converters.Add(new CustomerCallbackConverter());
}| <summary>To be added.</summary> | ||
| <value>To be added.</value> | ||
| <summary>Gets or sets a value that determines whether <see langword="null" /> values are ignored during serialization and deserialization. The default value is <see langword="false" />.</summary> | ||
| <value><see langword="true" /> to ignore null values during serialization and deserialization; otherwise, see langword="false" />.</value> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is missing a start tag
| <value><see langword="true" /> to ignore null values during serialization and deserialization; otherwise, see langword="false" />.</value> | |
| <value><see langword="true" /> to ignore null values during serialization and deserialization; otherwise, <see langword="false" />.</value> |
| <Docs> | ||
| <summary>To be added.</summary> | ||
| <value>To be added.</value> | ||
| <summary>Gets or sets a value that determines whether <see langword="null" /> values are ignored during serialization and deserialization. The default value is <see langword="false" />.</summary> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we have "the default value" specified in the summary text in some cases, but in remarks in others. Worth being consistent and moving them all to the remarks?
| ## Remarks | ||
| There is a performance cost associated with case-insensitie comparison (that is, when `PropertyNameCaseInsensitive` is `true`). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| There is a performance cost associated with case-insensitie comparison (that is, when `PropertyNameCaseInsensitive` is `true`). | |
| There is a performance cost associated with case-insensitive comparison (that is, when `PropertyNameCaseInsensitive` is `true`). |
| <value>To be added.</value> | ||
| <remarks>To be added.</remarks> | ||
| <summary>Gets or sets a value that specifies the policy used to convert a property's name on an object to another format, such as camel-casing. </summary> | ||
| <value>One of the enum values from <see cref="T:System.Text.Json.JsonNamingPolicy" />.</value> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JsonNamingPolicy is not an enum.
| <value>One of the enum values from <see cref="T:System.Text.Json.JsonNamingPolicy" />.</value> | |
| <value>An instance of a <see cref="T:System.Text.Json.JsonNamingPolicy" />.</value> |
| <value>To be added.</value> | ||
| <remarks>To be added.</remarks> | ||
| <summary>Gets or sets a value that defines how comments are handled during deserialization.</summary> | ||
| <value>A value that indicates whether comments are allowed, disallowed, or skipped.</value> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The enum value JsonCommentHandling.Allow isn't supported here.
| <value>A value that indicates whether comments are allowed, disallowed, or skipped.</value> | |
| <value>A value that indicates whether comments are disallowed or ignored.</value> |
| <summary>To be added.</summary> | ||
| <value>To be added.</value> | ||
| <remarks>To be added.</remarks> | ||
| <summary>Gets or sets a value that defines whether JSON should use pretty printing. By default, JSON is serialized without any extra white space.</summary> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"JSON using pretty printing" doesn't make sense.
| <summary>Gets or sets a value that defines whether JSON should use pretty printing. By default, JSON is serialized without any extra white space.</summary> | |
| <summary>Gets or sets a value that defines whether JSON should be written pretty printed. By default, JSON is serialized without any extra white space.</summary> |
| Pretty printing includes: | ||
| - Indenting nested JSON tokens. | ||
| - Adding new lines |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| - Adding new lines | |
| - Adding new lines between between consecutive JSON object or array elements. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some correctness feedback/typos.
New batch.