JKorf / Binance.Net

A C# .netstandard client library for the Binance REST and Websocket Spot and Futures API focusing on clear usage and models
https://jkorf.github.io/Binance.Net/
MIT License
1.02k stars 420 forks source link

ExchangeInfo - Cannot map enum value - TRD_GRP_024 #1326

Open Balint1 opened 7 months ago

Balint1 commented 7 months ago

Describe the bug Cannot map AccountType TRD_GRP_024

To Reproduce var resultInfo = await client.SpotApi.ExchangeData.GetExchangeInfoAsync();

Expected behavior Succesfully mapping the missing enum value

HoLyDreaM commented 7 months ago

I've been getting this error for 12 hours and I'm about to go crazy and sometimes it gives an error like this: "No response on query received"

AlgoExecutor commented 7 months ago

This line: result = Enum.Parse(objectType, value, true); in EnumConverter.cs is kind of desaster. No check that this value exists. This is my quick & dirty fix:

var eList = Enum.GetNames(objectType).Select(s => s.ToLower()).ToList();
if (eList.Contains(value.ToLower()))
{
  result = Enum.Parse(objectType, value, true);
  return true;
}
else
{
  result = default;
  return false;
} 

I'm afraid there are other unsafe places in the code with Enum.Parse

JKorf commented 7 months ago

I'm not sure where you got that snippet from, it's not actually in the EnumConverter. The source of which can be found here: https://github.com/JKorf/CryptoExchange.Net/blob/master/CryptoExchange.Net/Converters/EnumConverter.cs

HoLyDreaM commented 7 months ago

The code gives the error above.At least I didn't get it from somewhere

AlgoExecutor commented 6 months ago

I'm not sure where you got that snippet from, it's not actually in the EnumConverter. The source of which can be found here: https://github.com/JKorf/CryptoExchange.Net/blob/master/CryptoExchange.Net/Converters/EnumConverter.cs

This was only my fix for the EnumConverter.cs Problem in Line 124.