Error when enabling AutomaticProperties

Sep 1, 2009 at 11:39 AM

With 2.8.4 if I select as target 3.0/3.5 and enable AutomaticProperties (everything else is default value) it generates a wrong constructor:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema
    targetNamespace="http://MyProj/Things"
    elementFormDefault="qualified"
    xmlns="http://MyProj/Things"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
    <xs:element name="Things">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="Thing" minOccurs="0" maxOccurs="unbounded">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="Service">
                                <xs:complexType>
                                    <xs:attribute name="Name" type="xs:string" />
                                    <xs:attribute name="Cost" type="xs:decimal" />
                                </xs:complexType>
                            </xs:element>
                        </xs:sequence>
                        <xs:attribute name="Name" type="xs:string" />
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>

This is the XSD. The generated .cs has this error:

public ThingsThing() {
    if ((this.serviceField == null)) {
        this.serviceField = new ThingsThingService();
    }
}

The constructor is trying to use the serviceField field, but there isn't any serviceField field because it's using automatic properties.

Thanks

Massimiliano

Sep 10, 2009 at 4:16 PM

I have seen this error too.  I have made changes in the code to get it working for me.