-Fixed number parsing culture bugs
This commit is contained in:
@@ -178,7 +178,7 @@ namespace Newtonsoft.Json.Tests
|
||||
{
|
||||
try
|
||||
{
|
||||
; action();
|
||||
action();
|
||||
|
||||
Assert.Fail("Exception of type {0} expected; got none exception", typeof(TException).Name);
|
||||
}
|
||||
|
||||
@@ -1289,7 +1289,7 @@ namespace Newtonsoft.Json
|
||||
else
|
||||
{
|
||||
double d;
|
||||
if (double.TryParse(number, NumberStyles.Float | NumberStyles.AllowThousands, NumberFormatInfo.CurrentInfo, out d))
|
||||
if (double.TryParse(number, NumberStyles.Float | NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out d))
|
||||
numberValue = d;
|
||||
else
|
||||
throw JsonReaderException.Create(this, "Input string '{0}' is not a valid number.".FormatWith(CultureInfo.InvariantCulture, number));
|
||||
|
||||
@@ -490,7 +490,7 @@ namespace Newtonsoft.Json.Linq.JsonPath
|
||||
if (numberText.IndexOfAny(new char[] { '.', 'E', 'e' }) != -1)
|
||||
{
|
||||
double d;
|
||||
if (double.TryParse(numberText, out d))
|
||||
if (double.TryParse(numberText, NumberStyles.Float | NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out d))
|
||||
return d;
|
||||
else
|
||||
throw new JsonException("Could not read query value.");
|
||||
@@ -498,7 +498,7 @@ namespace Newtonsoft.Json.Linq.JsonPath
|
||||
else
|
||||
{
|
||||
long l;
|
||||
if (long.TryParse(numberText, out l))
|
||||
if (long.TryParse(numberText, NumberStyles.Integer, CultureInfo.InvariantCulture, out l))
|
||||
return l;
|
||||
else
|
||||
throw new JsonException("Could not read query value.");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RuleSet Name="Newtonsoft.Json.ruleset" ToolsVersion="10.0">
|
||||
<RuleSet Name="Newtonsoft.Json.ruleset" ToolsVersion="12.0">
|
||||
<IncludeAll Action="Warning" />
|
||||
<Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed">
|
||||
<Rule Id="CA1000" Action="None" />
|
||||
@@ -67,6 +67,8 @@
|
||||
<Rule Id="CA1301" Action="None" />
|
||||
<Rule Id="CA1302" Action="None" />
|
||||
<Rule Id="CA1303" Action="None" />
|
||||
<Rule Id="CA1304" Action="Error" />
|
||||
<Rule Id="CA1305" Action="Error" />
|
||||
<Rule Id="CA1306" Action="None" />
|
||||
<Rule Id="CA1307" Action="None" />
|
||||
<Rule Id="CA1308" Action="None" />
|
||||
|
||||
Reference in New Issue
Block a user