Quantcast
Channel: xsd2Code community edition .net class generator from XSD schema
Viewing all articles
Browse latest Browse all 543

Commented Issue: StackOverflowException for Recursive Element [7419]

$
0
0
This was reported as fixed, but it still happens in 2.8.1.

Here is a snippet from the schema:
<xsd:complexType name = "LocationType">
<xsd:sequence>
<xsd:element name = "EquipmentID" type="EquipmentIDType"/>
<xsd:element name = "EquipmentElementLevel" type="EquipmentElementLevelType"/>
<xsd:element name = "Location" type="LocationType" minOccurs="0"/>
<xsd:group ref = "Extended:Location" minOccurs="0" maxOccurs="1"/>
<!-- Added in V04 - The Any element should not be used in new schemas. This extension schema should be used to add user defined
elements to B2MML documents. In a future release the Any element will be removed from B2MML. -->
<xsd:element name = "Any" type="AnyType"
minOccurs="0" maxOccurs="unbounded"/>

</xsd:sequence>
</xsd:complexType>

Here is a snippet of generated code that has the exception:
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.3074")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://www.wbf.org/xml/B2MML-V0401")]
public partial class LocationType : System.ComponentModel.INotifyPropertyChanged
{

[EditorBrowsable(EditorBrowsableState.Never)]
private EquipmentIDType equipmentIDField;

[EditorBrowsable(EditorBrowsableState.Never)]
private EquipmentElementLevelType equipmentElementLevelField;

[EditorBrowsable(EditorBrowsableState.Never)]
private LocationType locationField;

[EditorBrowsable(EditorBrowsableState.Never)]
private List<AnyType> anyField;

public LocationType()
{
if ((this.anyField == null))
{
this.anyField = new List<AnyType>();
}
if ((this.locationField == null))
{
this.locationField = new LocationType();
}
if ((this.equipmentElementLevelField == null))
{
this.equipmentElementLevelField = new EquipmentElementLevelType();
}
if ((this.equipmentIDField == null))
{
this.equipmentIDField = new EquipmentIDType();
}
}
Comments: ** Comment from web user: reokubo **

The StackOverflowException does not happen on code generation. It happens when trying to create an instance of the generated class in another application. And if you use lazy loading, you can delay the StackOverflowException , but it will still happen. The only way that I can use generated classes that contain recursive elements is to modify the source code and recompile. I have made these modifications in different places as the source code has changed for newer versions of Xsd2Code, but it still works after the modifications.


Viewing all articles
Browse latest Browse all 543

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>