Skip to content

Commit

Permalink
Update doc and generic parameter name for JsonValue.GetValue (#56639)
Browse files Browse the repository at this point in the history
  • Loading branch information
steveharter committed Aug 3, 2021
1 parent 9be8c62 commit 7abe597
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/libraries/System.Text.Json/ref/System.Text.Json.cs
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ public abstract partial class JsonNode
public System.Text.Json.Nodes.JsonObject AsObject() { throw null; }
public System.Text.Json.Nodes.JsonValue AsValue() { throw null; }
public string GetPath() { throw null; }
public virtual TValue GetValue<TValue>() { throw null; }
public virtual T GetValue<T>() { throw null; }
public static explicit operator bool (System.Text.Json.Nodes.JsonNode value) { throw null; }
public static explicit operator byte (System.Text.Json.Nodes.JsonNode value) { throw null; }
public static explicit operator char (System.Text.Json.Nodes.JsonNode value) { throw null; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;

namespace System.Text.Json.Nodes
{
Expand Down Expand Up @@ -165,14 +164,23 @@ public JsonNode Root
/// <summary>
/// Gets the value for the current <see cref="JsonValue"/>.
/// </summary>
/// <remarks>
/// {T} can be the type or base type of the underlying value.
/// If the underlying value is a <see cref="JsonElement"/> then {T} can also be the type of any primitive
/// value supported by current <see cref="JsonElement"/>.
/// Specifying the <see cref="object"/> type for {T} will always succeed and return the underlying value as <see cref="object"/>.<br />
/// The underlying value of a <see cref="JsonValue"/> after deserialization is an instance of <see cref="JsonElement"/>,
/// otherwise it's the value specified when the <see cref="JsonValue"/> was created.
/// </remarks>
/// <seealso cref="System.Text.Json.Nodes.JsonValue.TryGetValue"></seealso>
/// <exception cref="FormatException">
/// The current <see cref="JsonNode"/> cannot be represented as a {TValue}.
/// The current <see cref="JsonNode"/> cannot be represented as a {T}.
/// </exception>
/// <exception cref="InvalidOperationException">
/// The current <see cref="JsonNode"/> is not a <see cref="JsonValue"/> or
/// is not compatible with {TValue}.
/// is not compatible with {T}.
/// </exception>
public virtual TValue GetValue<TValue>() =>
public virtual T GetValue<T>() =>
throw new InvalidOperationException(SR.Format(SR.NodeWrongType, nameof(JsonValue)));

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@ internal override void GetPath(List<string> path, JsonNode? child)
/// <summary>
/// Tries to obtain the current JSON value and returns a value that indicates whether the operation succeeded.
/// </summary>
/// <remarks>
/// {T} can be the type or base type of the underlying value.
/// If the underlying value is a <see cref="JsonElement"/> then {T} can also be the type of any primitive
/// value supported by current <see cref="JsonElement"/>.
/// Specifying the <see cref="object"/> type for {T} will always succeed and return the underlying value as <see cref="object"/>.<br />
/// The underlying value of a <see cref="JsonValue"/> after deserialization is an instance of <see cref="JsonElement"/>,
/// otherwise it's the value specified when the <see cref="JsonValue"/> was created.
/// </remarks>
/// <seealso cref="JsonNode.GetValue{T}"></seealso>
/// <typeparam name="T">The type of value to obtain.</typeparam>
/// <param name="value">When this method returns, contains the parsed value.</param>
/// <returns><see langword="true"/> if the value can be successfully obtained; otherwise, <see langword="false"/>.</returns>
Expand Down

0 comments on commit 7abe597

Please sign in to comment.