Any idea when VS2015 will be supported?
↧
New Post: VS2015
↧
Created Unassigned: Can't have multiple types with custom collection object type [17596]
When selecting "DefinedType" and setting a collection base class, the generator only creates a collection class for one of the types.
Looking at the code, I believe this bug comes from CodeExtension::Process (line : 125). CollectionTypes should not be cleared ! only the last one is kept otherwise.
Also, would it be possible to ass HashSet as a predefined collection object type ?
Looking at the code, I believe this bug comes from CodeExtension::Process (line : 125). CollectionTypes should not be cleared ! only the last one is kept otherwise.
Also, would it be possible to ass HashSet as a predefined collection object type ?
↧
↧
Created Unassigned: Use plural form of name when using collection [17597]
When an element can occur multiple times, the generator creates a collection, but the name of the field/property is not changed. It should take a plural form (adding an s).
Suggestions :
CodeExtension::ProcessProperty() line : 1883, add prop.Name += "s";
CodeExtension::ProcessFields() line : 1682, add field.Name += "s";
Suggestions :
CodeExtension::ProcessProperty() line : 1883, add prop.Name += "s";
CodeExtension::ProcessFields() line : 1682, add field.Name += "s";
↧
Updated Wiki: Home
Project Description
Xsd2Code community edition is a CSharp or Visual Basic Business Entity class Generator from XSD schema.
What Xsd2Code community edition can do ?
- Plugin integration for vs 2010, 2012, 2013
- Generate CS, VB code from xsd schema.
- Generate partial class.
- Support generic and custom collection (List<T>, ObservableCollection<T>, MyCustomCollection<T>).
- Support automatic properties when no special get or set is required.
- Can generate WCF attributes (DataContract/DataMember).
- Implement INotifyPropertyChanged for enable DataBinding.
- Generate summary documentation from xsd annotation.
- Save and load Xml document into isolated file storage for silverlight app.
- Read an write xml with UTF-8/32, ASCII, Unicode, Default.
- Save and load from XML file.
xsd2code is available as dual-licensing.
- xsd2code++ (www.xsd2code.com)
Paid version with additional features for developers and business customers working on commercial projects. (Vs 2010 to Vs 2015) - xsd2code community edition (here on codeplex)
How to use it ?
Xsd2Code community edition is an AddIn for visual studio 2008.
Right clic on xsd schema in solution explorer, choose options and generate code.
Enable databinding.
<xs:elementname="show"type="xs:boolean"nillable="true"/>
Result :
[System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]public System.Nullable<bool> show {get {returnthis.showField; }set {if ((showField.Equals(value) != true)) {this.showField = value; OnPropertyChanged("show"); } } }publicevent System.ComponentModel.PropertyChangedEventHandler PropertyChanged;privatevoid OnPropertyChanged(string info) { PropertyChangedEventHandler handler = PropertyChanged;if (handler != null) { handler(this, new PropertyChangedEventArgs(info)); } }
Hide private field in Visual studio.
[EditorBrowsable(EditorBrowsableState.Never)]private List <dvds> dvdsField;
Generic collection.
<xs:elementname="Product">
<xs:complexType>
<xs:sequencemaxOccurs="unbounded">
<xs:elementname="ProductName"type="xs:string"/>
<xs:elementname="ProductVersion"type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
Result :
///<summary>/// .ctor class constructor///</summary>public Product() {if ((this.productVersionField == null)) {this.productVersionField = new List<System.String>(); }if ((this.productNameField == null)) {this.productNameField = new List<System.String>(); } }///<remarks/> [System.Xml.Serialization.XmlElementAttribute("ProductName")]public List<System.String> ProductName {get {returnthis.productNameField; }set {if ((this.productNameField != null)) {if ((productNameField.Equals(value) != true)) {this.productNameField = value; OnPropertyChanged("ProductName"); } }else {this.productNameField = value; OnPropertyChanged("ProductName"); } } }
Lazy loading pattern.
[System.Xml.Serialization.XmlElementAttribute("Dvds")]public List<dvd> Dvds {get {if ((this.dvdsField == null)) {this.dvdsField = new List<dvd>(); }returnthis.dvdsField; }set {this.dvdsField = value; } }
Serialize/Deserialize XML.
///<summary>/// Serializes current EntityBase object into an XML document///</summary>// <returns>string XML value</returns>publicvirtualstring Serialize() { System.IO.StreamReader streamReader = null; System.IO.MemoryStream memoryStream = null;try { memoryStream = new System.IO.MemoryStream(); Serializer.Serialize(memoryStream, this); memoryStream.Seek(0, System.IO.SeekOrigin.Begin); streamReader = new System.IO.StreamReader(memoryStream);return streamReader.ReadToEnd(); }finally {if (streamReader != null) { streamReader.Dispose(); }if (memoryStream != null) { memoryStream.Dispose(); } } }///<summary>/// Deserializes workflow markup into an EntityBase object///</summary>// <param name="xml">string workflow markup to deserialize</param>// <param name="obj">Output EntityBase object</param>// <param name="exception">output Exception value if deserialize failed</param>// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>publicstaticbool Deserialize(string xml, out T obj, out System.Exception exception) { exception = null; obj = default(T);try { obj = Deserialize(xml);returntrue; }catch (System.Exception ex) { exception = ex;returnfalse; } }publicstaticbool Deserialize(string xml, out T obj) { System.Exception exception = null;return Deserialize(xml, out obj, out exception); }publicstatic T Deserialize(string xml) { System.IO.StringReader stringReader = null;try { stringReader = new System.IO.StringReader(xml);return ((T)(Serializer.Deserialize(System.Xml.XmlReader.Create(stringReader)))); }finally {if (stringReader != null) { stringReader.Dispose(); } } }
SaveToFile and LoadFromFile method.
///<summary>/// Serializes current EntityBase object into file///</summary>// <param name="fileName">full path of outupt xml file</param>// <param name="exception">output Exception value if failed</param>// <returns>true if can serialize and save into file; otherwise, false</returns>publicvirtualbool SaveToFile(string fileName, out System.Exception exception) { exception = null;try { SaveToFile(fileName);returntrue; }catch (System.Exception e) { exception = e;returnfalse; } }publicvirtualvoid SaveToFile(string fileName) { System.IO.StreamWriter streamWriter = null;try {string xmlString = Serialize(); System.IO.FileInfo xmlFile = new System.IO.FileInfo(fileName); streamWriter = xmlFile.CreateText(); streamWriter.WriteLine(xmlString); streamWriter.Close(); }finally {if (streamWriter != null) { streamWriter.Dispose(); } } }///<summary>/// Deserializes workflow markup from file into an EntityBase object///</summary>// <param name="xml">string workflow markup to deserialize</param>// <param name="obj">Output EntityBase object</param>// <param name="exception">output Exception value if deserialize failed</param>// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>publicstaticbool LoadFromFile(string fileName, out T obj, out System.Exception exception) { exception = null; obj = default(T);try { obj = LoadFromFile(fileName);returntrue; }catch (System.Exception ex) { exception = ex;returnfalse; } }publicstaticbool LoadFromFile(string fileName, out T obj) { System.Exception exception = null;return LoadFromFile(fileName, out obj, out exception); }publicstatic T LoadFromFile(string fileName) { System.IO.FileStream file = null; System.IO.StreamReader sr = null;try { file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read); sr = new System.IO.StreamReader(file);string xmlString = sr.ReadToEnd(); sr.Close(); file.Close();return Deserialize(xmlString); }finally {if (file != null) { file.Dispose(); }if (sr != null) { sr.Dispose(); } } }
Default value.
<xs:attributename="nationality"type="xs:string"default="US">
Result :
///<summary>/// .ctor class constructor///</summary>public Actor() {this.nationalityField = "US"; }
Code xml comment.
<xs:elementname="firstname"type="xs:string"><xs:annotation><xs:documentation> Gets or sets the firstname of the actor</xs:documentation></xs:annotation></xs:element>
Result :
///<summary>/// Gets or sets the firstname of the actor///</summary>publicstring firstname {get;set;}
Backup options generation in cs or vb header
// ------------------------------------------------------------------------------// <auto-generated>// Generated by Xsd2Code. Version 2.1.3148.17485// <NameSpace>XSD2Code.Test</NameSpace><Collection>List</Collection>...// <auto-generated>// ------------------------------------------------------------------------------namespace XSD2Code.Test {using System;using System.Diagnostics; ...
↧
Reviewed: xsd2code community edition 3.4 (mar. 04, 2016)
Rated 4 Stars (out of 5) - ok very very good my friends
↧
↧
Created Unassigned: Setters are generated for fixed elements [17636]
The following schema:
```
<xs:element name="user" type="xs:string" fixed="A" minOccurs="1" maxOccurs="1"/>
```
Results in the following generated code:
```
private string userField;
...
this.userField = "A";
...
public string user
{
get
{
return this.userField;
}
set
{
this.userField = value;
}
}
```
In fact, you can even set the value and serialize XML that doesn't meet the schema - though I guess that's more because the serializer doesn't know anything about the schema.
```
<xs:element name="user" type="xs:string" fixed="A" minOccurs="1" maxOccurs="1"/>
```
Results in the following generated code:
```
private string userField;
...
this.userField = "A";
...
public string user
{
get
{
return this.userField;
}
set
{
this.userField = value;
}
}
```
In fact, you can even set the value and serialize XML that doesn't meet the schema - though I guess that's more because the serializer doesn't know anything about the schema.
↧
Created Unassigned: Serialialization methods are unnecessary generated in inheriting classes [17642]
Hi all,
I really like the tool and have used it successfully for a C# project. I have a point of feedback regarding the tool xsd2Code, that could possibly be interesting to improve the tool even further...
In attachment, you will find 4 XSD-schemes, that belong together. The main scheme is the DIVArchiveWS.xsd-file. In Microsoft Visual Studio, I right-clicked on this file to run the xsd2Code tool and this generated the DIVArchiveWS.designer.cs-file, with the namespace DIVArchive, that I then used in my project. I saw the tool was smart enough to use Inheritance.
One small problem : in the inherited classes, it also generated Serialization methods. This is not needed, because they are exactly the same as the ones implemented in the base class. This did not break the functionality of the code, but as it is redundant, it caused warnings.
Maybe it is a good idea to, in this case, omit these methods in the inherited classes?
Kind regards,
Joachim Ally
I really like the tool and have used it successfully for a C# project. I have a point of feedback regarding the tool xsd2Code, that could possibly be interesting to improve the tool even further...
In attachment, you will find 4 XSD-schemes, that belong together. The main scheme is the DIVArchiveWS.xsd-file. In Microsoft Visual Studio, I right-clicked on this file to run the xsd2Code tool and this generated the DIVArchiveWS.designer.cs-file, with the namespace DIVArchive, that I then used in my project. I saw the tool was smart enough to use Inheritance.
One small problem : in the inherited classes, it also generated Serialization methods. This is not needed, because they are exactly the same as the ones implemented in the base class. This did not break the functionality of the code, but as it is redundant, it caused warnings.
Maybe it is a good idea to, in this case, omit these methods in the inherited classes?
Kind regards,
Joachim Ally
↧
New Post: VS2015
It looks to be supported now for xsd2code++
↧
New Post: Best way to use my XSD to create a SQL Server schema (or Code First set of C# classes)?
What is the best way to use xml2code to create a high-fidelity set of related, multi-table SQL Server database schema (single database)? ...or a set of Code FIrst compatible C# classes as an indirect set to producing the former?
Best regards,
Michael Herman (Toronto)
Best regards,
Michael Herman (Toronto)
↧
↧
New Post: Generation of C# classes through XSD is giving an error
Hi,
We have the XSD file which contains 77000 lines and it has too many recursive classes. so we tried to use xsd2code to generate C# classes for it but while executing it we are getting the error as
In command prompt we tried as:
C:\Program Files\Xsd2Code>Xsd2Code.exe Sample.xsd
Xsd2Code Version 3.4.0.32990
Code generation utility from XML schema files.
Error: Group "DOCUMENTATION-BLOCK" from targetNamespace-'http://sample.org/schema/r4.0' has invalid definition: Circular group reference.
SubType: Unspecified
Rule:
We have the XSD file which contains 77000 lines and it has too many recursive classes. so we tried to use xsd2code to generate C# classes for it but while executing it we are getting the error as
In command prompt we tried as:
C:\Program Files\Xsd2Code>Xsd2Code.exe Sample.xsd
Xsd2Code Version 3.4.0.32990
Code generation utility from XML schema files.
Error: Group "DOCUMENTATION-BLOCK" from targetNamespace-'http://sample.org/schema/r4.0' has invalid definition: Circular group reference.
SubType: Unspecified
Rule:
↧
New Post: XSD to C# class generation Error
Hi,
We have the XSD file which contains 77000 lines and it has too many recursive classes. so we tried to use xsd2code to generate C# classes for it but while executing it we are getting the error as
In command prompt we tried as:
C:\Program Files\Xsd2Code>Xsd2Code.exe Sample.xsd
Xsd2Code Version 3.4.0.32990
Code generation utility from XML schema files.
Error: Group "DOCUMENTATION-BLOCK" from targetNamespace-'http://sample.org/schema/r4.0' has invalid definition: Circular group reference.
SubType: Unspecified
We have the XSD file which contains 77000 lines and it has too many recursive classes. so we tried to use xsd2code to generate C# classes for it but while executing it we are getting the error as
In command prompt we tried as:
C:\Program Files\Xsd2Code>Xsd2Code.exe Sample.xsd
Xsd2Code Version 3.4.0.32990
Code generation utility from XML schema files.
Error: Group "DOCUMENTATION-BLOCK" from targetNamespace-'http://sample.org/schema/r4.0' has invalid definition: Circular group reference.
SubType: Unspecified
↧
Created Unassigned: Lazy properties + Reference to itself in a class = StackOverflowException [17695]
I have xsd complex type "A" representing herachy. So the complex type has the Parent property of type "A". If i use EnableLazyLoading option I get StackOverflowException while serialization.
I think the same problem exists for any circular dependencies.
I think the same problem exists for any circular dependencies.
↧
New Post: feature suggestion: convert class names to PascalCase
+1. Would be nice to have this feature.
↧
↧
New Post: Custome Attributes..
Hi community,
Is it possible to generate custom attributes for classes properties ?
I try to generate EF entities from Xsd, but it could be usefull to have some custom attributes on top of some properties (max lenght , default value etc.. )
Any idéa to manage that into the xsd ?
Thx.
Is it possible to generate custom attributes for classes properties ?
I try to generate EF entities from Xsd, but it could be usefull to have some custom attributes on top of some properties (max lenght , default value etc.. )
Any idéa to manage that into the xsd ?
Thx.
↧
New Post: Basic hesitation
First of all, excuse my bad english, please.
I've got a problem with a electronic bills validating program, that use some special ".xsd" schema files called "FacturaE".
I receive bill xml files and I have to check them against a variable list of .xsd (three ones in most cases, including Xdaes to sign validation).
I use Microsoft .Net for it, Framework 4.0.
My application had perfomance problems. One I get a pre-compiled XmlSchemaReader object, validation process used to last about 30 seconds. From a concrete date of november, without a sharp reason, it lasts 200 seconds.
I just have found your xsd2code tool, but I don't know if it could be useful in my problem.
Before download and make use of it, ¿can you tell me if it could help me for this trouble? I don't know exactly its features, specially if it includes PERFOMANCE, efficiency improvements in xml validating process.
Regards
I've got a problem with a electronic bills validating program, that use some special ".xsd" schema files called "FacturaE".
I receive bill xml files and I have to check them against a variable list of .xsd (three ones in most cases, including Xdaes to sign validation).
I use Microsoft .Net for it, Framework 4.0.
My application had perfomance problems. One I get a pre-compiled XmlSchemaReader object, validation process used to last about 30 seconds. From a concrete date of november, without a sharp reason, it lasts 200 seconds.
I just have found your xsd2code tool, but I don't know if it could be useful in my problem.
Before download and make use of it, ¿can you tell me if it could help me for this trouble? I don't know exactly its features, specially if it includes PERFOMANCE, efficiency improvements in xml validating process.
Regards
↧
New Post: Portable usage
Can Xsd2Code be used in a portable manner ?
I dont want to force everybody to install the tool to use it. I would like to put the exe and dependencies in a directory accessible by everybody and call code generation by command line.
The VS integration is great but its more like an issue in my context.
Thank you
I dont want to force everybody to install the tool to use it. I would like to put the exe and dependencies in a directory accessible by everybody and call code generation by command line.
The VS integration is great but its more like an issue in my context.
Thank you
↧
New Post: Where can I find a sample XML and .NET code using the generated class ?
I know .NET but I am new to xsd2code. Where can I find a project using an XML file that using the xsd2code generated class code ?
Thank you
Thank you
↧
↧
New Post: How to output string elements as cdata?
Hi,
how I can use CDATA support for string elements?
I see this option in spec, but I can't find in xsd2code++ GUI.
Could you help me please?
how I can use CDATA support for string elements?
I see this option in spec, but I can't find in xsd2code++ GUI.
Could you help me please?
↧
New Post: XSD2Code - Output elements of type string as cdata
cjard wrote:
Isn't this a hack to work around the fact that XmlSerializer doesnt do CDATA? Should Xsd2Code implement hacks? What is the problem with using escaped data? Does your reader at the other end not perform unescaping? Another option could be: Xsd2Code should be able to be given a list of members NOT to generate code for, and then you put the relevant code in the partial class file.. i.e. put your hack in the partial, so that regeneration does not overwrite itUnfortunately partial class does not resolve problems, because change order of markups and not always we can do this. Besides e.g. I have a client who has system with doesn't support escaped data and I have to adjust.... ;/
↧
Patch Uploaded: #18768
devi_ous has uploaded a patch.
Description:
Version VS2017 (just edit manifest)
↧