DTOMaker.Runtime.JsonSystemText 1.3.3-dev

This is a prerelease version of DTOMaker.Runtime.JsonSystemText.
There is a newer version of this package available.
See the version list below for details.
dotnet add package DTOMaker.Runtime.JsonSystemText --version 1.3.3-dev
                    
NuGet\Install-Package DTOMaker.Runtime.JsonSystemText -Version 1.3.3-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.JsonSystemText" Version="1.3.3-dev" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DTOMaker.Runtime.JsonSystemText" Version="1.3.3-dev" />
                    
Directory.Packages.props
<PackageReference Include="DTOMaker.Runtime.JsonSystemText" />
                    
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.JsonSystemText --version 1.3.3-dev
                    
#r "nuget: DTOMaker.Runtime.JsonSystemText, 1.3.3-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.JsonSystemText@1.3.3-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.JsonSystemText&version=1.3.3-dev&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=DTOMaker.Runtime.JsonSystemText&version=1.3.3-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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.7.25 0 1/19/2026
1.7.22 23 1/18/2026
1.7.20-dev 24 1/18/2026
1.7.18-dev 29 1/18/2026
1.7.8-dev 30 1/17/2026
1.7.1-dev 83 1/8/2026
1.6.12 82 1/6/2026
1.6.10 87 1/4/2026
1.6.2 85 1/3/2026
1.6.1 87 1/3/2026
1.5.23 87 1/1/2026
1.5.22-dev 80 1/1/2026
1.5.19-dev 79 1/1/2026
1.5.18-dev 87 12/28/2025
1.5.13-dev 84 12/27/2025
1.5.4-dev 125 12/26/2025
1.4.17 159 12/26/2025
1.4.16 169 12/25/2025
1.4.10 166 12/24/2025
1.4.8 174 12/24/2025
1.4.7-dev 168 12/23/2025
1.4.4-dev 164 12/22/2025
1.3.6 124 12/20/2025
1.3.5-dev 122 12/20/2025
1.3.4-dev 135 12/20/2025
1.3.3-dev 219 12/19/2025
1.2.11 259 12/17/2025
1.2.10 257 12/17/2025
1.2.9 261 12/17/2025
1.2.8-dev 260 12/17/2025
1.2.7-dev 258 12/17/2025
1.0.27 155 10/3/2025
1.0.26 297 9/19/2025
1.0.25 320 9/17/2025
1.0.23 193 9/10/2025
1.0.22 188 9/10/2025
1.0.18-dev 144 9/5/2025
1.0.17-dev 139 9/5/2025
1.0.15-dev 157 9/5/2025
1.0.14-dev 171 9/5/2025
1.0.13-dev 182 9/5/2025
1.0.11-dev 202 9/4/2025
1.0.9-dev 193 9/4/2025