[System.ServiceModel.Web] Fix JsonQueryStringConverter.ConvertValueToString to work...
authorSebastien Pouliot <sebastien@xamarin.com>
Tue, 18 Mar 2014 01:46:33 +0000 (21:46 -0400)
committerSebastien Pouliot <sebastien@xamarin.com>
Tue, 18 Mar 2014 01:46:33 +0000 (21:46 -0400)
mcs/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/JsonQueryStringConverter.cs
mcs/class/System.ServiceModel.Web/Test/System.ServiceModel.Dispatcher/JsonQueryStringConverterTest.cs

index 87bd458413b2699626454a24ac6dca4419e77963..41d0e7572810bd21650953001cd21c9ef731d568 100644 (file)
@@ -5,6 +5,7 @@
 //     Atsushi Enomoto  <atsushi@ximian.com>
 //
 // Copyright (C) 2008 Novell, Inc (http://www.novell.com)
+// Copyright 2014 Xamarin Inc. (http://www.xamarin.com)
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -182,7 +183,8 @@ namespace System.ServiceModel.Dispatcher
                                        var qname = (XmlQualifiedName) parameter;
                                        return String.Concat ("\"", qname.Name, ":", qname.Namespace, "\"");
                                }
-                               return parameter.ToString ();
+                               var f = (parameter as IFormattable);
+                               return (f == null) ? parameter.ToString () : f.ToString (null, CultureInfo.InvariantCulture);
                        }
                }
 
index a05da3e5b0ee6a7bdc932b925350e98111917550..22086ca8b2d645370a453b23de5c516adc8b66bc 100644 (file)
@@ -5,6 +5,7 @@
 //     Atsushi Enomoto  <atsushi@ximian.com>
 //
 // Copyright (C) 2008 Novell, Inc (http://www.novell.com)
+// Copyright 2014 Xamarin Inc. (http://www.xamarin.com)
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -32,6 +33,7 @@ using System.Globalization;
 using System.Runtime.Serialization;
 using System.ServiceModel.Dispatcher;
 using System.Text;
+using System.Threading;
 using System.Xml;
 using NUnit.Framework;
 
@@ -110,6 +112,19 @@ namespace MonoTests.System.ServiceModel.Description
                        Assert.AreEqual ("123.45", c.ConvertValueToString (123.45, typeof (int)));
                }
 
+               [Test]
+               public void ConvertValueToStringValidCast4_ptBR ()
+               {
+                       var ci = CultureInfo.CurrentCulture;
+                       try {
+                               Thread.CurrentThread.CurrentCulture = new CultureInfo ("pt-BR");
+                               Assert.AreEqual ("123.45", c.ConvertValueToString (123.45, typeof (int)));
+                       }
+                       finally {
+                               Thread.CurrentThread.CurrentCulture = ci;
+                       }
+               }
+
                [Test]
                public void ConvertValueToStringValidCast5 ()
                {