Search code examples
exportmetadatadatacontractserializersvcutil.exe

DatacontractSerializer. Export metadata. Type annotations


Tell me please is it possible to automatically generate annotation for types/elements in generated xsd file with comments somehow?

from

/// <summary>
/// Comment for myclass
/// </summary>
[DataContract]
public class myclass
{
}

to

<xs:complexType name="myclass">
  <xs:annotation>
   <xs:documentation>
    Comment for myclass
   </xs:documentation>
  </xs:annotation>
</xs:complexType>

or to element directly:

<xs:element name="myclass" type="tns:myclass" >
<xs:annotation>
<xs:documentation>
  Comment for myclass 
</xs:documentation>
</xs:annotation>
</xs:element>

Solution

  • No you cannot. XML comments are not compiled into your code. So svcutil just do not have this information.

    However depending on what is your actual goals you can try to alter WSDL and XSD of the service with instructions from this article.