GenericListXamlContentPrivateSetter Sample

Back to summary

Source

using System.Collections.Generic;
using System.ComponentModel;

namespace XmlSerializersTest.Samples
{
    public class GenericListXamlContentPrivateSetter
    {
        public GenericListXamlContentPrivateSetter()
        {
            Strings = new List<string> {"foo", "bar", "baz"};
        }

        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public List<string> Strings { get; private set; } 
    }
}

Standard Serializer

System.InvalidOperationException: Unable to generate a temporary class (result=1).
error CS0200: Property or indexer 'XmlSerializersTest.Samples.GenericListXamlContentPrivateSetter.Strings' cannot be assigned to -- it is read only
error CS0200: Property or indexer 'XmlSerializersTest.Samples.GenericListXamlContentPrivateSetter.Strings' cannot be assigned to -- it is read only

   at System.Xml.Serialization.Compiler.Compile(Assembly parent, String ns, XmlSerializerCompilerParameters xmlParameters, Evidence evidence)
   at System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, Evidence evidence, XmlSerializerCompilerParameters parameters, Assembly assembly, Hashtable assemblies)
   at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, String location, Evidence evidence)
   at System.Xml.Serialization.XmlSerializer.GenerateTempAssembly(XmlMapping xmlMapping, Type type, String defaultNamespace)
   at System.Xml.Serialization.XmlSerializer..ctor(Type type, String defaultNamespace)
   at System.Xml.Serialization.XmlSerializer..ctor(Type type)
   at XmlSerializersTest.Serializers.StandardXmlSerializer.Serialize(Object obj, XmlWriter writer) in C:\Ivan\dev\XmlSerializersTest\XmlSerializersTest\Serializers\StandardXmlSerializer.cs:line 13
   at XmlSerializersTest.SampleProcessor.SerializeToString(Object obj, IXmlSerializer serializer) in C:\Ivan\dev\XmlSerializersTest\XmlSerializersTest\SampleProcessor.cs:line 162
   at XmlSerializersTest.SampleProcessor.RecordSerializationResults(Object obj, IXmlSerializer serializer) in C:\Ivan\dev\XmlSerializersTest\XmlSerializersTest\SampleProcessor.cs:line 115

Deserialization skipped