CSharpDB.Generators 4.0.2

Prefix Reserved
dotnet add package CSharpDB.Generators --version 4.0.2
                    
NuGet\Install-Package CSharpDB.Generators -Version 4.0.2
                    
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="CSharpDB.Generators" Version="4.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CSharpDB.Generators" Version="4.0.2" />
                    
Directory.Packages.props
<PackageReference Include="CSharpDB.Generators" />
                    
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 CSharpDB.Generators --version 4.0.2
                    
#r "nuget: CSharpDB.Generators, 4.0.2"
                    
#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 CSharpDB.Generators@4.0.2
                    
#: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=CSharpDB.Generators&version=4.0.2
                    
Install as a Cake Addin
#tool nuget:?package=CSharpDB.Generators&version=4.0.2
                    
Install as a Cake Tool

CSharpDB.Generators

Source generator for CSharpDB generated collection models.

Use this package with CSharpDB.Engine when you want:

  • generated collection codecs backed by a System.Text.Json source-generated context
  • generated binary direct-payload writes for supported document graphs, with source-generated JSON fallback for unsupported binary shapes
  • generated CollectionField<,> descriptors such as User.Collection.Email
  • flattened nested descriptors such as User.Collection.Address_City and User.Collection.Orders_Sku
  • trim-safe typed collection access through Database.GetGeneratedCollectionAsync<T>(...)

Example:

using System.Text.Json.Serialization;
using CSharpDB.Engine;

[CollectionModel(typeof(UserJsonContext))]
public sealed partial record User(string Email, int Age);

[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase)]
[JsonSerializable(typeof(User))]
internal sealed partial class UserJsonContext : JsonSerializerContext;

await using var db = await Database.OpenAsync("app.db");
var users = await db.GetGeneratedCollectionAsync<User>("users");

await users.PutAsync("alice", new User("alice@example.com", 30));
await users.EnsureIndexAsync(User.Collection.Email);

The generator currently emits descriptors for:

  • top-level scalar members
  • top-level scalar collections like Tags[]
  • nested scalar members like Address.City
  • nested collection scalar members like Orders[].Sku

Descriptor names stay based on CLR member names even when payload names are renamed with JsonPropertyName.

Unsupported public members are ignored with a build warning (CDBGEN007) so generator coverage gaps fail loudly instead of silently omitting descriptors. When every serialized public member in the document graph maps to the supported binary collection payload shape, generated collections write the binary direct-payload format. If a member does not fit that binary shape, generated collections keep the existing source-generated JSON payload path.

At runtime, GetGeneratedCollectionAsync<T>(...) also expects existing collection indexes for that document type to bind through registered generated descriptors. Reflection-only path indexes should stay on GetCollectionAsync<T>(...) until the generated model covers those paths.

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
4.0.2 0 7/9/2026
4.0.1 94 7/5/2026
4.0.0 103 6/25/2026
3.9.1 103 6/11/2026