FunctionalDdd.CommonValueObjectGenerator
3.0.0-alpha.20
dotnet add package FunctionalDdd.CommonValueObjectGenerator --version 3.0.0-alpha.20
NuGet\Install-Package FunctionalDdd.CommonValueObjectGenerator -Version 3.0.0-alpha.20
<PackageReference Include="FunctionalDdd.CommonValueObjectGenerator" Version="3.0.0-alpha.20" />
<PackageVersion Include="FunctionalDdd.CommonValueObjectGenerator" Version="3.0.0-alpha.20" />
<PackageReference Include="FunctionalDdd.CommonValueObjectGenerator" />
paket add FunctionalDdd.CommonValueObjectGenerator --version 3.0.0-alpha.20
#r "nuget: FunctionalDdd.CommonValueObjectGenerator, 3.0.0-alpha.20"
#:package FunctionalDdd.CommonValueObjectGenerator@3.0.0-alpha.20
#addin nuget:?package=FunctionalDdd.CommonValueObjectGenerator&version=3.0.0-alpha.20&prerelease
#tool nuget:?package=FunctionalDdd.CommonValueObjectGenerator&version=3.0.0-alpha.20&prerelease
CommonValueObjectGenerator
Roslyn source generator for creating strongly-typed value objects with automatic validation and IParsable support.
What It Does
Automatically generates boilerplate code for classes inheriting from RequiredString or RequiredGuid:
// You write this:
public partial class OrderId : RequiredGuid
{
}
// Generator creates:
// - TryCreate(Guid?) method returning Result<OrderId>
// - TryCreate(string?) method returning Result<OrderId>
// - NewUnique() method for new GUIDs
// - Parse(string, IFormatProvider?) method (IParsable)
// - TryParse(string?, IFormatProvider?, out OrderId) method (IParsable)
// - Explicit cast operator from Guid
// - Validation error messages
Installation
This package is included automatically when you install FunctionalDDD.CommonValueObjects:
dotnet add package FunctionalDDD.CommonValueObjects
Note: Both packages are required - the main package provides base classes, this generator creates the implementations.
Generated API
For RequiredString Classes
public partial class ProductName : RequiredString
{
}
// Generated members:
ProductName.TryCreate(string?) // Result<ProductName>
ProductName.Parse(string, IFormatProvider?) // ProductName (throws)
ProductName.TryParse(string?, IFormatProvider?, out...) // bool
(ProductName)"ABC" // Explicit cast
For RequiredGuid Classes
public partial class UserId : RequiredGuid
{
}
// Generated members:
UserId.NewUnique() // New GUID
UserId.TryCreate(Guid?) // Result<UserId>
UserId.TryCreate(string?) // Result<UserId>
UserId.Parse(string, IFormatProvider?) // UserId (throws)
UserId.TryParse(string?, IFormatProvider?, out...) // bool
(UserId)Guid.NewGuid() // Explicit cast
Requirements
- .NET Standard 2.0 compatible (source generators must target netstandard2.0)
- C# 9.0+ for partial class support
- Requires
FunctionalDDD.CommonValueObjectspackage
How It Works
- Analyzes your code for partial classes inheriting from
RequiredStringorRequiredGuid - Generates implementation code at compile-time
- Code appears in IntelliSense automatically
- No runtime reflection - all compile-time
Validation
Generated code includes automatic validation:
var result = ProductName.TryCreate("");
// Returns: Result.Failure("Product Name cannot be empty.")
var result = UserId.TryCreate(Guid.Empty);
// Returns: Result.Failure("User Id cannot be empty.")
Error messages use the class name (e.g., "Product Name" from "ProductName").
Source Code
This is a source generator - it runs at compile-time and generates C# code. The generated code is visible in:
- Visual Studio: Project ? Dependencies ? Analyzers ? FunctionalDdd.CommonValueObjectGenerator
- Output:
obj/Debug/net10.0/generated/
Resources
License
MIT � Xavier John
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
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 |
|---|---|---|
| 3.0.0-alpha.20 | 34 | 1/6/2026 |
| 3.0.0-alpha.19 | 41 | 1/5/2026 |
| 3.0.0-alpha.13 | 38 | 1/5/2026 |
| 3.0.0-alpha.9 | 40 | 1/5/2026 |
| 3.0.0-alpha.3 | 144 | 12/20/2025 |
| 2.1.10 | 675 | 12/3/2025 |
| 2.1.9 | 266 | 11/21/2025 |
| 2.1.1 | 199 | 4/26/2025 |
| 2.1.0-preview.3 | 94 | 4/26/2025 |
| 2.0.1 | 198 | 1/23/2025 |
| 2.0.0-alpha.62 | 70 | 1/8/2025 |
| 2.0.0-alpha.61 | 80 | 1/7/2025 |
| 2.0.0-alpha.60 | 89 | 12/7/2024 |
| 2.0.0-alpha.55 | 89 | 11/22/2024 |
| 2.0.0-alpha.52 | 94 | 11/7/2024 |
| 2.0.0-alpha.48 | 88 | 11/2/2024 |
| 2.0.0-alpha.47 | 89 | 10/30/2024 |
| 2.0.0-alpha.44 | 157 | 10/18/2024 |
| 2.0.0-alpha.42 | 100 | 10/14/2024 |
| 2.0.0-alpha.39 | 117 | 6/27/2024 |
| 2.0.0-alpha.38 | 104 | 4/24/2024 |
| 2.0.0-alpha.33 | 102 | 4/17/2024 |
| 2.0.0-alpha.26 | 101 | 4/9/2024 |
| 2.0.0-alpha.21 | 101 | 4/1/2024 |
| 2.0.0-alpha.19 | 114 | 3/5/2024 |
| 2.0.0-alpha.18 | 107 | 2/28/2024 |
| 2.0.0-alpha.17 | 100 | 2/26/2024 |
| 2.0.0-alpha.15 | 116 | 1/30/2024 |
| 2.0.0-alpha.8 | 95 | 1/27/2024 |
| 2.0.0-alpha.6 | 118 | 1/5/2024 |
| 1.1.1 | 1,527 | 11/15/2023 |
| 1.1.0-alpha.32 | 154 | 11/2/2023 |
| 1.1.0-alpha.30 | 239 | 10/31/2023 |
| 1.1.0-alpha.28 | 122 | 10/28/2023 |
| 1.1.0-alpha.27 | 125 | 10/28/2023 |
| 1.1.0-alpha.24 | 114 | 10/20/2023 |
| 1.1.0-alpha.23 | 122 | 10/13/2023 |
| 1.1.0-alpha.22 | 115 | 10/13/2023 |
| 1.1.0-alpha.21 | 122 | 10/1/2023 |
| 1.1.0-alpha.20 | 124 | 9/30/2023 |
| 1.1.0-alpha.19 | 122 | 9/30/2023 |
| 1.1.0-alpha.18 | 126 | 9/29/2023 |
| 1.1.0-alpha.17 | 121 | 9/22/2023 |
| 1.1.0-alpha.13 | 117 | 9/16/2023 |
| 1.1.0-alpha.4 | 234 | 6/9/2023 |
| 1.1.0-alpha.3 | 167 | 6/8/2023 |
| 1.0.1 | 1,547 | 5/12/2023 |
| 0.1.0-alpha.40 | 228 | 4/6/2023 |
| 0.1.0-alpha.39 | 224 | 4/3/2023 |
| 0.1.0-alpha.38 | 237 | 4/2/2023 |
| 0.1.0-alpha.37 | 228 | 3/31/2023 |
| 0.1.0-alpha.35 | 216 | 3/29/2023 |
| 0.1.0-alpha.34 | 195 | 3/28/2023 |
| 0.1.0-alpha.32 | 237 | 3/18/2023 |
| 0.1.0-alpha.30 | 231 | 3/11/2023 |
| 0.1.0-alpha.27 | 227 | 3/7/2023 |
| 0.1.0-alpha.24 | 233 | 2/15/2023 |
| 0.1.0-alpha.22 | 219 | 2/15/2023 |
| 0.1.0-alpha.20 | 227 | 2/13/2023 |
| 0.1.0-alpha.19 | 180 | 2/13/2023 |
| 0.0.1-alpha.14 | 240 | 1/4/2023 |
| 0.0.1-alpha.4 | 215 | 12/30/2022 |
| 0.0.1-alpha.3 | 229 | 12/23/2022 |
| 0.0.1-alpha | 1,573 | 12/21/2022 |