-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Update doc for exceptions thrown during serialization #33400
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,10 @@ internal static TValue Deserialize<TValue>(ref Utf8JsonReader reader, JsonSerial | |
/// <exception cref="ArgumentException"> | ||
/// <paramref name="reader"/> is using unsupported options. | ||
/// </exception> | ||
/// <exception cref="NotSupportedException"> | ||
/// There is no compatible <see cref="System.Text.Json.Serialization.JsonConverter"/> | ||
/// for <typeparamref name="TValue"/> or its serializable members. | ||
/// </exception> | ||
/// <remarks> | ||
/// <para> | ||
/// If the <see cref="Utf8JsonReader.TokenType"/> property of <paramref name="reader"/> | ||
|
@@ -95,7 +99,7 @@ public static TValue Deserialize<TValue>(ref Utf8JsonReader reader, JsonSerializ | |
/// <param name="returnType">The type of the object to convert to and return.</param> | ||
/// <param name="options">Options to control the serializer behavior during reading.</param> | ||
/// <exception cref="ArgumentNullException"> | ||
/// Thrown if <paramref name="returnType"/> is null. | ||
/// <paramref name="returnType"/> is <see langword="null"/>. | ||
/// </exception> | ||
/// <exception cref="JsonException"> | ||
/// Thrown when the JSON is invalid, | ||
|
@@ -105,6 +109,10 @@ public static TValue Deserialize<TValue>(ref Utf8JsonReader reader, JsonSerializ | |
/// <exception cref="ArgumentException"> | ||
/// <paramref name="reader"/> is using unsupported options. | ||
/// </exception> | ||
/// <exception cref="NotSupportedException"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reminder: Port these to api docs so they become visible on the docs site: |
||
/// There is no compatible <see cref="System.Text.Json.Serialization.JsonConverter"/> | ||
/// for <paramref name="returnType"/> or its serializable members. | ||
/// </exception> | ||
/// <remarks> | ||
/// <para> | ||
/// If the <see cref="Utf8JsonReader.TokenType"/> property of <paramref name="reader"/> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,6 +114,13 @@ internal JsonConverter DetermineConverter(Type? parentClassType, Type runtimePro | |
/// <returns> | ||
/// The converter for the given type. | ||
/// </returns> | ||
/// <exception cref="InvalidOperationException"> | ||
/// The configured <see cref="JsonConverter"/> for <paramref name="typeToConvert"/> returned an invalid converter. | ||
/// </exception> | ||
/// <exception cref="NotSupportedException"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where do the checks happen that result in NSE here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If a converter is not yet cached, it is created from this method and currently the collection-based converters will throw NSE for not supported collections like multidimensional array. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
What about the non-collection-based converters/other converters? Is it ever possible that a converter couldn't be created for a particular type (one that we don't support today)? For example, what is the exception that we throw if someone happen to have a |
||
/// There is no compatible <see cref="System.Text.Json.Serialization.JsonConverter"/> | ||
/// for <paramref name="typeToConvert"/> or its serializable members. | ||
/// </exception> | ||
public JsonConverter GetConverter(Type typeToConvert) | ||
{ | ||
if (_converters.TryGetValue(typeToConvert, out JsonConverter? converter)) | ||
|
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.
We should make sure to update these manually in https://github.com/dotnet/dotnet-api-docs as well.
cc @carlossanlop