diff options
author | Alistair Bush <alistair.bush@gmail.com> | 2014-03-08 16:05:24 +0400 |
---|---|---|
committer | Alistair Bush <alistair.bush@gmail.com> | 2014-03-08 16:05:24 +0400 |
commit | f3296a15597ed9874ef1ce38c7853740b400cf63 (patch) | |
tree | a62e06c289ff5df315856861d528670f9e102725 /mcs/class/System.XML | |
parent | beb190172d1625f4b6076bb836e24647742f28bc (diff) |
When a read only property and the type is an interface we can't serialize the type.
This change is released under the MIT license.
Diffstat (limited to 'mcs/class/System.XML')
-rw-r--r-- | mcs/class/System.XML/System.Xml.Serialization/XmlReflectionImporter.cs | 1 | ||||
-rw-r--r-- | mcs/class/System.XML/Test/System.Xml.Serialization/XmlSerializerTestClasses.cs | 3 |
2 files changed, 4 insertions, 0 deletions
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlReflectionImporter.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlReflectionImporter.cs index 968ad43bf36..901e4b9988b 100644 --- a/mcs/class/System.XML/System.Xml.Serialization/XmlReflectionImporter.cs +++ b/mcs/class/System.XML/System.Xml.Serialization/XmlReflectionImporter.cs @@ -798,6 +798,7 @@ namespace System.Xml.Serialization { if (atts == null) atts = new XmlAttributes (prop); if (atts.XmlIgnore) continue; if (!prop.CanWrite) { + if (prop.PropertyType.IsInterface && typeof (IEnumerable).IsAssignableFrom (prop.PropertyType)) continue; if (prop.PropertyType.IsGenericType && TypeData.GetGenericListItemType (prop.PropertyType) == null) continue; // check this before calling GetTypeData() which raises error for missing Add(). See bug #704813. if (TypeTranslator.GetTypeData (prop.PropertyType).SchemaType != SchemaTypes.Array || prop.PropertyType.IsArray) continue; } diff --git a/mcs/class/System.XML/Test/System.Xml.Serialization/XmlSerializerTestClasses.cs b/mcs/class/System.XML/Test/System.Xml.Serialization/XmlSerializerTestClasses.cs index 15262591843..940a4cf404c 100644 --- a/mcs/class/System.XML/Test/System.Xml.Serialization/XmlSerializerTestClasses.cs +++ b/mcs/class/System.XML/Test/System.Xml.Serialization/XmlSerializerTestClasses.cs @@ -432,6 +432,7 @@ namespace MonoTests.System.Xml.TestClasses public class ReadOnlyProperties { string[] strArr = new string[2] { "string1", "string2" }; + List<string> strList = new List<string> { "listString1" }; public string[] StrArr { @@ -442,6 +443,8 @@ namespace MonoTests.System.Xml.TestClasses { get { return "fff"; } } + + public IList<string> StrList { get { return strList; } } } [XmlRoot ("root")] |