All Projects â†’ mamift â†’ LinqToXsdCore

mamift / LinqToXsdCore

Licence: MS-PL license
LinqToXsd ported to .NET Core (targets .NET Standard 2 for generated code and .NET Core 3.1, .NET 5+ 6 for the code generator CLI tool).

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to LinqToXsdCore

Beetle.js
ðŸŠē Javascript ORM, manage your data easily.
Stars: ✭ 53 (+130.43%)
Mutual labels:  linq
granate
Code generator for graphql
Stars: ✭ 21 (-8.7%)
Mutual labels:  code-generation
xsd to django model
Generate Django models from an XSD schema description (and a bunch of hints)
Stars: ✭ 20 (-13.04%)
Mutual labels:  xsd
typed-astunparse
Python 3 AST unparser with type comments support.
Stars: ✭ 27 (+17.39%)
Mutual labels:  code-generation
go-streams
Stream Collections for Go. Inspired in Java 8 Streams and .NET Linq
Stars: ✭ 127 (+452.17%)
Mutual labels:  linq
code-fold
Write the pattern, then let your code write itself.
Stars: ✭ 13 (-43.48%)
Mutual labels:  code-generation
toast
Plugin-driven CLI utility for code generation using Go source as IDL
Stars: ✭ 52 (+126.09%)
Mutual labels:  code-generation
mr.boilerplate
Online app to generate Scala boilerplate
Stars: ✭ 32 (+39.13%)
Mutual labels:  code-generation
sample-generator
Xcode Source Editor Extension to generate Swift model samples
Stars: ✭ 19 (-17.39%)
Mutual labels:  code-generation
gonstructor
A command-line tool to generate a constructor for the struct.
Stars: ✭ 55 (+139.13%)
Mutual labels:  code-generation
jgeXml
The Just-Good-Enough XML Toolkit
Stars: ✭ 20 (-13.04%)
Mutual labels:  xsd
cscg
Code Generation as a Dual Task of Code Summarization.
Stars: ✭ 28 (+21.74%)
Mutual labels:  code-generation
eaf-linter
ðŸĪŠ A linter, prettier, and test suite that does everything as-simple-as-possible.
Stars: ✭ 17 (-26.09%)
Mutual labels:  code-generation
fling
A fluent API generator
Stars: ✭ 20 (-13.04%)
Mutual labels:  code-generation
linqjs
Perform queries on collections in the manner of C#s System.Linq in JavaScript
Stars: ✭ 14 (-39.13%)
Mutual labels:  linq
FSharpWrap
Utility that automatically generates F# modules and functions based on your F# project file's references
Stars: ✭ 14 (-39.13%)
Mutual labels:  code-generation
Textrude
Code generation from YAML/JSON/CSV models via SCRIBAN templates
Stars: ✭ 79 (+243.48%)
Mutual labels:  code-generation
dotnet-arangodb
.NET Driver for ArangoDB
Stars: ✭ 52 (+126.09%)
Mutual labels:  linq
Rosalina
Rosalina is a code generation tool for Unity's UI documents. It generates C# code-behind script based on a UXML template.
Stars: ✭ 57 (+147.83%)
Mutual labels:  code-generation
linq
A familiar set of functions that operate on JavaScript iterables (ES2015+) in a similar way to .NET's LINQ does with enumerables.
Stars: ✭ 39 (+69.57%)
Mutual labels:  linq

LinqToXsdCore

Introduction

This is a port of LinqToXsd to .NET Core. Most of what was in the original project is here, but built for .NET Core! For people who specifically need .NET Framework 3.5 and 4.0-4.5 support, please use the original code on the codeplex archive. There's also a legacy nuget package.

This .NET Core port itself requires .NET Core 2.1 or 3.1, but it can generate code that is compatible with .NET Framework 4.6.x and .NET Core 2.x.

Build Status Nuget

Get started

You can get started by reading the instructions here to use the CLI tool to generate code.

After you've generated code for a given XSD, you can include the generated code in a shipping app or library, so long as it has a reference to the XObjectsCore nuget package. Don't add the LinqToXsdCore nuget package to your shipping app or library! That's just a command line tool to generate code.

