Settings in an XML file

Dec 27, 2012 at 7:16 PM

After looking through code, I discovered that when you use the command line, you can specify settings in an XML file.  That file must be called <myfilename>.xsd.xsd2code and you must run the executable as such:

 

> xsd2code.exe <myfilename>.xsd

Note - you cannot specify any other arguments.

The .xsd.xsd2code file should look something like this (note, you can copy the XML at the top of the generated source code file):

<auto-generated>
  <NameSpace>namespace</NameSpace>
  <Collection>List</Collection>
  <codeType>CSharp</codeType>
  <EnableDataBinding>False</EnableDataBinding>
  <EnableLazyLoading>False</EnableLazyLoading>
  <TrackingChangesEnable>False</TrackingChangesEnable>
  <GenTrackingClasses>False</GenTrackingClasses>
  <HidePrivateFieldInIDE>False</HidePrivateFieldInIDE>
  <EnableSummaryComment>False</EnableSummaryComment>
  <VirtualProp>True</VirtualProp>
  <IncludeSerializeMethod>False</IncludeSerializeMethod>
  <UseBaseClass>False</UseBaseClass>
  <GenBaseClass>False</GenBaseClass>
  <GenerateCloneMethod>False</GenerateCloneMethod>
  <GenerateDataContracts>True</GenerateDataContracts>
  <CodeBaseTag>Net35</CodeBaseTag>
  <SerializeMethodName>Serialize</SerializeMethodName>
  <DeserializeMethodName>Deserialize</DeserializeMethodName>
  <SaveToFileMethodName>SaveToFile</SaveToFileMethodName>
  <LoadFromFileMethodName>LoadFromFile</LoadFromFileMethodName>
  <GenerateXMLAttributes>True</GenerateXMLAttributes>
  <OrderXMLAttrib>False</OrderXMLAttrib>
  <EnableEncoding>False</EnableEncoding>
  <AutomaticProperties>False</AutomaticProperties>
  <GenerateShouldSerialize>True</GenerateShouldSerialize>
  <DisableDebug>True</DisableDebug>
  <PropNameSpecified>Default</PropNameSpecified>
  <Encoder>UTF8</Encoder>
  <CustomUsings>customUsings</CustomUsings>
  <ExcludeIncludedTypes>True</ExcludeIncludedTypes>
  <EnableInitializeFields>False</EnableInitializeFields>
</auto-generated>

 

Jan 22, 2013 at 10:15 PM

 

I'm the submitter who added this feature. Once upon a time there was some documentation on it. But I don't see the documentation anymore but it works like this:

 

The code will look for settings in 3 Locations in this order.

  1. [schemafilename].xsd.xsd2code if it exists and will use this file always for that schema. This represents Schema specific Settings.
  2. the header of the generated [schemaFilename].designer.[cs/vb] file if you've already run xsd2Code at least once.
  3. and finally a defaults.xsd2code file located in the same directory as the XSD file., if an only if neither of the other 2 files exists.

When using this from the command line, it functions when only the XSD file name is specified (arguments == 1)