byte[] and lazy loading

Nov 18, 2010 at 3:23 AM

Hi,

I've got an XSD which defines a type like so:

<xsd:element name="Image" minOccurs="0" maxOccurs="unbounded">
   <xsd:complexType>
      <xsd:simpleContent>
         <xsd:extension base="xsd:base64Binary">
            <xsd:attribute name="type" type="DocumentationTypes" use="optional"/>
            <xsd:attribute name="mediaType" type="MediaTypes" use="optional"/>
            <xsd:attribute name="fileName" type="xsd:string" use="optional"/>
            <xsd:attribute ref="xml:lang" use="optional"/>
         </xsd:extension>
      </xsd:simpleContent>
   </xsd:complexType>
</xsd:element>

xsd2code defines the Value property of this image like so:

[System.Xml.Serialization.XmlTextAttribute(DataType="base64Binary")]
public byte[] Value {
    get {
        return this.valueField;
    }
    set {
        this.valueField = value;
    }
}

This is all fine. However, if I have EnableLazyLoading=true, the getter includes:

if ((this.valueField == null)) {
    this.valueField = new byte[]();
}

And since you can't create an array without a size, this won't compile. I can go through and take these out by hand where they occur, but it would be nice if xsd2code didn't include this for byte[] properties.

Thanks,
Aaron.

Coordinator
Nov 20, 2010 at 2:18 PM

Hi,

you can try last 3.5 release. This bug is fixed.

Thank you for your feedback.

Pascal.