[Mono-bugs] [Bug 673019] New: XmlSerializer : Bad Custom serializer generated with "char" default value
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Thu Feb 17 08:54:35 EST 2011
https://bugzilla.novell.com/show_bug.cgi?id=673019
https://bugzilla.novell.com/show_bug.cgi?id=673019#c0
Summary: XmlSerializer : Bad Custom serializer generated with
"char" default value
Classification: Mono
Product: Mono: Class Libraries
Version: 2.6.x
Platform: Other
OS/Version: Other
Status: NEW
Severity: Normal
Priority: P5 - None
Component: Sys.XML
AssignedTo: atsushi at ximian.com
ReportedBy: informatique.internet at fiducial.fr
QAContact: mono-bugs at lists.ximian.com
Found By: ---
Blocker: ---
Created an attachment (id=414706)
--> (http://bugzilla.novell.com/attachment.cgi?id=414706)
TestXmlSerialization Monodevelop Solution (with binary file)
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; fr; rv:1.9.2.13)
Gecko/20101206 Ubuntu/10.10 (maverick) Firefox/3.5
There's a problem when Xml serializing such class :
[Serializable]
public class ToBeSerialized {
[DefaultValue('a')]
public char character='a';
public ToBeSerialized() {
}
}
With the "Custom" "fast" Xml Serializer... There's no problems with normal
reflection based serialiser
Reproducible: Always
Steps to Reproduce:
1.Try this program :
using System;
using System.Xml;
using System.IO;
using System.Xml.Serialization;
using System.ComponentModel;
namespace TestXmlSerialization
{
[Serializable]
public class ToBeSerialized {
[DefaultValue('a')]
public char character='a';
public ToBeSerialized() {
}
}
class MainClass
{
public static void Main (string[] args)
{
XmlSerializer SerializerObj = new
XmlSerializer(typeof(ToBeSerialized));
StringWriter writer = new StringWriter();
SerializerObj.Serialize(writer,new ToBeSerialized());
Console.WriteLine(writer.ToString());
}
}
}
2. Launch it with : MONO_XMLSERIALIZER_THS=0,nofallback
/bin/Debug/TestXmlSerialization.exe
Actual Results:
Error while compiling generated serializer
/tmp/4f615c5/46b16abc.cs(138,46) : error CS0103: The name `a' does not exist in
the current context
Unhandled Exception: System.InvalidOperationException: There was an error
generating the XML document. ---> System.InvalidOperationException: Error while
generating serializer
at System.Xml.Serialization.XmlSerializer.CreateWriter
(System.Xml.Serialization.XmlMapping typeMapping) [0x00000] in <filename
unknown>:0
at System.Xml.Serialization.XmlSerializer.Serialize (System.Xml.XmlWriter
writer, System.Object o, System.Xml.Serialization.XmlSerializerNamespaces
namespaces) [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlSerializer.Serialize (System.Xml.XmlWriter
writer, System.Object o, System.Xml.Serialization.XmlSerializerNamespaces
namespaces) [0x00000] in <filename unknown>:0
at System.Xml.Serialization.XmlSerializer.Serialize (System.IO.TextWriter
textWriter, System.Object o) [0x00000] in <filename unknown>:0
at TestXmlSerialization.MainClass.Main (System.String[] args) [0x00000] in
<filename unknown>:0
Expected Results:
<?xml version="1.0" encoding="utf-16"?>
<ToBeSerialized xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
More information about the mono-bugs
mailing list