Generate XmlAttribute for Silverlight

May 17, 2011 at 11:32 PM

Hi,

I'm trying to using the GenerateXmlAttribute option to generate XmlAttribute attributes for simple types for Silverlight.

Using the same options but for .NET generates the [XmlAttribute] tags fine, but it doesn't get generated for Silverlight.

        [System.Xml.Serialization.XmlAttributeAttribute()]
        public string Version
        {
            get
            {
                return this.versionField;
            }
            set
            {
                this.versionField = value;
            }
        }
It is possible to do this?

Thanks in advanced.

May 18, 2011 at 8:28 PM

I figured out how to keep the attributes there from looking at the source code...

In the method RemoveDefaultXmlAttributes, don't remove these attributes for Silverlight.

System.Xml.Serialization.XmlAttributeAttribute
System.Xml.Serialization.XmlTypeAttribute
System.Xml.Serialization.XmlElementAttribute
System.Xml.Serialization.XmlRootAttribute
(These attributes are supported in Silverlight 3, 4.)



May 20, 2011 at 8:17 AM

Thank you for your feedback.

i created a new issue #13545.

Nov 17, 2011 at 11:00 PM

As a workaround I generated the code as .NET 4.0 and used regular expressions to remove unsupported attributes:

 

    \[System.CodeDom.Compiler.GeneratedCodeAttribute\(\"System\.Xml\"\, \"4\.0\.30319\.233\"\)\]\n    \[System.SerializableAttribute\(\)\]\n    \[System.ComponentModel.DesignerCategoryAttribute\(\"code\"\)\]\n

 

    \[System.CodeDom.Compiler.GeneratedCodeAttribute\(\"System\.Xml\"\, \"4\.0\.30319\.233\"\)\]\n    \[System.SerializableAttribute\(\)\]\n