1
0
mirror of https://github.com/JKorf/CryptoExchange.Net synced 2025-06-07 16:06:15 +00:00

Support too large numbers for long value in NumberStringConverter, fall back to string

This commit is contained in:
JKorf 2024-08-02 12:07:15 +02:00
parent 27597bc994
commit ca9a711f22
3 changed files with 15 additions and 3 deletions

View File

@ -17,7 +17,12 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
return null; return null;
if (reader.TokenType == JsonTokenType.Number) 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(); return reader.GetString();
} }

View File

@ -357,6 +357,13 @@ namespace CryptoExchange.Net.Testing.Comparers
if (time != DateTimeConverter.ParseFromString(jsonValue.Value<string>()!)) if (time != DateTimeConverter.ParseFromString(jsonValue.Value<string>()!))
throw new Exception($"{method}: {property} not equal: {jsonValue.Value<string>()} vs {time}"); 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) else if (propertyType.IsEnum || Nullable.GetUnderlyingType(propertyType)?.IsEnum == true)
{ {
// TODO enum comparing // TODO enum comparing

View File

@ -121,8 +121,8 @@ namespace CryptoExchange.Net.Testing
if (disableOrdering) if (disableOrdering)
client.OrderParameters = false; client.OrderParameters = false;
var uriParams = client.ParameterPositions[method] == HttpMethodParameterPosition.InUri ? 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) : new Dictionary<string, object>(); var bodyParams = client.ParameterPositions[method] == HttpMethodParameterPosition.InBody ? client.CreateParameterDictionary(parameters) : null;
var headers = new Dictionary<string, string>(); var headers = new Dictionary<string, string>();