Bug 18131 - DataContractJsonSerializer ReadObject of a double returns invalid result in German Region
Summary: DataContractJsonSerializer ReadObject of a double returns invalid result in G...
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: 7.0.7
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-03-03 14:05 UTC by John Miller [MSFT]
Modified: 2014-03-04 09:01 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Repro Project (9.95 KB, application/zip)
2014-03-03 14:05 UTC, John Miller [MSFT]
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description John Miller [MSFT] 2014-03-03 14:05:44 UTC
Created attachment 6202 [details]
Repro Project

When the iOS device is in the German Region, DataContractJsonSerializer.ReadObject returns an invalid double result. 

The attached test project shows a value of "1234" on the screen, but it should read the double value from the json string as "12,34". This works as expected in Xamarin.iOS 7.0.6. 


Not working in 

Xamarin.iOS
Version: 7.0.7.2 (Business Edition)
Hash: fb4bc7b
Branch: 
Build date: 2014-17-02 17:43:23-0500
Comment 1 Sebastien Pouliot 2014-03-03 19:53:36 UTC
There not a big delta [1] between 7.0.6 and 7.0.7 - but there's a change wrt DataContractJsonSerializer, it was the fix for #16744 [2].

The diff for 21cb413 looks globalization safe - but the readon of Single/Double/Decimal were replaceed by code that might not be.

[1] http://docs.xamarin.com/releases/ios/xamarin.ios_7/xamarin.ios_7.0/#7
[2] https://bugzilla.xamarin.com/show_bug.cgi?id=16744
Comment 2 Sebastien Pouliot 2014-03-03 20:13:58 UTC
@John is that code yours ? or the customer ?

If so I'll convert it into a unit test and commit it along the fix (in the mono repo).
Comment 3 Sebastien Pouliot 2014-03-03 20:47:39 UTC
The fix itself is rather simple:

diff --git a/mcs/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/JsonSerializationReader.cs b/mcs/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/JsonSerializationReader.cs
index 1ca5792..29e3cfa 100644
--- a/mcs/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/JsonSerializationReader.cs
+++ b/mcs/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/JsonSerializationReader.cs
@@ -189,7 +189,7 @@ namespace System.Runtime.Serialization.Json
                object ReadValueType (Type type, bool nullable)
                {
                        string s = reader.ReadElementContentAsString ();
-                       return nullable && s.Trim ().Length == 0 ? null : Convert.ChangeType (s, type, null);
+                       return nullable && s.Trim ().Length == 0 ? null : Convert.ChangeType (s, type, CultureInfo.InvariantCulture);
                }

@John, let me know if I can reuse the sample (otherwise I'll create a unit test from scratch) and commit everything.
Comment 4 Sebastien Pouliot 2014-03-04 09:01:45 UTC
I created my own test.

Fixed in mono/master 56d406876f3455a13db8f71418d1cbf256889975