<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Generate Serialization Classes As Part of Your Build (Part 1)</title>
	<atom:link href="http://blogs.rev-net.com/ddewinter/2008/07/08/generate-serialization-classes-as-part-of-your-build-part-1/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.rev-net.com/ddewinter/2008/07/08/generate-serialization-classes-as-part-of-your-build-part-1/</link>
	<description>A Developer's Melting Pot</description>
	<pubDate>Fri, 21 Nov 2008 13:15:28 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
		<item>
		<title>By: David DeWinter &#187; Blog Archive &#187; Generate Serialization Classes As Part of Your Build (Part 2)</title>
		<link>http://blogs.rev-net.com/ddewinter/2008/07/08/generate-serialization-classes-as-part-of-your-build-part-1/#comment-1086</link>
		<dc:creator>David DeWinter &#187; Blog Archive &#187; Generate Serialization Classes As Part of Your Build (Part 2)</dc:creator>
		<pubDate>Sun, 28 Sep 2008 19:32:56 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.rev-net.com/ddewinter/2008/07/08/generate-serialization-classes-as-part-of-your-build-part-1/#comment-1086</guid>
		<description>[...] A while ago, I posted about integrating the xsd.exe tool into the build process within Visual Studio or MSBuild. This time around, we&#8217;ll look at generating the code for the XML Serialization object model and making a few tweaks as part of the process. Here I will specifically look at retrieving the comments in the xsd:documentation elements and applying them to code elements as XML comments. We&#8217;ll break this down into four steps: [...]</description>
		<content:encoded><![CDATA[<p>[...] A while ago, I posted about integrating the xsd.exe tool into the build process within Visual Studio or MSBuild. This time around, we&#8217;ll look at generating the code for the XML Serialization object model and making a few tweaks as part of the process. Here I will specifically look at retrieving the comments in the xsd:documentation elements and applying them to code elements as XML comments. We&#8217;ll break this down into four steps: [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marcelo Lopez</title>
		<link>http://blogs.rev-net.com/ddewinter/2008/07/08/generate-serialization-classes-as-part-of-your-build-part-1/#comment-718</link>
		<dc:creator>Marcelo Lopez</dc:creator>
		<pubDate>Thu, 28 Aug 2008 16:24:45 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.rev-net.com/ddewinter/2008/07/08/generate-serialization-classes-as-part-of-your-build-part-1/#comment-718</guid>
		<description>Does anyone know where to download this XSD2ClassGen, because the link above points to page who's download link is broken. Anyone have this laying around that can post it to the web ?</description>
		<content:encoded><![CDATA[<p>Does anyone know where to download this XSD2ClassGen, because the link above points to page who&#8217;s download link is broken. Anyone have this laying around that can post it to the web ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David DeWinter</title>
		<link>http://blogs.rev-net.com/ddewinter/2008/07/08/generate-serialization-classes-as-part-of-your-build-part-1/#comment-615</link>
		<dc:creator>David DeWinter</dc:creator>
		<pubDate>Tue, 29 Jul 2008 03:10:14 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.rev-net.com/ddewinter/2008/07/08/generate-serialization-classes-as-part-of-your-build-part-1/#comment-615</guid>
		<description>Hi Lane,

Thanks for the compliments. Here are some thoughts.

xsd.exe does respect using xsd:include and will essentially merge your schemas into one large schema file before generating code from them. If you have &lt;em&gt;one&lt;/em&gt; schema that includes all of the others (e.g. schema A includes schemas B, C, and D only), then you can run xsd.exe on that one and achieve the same results as laid out in this post. However...

If you have multiple schemas that include common schemas (e.g. schema A includes schemas B and C, and schema D includes schema B), then it will be a bit tougher for xsd.exe to generate classes. If you tell xsd.exe to run on schemas A and D, then the types in B will generated twice, which is obviously not something you want.

As a workaround, you can specify different namespaces for the classes generated by schemas A and D. (You can use the /namespace switch on xsd.exe to do this.) You can then write code to translate between the schema B types in the first namespace and the second namespace if needed. This isn't really an ideal solution though.

Another workaround is to build your own version of xsd.exe which can ignore generating certain types. The end result would be that running this modified xsd.exe on schema A would yield types in schema B, but running it on schema D would not. This is difficult but will be the subject of part 2 of this series, so stay tuned!

David</description>
		<content:encoded><![CDATA[<p>Hi Lane,</p>
<p>Thanks for the compliments. Here are some thoughts.</p>
<p>xsd.exe does respect using xsd:include and will essentially merge your schemas into one large schema file before generating code from them. If you have <em>one</em> schema that includes all of the others (e.g. schema A includes schemas B, C, and D only), then you can run xsd.exe on that one and achieve the same results as laid out in this post. However&#8230;</p>
<p>If you have multiple schemas that include common schemas (e.g. schema A includes schemas B and C, and schema D includes schema B), then it will be a bit tougher for xsd.exe to generate classes. If you tell xsd.exe to run on schemas A and D, then the types in B will generated twice, which is obviously not something you want.</p>
<p>As a workaround, you can specify different namespaces for the classes generated by schemas A and D. (You can use the /namespace switch on xsd.exe to do this.) You can then write code to translate between the schema B types in the first namespace and the second namespace if needed. This isn&#8217;t really an ideal solution though.</p>
<p>Another workaround is to build your own version of xsd.exe which can ignore generating certain types. The end result would be that running this modified xsd.exe on schema A would yield types in schema B, but running it on schema D would not. This is difficult but will be the subject of part 2 of this series, so stay tuned!</p>
<p>David</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lane Wimberley</title>
		<link>http://blogs.rev-net.com/ddewinter/2008/07/08/generate-serialization-classes-as-part-of-your-build-part-1/#comment-573</link>
		<dc:creator>Lane Wimberley</dc:creator>
		<pubDate>Wed, 23 Jul 2008 17:02:06 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.rev-net.com/ddewinter/2008/07/08/generate-serialization-classes-as-part-of-your-build-part-1/#comment-573</guid>
		<description>Hello, David.  Thanks so much for this post.  As someone who is very new to Microsoft software development, .NET, C# and Visual Studio, and  somewhat less new to XSD, I greatly appreciated this extremely helpful description. 

I was wondering whether you had any advice for using XSD "include" in the scenario you describe above.  In particular, I have a need to develop multiple schemata that share some common definitions.  So, I've put the common defs into a separate file, which I then include into the top-level schemata.

I'm not sure exactly how to organize my projects (one class library, or multiple?  if multiple, where to put the shared definitions, etc.), nor even how to get XSD include to work properly with xsd.exe.

Any additional advice you would have along these lines would be appreciated!  

-Lane</description>
		<content:encoded><![CDATA[<p>Hello, David.  Thanks so much for this post.  As someone who is very new to Microsoft software development, .NET, C# and Visual Studio, and  somewhat less new to XSD, I greatly appreciated this extremely helpful description. </p>
<p>I was wondering whether you had any advice for using XSD &#8220;include&#8221; in the scenario you describe above.  In particular, I have a need to develop multiple schemata that share some common definitions.  So, I&#8217;ve put the common defs into a separate file, which I then include into the top-level schemata.</p>
<p>I&#8217;m not sure exactly how to organize my projects (one class library, or multiple?  if multiple, where to put the shared definitions, etc.), nor even how to get XSD include to work properly with xsd.exe.</p>
<p>Any additional advice you would have along these lines would be appreciated!  </p>
<p>-Lane</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David DeWinter</title>
		<link>http://blogs.rev-net.com/ddewinter/2008/07/08/generate-serialization-classes-as-part-of-your-build-part-1/#comment-496</link>
		<dc:creator>David DeWinter</dc:creator>
		<pubDate>Mon, 14 Jul 2008 23:56:20 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.rev-net.com/ddewinter/2008/07/08/generate-serialization-classes-as-part-of-your-build-part-1/#comment-496</guid>
		<description>From &lt;a href="http://www.west-wind.com/weblog/posts/10491.aspx" rel="nofollow"&gt;what&lt;/a&gt; &lt;a href="http://www.themssforum.com/Framework/xsdexe-Object/" rel="nofollow"&gt;I've&lt;/a&gt; &lt;a href="http://www.chrisdanielson.com/blog/archives/000149.html" rel="nofollow"&gt;seen&lt;/a&gt;, &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=89e6b1e5-f66c-4a4d-933b-46222bb01eb0&#038;DisplayLang=enhttp://www.microsoft.com/downloads/details.aspx?FamilyID=89e6b1e5-f66c-4a4d-933b-46222bb01eb0&#038;DisplayLang=en" rel="nofollow"&gt;XSDObjGen&lt;/a&gt; was an alternative to xsd.exe around the time of .NET 1.1; apparently, xsd.exe couldn't handle some schema constructs very well.

I tried to use XSDObjGen, but I didn't want to install .NET 1.1. I did, however, find an update for it called XSDClassGen, located &lt;a href="http://www.dotnetjunkies.com/WebLog/ram-marappan/comments/149148.aspx" rel="nofollow"&gt;here&lt;/a&gt;. I compared the outputs of xsd.exe with the output of XSDClassGen.exe. Here are the differences I found, in order of the magnitude of their effect on the consumer:

1. XSDClassGen will construct the XML from public fields, not properties (although properties are generated). It does place an EditorBrowsableAttribute with EditorBrowsableState.Never on these fields, but you can still see them from the IntelliSense window if the generated code is in the same solution as the code you're accessing it from.
2. XSDClassGen will generate collection constructs as List&#60;T&#62;, not a T[].
3. XSDClassGen can expose value types in the XSD as properties/fields of type Nullable&#60;T&#62;.
4. XSDClassGen can lazily initialize the fields when accessed through properties.
5. XSDClassGen does not place the DebuggerStepThroughAttribute on the generated classes.
6. XSDClassGen won't put a CompilerGeneratedAttribute on your classes. This can be important for people who don't want Code Analysis to analyze generated code.

Based on this, my choice for a "recommended tool" is xsd.exe, as it is officially supported by Microsoft and has probably been improved to account for cases where xsdobjgen.exe was useful. The fact that it was very difficult to find any up-to-date information on XSDObjGen.exe supports my choice as well.</description>
		<content:encoded><![CDATA[<p>From <a href="http://www.west-wind.com/weblog/posts/10491.aspx" rel="nofollow">what</a> <a href="http://www.themssforum.com/Framework/xsdexe-Object/" rel="nofollow">I&#8217;ve</a> <a href="http://www.chrisdanielson.com/blog/archives/000149.html" rel="nofollow">seen</a>, <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=89e6b1e5-f66c-4a4d-933b-46222bb01eb0&#038;DisplayLang=enhttp://www.microsoft.com/downloads/details.aspx?FamilyID=89e6b1e5-f66c-4a4d-933b-46222bb01eb0&#038;DisplayLang=en" rel="nofollow">XSDObjGen</a> was an alternative to xsd.exe around the time of .NET 1.1; apparently, xsd.exe couldn&#8217;t handle some schema constructs very well.</p>
<p>I tried to use XSDObjGen, but I didn&#8217;t want to install .NET 1.1. I did, however, find an update for it called XSDClassGen, located <a href="http://www.dotnetjunkies.com/WebLog/ram-marappan/comments/149148.aspx" rel="nofollow">here</a>. I compared the outputs of xsd.exe with the output of XSDClassGen.exe. Here are the differences I found, in order of the magnitude of their effect on the consumer:</p>
<p>1. XSDClassGen will construct the XML from public fields, not properties (although properties are generated). It does place an EditorBrowsableAttribute with EditorBrowsableState.Never on these fields, but you can still see them from the IntelliSense window if the generated code is in the same solution as the code you&#8217;re accessing it from.<br />
2. XSDClassGen will generate collection constructs as List&lt;T&gt;, not a T[].<br />
3. XSDClassGen can expose value types in the XSD as properties/fields of type Nullable&lt;T&gt;.<br />
4. XSDClassGen can lazily initialize the fields when accessed through properties.<br />
5. XSDClassGen does not place the DebuggerStepThroughAttribute on the generated classes.<br />
6. XSDClassGen won&#8217;t put a CompilerGeneratedAttribute on your classes. This can be important for people who don&#8217;t want Code Analysis to analyze generated code.</p>
<p>Based on this, my choice for a &#8220;recommended tool&#8221; is xsd.exe, as it is officially supported by Microsoft and has probably been improved to account for cases where xsdobjgen.exe was useful. The fact that it was very difficult to find any up-to-date information on XSDObjGen.exe supports my choice as well.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Black</title>
		<link>http://blogs.rev-net.com/ddewinter/2008/07/08/generate-serialization-classes-as-part-of-your-build-part-1/#comment-490</link>
		<dc:creator>Dave Black</dc:creator>
		<pubDate>Mon, 14 Jul 2008 04:28:45 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.rev-net.com/ddewinter/2008/07/08/generate-serialization-classes-as-part-of-your-build-part-1/#comment-490</guid>
		<description>Good post. Thanks.

I'd like to ask a related question though - what is the recommended tool for generating serialization objects from a schema - xsd.exe or XSDObjGen.exe from Microsoft?

I know they generate vastly different code for the same given schema.  Also, there have been times when one has worked and the other has not even when using similar command-line options.  I would assume that the recommended tool to use is "xsd.exe" since it is part of the Framework SDK.  However, if this was the case, why did MS ever develop "xsdobjgen.exe"?

TIA</description>
		<content:encoded><![CDATA[<p>Good post. Thanks.</p>
<p>I&#8217;d like to ask a related question though - what is the recommended tool for generating serialization objects from a schema - xsd.exe or XSDObjGen.exe from Microsoft?</p>
<p>I know they generate vastly different code for the same given schema.  Also, there have been times when one has worked and the other has not even when using similar command-line options.  I would assume that the recommended tool to use is &#8220;xsd.exe&#8221; since it is part of the Framework SDK.  However, if this was the case, why did MS ever develop &#8220;xsdobjgen.exe&#8221;?</p>
<p>TIA</p>
]]></content:encoded>
	</item>
</channel>
</rss>
