Freigeben über


Avoiding Infinite Schema Chains

I was working on some services with recursive data structures when I noticed that there were a few cases where I would get crashes while trying to generate proxy classes. The problems seemed to be around types that were a sequence of instances of themselves. That looks like this:

 <xs:schema xmlns:tns="test" targetNamespace="test" xmlns:xs="www.w3.org/2001/XMLSchema">
  <xs:complexType name="CircularList">
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="unbounded" name="CircularList" nillable="true" type="tns:CircularList" />
    </xs:sequence>
  </xs:complexType>
  <xs:element name="CircularList" nillable="true" type="tns:CircularList" />
</xs:schema>

When using message contracts I was able to fix the problem by moving the minOccurs and maxOccurs from the element to the containing sequence. This didn't change the meaning of the type when I examined the proxy.

With data contracts, trying the same fix caused proxy generation to go into an infinite loop rather than crash, but that's not much of an improvement. The data contract serializer worked best when I defined an intermediate type to represent the sequence rather than directly including the list type in itself.

These all look like bugs with schema analysis.

Next time: Waiting for Ready Channels

Comments

  • Anonymous
    August 27, 2008
    The comment has been removed