File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
src/Elastic.Clients.Elasticsearch/_Shared/Next Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,15 @@ internal sealed class DoubleWithFractionalPortionConverter :
1717 // https://github.com/dotnet/runtime/blob/main/src/libraries/System.Text.Json/src/System/Text/Json/JsonConstants.cs#L78
1818 public const int MaximumFormatLength = 128 + 2 ;
1919
20+ #if ! NETFRAMEWORK
21+ // Use G17 to ensure round-tripping of double values.
22+ // See here: https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings#the-g-format-specifier
2023 private static readonly StandardFormat DefaultFormat = StandardFormat . Parse ( "G17" ) ;
24+ #else
25+ // .NET Framework does not support a custom precision specifier with the G format.
26+ private static readonly StandardFormat DefaultFormat = StandardFormat . Parse ( "G" ) ;
27+ #endif
28+
2129 private static readonly JsonEncodedText NaN = JsonEncodedText . Encode ( "NaN"u8 ) ;
2230 private static readonly JsonEncodedText PositiveInfinity = JsonEncodedText . Encode ( "Infinity"u8 ) ;
2331 private static readonly JsonEncodedText NegativeInfinity = JsonEncodedText . Encode ( "-Infinity"u8 ) ;
Original file line number Diff line number Diff line change @@ -17,7 +17,15 @@ internal sealed class SingleWithFractionalPortionConverter :
1717 // https://github.com/dotnet/runtime/blob/main/src/libraries/System.Text.Json/src/System/Text/Json/JsonConstants.cs#L79
1818 public const int MaximumFormatLength = 128 + 2 ;
1919
20+ #if ! NETFRAMEWORK
21+ // Use G9 to ensure round-tripping of float values.
22+ // See here: https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings#the-g-format-specifier
2023 private static readonly StandardFormat DefaultFormat = StandardFormat . Parse ( "G9" ) ;
24+ #else
25+ // .NET Framework does not support a custom precision specifier with the G format.
26+ private static readonly StandardFormat DefaultFormat = StandardFormat . Parse ( "G" ) ;
27+ #endif
28+
2129 private static readonly JsonEncodedText NaN = JsonEncodedText . Encode ( "NaN"u8 ) ;
2230 private static readonly JsonEncodedText PositiveInfinity = JsonEncodedText . Encode ( "Infinity"u8 ) ;
2331 private static readonly JsonEncodedText NegativeInfinity = JsonEncodedText . Encode ( "-Infinity"u8 ) ;
You can’t perform that action at this time.
0 commit comments