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
2 changes: 1 addition & 1 deletion Version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.0-beta.4
1.1.0-beta.5
16 changes: 16 additions & 0 deletions src/Id/Json/GuidIdJsonConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@ namespace Wrap.Json;
internal sealed class GuidIdJsonConverter<TId> : IdJsonConverter<TId, Guid>
where TId : GuidId<TId>, new()
{
/// <summary>
/// Write an <see cref="IId{TId, TValue}"/> type value.
/// </summary>
/// <param name="writer">Json Writer.</param>
/// <param name="value">ID value.</param>
/// <param name="options">JSON options.</param>
public override void Write(Utf8JsonWriter writer, TId value, JsonSerializerOptions options) =>
writer.WriteStringValue(value switch
{
TId id =>
id.Value.ToString(),

_ =>
null
});

/// <summary>
/// Read <see cref="GuidId{TId}"/> type value.
/// </summary>
Expand Down
16 changes: 0 additions & 16 deletions src/Id/Json/IdJsonConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,6 @@ internal abstract class IdJsonConverter<TId, TValue> : JsonConverter<TId>
where TId : Id<TId, TValue>, new()
where TValue : struct
{
/// <summary>
/// Write an <see cref="IId{TId, TValue}"/> type value.
/// </summary>
/// <param name="writer">Json Writer.</param>
/// <param name="value">ID value.</param>
/// <param name="options">JSON options.</param>
public override void Write(Utf8JsonWriter writer, TId value, JsonSerializerOptions options) =>
writer.WriteStringValue(value switch
{
TId id =>
id.Value.ToString(),

_ =>
null
});

/// <summary>
/// Try to skip the JSON token (because it hasn't been matched correctly) and return a default value.
/// </summary>
Expand Down
9 changes: 9 additions & 0 deletions src/Id/Json/IntIdJsonConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ namespace Wrap.Json;
internal sealed class IntIdJsonConverter<TId> : IdJsonConverter<TId, int>
where TId : IntId<TId>, new()
{
/// <summary>
/// Write an <see cref="IId{TId, TValue}"/> type value.
/// </summary>
/// <param name="writer">Json Writer.</param>
/// <param name="value">ID value.</param>
/// <param name="options">JSON options.</param>
public override void Write(Utf8JsonWriter writer, TId value, JsonSerializerOptions options) =>
writer.WriteNumberValue(value.Value);

/// <summary>
/// Read <see cref="GuidId{TId}"/> type value.
/// </summary>
Expand Down
9 changes: 9 additions & 0 deletions src/Id/Json/LongIdJsonConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ namespace Wrap.Json;
internal sealed class LongIdJsonConverter<TId> : IdJsonConverter<TId, long>
where TId : LongId<TId>, new()
{
/// <summary>
/// Write an <see cref="IId{TId, TValue}"/> type value.
/// </summary>
/// <param name="writer">Json Writer.</param>
/// <param name="value">ID value.</param>
/// <param name="options">JSON options.</param>
public override void Write(Utf8JsonWriter writer, TId value, JsonSerializerOptions options) =>
writer.WriteNumberValue(value.Value);

/// <summary>
/// Read <see cref="GuidId{TId}"/> type value.
/// </summary>
Expand Down
9 changes: 9 additions & 0 deletions src/Id/Json/UIntIdJsonConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ namespace Wrap.Json;
internal sealed class UIntIdJsonConverter<TId> : IdJsonConverter<TId, uint>
where TId : UIntId<TId>, new()
{
/// <summary>
/// Write an <see cref="IId{TId, TValue}"/> type value.
/// </summary>
/// <param name="writer">Json Writer.</param>
/// <param name="value">ID value.</param>
/// <param name="options">JSON options.</param>
public override void Write(Utf8JsonWriter writer, TId value, JsonSerializerOptions options) =>
writer.WriteNumberValue(value.Value);

/// <summary>
/// Read <see cref="GuidId{TId}"/> type value.
/// </summary>
Expand Down
9 changes: 9 additions & 0 deletions src/Id/Json/ULongIdJsonConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ namespace Wrap.Json;
internal sealed class ULongIdJsonConverter<TId> : IdJsonConverter<TId, ulong>
where TId : ULongId<TId>, new()
{
/// <summary>
/// Write an <see cref="IId{TId, TValue}"/> type value.
/// </summary>
/// <param name="writer">Json Writer.</param>
/// <param name="value">ID value.</param>
/// <param name="options">JSON options.</param>
public override void Write(Utf8JsonWriter writer, TId value, JsonSerializerOptions options) =>
writer.WriteNumberValue(value.Value);

/// <summary>
/// Read <see cref="GuidId{TId}"/> type value.
/// </summary>
Expand Down