Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Broken floating-point source serialization for .NET Framework #8696

Open
Labels
8.xRelates to a 8.x client version Category: Bug
@onyxmaster

Description

Elastic.Clients.Elasticsearch version:
8.19.5

Elasticsearch version:
Not relevant

.NET runtime version:
.NET Framework 4.8.1

Operating system version:
Windows 11

Description of the problem including expected versus actual behavior:
Floating-point serialization is broken for source serializer on .NET Framework, because the System.Memory shim (even the latest version version 4.6.3) for .NET Framework, does not support specifying custom precision for serialized data.

It crashes with NotSupportedException "The 'G' format combined with a precision is not supported.", stack trace is as follows:

System.Memory.dll!System.Buffers.Text.Utf8Formatter.TryFormatFloatingPoint<double>(double value, System.Span<byte> destination, out int bytesWritten, System.Buffers.StandardFormat format)
	at /_/src/System.Memory/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Float.cs(79)
System.Memory.dll!System.Buffers.Text.Utf8Formatter.TryFormat(double value, System.Span<byte> destination, out int bytesWritten, System.Buffers.StandardFormat format)
	at /_/src/System.Memory/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Float.cs(33)
Elastic.Clients.Elasticsearch.dll!Elastic.Clients.Elasticsearch.Serialization.DoubleWithFractionalPortionConverter.Write(System.Text.Json.Utf8JsonWriter writer, double value, System.Text.Json.JsonSerializerOptions options)
	at /_/src/Elastic.Clients.Elasticsearch/_Shared/Next/DoubleWithFractionalPortionConverter.cs(94)
System.Text.Json.dll!System.Text.Json.Serialization.JsonConverter<double>.TryWrite(System.Text.Json.Utf8JsonWriter writer, double value, System.Text.Json.JsonSerializerOptions options, ref System.Text.Json.WriteStack state)
	at /_/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonConverterOfT.cs(354)
System.Text.Json.dll!System.Text.Json.Serialization.JsonConverter<double>.WriteCore(System.Text.Json.Utf8JsonWriter writer, double value, System.Text.Json.JsonSerializerOptions options, ref System.Text.Json.WriteStack state)
	at /_/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonConverterOfT.WriteCore.cs(16)
System.Text.Json.dll!System.Text.Json.Serialization.Metadata.JsonTypeInfo<double>.Serialize(System.IO.Stream utf8Json, double rootValue, object rootValueBoxed)
	at /_/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonTypeInfoOfT.WriteHelpers.cs(314)
System.Text.Json.dll!System.Text.Json.JsonSerializer.Serialize<double>(System.IO.Stream utf8Json, double value, System.Text.Json.JsonSerializerOptions options)
	at /_/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializer.Write.Stream.cs(83)
Elastic.Transport.dll!Elastic.Transport.SystemTextJsonSerializer.Serialize<double>(double data, System.IO.Stream stream, Elastic.Transport.SerializationFormatting formatting)
	at Elastic.Transport\SystemTextJsonSerializer.cs(66)

Steps to reproduce:

using System.IO;
using Elastic.Clients.Elasticsearch;
using Xunit;
namespace Dnet.Elastic.Tests;
public sealed class SerializationTests
{
 [Fact]
 public void Works()
 {
 using var client = new ElasticsearchClientSettings();
 client.SourceSerializer.Serialize(2.3, new MemoryStream());
 }
}

Expected behavior
I expect floating-point source serialization to work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    8.xRelates to a 8.x client version Category: Bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /