OzzCodeGen is a pluggable code generator library with a WPF UI, OzzCodeGen.Wpf. OzzLocalization is a companion library (with its own UI OzzLocalization.Wpf) used to create and manage translated strings that OzzCodeGen can consume during code generation.
- .NET 10 SDK – Download from dotnet.microsoft.com
- Visual Studio 2026 (or later) with WPF and C# workloads, or Visual Studio Code with C# extensions
- Git (optional, for cloning the repository)
OzzUtils (Shared Utilities)
↓
OzzLocalization ←→ OzzLocalization.Wpf
↓
OzzCodeGen ←→ OzzCodeGen.Wpf
├── CodeEngines (Pluggable generators)
└── Providers (Empty)
- OzzUtils: Shared utilities library (extensions, helpers) consumed by code generation and localization projects.
- OzzCodeGen: Core library with domain model (
DataModel,EntityDefinition,BaseProperty), provider abstractions (IModelProvider), and multiple code engines underOzzCodeGen/CodeEngines. - OzzCodeGen.Wpf: WPF application for creating/opening a
CodeGenProject, selecting a Model Provider, adding Code Engines, and generating artifacts. - OzzLocalization: Library that manages XML vocabularies (see
OzzLocalization/Vocabularies.cs,OzzLocalization/Vocabulary.cs). Providesvocabulary.??.xmlfiles consumed by resource-related engines. - OzzLocalization.Wpf: WPF application for editing and organizing vocabularies used by OzzCodeGen.
- OzzCodeGen.sln: Complete tooling solution containing code generation and vocabulary management (all projects listed above).
Use .NET 10 SDK.
dotnet restore OzzCodeGen.sln
dotnet build OzzCodeGen.sln -c Debug- CodeGen UI: Start
OzzCodeGen.Wpf. Create/open a project (*.OzzGen), choose a Model Provider, add engines, then generate outputs. - Localization UI: Start
OzzLocalization.Wpf. Editvocabulary.??.xmlfiles (defaultnotr) and save; engines in OzzCodeGen can use these strings.
- Visual Studio: Open
OzzCodeGen.sln, then set a WPF project as Startup (right-click project → Set as Startup Project). - VS Code: Open the workspace folder; use the C# extension for IntelliSense and debugging.
- Clone the repository:
git clone https://github.com/ozalpd/OzzCodeGen.git - Open
OzzCodeGen.slnin your IDE - Restore and build:
dotnet restore && dotnet build - Set
OzzCodeGen.WpforOzzLocalization.Wpfas Startup Project - Press F5 to run or Ctrl+F5 to run without debugging
- Create a new folder under
OzzCodeGen/CodeEngines/<YourEngineName>/ - Create a
BaseCodeEnginesubclass with:EngineIdproperty (unique identifier)DefaultFileNamefor saving engine stateOpenFile()andSaveToFile()for persistenceRefreshFromProject()to sync withCodeGenProjectUiControlproperty exposing a WPFUserControlfor UI
- Add UI folder:
CodeEngines/<YourEngineName>/UI/with your control - Register the engine in
OzzCodeGen/CodeEngines/EngineTypes.cs:- Add a new case in
GetInstance()method - Map the ID in the
OpenFile()method
- Add a new case in
- For templates, use
.tt(T4 template) +*.part.cspattern and wireDependentUponin.csproj
- Implement
IModelProviderinterface (seeOzzCodeGen/Providers/IModelProvider.cs) - Implement
SelectSource()for source selection UI - Implement
RefreshDataModel()to return/update aDataModel - Wire provider selection in
MainWindow.xaml.csor provider dialog
- Templates are
.tt(T4) files with accompanying*.part.csfiles - Example:
CodeEngines/Localization/Templates/SingleResx.tt+SingleResx.part.cs - Regenerate manually: Right-click
.tt→ Run Custom Tool - Automatic regeneration: Preprocessed at build time via
.csprojconfiguration
- Build the solution (see Build section).
- Launch
OzzLocalization.Wpfand createvocabulary.notr.xmlunder a folder next to your project file. - Launch
OzzCodeGen.Wpfand create a new project:- Pick a Model Provider (e.g., Empty).
- Add engines via the plus button, e.g.,
Localization_Resource_Generator. - Save the project (
.OzzGen) to establishTargetSolutionDir.
- In the
Localization_Resource_GeneratorUI:- Set
TargetFolder(default$"{Project.TargetFolder}\\{Project.Name}.i18n"). - Set
VocabularyFolderto the folder containingvocabulary.??.xml(relative to the project file). - Choose
SingleResxfor a combined resource or per-entity resources. - Click Render to generate
.resxfiles underTargetSolutionDir/TargetFolder.
- Set
- Engine ID:
Localization_Resource_Generator(seeOzzCodeGen/CodeEngines/EngineTypes.cs). - Vocabulary discovery: ResxEngine loads vocabularies from
VocabularyDirresolved fromCodeGenProject.SavedFileName+VocabularyFolder(seeResxEngine.VocabularyDir). - Outputs:
- Default target folder is
$"{Project.TargetFolder}\\{Project.Name}.i18n"(seeResxEngine.GetDefaultTargetFolder). - Default combined resource base name is
SingleResxFilename = "LocalizedStrings". - Generates one
.resxper culture code for each entity or a single combined file whenSingleResxis enabled (seeResxEngine.RenderSelectedTemplate).
- Default target folder is
- Optional: Set
SaveWithVocabulariesto duplicatevocabulary.??.xmlinto the target directory on save (seeResxEngine.SaveToFile).
- SingleResx enabled:
LocalizedStrings.notr.resx,LocalizedStrings.tr.resx(default file base isSingleResxFilename→LocalizedStrings). - Per-entity resources:
CustomerString.notr.resx,OrderString.tr.resx(default base fromGetDefaultTargetFile→${entity.Name}String).
CodeGenProject.TargetPlatform controls the target .NET platform for generated code via the TargetDotNetPlatform enum (defined in OzzCodeGen/_enums.cs):
| Value | Description |
|---|---|
DotNetFramework |
Classic .NET Framework output (default for backward compatibility). |
ModernDotNet |
Modern .NET (.NET 6+) output — enables nullable reference type annotations (? suffix) and other modern conventions. |
Engines check Project.TargetPlatform to adapt generated code. For example, MetadataPropertySetting.GetTypeName() appends ? for nullable reference types only when targeting ModernDotNet. The WPF UI exposes this via a Target Platform ComboBox in the toolbar.
| Engine ID | Description | Status |
|---|---|---|
Model_Class_Generator |
Generates model classes (primary path) using ModelClassTemplate/BaseModelClassTemplate. |
✅ Active |
Metadata_Class_Generator |
Generates metadata/validation attribute classes (legacy compatibility path). | ✅ Active |
AspNetMvc_Controller_View_Generator |
Generates ASP.NET MVC controllers and Razor views. | ✅ Active |
T-Sql_Scripts_Generator |
Generates T-SQL DDL scripts. | ✅ Active |
Sqlite_Scripts_Generator |
Generates SQLite DDL scripts. | ✅ Active |
Localization_Resource_Generator |
Generates .resx resource files from XML vocabularies. |
✅ Active |
EF_Technical_Document |
Generates technical documentation from the data model. | ✅ Active |
EF_DatabaseFirst_DataLayer |
EF Database-First data layer generation. | ❌ Removed |
ObjectiveC_Code_Generator |
Objective-C code generation. | ❌ Removed |
Android_Code_Generator |
Android/Java code generation. | ❌ Removed |
- Use
Model_Class_Generatorfor new projects. It is the primary and actively evolved model-class generation path. - Keep
Metadata_Class_Generatorfor existing/legacy projects that already depend on metadata engine IDs/settings and serialized project compatibility. - Both engines remain loadable, but migration should be incremental:
- Create new outputs with
Model_Class_Generator. - Keep
Metadata_Class_Generatorenabled for old outputs/settings until manual validation is complete. - Remove legacy engine usage only after save/load and generated output parity checks pass.
- Create new outputs with
- Engine IDs and registration: see
OzzCodeGen/CodeEngines/EngineTypes.cs. - Model-class primary stack:
OzzCodeGen/CodeEngines/ModelClass/ModelClassCodeEngine.csOzzCodeGen/CodeEngines/ModelClass/BaseModelClassCodeEngine.csOzzCodeGen/CodeEngines/ModelClass/Templates/ModelClassTemplate.ttOzzCodeGen/CodeEngines/ModelClass/Templates/BaseModelClassTemplate.cs
- Metadata compatibility stack:
OzzCodeGen/CodeEngines/Metadata/MetadataCodeEngine.cs
- Project orchestration: see
OzzCodeGen/CodeGenProject.cs. - Target platform enum: see
OzzCodeGen/_enums.cs(TargetDotNetPlatform). - Data model serialization and helpers: see
OzzCodeGen/DataModel.cs. - Model provider implementation (Empty): see
OzzCodeGen/Providers/EmptyModel.cs. - Vocabulary loading/saving: see
OzzLocalization/Vocabularies.csandOzzLocalization/Vocabulary.cs.
- Restore fails: Ensure .NET 10 SDK is installed (
dotnet --version). - NuGet errors: Clear cache:
dotnet nuget locals all --clearand retry.
- Project fails to load: Check
.OzzGenfile is valid XML. Verify model provider paths are accessible. - Model provider refresh fails: For Empty, verify
Defaults/folder exists. - Engine output not appearing: Check
TargetFolderis accessible. Verify engine template is selected. Review Output window logs. - BuildInfo.Date not updating: Right-click
BuildInfo.tt→ Run Custom Tool or rebuild solution.
For deeper troubleshooting, see .github/copilot-instructions.md.