[S.R.Serialization] fix array element deserialization.
authorAtsushi Eno <atsushieno@gmail.com>
Tue, 7 Apr 2015 15:25:14 +0000 (00:25 +0900)
committerAtsushi Eno <atsushieno@gmail.com>
Fri, 24 Apr 2015 05:36:53 +0000 (14:36 +0900)
Array elements were not deserialized correctly and causing null (default)
items put into the array.

mcs/class/System.Runtime.Serialization/ReferenceSources/CodeInterpreter.cs
mcs/class/System.Runtime.Serialization/ReferenceSources/XmlFormatReaderGenerator_static.cs

index e0e1dcf100eb19dd31a0acceb5fa8f44607413fc..4de29bbcae33a60533ec958609457dbb722d2704 100644 (file)
@@ -42,7 +42,7 @@ namespace System.Runtime.Serialization
             {
                 if (source.IsValueType)
                 {
-                    if (CanConvert (Type.GetTypeCode(target)))
+                    if (!CanConvert (Type.GetTypeCode (target)))
                         throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.GetString(SR.NoConversionPossibleTo, DataContract.GetClrTypeFullName(target))));
                     else
                                                return target;
index ebede5aec679bbcc8069c74904a66c3b358a179c..8103cc25760887d90bd2154a79c3e2e5db9e396b 100644 (file)
@@ -353,9 +353,9 @@ namespace System.Runtime.Serialization
 
                        if (type.IsPointer)
                                // wow, there is no way to convert void* to object in strongly typed way...
-                               return CodeInterpreter.ConvertValue (XmlFormatGeneratorStatics.UnboxPointer.Invoke (null, new object [] {obj}), Globals.TypeOfObject, type);
+                               return XmlFormatGeneratorStatics.UnboxPointer.Invoke (null, new object [] {obj});
                        else
-                               return obj;
+                               return CodeInterpreter.ConvertValue (obj, Globals.TypeOfObject, type);
                }
 
                object WrapNullableObject (Type innerType, object innerValue, Type outerType, int nullables)
@@ -420,7 +420,7 @@ namespace System.Runtime.Serialization
                        if (isArray && TryReadPrimitiveArray (type, itemType, size))
                                canReadPrimitiveArray = true;
 
-                       if (!canReadPrimitiveArray) {
+                       if (objectId != null) {
                                if (size == -1) {
 
                                        object growingCollection = null;