How to generate .NET classes with comments from WSDL and XSD

谁都会走 提交于 2019-12-06 06:11:41

问题


There are some XSDs and WSDLs. I want to generate C# code from them. I used svcutil.exe, but it does not generate XML-comments from XSDs annotations:

<annotation>
    <documentation>VERY USEFULL DOCUMENTATION</documentation>
</annotation>

I want this inside generated file:

public class SomeData
{
    /// <summary>
    /// VERY USEFULL DOCUMENTATION
    /// </summary>
    public string SomeField
    {...}
}

Another question: how to force svcutil.exe to generate one file per class? (I know that I can use refactor from Resharper to move classes to separate files, but I don't like this solution)

So how to generate multiple files (one file per class) with XML-comments from XSDs and WSDLs


回答1:


You might be able to use the WCFExtras+ http://wcfextrasplus.codeplex.com/.

  1. Make WCFExtras.dll visible to svcutil.exe (such as by putting them in the same directory)
  2. add this section to the app.config of the client app, or place in a new config file and invoke svcutil with the /svcutilConfig switch

     <configuration>
      <system.serviceModel>
        <client>
          <metadata>
            <wsdlImporters>
              <extension type="WCFExtras.Wsdl.Documentation.XmlCommentsImporter, WCFExtras" />
            </wsdlImporters>
          </metadata>
        </client>
      </system.serviceModel>
    </configuration>
    

example command line, where configfile.xml is the config file above: SvcUtil.exe [service url] /svcutilConfig:[path to configfile.xml]




回答2:


I just learned about xsd2Code visual studio add-in. It does exactly what you want with the Xsd annotation/documentation text moved into a c# xml documentation summary tag.

There is a community version on CodePlex. The paid version has some other nice advanced features so I decided to pay the $45 for a one year license. Note: I'm not part of the company, just a satisfied customer.

Scott Crowder



来源:https://stackoverflow.com/questions/8617592/how-to-generate-net-classes-with-comments-from-wsdl-and-xsd

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!