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 2022 (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 (EF Db-first, Empty)
└── OzzCodeGen.Ef (EF integration)
- 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 (EF or Empty), 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 or EF
.edmx). - Add engines via the plus button, e.g.,
Localization_Resource_Generator. - Save the project (
.OzzGen) to establishTargetSolutionDir.
- Pick a Model Provider (e.g., Empty or EF
- In the
Localization_Resource_GeneratorUI:- Set
TargetFolder(defaultApp_GlobalResources). - 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
App_GlobalResources(seeResxEngine.GetDefaultTargetFolder). - 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:
EntityStrings.notr.resx,EntityStrings.tr.resx(default file base isSingleResxFilename→EntityStrings). - Per-entity resources:
CustomerString.notr.resx,OrderString.tr.resx(default base fromGetDefaultTargetFile→${entity.Name}String).
- Engine IDs and registration: see
OzzCodeGen/CodeEngines/EngineTypes.cs. - Project orchestration: see
OzzCodeGen/CodeGenProject.cs. - Data model serialization and helpers: see
OzzCodeGen/DataModel.cs. - EF Db-first provider: see
OzzCodeGen.Ef/Ef5.Provider.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 EF, ensure
.edmxfile exists and is valid. For Empty, verifyDefaults/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.