DTOMaker.Runtime 1.3.4-dev

This is a prerelease version of DTOMaker.Runtime.
There is a newer version of this package available.
See the version list below for details.
dotnet add package DTOMaker.Runtime --version 1.3.4-dev
                    
NuGet\Install-Package DTOMaker.Runtime -Version 1.3.4-dev
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DTOMaker.Runtime" Version="1.3.4-dev" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DTOMaker.Runtime" Version="1.3.4-dev" />
                    
Directory.Packages.props
<PackageReference Include="DTOMaker.Runtime" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DTOMaker.Runtime --version 1.3.4-dev
                    
#r "nuget: DTOMaker.Runtime, 1.3.4-dev"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DTOMaker.Runtime@1.3.4-dev
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DTOMaker.Runtime&version=1.3.4-dev&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=DTOMaker.Runtime&version=1.3.4-dev&prerelease
                    
Install as a Cake Tool

DTOMaker

Build-Deploy NuGet Version NuGet Downloads GitHub License GitHub Sponsors

Warning: This is pre-release software under active development. Breaking changes may occur.

Model-driven compile-time source generators for quickly creating polymorphic, freezable DTOs (Data Transport Objects) supporting various serialization protocols:

  • JSON (System.Text.Json)
  • JSON (Newtonsoft.Json) [in progress]
  • MessagePack [coming soon]
  • MemBlocks [coming soon]

Workflow

---
title: Workflow
---
flowchart LR
    def(Define models e.g. IMyDTO.cs)
    ref1(Reference DTOMaker.Models)
    ref2(Reference DTOMaker.Runtime.JsonSystemText)
    ref3(Reference DTOMaker.SrcGen.JsonSystemText)
    bld(VS/Code/MSBuild)
    pkg(Assembly)
    ref1-->def
    def-->ref2
    def-->ref3
    ref2-->bld
    ref3-->bld
    bld-->pkg

Models are defined as C# interfaces with additional attributes. So let's start with a non-trivial model. Here's how to define a generic recursive tree type with an example closed instance:

[Entity][Id(1)]
public interface ITree<TK, TV> : IEntityBase
{
    [Member(1)] int Count { get; set; }
    [Member(2)] TK Key { get; set; }
    [Member(3)] TV Value { get; set; }
    [Member(4)] ITree<TK, TV>? Left { get; set; }
    [Member(5)] ITree<TK, TV>? Right { get; set; }
}
[Entity][Id(2)]
public interface IMyTree : ITree<String, Octets> { }

The following implmentation will be generated (simplified for readability):

[JsonPolymorphic]
[JsonDerivedType(typeof(MyTree))]
public partial class Tree_2_String_Octets : EntityBase, ITree<String, Octets>, IEquatable<Tree_2_String_Octets>
{
    [JsonIgnore] private Int32 _Count = default;
    public Int32 Count { get => _Count; set => _Count = value; }

    [JsonIgnore] private string _Key = string.Empty;
    public string Key { get => _Key; set => _Key = value; }

    [JsonIgnore] private byte[] _Value = Array.Empty<byte>();
    public byte[] Value { get => _Value; set => _Value = value; }
    Octets ITree<String, Octets>.Value
    {
        get => _Value.Length == 0 ? Octets.Empty : new Octets(_Value);
        set => _Value = value.ToByteArray();
    }

    [JsonIgnore] private Tree_2_String_Octets? _Left;
    public Tree_2_String_Octets? Left { get => _Left; set => _Left = value; }
    ITree<String, Octets>? ITree<String, Octets>.Left
    {
        get => _Left;
        set => _Left = value is null ? null : Tree_2_String_Octets.CreateFrom(value));
    }

    [JsonIgnore] private Tree_2_String_Octets? _Right;
    public Tree_2_String_Octets? Right { get => _Right; set => _Right = value; }
    ITree<String, Octets>? ITree<String, Octets>.Right
    {
        get => _Right;
        set => _Right = value is null ? null : Tree_2_String_Octets.CreateFrom(value);
    }
}
public partial class MyTree : Tree_2_String_Octets, IMyTree, IEquatable<MyTree>

