DTOMaker.MessagePack
0.71.8
dotnet add package DTOMaker.MessagePack --version 0.71.8
NuGet\Install-Package DTOMaker.MessagePack -Version 0.71.8
<PackageReference Include="DTOMaker.MessagePack" Version="0.71.8" />
<PackageVersion Include="DTOMaker.MessagePack" Version="0.71.8" />
<PackageReference Include="DTOMaker.MessagePack" />
paket add DTOMaker.MessagePack --version 0.71.8
#r "nuget: DTOMaker.MessagePack, 0.71.8"
#:package DTOMaker.MessagePack@0.71.8
#addin nuget:?package=DTOMaker.MessagePack&version=0.71.8
#tool nuget:?package=DTOMaker.MessagePack&version=0.71.8
DTOMaker
Warning: This is pre-release software under active development. Breaking changes may occur.
A collection of model-driven compile-time source generators for quickly creating DTOs (Data Transport Objects) supporting the following serialization schemes:
- JSON (NewtonSoft)
- MessagePack
- MemBlocks
and related types.
Workflow
---
title: Workflow
---
flowchart LR
def(Define models e.g. IMyDTO.cs)
ref1(Reference DTOMaker.Models.*)
ref2(Reference DTOMaker.Runtime.*)
ref3(Reference one or more source generators e.g. DTOMaker.MessagePack)
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. Here's a trivial example:
[Entity][Id(1)]
public interface IMyFirstDTO
{
[Member(1)] string Name { get; set; }
}
If using the MessagePack source generator, the following implmentation will be generated (simplified):
[MessagePackObject]
public sealed class MyFirstDTO : EntityBase, IMyFirstDTO, IEquatable<MyFirstDTO>
{
[Key(1)] string Name { get; set; }
}
Included Packages
This repo includes the following packages:
DTOMaker.Models
Attributes for defining simple data models as interfaces in C#.
DTOMaker.JsonNewtonSoft
A source generator that creates DTOs (Data Transport Objects) that are serializable to JSON using the Newtonsoft.Json package.
DTOMaker.MessagePack
A source generator that creates MessagePack DTOs (Data Transport Objects). See https://github.com/MessagePack-CSharp/MessagePack-CSharp.
DTOMaker.Models.MessagePack
Additional attributes used by the DTOMaker.MessagePack source generator, to manage MessagePack entity and member keys.
DTOMaker.MemBlocks
Generates DTOs whose internal data is a single memory block (Memory<byte>). Property getters and setters decode and encode values directly to the block with little-endian (default) or big-endian byte ordering.
DTOMaker.Models.MemBlocks
Additional attributes used by the DTOMaker.MemBlocks source generator, to manage entity and member memory layout.
DTOMaker.CSPoco
Generates basic POCOs (Plain Old C# Objects) that implement the model interfaces.
DTOMaker.Runtime
Common types used at runtime by DTOMaker generated entities.
Model features
- Member value types: Boolean, S/Byte, U/Int16/32/64/128, Double, Single, Half, Char, Guid, Decimal
- String member types
- Binary member types (Octets)
- polymorphic types
- generic types
- entity members
- Built-in freezability (mutable until frozen) support
- [Obsolete] members
- Fixed length arrays of above value types.
- IEquatable<T> support
- Templates as testable code, template-to-generator processing.
MemBlocks features
- auto-embedded string, binary and entity members when encoded < 63 bytes.
- fixed-length string and binary member types.
!Limitations
Single compilation unit
All models and generated DTOs are contained within a single assembly. Models cannot reference types in other projects or packages (other than native or built-in types). Generated classes are partial, which can help you mitigate the single assembly constraint.
Development
In progress
- custom struct members (to avoid primitive obsession)
Coming soon
- Json (System.Text) generator
- upgrade source generators to IIncrementalGenerator
- global interface equality comparer
- reservation (hidden members)
- Orleans generator
- ProtobufNet 3.0 generator
- MessagePack 3.x generator
- NetStrux generator
- MemBlocks compact layout method
- Enum data types. Workaround - enums can be implemented with an underlying integer property and a cast.
- MemBlocks nullable types. Workaround - T? can be implemented with a pair of members (Boolean, T).
Coming later
- Google Protobuf .proto generation
- model.json generation
- command-line alternative
- variable length arrays
- logical value equality
- Rune member types
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- Microsoft.Bcl.HashCode (>= 6.0.0)
- Microsoft.CodeAnalysis (>= 4.12.0)
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 |
|---|---|---|
| 0.71.8 | 154 | 10/3/2025 |
| 0.71.7 | 311 | 9/19/2025 |
| 0.71.6 | 326 | 9/17/2025 |
| 0.71.5 | 333 | 9/16/2025 |
| 0.71.4 | 271 | 9/15/2025 |
| 0.71.3 | 267 | 9/15/2025 |
| 0.71.1 | 266 | 9/15/2025 |
| 0.70.3 | 193 | 9/9/2025 |
| 0.70.2 | 189 | 9/2/2025 |
| 0.70.1-dev | 235 | 8/27/2025 |
| 0.69.10 | 166 | 8/17/2025 |
| 0.69.9 | 128 | 8/16/2025 |
| 0.69.8 | 196 | 8/13/2025 |
| 0.69.7-dev | 204 | 8/13/2025 |
| 0.69.6-dev | 186 | 8/12/2025 |
| 0.69.4-dev | 161 | 8/9/2025 |
| 0.69.3-dev | 122 | 7/19/2025 |
| 0.69.2-dev | 107 | 7/19/2025 |
| 0.68.6 | 137 | 7/19/2025 |
| 0.68.5-dev | 112 | 7/19/2025 |