Could you file a bug report with a test case?

On Thu, Sep 18, 2014 at 5:28 AM, gbenrais <gbenr...@wakuroo.com> wrote:

> Hello,
> I have an issue when datacontractserializing dictionaries with mono. The
> serializer names differently the elements corresponding to dictionaries.
> Serialization program
>
> /Dictionary<int, Person> persons = new Dictionary<int, Person>();
> persons[1] = new Person("John");
> persons[2] = new Person("Bob");
> string xml = GetXmlFromData(persons);
> persons = GetModelFromXml(xml);
> static string GetXmlFromData (object data)
> {
>   StringWriter sw = new StringWriter ();
>   XmlTextWriter xw = new XmlTextWriter (sw);
>   DataContractSerializer serializer = new
> DataContractSerializer(typeof(Dictionary<int, Person>));
>   serializer.WriteObject (xw, data);
>   xw.Close ();
>   sw.Close ();
>   return sw.ToString();
> }/
> .Net xml
>
> /<ArrayOfKeyValueOfintPerson7l_PWQ7_Pn
> xmlns:i="http://www.w3.org/2001/XMLSchema-instance";
> xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays
> "><*KeyValueOfintPerson7l_PWQ7_Pn*><Key>1</Key><Value
> xmlns:d3p1="http://schemas.datacontract.org/2004/07/Serialization
> "><d3p1:_name>John</d3p1:_name></Value></KeyValueOfintPerson7l_PWQ7_Pn><KeyValueOfintPerson7l_PWQ7_Pn><Key>2</Key><Value
> xmlns:d3p1="http://schemas.datacontract.org/2004/07/Serialization
> "><d3p1:_name>Bob</d3p1:_name></Value></KeyValueOfintPerson7l_PWQ7_Pn></ArrayOfKeyValueOfintPerson7l_PWQ7_Pn>/
> Mono xml
>
> /<ArrayOfKeyValueOfintPerson
> xmlns:i="http://www.w3.org/2001/XMLSchema-instance";
> xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays
> "><*KeyValueOfintPerson*><Key>1</Key><Value><_name
> xmlns="http://schemas.datacontract.org/2004/07/Serialization
> ">John</_name></Value></KeyValueOfintPerson><KeyValueOfintPerson><Key>2</Key><Value><_name
> xmlns="http://schemas.datacontract.org/2004/07/Serialization
> ">Bob</_name></Value></KeyValueOfintPerson></ArrayOfKeyValueOfintPerson>/
>
> As we can see, we get different names (KeyValueOfintPerson7l_PWQ7_Pn vs
> KeyValueOfintPerson). And the program run with mono fails when it reads the
> xml from a file output by a program run with .Net.
>
> Thank you for your help,
> Ghislain
>
>
>
> --
> View this message in context:
> http://mono.1490590.n4.nabble.com/DataContractSerializer-dictionaries-element-names-tp4663929.html
> Sent from the Mono - General mailing list archive at Nabble.com.
> _______________________________________________
> Mono-list maillist  -  Mono-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>
_______________________________________________
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to