Development

In progress

  • JSON (NewtonSoft) source generator

Coming soon

  • custom struct members (to avoid primitive obsession)
  • global interface equality comparer
  • reservation (hidden members)

Coming later

  • model.json generation
  • command-line alternative
  • variable length arrays
  • logical value equality

How to sponsor

If you find these tools useful, please consider sponsoring my work on GitHub at https://github.com/sponsors/Psiman62 or buy me a coffee at https://www.buymeacoffee.com/psiman62

License

This project is licensed under the Apache-2.0 License - see the LICENSE file for details.

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 is compatible.  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.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages (7)

Showing the top 5 NuGet packages that depend on DTOMaker.Runtime:

Package Downloads
DTOMaker.Runtime.MemBlocks

Runtime types for generated entities

DTOMaker.Runtime.MessagePack

Runtime types for DTOMaker.MessagePack entities

DTOMaker.Runtime.CSPoco

Runtime types for DTOMaker.CSPoco entities

DTOMaker.Runtime.JsonNewtonSoft

Runtime types for generated entities

DTOMaker.Runtime.CSRecord

Runtime types for DTOMaker.CSRecord entities

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.5.4-dev 0 12/26/2025
1.4.17 42 12/26/2025
1.4.16 71 12/25/2025
1.4.10 69 12/24/2025
1.4.8 80 12/24/2025
1.4.7-dev 146 12/23/2025
1.4.4-dev 188 12/22/2025
1.3.6 202 12/20/2025
1.3.5-dev 199 12/20/2025
1.3.4-dev 130 12/20/2025
1.3.3-dev 215 12/19/2025
1.2.11 257 12/17/2025
1.2.10 254 12/17/2025
1.2.9 256 12/17/2025
1.2.8-dev 257 12/17/2025
1.2.7-dev 256 12/17/2025
1.2.6-dev 255 12/17/2025
1.2.5-dev 256 12/17/2025
1.2.4-dev 260 12/17/2025
0.72.6 182 11/27/2025
0.72.5 330 11/17/2025
0.72.4 270 11/13/2025
0.72.3 271 11/13/2025
0.71.12 142 10/10/2025
0.71.11 363 10/3/2025
0.71.9 477 9/19/2025
0.71.8 521 9/17/2025
0.71.7 490 9/16/2025
0.71.5 258 9/15/2025
0.71.3 409 9/15/2025
0.71.1 431 9/15/2025
0.70.3 469 9/9/2025
0.70.2 576 9/2/2025
0.70.1-dev 379 8/27/2025
0.69.10 290 8/17/2025
0.69.9 255 8/16/2025
0.69.8 345 8/13/2025
0.69.7-dev 316 8/13/2025
0.69.6-dev 320 8/12/2025
0.69.4-dev 299 8/9/2025
0.69.3-dev 253 7/19/2025
0.69.2-dev 224 7/19/2025
0.68.6 237 7/19/2025
0.68.5-dev 240 7/19/2025
0.68.2-dev 311 7/17/2025
0.68.1-dev 326 7/17/2025
0.67.7 330 7/17/2025
0.67.6-dev 333 7/9/2025
0.67.5-dev 317 7/9/2025
0.67.3-dev 331 7/7/2025
0.67.1-dev 471 6/10/2025
0.66.18 440 6/9/2025
0.66.17-dev 393 6/9/2025
0.66.16-dev 276 6/8/2025
0.66.14-dev 248 6/7/2025
0.66.13-dev 292 6/5/2025
0.66.10-dev 345 6/5/2025
0.66.9-dev 347 6/5/2025
0.66.8-dev 338 6/5/2025
0.66.7-dev 342 6/4/2025
0.66.2-dev 282 5/31/2025
0.65.20-generics-g24a665d336 282 5/31/2025
0.65.13-generics-ge74b19332f 368 4/23/2025
0.65.10-generics-g6f262eb134 445 4/17/2025
0.65.1-generics 285 5/31/2025
0.64.27 357 5/27/2025
0.64.26 410 5/16/2025
0.64.24 375 5/8/2025
0.64.22 369 4/23/2025
0.64.20 394 4/10/2025
0.64.18 413 4/10/2025
0.64.17 381 4/10/2025
0.64.16 359 4/9/2025
0.64.10 369 4/7/2025
0.64.9 321 4/4/2025
0.64.8-dev 382 4/1/2025
0.64.7-dev-g53a80ba3be 345 4/1/2025
0.64.5-dev-g449e36f771 677 3/25/2025
0.64.5-dev-g2fcf9bff64 364 4/1/2025
0.64.4-dev 381 4/1/2025
0.64.3-dev 338 3/31/2025
0.64.2-dev 654 3/25/2025
0.64.1-dev 654 3/25/2025
0.63.60-gee4d301e03 659 3/25/2025
0.63.19 289 3/21/2025
0.63.19-g2e909c64aa 257 3/21/2025
0.63.17 293 3/14/2025
0.63.16 287 3/14/2025
0.63.15 332 3/13/2025
0.63.13 371 3/11/2025
0.63.12 350 3/11/2025
0.63.11-dev 357 3/11/2025
0.63.9-dev 333 3/11/2025
0.63.8-dev 305 3/10/2025
0.63.7-dev 322 3/10/2025
0.63.6-dev 352 3/10/2025
0.63.3-dev 332 3/10/2025
0.62.10 386 3/8/2025
0.62.9 359 3/8/2025
0.62.7 393 3/7/2025
0.62.6-dev 349 3/7/2025
0.62.5-dev 356 3/7/2025
0.61.14 406 3/6/2025
0.61.13-dev 342 3/6/2025
0.61.12-dev 370 3/6/2025
0.61.10-dev 371 3/6/2025
0.61.9-dev 346 3/5/2025
0.61.8-dev 341 3/5/2025
0.61.5-dev 369 3/4/2025
0.61.3-dev 332 3/4/2025
0.61.2-dev 285 3/3/2025
0.60.8 296 2/27/2025
0.60.7 275 2/27/2025
0.60.6-dev 230 2/27/2025
0.60.3-dev 233 2/25/2025
0.59.10 308 2/19/2025
0.59.8-dev 262 2/19/2025
0.59.5-dev 268 2/17/2025
0.59.4-dev 260 2/15/2025
0.58.9 285 2/4/2025
0.58.8-dev 275 2/4/2025
0.57.6 275 2/1/2025
0.57.4 282 2/1/2025
0.57.2-dev 257 2/1/2025
0.57.1-dev 234 2/1/2025
0.56.13 292 1/31/2025
0.56.12-dev 269 1/31/2025
0.56.11-dev 247 1/30/2025
0.56.10-dev 254 1/30/2025
0.56.9-dev 269 1/30/2025
0.56.6-dev 248 1/24/2025
0.56.5-dev 222 1/24/2025
0.56.4-dev 256 1/24/2025
0.56.3-dev 242 1/24/2025
0.55.38 281 1/23/2025
0.55.37-dev 248 1/23/2025
0.55.36-dev 260 1/22/2025
0.55.34-dev 240 1/22/2025
0.55.32-dev 245 1/22/2025
0.55.31-dev 264 1/21/2025
0.55.30-dev 226 1/21/2025
0.55.29-dev 240 1/20/2025
0.55.27-dev 224 1/20/2025
0.55.25-dev 247 1/20/2025
0.55.24-dev 253 1/20/2025
0.55.23-dev 251 1/19/2025
0.55.20-dev 216 1/19/2025
0.55.17-dev 243 1/19/2025
0.55.14-dev 236 1/19/2025
0.55.3-dev 124 1/9/2025
0.55.2-dev 94 1/9/2025
0.54.2 303 1/3/2025
0.54.1-dev 185 1/3/2025
0.53.3 368 1/1/2025
0.53.2 336 12/31/2024
0.53.1-dev 239 12/31/2024
0.51.2 429 12/31/2024
0.51.1 142 12/31/2024