[Mono-bugs] [Bug 676681] New: XML Serialization - unexpected characters and missing ending ">"
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Thu Mar 3 08:56:08 EST 2011
https://bugzilla.novell.com/show_bug.cgi?id=676681
https://bugzilla.novell.com/show_bug.cgi?id=676681#c0
Summary: XML Serialization - unexpected characters and missing
ending ">"
Classification: Mono
Product: Mono: Class Libraries
Version: 2.8.x
Platform: Other
OS/Version: RHEL 5
Status: NEW
Severity: Major
Priority: P5 - None
Component: Sys.XML
AssignedTo: atsushi at ximian.com
ReportedBy: adamka at dgt.com.pl
QAContact: mono-bugs at lists.ximian.com
Found By: ---
Blocker: ---
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; pl; rv:1.9.2.14)
Gecko/20110218 Firefox/3.6.14
XMLSerialization object return string that has unexpected characters and
missing ending ">"
Under mono result serialization:
?˙<?xml version="1.0" encoding="utf-8"?><AcdCpaInfo
xmlns:xsi="http://www.w3.org /2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"><Applicat
ionId>50</ApplicationId><IdCall>58682074963644</IdCall><Cpa>586820749</Cpa><SwdN
otice>NB</SwdNotice><SudNotice>ZA</SudNotice><IdRequest>4097</IdRequest></AcdCpa
Info
Reproducible: Always
Steps to Reproduce:
1.Object to serialize
[Serializable]
public class AcdCpaInfo
{
public UInt16 ApplicationId;
public string IdCall;
public string Cpa;
public string SwdNotice;
public string SudNotice;
public UInt32 IdRequest;
}
2. Fill object
AcdCpaInfo = new AcdCpaInfo
{
ApplicationId = 50,
Cpa = "586820749",
IdCall = "586820749" + 0xF89C,
SudNotice = "ZA",
SwdNotice = "NB",
IdRequest = 0xFFF + 2
};
3.Serialize object, my code:
var memoryStream = new MemoryStream();
var xs = new XmlSerializer(AcdCpaInfo.getType() , AcdCpaInfo);
var xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8);
xs.Serialize(xmlTextWriter, AcdCpaInfo);
memoryStream = (MemoryStream)xmlTextWriter.BaseStream;
var xmlizedString = Utf8ByteArrayToString(memoryStream.ToArray());
return xmlizedString;
Method Utf8ByteArrayToString:
private static String Utf8ByteArrayToString(Byte[] characters)
{
var encoding = new UTF8Encoding();
var constructedString = encoding.GetString(characters);
return (constructedString);
}
Actual Results:
?˙<?xml version="1.0" encoding="utf-8"?><AcdCpaInfo
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"><ApplicationId>50</ApplicationId><IdCall>58682074963644</IdCall><Cpa>586820749</Cpa><SwdNotice>NB</SwdNotice><SudNotice>ZA</SudNotice><IdRequest>4097</IdRequest></AcdCpaInfo
Expected Results:
<?xml version="1.0" encoding="utf-8"?><AcdCpaInfo
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"><ApplicationId>50</ApplicationId><IdCall>58682074963644</IdCall><Cpa>586820749</Cpa><SwdNotice>NB</SwdNotice><SudNotice>ZA</SudNotice><IdRequest>4097</IdRequest></AcdCpaInfo>
--
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