Everything returns 0 with ByteSize.Parse or ByteSize.TryParse
erwinkramer opened this issue · comments
Installed the latest version from NuGet. Using Visual Studio 2015 targeting .NET 4.5 and made this code:
var m = ByteSize.Parse("1.55B").MegaBytes;
var n = ByteSize.Parse("24.44 gB").MegaBytes;
ByteSize output;
ByteSize.TryParse("24.44 gB", out output);
var o = output.MegaBytes;
All 3 variables (m,n,o) result in 0. Not sure what's the matter here.
The following example does work as intended:
var monthlyUsage = ByteSize.FromGigaBytes(10);
Thanks for filing the issue.
What culture/locale are you running in?
That seems to be the problem Omar,
My locale is '{nl-NL}'
If i set it manually, on the thread, to en-US like below it works just fine:
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US");
It should be working for {nl-NL} too, right?
Yes, it should work in nl-NL
.
The nl-NL
culture NumberDecimalSeparator
is a ,
so the code is looking for that. It's not looking for the NumberGroupSeparator
per locale. I believe that's the issue. See https://github.com/omar/ByteSize/blob/master/src/ByteSizeLib/ByteSize.cs#L326
My parallels isn't working (I'm on a Mac). I need to figure out how to get ByteSize setup for dotnet core and then I can fix this.
@erwinkramer, I just released v1.2.1 on NuGet with the fix. Thanks for reporting this.