Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions JsonExtensions/Http/HttpExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ public async Task<JsonElement> GetJsonAsync(
return await response.Content.ReadAsJsonAsync(cancellationToken).ConfigureAwait(false);
}

/// <summary>
/// Sends a GET request to <paramref name="requestUri"/> and deserializes the response body as a <see cref="JsonElement"/>.
/// </summary>
/// <inheritdoc cref="GetJsonAsync(HttpClient, Uri, CancellationToken)" />
public async Task<JsonElement> GetJsonAsync(
string requestUri,
CancellationToken cancellationToken = default
Expand Down
108 changes: 24 additions & 84 deletions JsonExtensions/Writing/OptionalExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ public void WriteNumberValue(byte? value)
writer.WriteNullValue();
}

/// <summary>
/// Writes <paramref name="value"/> as a JSON number, or a JSON null if <paramref name="value"/> is null.
/// </summary>
/// <inheritdoc cref="WriteNumberValue(Utf8JsonWriter, byte?)" />
public void WriteNumberValue(decimal? value)
{
if (value is not null)
Expand All @@ -55,9 +53,7 @@ public void WriteNumberValue(decimal? value)
writer.WriteNullValue();
}

/// <summary>
/// Writes <paramref name="value"/> as a JSON number, or a JSON null if <paramref name="value"/> is null.
/// </summary>
/// <inheritdoc cref="WriteNumberValue(Utf8JsonWriter, byte?)"/>
public void WriteNumberValue(double? value)
{
if (value is not null)
Expand All @@ -66,9 +62,7 @@ public void WriteNumberValue(double? value)
writer.WriteNullValue();
}

/// <summary>
/// Writes <paramref name="value"/> as a JSON number, or a JSON null if <paramref name="value"/> is null.
/// </summary>
/// <inheritdoc cref="WriteNumberValue(Utf8JsonWriter, byte?)"/>
public void WriteNumberValue(float? value)
{
if (value is not null)
Expand All @@ -77,9 +71,7 @@ public void WriteNumberValue(float? value)
writer.WriteNullValue();
}

/// <summary>
/// Writes <paramref name="value"/> as a JSON number, or a JSON null if <paramref name="value"/> is null.
/// </summary>
/// <inheritdoc cref="WriteNumberValue(Utf8JsonWriter, byte?)"/>
public void WriteNumberValue(int? value)
{
if (value is not null)
Expand All @@ -88,9 +80,7 @@ public void WriteNumberValue(int? value)
writer.WriteNullValue();
}

/// <summary>
/// Writes <paramref name="value"/> as a JSON number, or a JSON null if <paramref name="value"/> is null.
/// </summary>
/// <inheritdoc cref="WriteNumberValue(Utf8JsonWriter, byte?)"/>
public void WriteNumberValue(long? value)
{
if (value is not null)
Expand All @@ -99,9 +89,7 @@ public void WriteNumberValue(long? value)
writer.WriteNullValue();
}

/// <summary>
/// Writes <paramref name="value"/> as a JSON number, or a JSON null if <paramref name="value"/> is null.
/// </summary>
/// <inheritdoc cref="WriteNumberValue(Utf8JsonWriter, byte?)"/>
public void WriteNumberValue(sbyte? value)
{
if (value is not null)
Expand All @@ -110,9 +98,7 @@ public void WriteNumberValue(sbyte? value)
writer.WriteNullValue();
}

/// <summary>
/// Writes <paramref name="value"/> as a JSON number, or a JSON null if <paramref name="value"/> is null.
/// </summary>
/// <inheritdoc cref="WriteNumberValue(Utf8JsonWriter, byte?)"/>
public void WriteNumberValue(short? value)
{
if (value is not null)
Expand All @@ -121,9 +107,7 @@ public void WriteNumberValue(short? value)
writer.WriteNullValue();
}

/// <summary>
/// Writes <paramref name="value"/> as a JSON number, or a JSON null if <paramref name="value"/> is null.
/// </summary>
/// <inheritdoc cref="WriteNumberValue(Utf8JsonWriter, byte?)"/>
public void WriteNumberValue(uint? value)
{
if (value is not null)
Expand All @@ -132,9 +116,7 @@ public void WriteNumberValue(uint? value)
writer.WriteNullValue();
}

/// <summary>
/// Writes <paramref name="value"/> as a JSON number, or a JSON null if <paramref name="value"/> is null.
/// </summary>
/// <inheritdoc cref="WriteNumberValue(Utf8JsonWriter, byte?)"/>
public void WriteNumberValue(ulong? value)
{
if (value is not null)
Expand All @@ -143,9 +125,7 @@ public void WriteNumberValue(ulong? value)
writer.WriteNullValue();
}

/// <summary>
/// Writes <paramref name="value"/> as a JSON number, or a JSON null if <paramref name="value"/> is null.
/// </summary>
/// <inheritdoc cref="WriteNumberValue(Utf8JsonWriter, byte?)"/>
public void WriteNumberValue(ushort? value)
{
if (value is not null)
Expand All @@ -164,100 +144,70 @@ public void WriteNumber(string propertyName, byte? value)
writer.WriteNumberValue(value);
}

/// <summary>
/// Writes a property named <paramref name="propertyName"/> with a numeric value,
/// or a JSON null if <paramref name="value"/> is null.
/// </summary>
/// <inheritdoc cref="WriteNumber(Utf8JsonWriter, string, byte?)"/>
public void WriteNumber(string propertyName, decimal? value)
{
writer.WritePropertyName(propertyName);
writer.WriteNumberValue(value);
}