Release notes are here.

RELEASENOTES.md

Wait so what is this?

LinqToXsd was first released back in 2009, and it was billed then as a way of 'providing .NET developers with support for typed XML programming...LINQ to XSD enhances the existing LINQ to XML technology'.

Basically LinqToXsd generates code at design time, which models the structure of a XML document according, according to a W3C XML Schema (XSD). This allows a developer to program against the generated code, using strong types, where classes represents element definitions and class properties (i.e. getters and setters) represent attributes on XML elements.

Consider this XML:

<?xml version="1.0" encoding="UTF-8"?>
<purchaseOrder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:noNamespaceSchemaLocation="./Purchase Order.xsd">
    <general>
        <poNum>poNum0</poNum>
        <poDate>2006-05-04</poDate>
    </general>
    <order>
        <companyName>companyName0</companyName>
        <address>address0</address>
        <city>city0</city>
        <stateProv>stateProv0</stateProv>
        <zipCode>zipCode0</zipCode>
        <country>country0</country>
        <phone>phone0</phone>
        <fax>fax0</fax>
        <contactName>contactName0</contactName>
    </order>
</purchaseOrder>

To get the <city> element with regular LINQ to XML code, you'd write:

var purchaseOrderDoc = XDocument.Load("po.xml");
var orderElement = purchaseOrderDoc.Descendants(XName.Get("order"));
var cityElement = orderElement.Descendants(XName.Get("city"));

With LinqToXsd you can instead write:

var po = purchaseOrder.Load("po.xml");
var order = po.order;
var city = order.city;

The amount of code one writes to traverse an XML document is reduced as LinqToXsd builds a strongly-typed model for you through its code generator. This makes LinqToXsd incredibly helpful when dealing with XML data, especially if it comes with an accompanying XSD file, as most XML formats tend to do nowadays.

You can also use LinqToXsd to create XML documents programmatically using the object API:

var newPo = new PurchaseOrder();
newPo.order = new Order();
order.city = "city1";
// now save
newPo.Save("newPo.xml");

Even if there isn't a native XSD, you can infer an XSD from an existing XML file and speed up your development that way.

How does this compare to xsd.exe?

LinqToXsd, ends up providing something very similar to the C# code-generation facilities that xsd.exe provides. The main difference between the two is that LinqToXsd takes a code-generation, in-memory model and LINQ-only approach where as xsd.exe provides several legacy facilities such as XDR to XSD, XSD to DataSet, direct assembly generation, and can even do the reverse of what LinqToXsd does and generate an XSD from CLR types.

LinqToXsd also tries very closely to model XSD constraints and compositors (sequence, choice, all, substitution groups) and user defined types as much as possible, including simple and complex types, both named and anonymous. A key distinction is that LinqToXsd models XML elements and types with generated C# classes to build 'XML Objects', transposing XSD semantics in a CLR, object-oriented way. These XML objects inherit from the base class XTypedElement.

Essentially LinqToXsd generates an in memory model of the XSD schema as opposed to the classes that xsd.exe generates, which are closer to plain old C# objects (POCOs). This has the end result of making LinqToXsd a very powerful tool for modeling custom document markup languages, and preserving schema semantics in code.

To get a more technical explanation of what LinqToXsd provides, please see the wiki.

Things not supported in this .NET Core port

  • No assembly generation - due to a dependency on CodeDOM, no direct code-generation (i.e. emitting .DLL files) is supported. CodeDOM for .NET Core does not support this on any platform (even Windows).

  • Custom build action - the Visual Studio targets project (which allowed feeding an XSD and configuration file as a custom build action) has not been ported and there are no plans to do so at the moment. This was decided because the code generation utility can be installed as a global tool using dotnet. Regenerating code on build can be automated by adding a Visual Studio pre-build event (see instructions here).

License

This is licensed under the same license that the original LinqToXsd project was licensed under, which is the Microsoft Public License (MS-PL): https://opensource.org/licenses/MS-PL

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].