Skip to content

Commit a485d68

Browse files
committed
Fixed #775 deserialization of GeoBoundingFilter not using invariantculture, we now also force invariant culture on all strings formatted with the .F() extension method.
1 parent a7ef216 commit a485d68

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Diff for: src/Nest/Extensions/Extensions.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,12 @@ internal static void ThrowIfNull<T>(this T value, string name)
9696
if (value == null)
9797
throw new ArgumentNullException(name);
9898
}
99+
99100
internal static string F(this string format, params object[] args)
100101
{
102+
var c = CultureInfo.InvariantCulture;
101103
format.ThrowIfNull("format");
102-
return string.Format(format, args);
104+
return string.Format(c, format, args);
103105
}
104106
internal static string EscapedFormat(this string format, params object[] args)
105107
{

Diff for: src/Nest/Resolvers/Converters/Filters/GeoBoundingFilterConverter.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.CodeDom;
33
using System.Collections.Generic;
4+
using System.Globalization;
45
using System.Linq;
56
using System.Text;
67
using Newtonsoft.Json;
@@ -102,6 +103,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
102103

103104
private void ReadBox(IGeoBoundingBoxFilter filter, JsonReader reader)
104105
{
106+
var c = CultureInfo.InvariantCulture;
105107
reader.Read();
106108
if (reader.TokenType != JsonToken.StartObject)
107109
return;
@@ -120,11 +122,11 @@ private void ReadBox(IGeoBoundingBoxFilter filter, JsonReader reader)
120122
else if (reader.TokenType == JsonToken.StartArray)
121123
{
122124
var values = JArray.Load(reader).Values<double>();
123-
filter.TopLeft = string.Join(", ", values);
125+
filter.TopLeft = string.Join(", ", values.Select(v=>v.ToString(c)));
124126
reader.Read();
125127
reader.Read();
126128
values = JArray.Load(reader).Values<double>();
127-
filter.BottomRight =string.Join(", ", values);
129+
filter.BottomRight =string.Join(", ", values.Select(v=>v.ToString(c)));
128130
}
129131
else if (reader.TokenType == JsonToken.StartObject)
130132
{

0 commit comments

Comments
 (0)