Skip to content

Commit e4bd71b

Browse files
committed
Test fixes.
1 parent 8a24f76 commit e4bd71b

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

CSharpToJavaScript/Walker.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System;
66
using System.Collections.Generic;
77
using System.Collections.Immutable;
8+
using System.Globalization;
89
using System.Linq;
910
using System.Reflection;
1011
using System.Text;
@@ -2238,8 +2239,9 @@ public override void VisitLiteralExpression(LiteralExpressionSyntax node)
22382239
case SyntaxKind.NumericLiteralToken:
22392240
{
22402241
string _value = asToken.Text;
2241-
2242+
22422243
_value = _value.Replace("_","");
2244+
_value = _value.Replace(',', '.');
22432245

22442246
if (_value.EndsWith('f') ||
22452247
_value.EndsWith('d') ||
@@ -2252,15 +2254,11 @@ public override void VisitLiteralExpression(LiteralExpressionSyntax node)
22522254
_value.EndsWith('U') ||
22532255
_value.EndsWith('L'))
22542256
_value = _value.Remove(_value.Length - 1);
2255-
2257+
22562258
if (_value.Length > 10)
22572259
{
2258-
double _d = 0;
2259-
2260-
if (_value.Contains("E"))
2261-
_d = double.Parse(_value.Replace('.', ','), System.Globalization.NumberStyles.Float);
2262-
else
2263-
_d = Convert.ToDouble(_value.Replace('.', ','));
2260+
NumberStyles _styles = NumberStyles.AllowTrailingSign | NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands | NumberStyles.AllowExponent | NumberStyles.AllowCurrencySymbol;
2261+
double _d = double.Parse(_value.Replace('.', ','), _styles);
22642262

22652263
if (_value.StartsWith('-'))
22662264
{

0 commit comments

Comments
 (0)