There is an issue with the float.Parse used when getting values from the settings.json file.
By default, float.Parse will always use the CurrentCulture of the application context and, as this application runs locally, it will get the culture from the Operating System installed in the user's PC. And that is causing issues for people from all the cultures that uses a comma to separate decimals.
For instance, when using the default settings, this line:
float airDensity = float.Parse(Configuration["airDensity"] ?? "1");
will return airDensity = 1.225 for an american user, but airDensity = 1225 for a german or spanish user.
I detected this because I'm spanish and I got wrong shots in GSPRO while using this adapter, so I decided to take a look at the code.
The bug would be solved easily by adding the InvariantCulture as a parameter in the parse operation. Like this:
float airDensity = float.Parse(Configuration["airDensity"] ?? "1", CultureInfo.InvariantCulture);
There is an issue with the
float.Parse
used when getting values from thesettings.json
file.By default,
float.Parse
will always use theCurrentCulture
of the application context and, as this application runs locally, it will get the culture from the Operating System installed in the user's PC. And that is causing issues for people from all the cultures that uses a comma to separate decimals.For instance, when using the default settings, this line:
float airDensity = float.Parse(Configuration["airDensity"] ?? "1");
will returnairDensity = 1.225
for an american user, butairDensity = 1225
for a german or spanish user.I detected this because I'm spanish and I got wrong shots in GSPRO while using this adapter, so I decided to take a look at the code.
The bug would be solved easily by adding the
InvariantCulture
as a parameter in the parse operation. Like this:float airDensity = float.Parse(Configuration["airDensity"] ?? "1", CultureInfo.InvariantCulture);
I have created a fiddle with an example of how it would work for different cultures: https://dotnetfiddle.net/ZAYylE