-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Description
InvariantGlobalization causes TryConvertCoinsValue to fail. A call within such assembly is not compatible with current Coins implementation. The globalization-invariant mode means that the application doesn't have access to specific culture information except for the invariant one.
InvariantGlobalization .csproj setting:
<PropertyGroup>
<InvariantGlobalization>true</InvariantGlobalization>
</PropertyGroup>
Exception thrown:
Only the invariant culture is supported in globalization-invariant mode. See https://aka.ms/GlobalizationInvariantMode for more information. (Parameter 'name')
en-US is an invalid culture identifier.
TonSdk.NET code causing issue:
private static bool TryConvertCoinsValue(object value, out Decimal result)
{
result = 0M;
try
{
if (Decimal.TryParse(value.ToString(), NumberStyles.Any, (IFormatProvider) new CultureInfo("en-US"), out result))
return true;
double result1;
if (!double.TryParse(value.ToString(), NumberStyles.Any, (IFormatProvider) new CultureInfo("en-US"), out result1))
return false;
result = (Decimal) result1;
return true;
}
catch
{
return false;
}
}
POC:
Csproj code running in
- added
<InvariantGlobalization>false</InvariantGlobalization>to .csproj
Code:
new Coins(0.01m),
Results:
Metadata
Metadata
Assignees
Labels
No labels
