LinqToXsdCore 3.0.0.5

There is a newer version of this package available.
See the version list below for details.
dotnet tool install --global LinqToXsdCore --version 3.0.0.5                
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest # if you are setting up this repo
dotnet tool install --local LinqToXsdCore --version 3.0.0.5                
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=LinqToXsdCore&version=3.0.0.5                
nuke :add-package LinqToXsdCore --version 3.0.0.5                

LinqToXsd

This project forms the command-line interface utility used to generate C# code that represents the structure of an XML document that conforms to an W3C XML Schema (XSD).

Most of the logic for reading an XSD is coded in the XObjectsCore project, but logic that is specific to an individual XSD (like custom types and elements), is generated as C# code using the CodeDOM provider (also inside XObjectsCore) that is invoked via this CLI tool.

The code this tool generates has a dependency on namespaces defined in the XObjectsCore library. You can add a reference to that library via nuget here: https://www.nuget.org/packages/XObjectsCore

Don't add this project as a dependency to your shipping libraries or app - depend on the code it generates, and the XObjectsCore library instead.

This project adds additional features from the old CLI tool (the XObjectsGenerator project is the legacy CLI), like generating .config files with default values from an existing XSD and generating code from multiple XSD's and multiple .config files.

Installation

This tool is published as a global .NET tool here: https://www.nuget.org/packages/LinqToXsdCore. Install it using

dotnet tool install LinqToXsdCore -g

After that, you can use the tool globally via the command 'LinqToXsd' at a console (cmd or powershell).

Using LinqToXsd to generate code

Before generating code, create an example configuration file from your XSD (this will allow you to customize how XML namespaces map to .NET CLR namepsaces).

linqtoxsd config -e wss.xsd

Currently, as this is a port of the LinqToXsd project, some configuration elements are not documented but for some reason or another are processed and interpreted in source code. But the gist of what you need as a developer is to pay attention to the <Namespaces /> element.

Under that element, it will create default namepsace mappings similar to the following example:

<Namespaces>
  <Namespace Schema="http://schemas.microsoft.com/sharepoint/" Clr="schemas.microsoft.com.sharepoint" />
</Namespaces>

The XML namespace http://schemas.microsoft.com/sharepoint/ becomes: schemas.microsoft.com.sharepoint in the generated C# code. And obviously now that you have a configuration file you can change the default values to something more suitable for you.

To use your new configuraton file to generate code:

linqtoxsd gen wss.xsd -c .\wss.xsd.config

It will output code to 'file.xsd.cs', or in this case 'wss.xsd.cs'.

Regenerating code

You can also add a pre-build event in your Visual Studio project definition, invoking the linqtoxsd tool to regenerate code every time you build your solution:

linqtoxsd gen "$(ProjectDir)wss.xsd" -c "$(ProjectDir)wss.xsd.config"

In the above example, the strings beginning with $() are MSBuild macros.

Help for other functions

There's some other miscellaneous functions in the CLI tool that may be helpful to you, and be used to exert finer control over code output. To view the help screen for this tool:

linqtoxsd help

To view help for a specific verb:

linqtoxsd <verb> --help

To view help on configuration file generation:

linqtoxsd config --help

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.1 is compatible.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last updated
3.4.7 505 7/19/2024
3.4.6 2,504 2/13/2024
3.4.5 230 2/6/2024
3.4.4 238 1/29/2024
3.4.3 217 1/24/2024
3.4.2 604 10/2/2023
3.4.1 283 9/16/2023
3.4.0 367 7/3/2023
3.3.3 603 1/6/2023
3.3.2 833 3/30/2022
3.3.1 452 3/29/2022
3.3.0 521 3/28/2022
3.2.1 1,037 7/3/2021
3.2.0 528 2/15/2021
3.1.0 743 5/3/2020
3.0.1 668 3/15/2020
3.0.0.12 506 3/11/2020
3.0.0.11 563 3/5/2020
3.0.0.10 594 2/14/2020
3.0.0.9 568 1/18/2020
3.0.0.8 615 10/27/2019
3.0.0.7 648 10/1/2019
3.0.0.6 615 9/27/2019
3.0.0.5 607 8/20/2019
3.0.0.4 649 6/7/2019
3.0.0.3-beta 429 5/15/2019