Csag.Blueprint.SourceGenerators
0.1.0
dotnet add package Csag.Blueprint.SourceGenerators --version 0.1.0
NuGet\Install-Package Csag.Blueprint.SourceGenerators -Version 0.1.0
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="Csag.Blueprint.SourceGenerators" Version="0.1.0"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Csag.Blueprint.SourceGenerators" Version="0.1.0" />
<PackageReference Include="Csag.Blueprint.SourceGenerators"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
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 Csag.Blueprint.SourceGenerators --version 0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Csag.Blueprint.SourceGenerators, 0.1.0"
#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 Csag.Blueprint.SourceGenerators@0.1.0
#: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=Csag.Blueprint.SourceGenerators&version=0.1.0
#tool nuget:?package=Csag.Blueprint.SourceGenerators&version=0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Csag.Blueprint.SourceGenerators
Overview
This package contains a Roslyn incremental source generator that scans TranslationDefaults class hierarchies at compile time and produces strongly-typed translation registries and DTOs for multilingual support.
What it generates
Given a TranslationDefaults class with nested static classes and string constants, the generator produces three files:
| Generated file | Contents |
|---|---|
TranslationDefaults.g.cs |
A partial class extending TranslationDefaults with an All property (IReadOnlyDictionary<string, string> mapping dot-path keys to English defaults). |
TranslationKeys.g.cs |
A static class mirroring the TranslationDefaults hierarchy where each constant holds the dot-separated key path (e.g. "Validation.EmailRequired"). Pass these to IStringLocalizer for direct database lookup. |
TranslationValues.g.cs |
A sealed TranslationValues DTO mirroring the TranslationDefaults hierarchy. Each category becomes a nested sealed class with JsonPropertyName attributes (camelCase). Includes a static FromDictionary() method for populating from a flat key-value dictionary. |
How it works
- The generator filters for
ClassDeclarationSyntaxnodes namedTranslationDefaults. - It recursively collects all constant string fields and nested static classes, building dot-separated key paths (e.g.,
Validation.EmailRequired). - It builds a tree from the flat entries and emits all three source files.
Usage
// TranslationDefaults.cs — define keys with English text as the const value
public static class Validation
{
public const string EmailRequired = "Email is required";
}
// Call sites — use the generated TranslationKeys for the localizer
localizer[TranslationKeys.Validation.EmailRequired]
// Localizer does a direct DB lookup by "Validation.EmailRequired".
// Falls back to "Email is required" (from TranslationDefaults.All) if not found.
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 |
|---|---|---|
| 0.1.0 | 40 | 7/3/2026 |