/// <summary>
/// Writes a property named <paramref name="propertyName"/> with a numeric value,
/// or a JSON null if <paramref name="value"/> is null.
/// </summary>
/// <inheritdoc cref="WriteNumber(Utf8JsonWriter, string, byte?)"/>
public void WriteNumber(string propertyName, double? value)
{
writer.WritePropertyName(propertyName);
writer.WriteNumberValue(value);
}

/// <summary>
/// Writes a property named <paramref name="propertyName"/> with a numeric value,
/// or a JSON null if <paramref name="value"/> is null.
/// </summary>
/// <inheritdoc cref="WriteNumber(Utf8JsonWriter, string, byte?)"/>
public void WriteNumber(string propertyName, float? value)
{
writer.WritePropertyName(propertyName);
writer.WriteNumberValue(value);
}

/// <summary>
/// Writes a property named <paramref name="propertyName"/> with a numeric value,
/// or a JSON null if <paramref name="value"/> is null.
/// </summary>
/// <inheritdoc cref="WriteNumber(Utf8JsonWriter, string, byte?)"/>
public void WriteNumber(string propertyName, int? value)
{
writer.WritePropertyName(propertyName);
writer.WriteNumberValue(value);
}

/// <summary>
/// Writes a property named <paramref name="propertyName"/> with a numeric value,
/// or a JSON null if <paramref name="value"/> is null.
/// </summary>
/// <inheritdoc cref="WriteNumber(Utf8JsonWriter, string, byte?)"/>
public void WriteNumber(string propertyName, long? value)
{
writer.WritePropertyName(propertyName);
writer.WriteNumberValue(value);
}

/// <summary>
/// Writes a property named <paramref name="propertyName"/> with a numeric value,
/// or a JSON null if <paramref name="value"/> is null.
/// </summary>
/// <inheritdoc cref="WriteNumber(Utf8JsonWriter, string, byte?)"/>
public void WriteNumber(string propertyName, sbyte? value)
{
writer.WritePropertyName(propertyName);
writer.WriteNumberValue(value);
}

/// <summary>
/// Writes a property named <paramref name="propertyName"/> with a numeric value,
/// or a JSON null if <paramref name="value"/> is null.
/// </summary>
/// <inheritdoc cref="WriteNumber(Utf8JsonWriter, string, byte?)"/>
public void WriteNumber(string propertyName, short? value)
{
writer.WritePropertyName(propertyName);
writer.WriteNumberValue(value);
}

/// <summary>
/// Writes a property named <paramref name="propertyName"/> with a numeric value,
/// or a JSON null if <paramref name="value"/> is null.
/// </summary>
/// <inheritdoc cref="WriteNumber(Utf8JsonWriter, string, byte?)"/>
public void WriteNumber(string propertyName, uint? value)
{
writer.WritePropertyName(propertyName);
writer.WriteNumberValue(value);
}

/// <summary>
/// Writes a property named <paramref name="propertyName"/> with a numeric value,
/// or a JSON null if <paramref name="value"/> is null.
/// </summary>
/// <inheritdoc cref="WriteNumber(Utf8JsonWriter, string, byte?)"/>
public void WriteNumber(string propertyName, ulong? value)
{
writer.WritePropertyName(propertyName);
writer.WriteNumberValue(value);
}

/// <summary>
/// Writes a property named <paramref name="propertyName"/> with a numeric value,
/// or a JSON null if <paramref name="value"/> is null.
/// </summary>
/// <inheritdoc cref="WriteNumber(Utf8JsonWriter, string, byte?)"/>
public void WriteNumber(string propertyName, ushort? value)
{
writer.WritePropertyName(propertyName);
Expand All @@ -275,9 +225,7 @@ public void WriteStringValue(DateTime? value)
writer.WriteNullValue();
}

/// <summary>
/// Writes <paramref name="value"/> as a JSON string, or a JSON null if <paramref name="value"/> is null.
/// </summary>
/// <inheritdoc cref="WriteStringValue(Utf8JsonWriter, DateTime?)"/>
public void WriteStringValue(DateTimeOffset? value)
{
if (value is not null)
Expand All @@ -286,9 +234,7 @@ public void WriteStringValue(DateTimeOffset? value)
writer.WriteNullValue();
}

/// <summary>
/// Writes <paramref name="value"/> as a JSON string, or a JSON null if <paramref name="value"/> is null.
/// </summary>
/// <inheritdoc cref="WriteStringValue(Utf8JsonWriter, DateTime?)"/>
public void WriteStringValue(Guid? value)
{
if (value is not null)
Expand All @@ -307,20 +253,14 @@ public void WriteString(string propertyName, DateTime? value)
writer.WriteStringValue(value);
}

/// <summary>
/// Writes a property named <paramref name="propertyName"/> with a string value,
/// or a JSON null if <paramref name="value"/> is null.
/// </summary>
/// <inheritdoc cref="WriteString(Utf8JsonWriter, string, DateTime?)"/>
public void WriteString(string propertyName, DateTimeOffset? value)
{
writer.WritePropertyName(propertyName);
writer.WriteStringValue(value);
}

/// <summary>
/// Writes a property named <paramref name="propertyName"/> with a string value,
/// or a JSON null if <paramref name="value"/> is null.
/// </summary>
/// <inheritdoc cref="WriteString(Utf8JsonWriter, string, DateTime?)"/>
public void WriteString(string propertyName, Guid? value)
{
writer.WritePropertyName(propertyName);
Expand Down