Dalion.ValueObjects
1.0.0-beta03
dotnet add package Dalion.ValueObjects --version 1.0.0-beta03
NuGet\Install-Package Dalion.ValueObjects -Version 1.0.0-beta03
<PackageReference Include="Dalion.ValueObjects" Version="1.0.0-beta03" />
<PackageVersion Include="Dalion.ValueObjects" Version="1.0.0-beta03" />
<PackageReference Include="Dalion.ValueObjects" />
paket add Dalion.ValueObjects --version 1.0.0-beta03
#r "nuget: Dalion.ValueObjects, 1.0.0-beta03"
#:package Dalion.ValueObjects@1.0.0-beta03
#addin nuget:?package=Dalion.ValueObjects&version=1.0.0-beta03&prerelease
#tool nuget:?package=Dalion.ValueObjects&version=1.0.0-beta03&prerelease
ValueObjects <img src="https://dalion.eu/dalion128.png" align="right" width="48">
A C# code generator to cure my Primitive Obsession.
ValueObjects is a .NET Source Generator and analyzer. It turns your primitives (ints, decimals etc.) into value objects that represent domain concepts (CustomerId, AccountBalance etc.).
Please see the Wiki for more detailed information, such as getting started, tutorials, and how-tos.
Give a Star! ⭐
If you like or are using this project please give it a star. Thanks!
Motivation
Creating value objects is a repetitive task. This project aims to reduce the amount of boilerplate code that needs to be written, by generating it.
Inspired by Vogen.
Limitations Overcome
This library addresses several limitations found in similar solutions, such as Vogen:
No Run-Time Dependency:
Unlike e.g. Vogen, which requiresVogen.SharedTypes.dllat run-time, all necessary types are generated alongside your value objects. There are no additional run-time dependencies. All required types are generated at compile-time and generated code is self-contained.Automatic Generation of Pre-Set Values:
Every value object automatically gets anEmptyorDefault(configurable) pre-set value, reducing boilerplate and ensuring consistency.
Fundamental Differences in Approach
This library takes a distinct approach to value objects, with perspectives and assumptions that are hard to align with solutions like Vogen.
Comparison of Uninitialized Value Objects:
- Vogen: Treats uninitialized value objects as different from each other.
- This Library: Considers uninitialized value objects of a type to be equal.Serialization of Uninitialized Value Objects:
- Vogen: Cannot serialize uninitialized value objects.
- This Library: Supports serialization and round-tripping of uninitialized value objects.Deserialization of Pre-Set Values:
- Vogen: Only supports deserialization of pre-set values declared via attributes.
- This Library: Can deserialize any pre-set value declared as apublic static readonlyfield, even if it does not pass validation.Validation and Error Reporting:
- Vogen: Validation information is private and inaccessible.
- This Library: Exposes validation status and error messages, allowing you to check if a value object is valid and retrieve the reason if not. This enables creation of pre-set, initialized, but invalid values.
These assumptions and aproaches reflect my personal perspective on value objects, which may differ from others. For me, they make this library more practical and usable in real-world projects.
Support
If you've got value from any of the content which I have created, but pull requests are not your thing, then I would also very much appreciate your support by buying me a coffee.
<a href="https://www.buymeacoffee.com/DavidLievrouw" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: 41px !important;width: 174px !important;box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;" ></a>
"Anybody can make something that works. Software craftsmanship is the ability to keep it understandable, maintainable and extensible."
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- Microsoft.CodeAnalysis.CSharp (>= 4.14.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 |
|---|---|---|
| 1.0.0-beta03 | 120 | 10/21/2025 |