FunctionalDdd.CommonValueObjectGenerator 3.0.0-alpha.20

This is a prerelease version of FunctionalDdd.CommonValueObjectGenerator.
dotnet add package FunctionalDdd.CommonValueObjectGenerator --version 3.0.0-alpha.20
                    
NuGet\Install-Package FunctionalDdd.CommonValueObjectGenerator -Version 3.0.0-alpha.20
                    
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="FunctionalDdd.CommonValueObjectGenerator" Version="3.0.0-alpha.20" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FunctionalDdd.CommonValueObjectGenerator" Version="3.0.0-alpha.20" />
                    
Directory.Packages.props
<PackageReference Include="FunctionalDdd.CommonValueObjectGenerator" />
                    
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 FunctionalDdd.CommonValueObjectGenerator --version 3.0.0-alpha.20
                    
#r "nuget: FunctionalDdd.CommonValueObjectGenerator, 3.0.0-alpha.20"
                    
#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 FunctionalDdd.CommonValueObjectGenerator@3.0.0-alpha.20
                    
#: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=FunctionalDdd.CommonValueObjectGenerator&version=3.0.0-alpha.20&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=FunctionalDdd.CommonValueObjectGenerator&version=3.0.0-alpha.20&prerelease
                    
Install as a Cake Tool

CommonValueObjectGenerator

NuGet

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.CommonValueObjects package

How It Works

  1. Analyzes your code for partial classes inheriting from RequiredString or RequiredGuid
  2. Generates implementation code at compile-time
  3. Code appears in IntelliSense automatically
  4. 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

There are no supported framework assets in this package.

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 41 1/6/2026
3.0.0-alpha.19 42 1/5/2026
3.0.0-alpha.13 40 1/5/2026
3.0.0-alpha.9 42 1/5/2026
3.0.0-alpha.3 145 12/20/2025
2.1.10 679 12/3/2025
2.1.9 272 11/21/2025
2.1.1 202 4/26/2025
2.1.0-preview.3 98 4/26/2025
2.0.1 201 1/23/2025
2.0.0-alpha.62 74 1/8/2025
2.0.0-alpha.61 82 1/7/2025
2.0.0-alpha.60 94 12/7/2024
2.0.0-alpha.55 92 11/22/2024
2.0.0-alpha.52 98 11/7/2024
2.0.0-alpha.48 91 11/2/2024
2.0.0-alpha.47 95 10/30/2024
2.0.0-alpha.44 160 10/18/2024
2.0.0-alpha.42 103 10/14/2024
2.0.0-alpha.39 120 6/27/2024
2.0.0-alpha.38 108 4/24/2024
2.0.0-alpha.33 106 4/17/2024
2.0.0-alpha.26 105 4/9/2024
2.0.0-alpha.21 106 4/1/2024
2.0.0-alpha.19 118 3/5/2024
2.0.0-alpha.18 110 2/28/2024
2.0.0-alpha.17 106 2/26/2024
2.0.0-alpha.15 119 1/30/2024
2.0.0-alpha.8 100 1/27/2024
2.0.0-alpha.6 121 1/5/2024
1.1.1 1,532 11/15/2023
1.1.0-alpha.32 157 11/2/2023
1.1.0-alpha.30 243 10/31/2023
1.1.0-alpha.28 125 10/28/2023
1.1.0-alpha.27 129 10/28/2023
1.1.0-alpha.24 117 10/20/2023
1.1.0-alpha.23 125 10/13/2023
1.1.0-alpha.22 118 10/13/2023
1.1.0-alpha.21 126 10/1/2023
1.1.0-alpha.20 129 9/30/2023
1.1.0-alpha.19 124 9/30/2023
1.1.0-alpha.18 130 9/29/2023
1.1.0-alpha.17 125 9/22/2023
1.1.0-alpha.13 122 9/16/2023
1.1.0-alpha.4 238 6/9/2023
1.1.0-alpha.3 170 6/8/2023
1.0.1 1,551 5/12/2023
0.1.0-alpha.40 232 4/6/2023
0.1.0-alpha.39 227 4/3/2023
0.1.0-alpha.38 240 4/2/2023
0.1.0-alpha.37 232 3/31/2023
0.1.0-alpha.35 221 3/29/2023
0.1.0-alpha.34 199 3/28/2023
0.1.0-alpha.32 244 3/18/2023
0.1.0-alpha.30 234 3/11/2023
0.1.0-alpha.27 231 3/7/2023
0.1.0-alpha.24 236 2/15/2023
0.1.0-alpha.22 223 2/15/2023
0.1.0-alpha.20 229 2/13/2023
0.1.0-alpha.19 185 2/13/2023
0.0.1-alpha.14 243 1/4/2023
0.0.1-alpha.4 218 12/30/2022
0.0.1-alpha.3 234 12/23/2022
0.0.1-alpha 1,576 12/21/2022