Skip to content

Commit

Permalink
Support too large numbers for long value in NumberStringConverter, fa…
Browse files Browse the repository at this point in the history
…ll back to string
  • Loading branch information
JKorf committed Aug 2, 2024
1 parent 27597bc commit ca9a711
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ public class NumberStringConverter : JsonConverter<string?>
return null;

if (reader.TokenType == JsonTokenType.Number)
return reader.GetInt64().ToString();
{
if (reader.TryGetInt64(out var value))
return value.ToString();

return reader.GetDecimal().ToString();
}

return reader.GetString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,13 @@ private static void CheckValues(string method, string property, Type propertyTyp
if (time != DateTimeConverter.ParseFromString(jsonValue.Value<string>()!))
throw new Exception($"{method}: {property} not equal: {jsonValue.Value<string>()} vs {time}");
}
else if (objectValue is bool bl)
{
if (bl && jsonValue.Value<string>() != "1")
throw new Exception($"{method}: {property} not equal: {jsonValue.Value<string>()} vs {bl}");
if (!bl && jsonValue.Value<string>() != "0")
throw new Exception($"{method}: {property} not equal: {jsonValue.Value<string>()} vs {bl}");
}
else if (propertyType.IsEnum || Nullable.GetUnderlyingType(propertyType)?.IsEnum == true)
{
// TODO enum comparing
Expand Down
4 changes: 2 additions & 2 deletions CryptoExchange.Net/Testing/TestHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ public static void CheckSignature(
if (disableOrdering)
client.OrderParameters = false;

var uriParams = client.ParameterPositions[method] == HttpMethodParameterPosition.InUri ? client.CreateParameterDictionary(parameters) : new Dictionary<string, object>();
var bodyParams = client.ParameterPositions[method] == HttpMethodParameterPosition.InBody ? client.CreateParameterDictionary(parameters) : new Dictionary<string, object>();
var uriParams = client.ParameterPositions[method] == HttpMethodParameterPosition.InUri ? client.CreateParameterDictionary(parameters) : null;
var bodyParams = client.ParameterPositions[method] == HttpMethodParameterPosition.InBody ? client.CreateParameterDictionary(parameters) : null;

var headers = new Dictionary<string, string>();

Expand Down

0 comments on commit ca9a711

Please sign in to comment.