KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am using xsd.exe to generate some c# classes from a .xsd file. I ran into the same issue that is covered here and on other sites where xsd.exe generates Type[] arrays instead of generic List collections for types in the .xsd file. Some people have suggested that svcutil.exe can be used as a replacement for xsd.exe if you pass the /dataContractOnly parameter to svcutil.exe. However, it seems like those people are mistaken because svcutil.exe actually generates System.Xml.XmlNode[] array properties instead of creating types based on the schema in the .xsd file. For example, given this simple .xsd schema: <?xml version="1.0" encoding="utf-8"?> <xs:schema targetNamespace="http://tempuri.org/XMLSchema.xsd" elementFormDefault="qualified" xmlns="http://tempuri.org/XMLSchema.xsd" xmlns:mstns="http://tempuri.org/XMLSchema.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" > <xs:complexType name="Employee"> <xs:all> <xs:element name="FirstName" type="xs:string"></xs:element> <xs:element name="LastName" type="xs:string"></xs:element> </xs:all> </xs:complexType> <xs:element name="Employees"> <xs:complexType> <xs:sequence maxOccurs="unbounded"> <xs:element name="Employee" type="Employee"></xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> 'xsd.exe /classes Example.xsd' generates: public partial class Employees { private Employee[] employeeField; public Employee[] Employee { get { return this.employeeField; } set { this.employeeField = value; } } } public partial class Employee { private string firstNameField; private string lastNameField; public string FirstName { get { return this.firstNameField; } set { this.fi
Tags (comma-separated)
Save Edits
Cancel