PDIBWade / xsd-to-classes

Automatically exported from code.google.com/p/xsd-to-classes
0 stars 0 forks source link

Feature request : add comment (from xml element annotation) to generated properties #1

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
This XSD definition:

<xs:element name="FamilyName" minOccurs="0">
  <xs:annotation>
    <xs:documentation>This defines the family name (max length = 40).</xs:documentation>
  </xs:annotation>
  <xs:simpleType>
    <xs:restriction base="xs:string">
      <xs:maxLength value="40"/>
    </xs:restriction>
  </xs:simpleType>
</xs:element>

should generate this code:

/// <summary>
/// This defines the family name (max length = 40).
/// </summary>
/// <value>
/// The FamilyName
/// </value>
public string FamilyName {
  get {
    return this.familyNameField;
  }
  set {
    this.familyNameField = value;
    this.RaisePropertyChanged("FamilyName");
  }
}

Original issue reported on code.google.com by stef.hey...@gmail.com on 5 Aug 2011 at 10:13

GoogleCodeExporter commented 9 years ago
Good idea. 
Difficult to implement, but not impossible.
Need to 
1) access the xs:documentation element in the XSD object model
2) use the CodeDOM to modify the comment in the right place.

See the code modifier: 
http://code.google.com/p/xsd-to-classes/source/browse/CodeGeneration/CodeModifie
rs/AddDocComments.cs for an example of how to add comments using the CodeDOM.

Do you want to be attached to the project?

Original comment by michael....@bluetoque.ca on 9 Aug 2011 at 5:38

GoogleCodeExporter commented 9 years ago
The real difficulty is correlating the doc comment with the CodeDOM object 
model. By the time the CodeModifier is run, the XSD is closed and you can't 
easily find the element that generated the piece of code. 

Original comment by michael....@bluetoque.ca on 9 Aug 2011 at 5:42