Skip to content
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

Fix Stringified converters #7965

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Serialization;
namespace Elastic.Clients.Elasticsearch.Serialization;
#endif

internal sealed class StringifiedLongConverter : JsonConverter<long?>
internal sealed class StringifiedLongConverter : JsonConverter<long>
{
public override long? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => ReadStringifiedLong(ref reader);
public override long Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => ReadStringifiedLong(ref reader);

public override void Write(Utf8JsonWriter writer, long? value, JsonSerializerOptions options) => writer.WriteNumberValue(value.Value);
public override void Write(Utf8JsonWriter writer, long value, JsonSerializerOptions options) => writer.WriteNumberValue(value);

public static long ReadStringifiedLong(ref Utf8JsonReader reader)
{
Expand All @@ -39,11 +39,11 @@ public static long ReadStringifiedLong(ref Utf8JsonReader reader)
}
}

internal sealed class StringifiedIntegerConverter : JsonConverter<int?>
internal sealed class StringifiedIntegerConverter : JsonConverter<int>
{
public override int? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => ReadStringifiedInteger(ref reader);
public override int Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => ReadStringifiedInteger(ref reader);

public override void Write(Utf8JsonWriter writer, int? value, JsonSerializerOptions options) => writer.WriteNumberValue(value.Value);
public override void Write(Utf8JsonWriter writer, int value, JsonSerializerOptions options) => writer.WriteNumberValue(value);

public static int ReadStringifiedInteger(ref Utf8JsonReader reader)
{
Expand All @@ -66,11 +66,11 @@ public static int ReadStringifiedInteger(ref Utf8JsonReader reader)
}
}

internal sealed class StringifiedBoolConverter : JsonConverter<bool?>
internal sealed class StringifiedBoolConverter : JsonConverter<bool>
{
public override bool? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => ReadStringifiedBool(ref reader);
public override bool Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => ReadStringifiedBool(ref reader);

public override void Write(Utf8JsonWriter writer, bool? value, JsonSerializerOptions options) => writer.WriteBooleanValue(value.Value);
public override void Write(Utf8JsonWriter writer, bool value, JsonSerializerOptions options) => writer.WriteBooleanValue(value);

public static bool ReadStringifiedBool(ref Utf8JsonReader reader)
{
Expand Down