xsd2code byte[] array init

Feb 25, 2010 at 1:03 PM

xsd2exe generates xml attribute of type base64 like:

<font size="2" color="#0000ff"><font size="2" color="#0000ff">

this

</font></font><font size="2" color="#0000ff">

 

</font>

.binaryField = new byte[]()

 

This will not compile

Can this bug be fixed easily?

 

Thanks

 

this is my first post - please take it easy :)

Feb 25, 2010 at 2:55 PM

would you believe that I have the exact same problem? I'm just looking at this today and saw your post.

It's causing my code to fail at building. Again, the line is

[System.Xml.Serialization.XmlAttributeAttribute(DataType = "base64Binary")]
        public byte[] integrityCheck
        {
            get {
                if ((this.integrityCheckField == null)) {
                    this.integrityCheckField = new byte[]();
                }
                return this.integrityCheckField;
            }
            set
            {
                this.integrityCheckField = value;
            }
        }

I set the array to some arbitary value, but alas I get a stack overflow.

Feb 25, 2010 at 2:59 PM

So I tried this

this.integrityCheckField = new List<byte>();

Seems to compile. You could try:

.binaryField = new List<byte>();

Mar 1, 2010 at 2:48 PM

I cannot convert it to List<byte> as it would break number of projects. Also a problem is not solved by hiding it. Anotehr problem with this code generator is that it's not generating comments for attributes or even classes which are defined as a complex type.

 

If I get a chance I'll look at the source code to see where the issues are coming from.

 

Thanks

Coordinator
Mar 8, 2010 at 8:08 PM

Can you post a litte XSD sample.

Thx.

Pascal.

 

Mar 9, 2010 at 8:56 AM

Here's a cut down version of my schema. 

Thanks


  <xs:complexType name="BinaryCapture">
    <xs:annotation>
      <xs:documentation>A image capture.</xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="CaptureBase">
        <xs:attribute name="BinaryImage" type="xs:base64Binary">
          <xs:annotation>
            <xs:documentation>Gets or sets the image data.</xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="BinaryDataType" default="None" type="mstns:BinaryDataTypes">
          <xs:annotation>
            <xs:documentation>Gets or sets the type of the image.</xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <!--<xs:attribute name="BinaryImageFileName" type="xs:string">
          <xs:annotation>
            <xs:documentation>Gets or sets the image file name.</xs:documentation>
          </xs:annotation>
        </xs:attribute>-->
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>


  <xs:element name="Captures">
    <xs:complexType>
        <xs:element name="BinaryCaptures" type="mstns:BinaryCapture" maxOccurs="unbounded" minOccurs="1">
          <xs:annotation>
            <xs:documentation>List of binary captures.</xs:documentation>
          </xs:annotation>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

Jun 7, 2010 at 5:15 PM
Edited Jun 7, 2010 at 5:16 PM

I have similar issue.

XSD snippet:

  <simpleType name="colorType">
    <annotation>
      <documentation><![CDATA[
        
        aabbggrr
        
        ffffffff: opaque white
        ff000000: opaque black
        
        ]]></documentation>
    </annotation>
    <restriction base="hexBinary">
      <length value="4"/>
    </restriction>
  </simpleType>

Later, an element declared thus:
  <element name="bgColor" type="kml:colorType" default="ffffffff"/>

Gets converted to: 
		private byte[] bgColorField;
...
            this.bgColorField = new byte[]();

Instead, it should be declared as byte[4], per the colorType definition.
Jun 7, 2010 at 6:05 PM

I reported this as issue 7210.