DTOMaker.Models
3.0.19-dev
dotnet add package DTOMaker.Models --version 3.0.19-dev
NuGet\Install-Package DTOMaker.Models -Version 3.0.19-dev
<PackageReference Include="DTOMaker.Models" Version="3.0.19-dev" />
<PackageVersion Include="DTOMaker.Models" Version="3.0.19-dev" />
<PackageReference Include="DTOMaker.Models" />
paket add DTOMaker.Models --version 3.0.19-dev
#r "nuget: DTOMaker.Models, 3.0.19-dev"
#:package DTOMaker.Models@3.0.19-dev
#addin nuget:?package=DTOMaker.Models&version=3.0.19-dev&prerelease
#tool nuget:?package=DTOMaker.Models&version=3.0.19-dev&prerelease
This is the main development repo for V3+
DTOMaker
This repo contains model-driven compile-time source generators for quickly creating and maintaining polymorphic, immutable DTOs (Data Transport Objects) supporting various serialization protocols.
The objective of these generators is to improve developer productivity, saving time and reducing errors incurred maintaining boilerplate DTO code, by allowing developers to focus on the more interesting data model design, rather than on coding the implementations.
Features
All DTOs created by these generators support the following features:
- Common interfaces: Models are defined as C# interfaces. As each implementation has constructors that accept these interfaces, different implementations can be used interchangeably, allowing simple conversion between different serialization formats.
- Immutability/Freezability: Newly created instances are mutable until frozen. Once frozen, instances become immutable and can be safely shared across threads without locking.
- Backward compatibility: New properties can be added to models without breaking backward compatibility. Older versions of the DTOs will simply ignore new properties.
- Polymorphism: Model types are defined as interfaces that can inherit from other interfaces. This allows for polymorphic types, where a property of a base type can hold instances of derived types.
- Incremental serialization: When serializing an object graph, only the parts of the graph that have changed since the last serialization need to be re-serialized. This can significantly improve performance when working with large object graphs where only a small portion of the data changes between serializations. For some serialization protocols, this will be optional on an opt-in basis, and for others it is mandatory e.g. MemBlox2. All DTOs implement incremental serialization via the IPackable interface.
- Built-in type support: Most .NET primitive types are supported out of the box, including integers, floats, strings, Guid, etc. Raw byte arrays are supported using the built-in Octets type. Other common types such as DateTime, DateTimeOffset, TimeSpan are supported by built-in converters. All types can be nullable.
- Custom type support: User-defined value types can be supported via user-defined converters to built-in types. For example, a custom type representing a 3D point could be converted to and from a built-in type such as a tuple of three floats.
- Collections types: Collection properties are natively supported. Initially only array-like collections are supported, but support for other collection types is planned.
Serialization Protocols
The following serialization protocols are supported via separate source generators and runtime libraries. You can choose which ones to use by referencing the appropriate source generator and runtime library in your project.
- JSON (System.Text.Json)
- JSON (Newtonsoft.Json)
- MessagePack 3.x
- MemBlox2 (a performant binary format based on fixed memory blocks)
Example
using DTOMaker.Models;
namespace MyModels;
[Entity(1)] public interface INode : IEntityBase
{
[Member(1)] String Key { get; set; }
}
[Entity(2)] public interface IStringNode : INode
{
[Member(1)] String Value { get; set; }
}
[Entity(3)] public interface INumberNode : INode
{
[Member(1)] Int64 Value { get; set; }
}
[Entity(4)] public interface ITree : IEntityBase
{
[Member(1)] ITree? Left { get; set; }
[Member(2)] ITree? Right { get; set; }
[Member(3)] INode? Node { get; set; }
}
Workflow
flowchart TB
defmodel(Define models e.g. IMyDTO.cs)
refmodel(Reference DTOMaker.Models)
choose(Choose serialization protocol e.g. JsonSystemText)
refruntime(Reference runtime e.g. DTOMaker.Runtime.JsonSystemText)
refsrcgen(Reference source generator e.g. DTOMaker.SrcGen.JsonSystemText)
bld(Build/Run)
refmodel-->defmodel
defmodel-->choose
choose-->refruntime
choose-->refsrcgen
refruntime-->bld
refsrcgen-->bld
Open Source Declaration
This is an open source project. This means that you are free to use the source code and released binaries within the terms of the license. Use of such constitutes agreement to the license terms.
This project is maintained by unpaid developers who enjoy doing this. Please remember that developers are ordinary people, probably much like you, that have families, homes, vehicles and other everyday expenses.
If you find this project useful in any way, including generating revenue for your organisation, we ask that you consider sponsoring this project financially. We leave it up to you to decide how much. Any amount is appreciated.
You can contribute via GitHub Sponsors.
Coming next in V3.0
- Breaking changes.
- Incremental serialization (IPackable support) for all DTOs
- Generators for records and plain classes
- MessagePack 3.x generator
Coming later
- ref type converters
- more collection types
- Orleans serialization
- Protobuf.Net serialization
- model.json generation
- command-line alternative
- logical value equality
License
This project is licensed under the Apache-2.0 License - see the LICENSE file for details.
Miscellaneous
- This readme was last updated 4th June 2026.
| Product | Versions 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 was computed. 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. |
-
.NETStandard 2.0
- DataFac.Memory (>= 2.0.9)
- System.Memory (>= 4.6.3)
-
net10.0
- DataFac.Memory (>= 2.0.9)
-
net8.0
- DataFac.Memory (>= 2.0.9)
NuGet packages (8)
Showing the top 5 NuGet packages that depend on DTOMaker.Models:
| Package | Downloads |
|---|---|
|
DTOMaker.Runtime
Runtime types for generated entities |
|
|
DTOMaker.Runtime.MemBlocks
Runtime types for generated entities |
|
|
DTOMaker.Runtime.JsonNewtonSoft
Runtime types for generated entities |
|
|
DTOMaker.Runtime.JsonSystemText
Runtime types for generated entities |
|
|
DTOMaker.Runtime.MsgPack2
Runtime types for generated entities |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.19-dev | 71 | 6/30/2026 |
| 3.0.16-dev | 391 | 6/17/2026 |
| 3.0.14-dev | 404 | 6/4/2026 |
| 3.0.3-dev | 353 | 5/30/2026 |
| 2.1.12 | 98 | 6/30/2026 |
| 2.1.11 | 398 | 6/19/2026 |
| 2.1.10 | 400 | 6/17/2026 |
| 2.1.9 | 403 | 6/17/2026 |
| 2.1.7 | 388 | 6/17/2026 |
| 2.1.5-dev | 388 | 6/17/2026 |
| 2.0.58 | 365 | 5/28/2026 |
| 2.0.57 | 354 | 5/26/2026 |
| 2.0.54 | 353 | 5/16/2026 |
| 2.0.52 | 354 | 5/15/2026 |
| 2.0.50 | 366 | 5/4/2026 |
| 2.0.49 | 353 | 4/26/2026 |
| 2.0.48 | 340 | 4/25/2026 |
| 2.0.46-dev | 333 | 4/25/2026 |
| 2.0.45-dev | 339 | 4/16/2026 |
| 2.0.39-dev | 353 | 4/2/2026 |