FunctionalDdd.AspSourceGenerator 3.0.0-alpha.72

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

FunctionalDdd.Asp Source Generator

A Roslyn source generator that automatically creates AOT-compatible JSON converters and serializer context entries for types implementing IScalarValue<TSelf, TPrimitive>.

Features

  • AOT Compatible: Generated code works with Native AOT compilation
  • No Reflection: All type information is resolved at compile time
  • Faster Startup: No runtime type scanning or assembly reflection
  • Trimming Safe: Code won't be trimmed away since it's explicitly generated
  • Automatic Discovery: Finds all types implementing IScalarValue in your assembly

Usage

  1. Add a reference to the source generator package in your project.

  2. Create a partial JsonSerializerContext and mark it with [GenerateScalarValueConverters]:

using System.Text.Json.Serialization;
using FunctionalDdd;

[GenerateScalarValueConverters]
[JsonSerializable(typeof(MyDto))]
public partial class AppJsonSerializerContext : JsonSerializerContext
{
}
  1. The generator will automatically:
    • Create AOT-compatible JSON converters for all IScalarValue<TSelf, TPrimitive> types
    • Add [JsonSerializable] attributes for all scalar value types to your context
    • Generate a GeneratedScalarValueConverterFactory you can use directly

Generated Code

For each type implementing IScalarValue like:

public class CustomerId : ScalarValueObject<CustomerId, Guid>, IScalarValue<CustomerId, Guid>
{
    // ...
}

The generator creates:

  1. A strongly-typed CustomerIdJsonConverter class
  2. A [JsonSerializable(typeof(CustomerId))] attribute on your context
  3. Entry in GeneratedScalarValueConverterFactory for automatic converter resolution

Using the Generated Factory

You can use the generated factory directly:

var options = new JsonSerializerOptions
{
    TypeInfoResolver = AppJsonSerializerContext.Default
};
options.Converters.Add(new FunctionalDdd.Generated.GeneratedScalarValueConverterFactory());

Benefits Over Runtime Reflection

Feature Runtime Reflection Source Generator
AOT Support ❌ Not compatible ✅ Full support
Startup Time Slower (type scanning) Faster (precompiled)
Trimming May break Trimming safe
Memory Higher (reflection cache) Lower
IDE Support None Full IntelliSense

Requirements

  • .NET 6.0 or later
  • C# 10.0 or later
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.72 39 2/8/2026
3.0.0-alpha.60 38 2/4/2026
3.0.0-alpha.59 45 2/1/2026
3.0.0-alpha.56 42 1/31/2026
3.0.0-alpha.55 42 1/31/2026