[Mono-bugs] [Bug 78593][Nor] New - Serialization formatters don't
throw on missing fields
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Tue Jun 6 19:38:35 EDT 2006
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 robertj at gmx.net.
http://bugzilla.ximian.com/show_bug.cgi?id=78593
--- shadow/78593 2006-06-06 19:38:35.000000000 -0400
+++ shadow/78593.tmp.17404 2006-06-06 19:38:35.000000000 -0400
@@ -0,0 +1,82 @@
+Bug#: 78593
+Product: Mono: Class Libraries
+Version: 1.1
+OS: All
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: CORLIB
+AssignedTo: mono-bugs at ximian.com
+ReportedBy: robertj at gmx.net
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Serialization formatters don't throw on missing fields
+
+MS.NET throws a SerializationException if a field is missing
+from the deserialization stream.
+
+Mono simply ignores the field, which remains uninitialized.
+Both formatters (BinaryFormatter, SoapFormatter) have this
+problem.
+
+Fix proposal: instead of iterating over the field names
+obtained from the deserialization stream, both formatter
+readers should interatate over the current type field
+members, maybe using FormatterServices.GetSerializableMembers.
+
+
+Steps to reproduce the problem:
+
+1) compile the code
+2) $ mono test.exe
+3) comment out the A.S field from the code
+4) recompile
+5) $ mono test.exe load
+
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Runtime.Serialization;
+using System.Runtime.Serialization.Formatters.Binary;
+using System.Text;
+
+class T
+{
+ static void Main (string[] args)
+ {
+ if (args.Length > 0) {
+ A a = (A) Load ();
+ Console.WriteLine (a);
+ } else {
+ Save (new A ());
+ Console.WriteLine ("Saved");
+ }
+ }
+
+ static void Save (object data)
+ {
+ using (FileStream fs = File.Create ("dump.ser")) {
+ BinaryFormatter f = new BinaryFormatter ();
+ f.Serialize (fs, data);
+ }
+ }
+
+ static object Load ()
+ {
+ using (FileStream fs = File.OpenRead ("dump.ser")) {
+ BinaryFormatter f = new BinaryFormatter ();
+ return f.Deserialize (fs);
+ }
+ }
+}
+
+[Serializable]
+class A
+{
+ public string S = "Hola";
+}
More information about the mono-bugs
mailing list