pauldeen79.ClassFramework.TemplateFramework 0.13.1

dotnet add package pauldeen79.ClassFramework.TemplateFramework --version 0.13.1
NuGet\Install-Package pauldeen79.ClassFramework.TemplateFramework -Version 0.13.1
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="pauldeen79.ClassFramework.TemplateFramework" Version="0.13.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add pauldeen79.ClassFramework.TemplateFramework --version 0.13.1
#r "nuget: pauldeen79.ClassFramework.TemplateFramework, 0.13.1"
#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.
// Install pauldeen79.ClassFramework.TemplateFramework as a Cake Addin
#addin nuget:?package=pauldeen79.ClassFramework.TemplateFramework&version=0.13.1

// Install pauldeen79.ClassFramework.TemplateFramework as a Cake Tool
#tool nuget:?package=pauldeen79.ClassFramework.TemplateFramework&version=0.13.1

ClassFramework

Class modeling framework for C#

If you want to create a C# class structure based on a model, this framework is for you!

We are using the following dependencies:

  • CsharpExpressionDumper, to generate c# code for values
  • CrossCutting.ProcessingPipeline, for extendable pipelines for transformation of classes and interfaces
  • CrossCutting.Utilities.Parsers, for parsing named format strings like {Name}Builder
  • TemplateFramework, to translate the domain model to actual c# code files

The Domain and Pipelines packages target .NET Standard 2.0, so you can use it anywhere. Because of the dependency to TemplateFramework, we target some projects to .NET 8.0.

Background

Imagine you want to create some domain model for a new project.

First, you need to create a console project named [YourProjectName].CodeGeneration.

In this project, there are a number of components:

  • The Program.cs class, which runs the code generation
  • The Models folder, which contains interfaces for all your domain entities
  • The CodeGenerationProviders folder, which contains all types of code generators, like entities, builders and maybe abstractions

Philosophy

The entity and builder generators use the following characteristics:

  • The entity can be either a POCO or a DDD-style object, which takes all input in the constructor and then validates the state
  • You can use either immutable or mutable entities, and you can choose to make the setters private or public
  • You can use observable properties on entities, if you need to
  • For immutable entities, you can also generate builders. These are mutable, and you can easily convert between the two types (unless you want the entities in a separate project, without a reference to the builders)
  • Validation is supported using the IValidatableObject interface (standard .NET validation), and can be shared between the entities and the builders
  • Default values on the model properties can automatically be set in the constructor of the builders, if you want to
  • You can either create entities without interfaces, or interface-based entities (possibly in a different namespace, e.g. MyProject.Core and MyProject.Abstractions)

Dog fooding

I have decided that the models for ClassFramework need to be generated using ClassFramework. To make this possible, I have first generated everything with another framework (called ModelFramework) as a Bootstrap action. After this, I re-generated everything using ClassFramework.

But since version 0.9.1, I stored the generated code, so I could add breaking changes. This means the code generation in the build pipelines has been removed.

Known issues

If you have types with nested or multiple generic arguments, the nullability of those types will not get determined correctly... Try to fix this by creating types for this. E.g. System.Func<System.Object, System.Int32, System.Object?> Just create a delegate for this, and add this to the type mapping.

If you still get errors, you could use the CsharpTypeNameAttribute to decorate your property/field/parameter.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on pauldeen79.ClassFramework.TemplateFramework:

Package Downloads
DatabaseFramework.CodeGeneration

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.13.1 26 5/18/2024
0.13.0 77 5/17/2024
0.12.7 265 5/9/2024
0.12.6 64 5/9/2024
0.12.5 118 5/8/2024
0.12.4 128 5/7/2024
0.12.3 80 5/7/2024
0.12.2 53 5/3/2024
0.12.1 68 5/2/2024
0.12.0 53 5/1/2024
0.11.0 147 4/19/2024
0.10.0 127 4/16/2024
0.9.3 147 4/12/2024
0.9.2 93 4/9/2024
0.9.1 102 4/7/2024
0.9.0 110 4/6/2024
0.8.9 89 4/5/2024
0.8.8 83 4/5/2024
0.8.7 85 4/5/2024
0.8.6 85 4/4/2024
0.8.5 95 4/3/2024
0.8.4 98 4/3/2024
0.8.3 81 4/3/2024
0.8.1 88 4/2/2024
0.8.0 195 3/23/2024
0.7.2 130 3/22/2024
0.7.1 94 3/22/2024
0.7.0 124 3/20/2024
0.6.0 170 3/17/2024
0.5.6 141 3/15/2024
0.5.5 102 3/15/2024
0.5.4 107 3/14/2024
0.5.3 93 3/14/2024
0.5.2 86 3/14/2024
0.5.1 119 3/13/2024
0.4.2 236 3/8/2024
0.4.1 83 3/8/2024
0.4.0 84 3/8/2024
0.3.1 170 3/5/2024
0.3.0 83 3/5/2024
0.2.0 126 3/4/2024
0.1.0 288 2/25/2024