[Mono-bugs] [Bug 52038][Nor] New - Xml deserialization of non-valid types succeeds.

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Thu, 11 Dec 2003 06:16:59 -0500 (EST)

Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by erezl@mainsoft.com.


--- shadow/52038	2003-12-11 06:16:59.000000000 -0500
+++ shadow/52038.tmp.14286	2003-12-11 06:16:59.000000000 -0500
@@ -0,0 +1,73 @@
+Bug#: 52038
+Product: Mono/Class Libraries
+Version: unspecified
+OS: All
+OS Details: 
+Status: NEW   
+Priority: Normal
+Component: System.XML
+AssignedTo: lluis@ximian.com                            
+ReportedBy: erezl@mainsoft.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+Summary: Xml deserialization of non-valid types succeeds.
+Please fill in this template when reporting a bug, unless you know what 
+you are doing.
+Description of Problem:
+When deserializing an objrct from an xml that contain unknown elements,
+An exception is not thrown.
+Steps to reproduce the problem:
+1. Save the attached cs and xml files.
+2. Write a code that deserializes the xml file into a TestClass object.
+This should look somthing like:
+using System;
+using System.Xml.Serialization;
+class SerailizationTest
+	static void Main(string[] args)
+	{
+		XmlSerializer serializer = new XmlSerializer(typeof
+		System.IO.StreamReader sin = new System.IO.StreamReader
+		TestClass res = serializer.Deserialize(sin);
+		sin.Close();
+	}
+3. Build, and execute. (make sure that SerailizationTest.exe 
+TestClass.xml are in the same directory.)
+Actual Results:
+The deserialize operation is compleated without any exception.
+Expected Results:
+deserialize should fail.
+in .NET I get:
+Unhandled Exception: System.InvalidOperationException: There is an error 
+in XML document (2, 2). 
+---> System.InvalidOperationException: <NonValidItem xmlns=''> was not 
+   at 
+   --- End of inner exception stack trace ---
+   at System.Xml.Serialization.XmlSerializer.Deserialize
+(XmlReaderxmlReader, String encodingStyle)
+   at System.Xml.Serialization.XmlSerializer.Deserialize
+   at SerailizationTest.Main(String[] args) 
+in :\temp\testdeserializer\class1.cs:line 11
+How often does this happen? 
+Additional Information: