DTOMaker.Runtime 1.3.5-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.5-dev
                    
NuGet\Install-Package DTOMaker.Runtime -Version 1.3.5-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.5-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.5-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.5-dev
                    
#r "nuget: DTOMaker.Runtime, 1.3.5-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.5-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.5-dev&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=DTOMaker.Runtime&version=1.3.5-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.19-dev 0 1/1/2026
1.5.18-dev 246 12/28/2025
1.5.13-dev 244 12/27/2025
1.5.4-dev 293 12/26/2025
1.4.17 270 12/26/2025
1.4.16 292 12/25/2025
1.4.10 289 12/24/2025
1.4.8 288 12/24/2025
1.4.7-dev 285 12/23/2025
1.4.4-dev 277 12/22/2025
1.3.6 204 12/20/2025
1.3.5-dev 200 12/20/2025
1.3.4-dev 131 12/20/2025
1.3.3-dev 216 12/19/2025
1.2.11 258 12/17/2025
1.2.10 256 12/17/2025
1.2.9 257 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 184 11/27/2025
0.72.5 333 11/17/2025
0.72.4 273 11/13/2025
0.72.3 273 11/13/2025
0.71.12 144 10/10/2025
0.71.11 368 10/3/2025
0.71.9 479 9/19/2025
0.71.8 522 9/17/2025
0.71.7 492 9/16/2025
0.71.5 261 9/15/2025
0.71.3 410 9/15/2025
0.71.1 434 9/15/2025
0.70.3 471 9/9/2025
0.70.2 578 9/2/2025
0.70.1-dev 380 8/27/2025
0.69.10 293 8/17/2025
0.69.9 256 8/16/2025
0.69.8 346 8/13/2025
0.69.7-dev 317 8/13/2025
0.69.6-dev 323 8/12/2025
0.69.4-dev 301 8/9/2025
0.69.3-dev 255 7/19/2025
0.69.2-dev 225 7/19/2025
0.68.6 239 7/19/2025
0.68.5-dev 240 7/19/2025
0.68.2-dev 312 7/17/2025
0.68.1-dev 328 7/17/2025
0.67.7 334 7/17/2025
0.67.6-dev 334 7/9/2025
0.67.5-dev 319 7/9/2025
0.67.3-dev 333 7/7/2025
0.67.1-dev 473 6/10/2025
0.66.18 444 6/9/2025
0.66.17-dev 395 6/9/2025
0.66.16-dev 277 6/8/2025
0.66.14-dev 249 6/7/2025
0.66.13-dev 294 6/5/2025
0.66.10-dev 346 6/5/2025
0.66.9-dev 349 6/5/2025
0.66.8-dev 341 6/5/2025
0.66.7-dev 344 6/4/2025
0.66.2-dev 284 5/31/2025
0.65.20-generics-g24a665d336 284 5/31/2025
0.65.13-generics-ge74b19332f 369 4/23/2025
0.65.10-generics-g6f262eb134 447 4/17/2025
0.65.1-generics 287 5/31/2025
0.64.27 359 5/27/2025
0.64.26 411 5/16/2025
0.64.24 377 5/8/2025
0.64.22 370 4/23/2025
0.64.20 396 4/10/2025
0.64.18 414 4/10/2025
0.64.17 383 4/10/2025
0.64.16 362 4/9/2025
0.64.10 371 4/7/2025
0.64.9 325 4/4/2025
0.64.8-dev 384 4/1/2025
0.64.7-dev-g53a80ba3be 347 4/1/2025
0.64.5-dev-g449e36f771 679 3/25/2025
0.64.5-dev-g2fcf9bff64 366 4/1/2025
0.64.4-dev 384 4/1/2025
0.64.3-dev 340 3/31/2025
0.64.2-dev 657 3/25/2025
0.64.1-dev 657 3/25/2025
0.63.60-gee4d301e03 660 3/25/2025
0.63.19 292 3/21/2025
0.63.19-g2e909c64aa 258 3/21/2025
0.63.17 295 3/14/2025
0.63.16 290 3/14/2025
0.63.15 332 3/13/2025
0.63.13 373 3/11/2025
0.63.12 353 3/11/2025
0.63.11-dev 357 3/11/2025
0.63.9-dev 334 3/11/2025
0.63.8-dev 306 3/10/2025
0.63.7-dev 324 3/10/2025
0.63.6-dev 353 3/10/2025
0.63.3-dev 335 3/10/2025
0.62.10 388 3/8/2025
0.62.9 361 3/8/2025
0.62.7 395 3/7/2025
0.62.6-dev 351 3/7/2025
0.62.5-dev 357 3/7/2025
0.61.14 409 3/6/2025
0.61.13-dev 344 3/6/2025
0.61.12-dev 372 3/6/2025
0.61.10-dev 373 3/6/2025
0.61.9-dev 348 3/5/2025
0.61.8-dev 344 3/5/2025
0.61.5-dev 369 3/4/2025
0.61.3-dev 334 3/4/2025
0.61.2-dev 288 3/3/2025
0.60.8 300 2/27/2025
0.60.7 279 2/27/2025
0.60.6-dev 231 2/27/2025
0.60.3-dev 237 2/25/2025
0.59.10 313 2/19/2025
0.59.8-dev 263 2/19/2025
0.59.5-dev 269 2/17/2025
0.59.4-dev 261 2/15/2025
0.58.9 288 2/4/2025
0.58.8-dev 276 2/4/2025
0.57.6 278 2/1/2025
0.57.4 284 2/1/2025
0.57.2-dev 259 2/1/2025
0.57.1-dev 236 2/1/2025
0.56.13 294 1/31/2025
0.56.12-dev 271 1/31/2025
0.56.11-dev 247 1/30/2025
0.56.10-dev 256 1/30/2025
0.56.9-dev 270 1/30/2025
0.56.6-dev 250 1/24/2025
0.56.5-dev 223 1/24/2025
0.56.4-dev 257 1/24/2025
0.56.3-dev 244 1/24/2025
0.55.38 281 1/23/2025
0.55.37-dev 253 1/23/2025
0.55.36-dev 261 1/22/2025
0.55.34-dev 242 1/22/2025
0.55.32-dev 247 1/22/2025
0.55.31-dev 266 1/21/2025
0.55.30-dev 230 1/21/2025
0.55.29-dev 242 1/20/2025
0.55.27-dev 227 1/20/2025
0.55.25-dev 249 1/20/2025
0.55.24-dev 254 1/20/2025
0.55.23-dev 253 1/19/2025
0.55.20-dev 217 1/19/2025
0.55.17-dev 245 1/19/2025
0.55.14-dev 237 1/19/2025
0.55.3-dev 126 1/9/2025
0.55.2-dev 97 1/9/2025
0.54.2 306 1/3/2025
0.54.1-dev 186 1/3/2025
0.53.3 371 1/1/2025
0.53.2 339 12/31/2024
0.53.1-dev 242 12/31/2024
0.51.2 432 12/31/2024
0.51.1 145 12/31/2024