[Mono-bugs] [Bug 75299][Wis] New - [GMCS] binary serialization do not work with generics

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Fri Jun 17 15:44:19 EDT 2005


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 nazgul at omega.pl.

http://bugzilla.ximian.com/show_bug.cgi?id=75299

--- shadow/75299	2005-06-17 15:44:19.000000000 -0400
+++ shadow/75299.tmp.14951	2005-06-17 15:44:19.000000000 -0400
@@ -0,0 +1,122 @@
+Bug#: 75299
+Product: Mono: Runtime
+Version: 1.0
+OS: 
+OS Details: mono svn from 17.06.2005
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: misc
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: nazgul at omega.pl               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: [GMCS] binary serialization do not work with generics
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+Runtime fails to read deserialized field
+
+Steps to reproduce the problem:
+1. Compile with gmcs t.cs
+
+using System;
+using System.IO;
+using System.Runtime.Serialization;
+using System.Runtime.Serialization.Formatters.Binary;
+
+[Serializable]
+public class Tuple <a,b> {
+  public a field1;
+  public b field2;
+
+  public Tuple (a x, b y) {
+    field1 = x;
+    field2 = y;
+  }
+}
+
+
+public class Test {
+   public static void Main()  {
+
+      //Creates a new TestSimpleObject object.
+      TestSimpleObject obj = new TestSimpleObject();
+
+      Console.WriteLine("Before serialization the object contains: ");
+      obj.Print();
+
+      //Opens a file and serializes the object into it in binary format.
+      Stream stream = File.Open("data.xml", FileMode.Create);
+      BinaryFormatter formatter = new BinaryFormatter();
+
+      //BinaryFormatter formatter = new BinaryFormatter();
+
+      formatter.Serialize(stream, obj);
+      stream.Close();
+   
+      //Empties obj.
+      obj = null;
+   
+      //Opens file "data.xml" and deserializes the object from it.
+      stream = File.Open("data.xml", FileMode.Open);
+      formatter = new BinaryFormatter();
+
+      //formatter = new BinaryFormatter();
+
+      obj = (TestSimpleObject)formatter.Deserialize(stream);
+      stream.Close();
+
+      Console.WriteLine("");
+      Console.WriteLine("After deserialization the object contains: ");
+      obj.Print();
+   }
+}
+
+
+// A test object that needs to be serialized.
+[Serializable()]        
+public class TestSimpleObject  {
+
+    public Tuple <string,int>  member6;
+    
+    public TestSimpleObject() {
+        member6 = new Tuple <string, int> ("aa", 22);
+    }
+
+
+    public void Print() {
+        Console.WriteLine("member6 = '{0}'", member6);
+    }
+}
+
+2. Run mono t.exe
+3. 
+
+Actual Results:
+Before serialization the object contains:
+member6 = 'Tuple`2[[System.String, mscorlib, Version=2.0.3600.0,
+Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Int32, mscorlib,
+Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]'
+
+** ERROR **: type 0x15 not handled in ves_icall_FieldInfo_SetValueInternal
+aborting...
+Aborted
+
+
+Expected Results:
+Before serialization the object contains:
+member6 = 'Tuple`2[System.String,System.Int32]'
+
+After deserialization the object contains:
+member6 = 'Tuple`2[System.String,System.Int32]'
+
+
+How often does this happen? 
+Always
+
+Additional Information:


More information about the mono-bugs mailing list