Serenity Code Generator (Sergen)
Serenity code generator (sergen) configuration file
| Type | object |
|---|---|
| File match |
sergen.json
sergen.*.json
*.sergen.json
|
| Schema URL | https://catalog.lintel.tools/schemas/schemastore/serenity-code-generator-sergen/latest.json |
| Source | https://www.schemastore.org/sergen.json |
Validate with Lintel
npx @lintel/lintel check
Serenity code generator (sergen) configuration
Properties
If specified, the settings in this file extends settings in a base file similar to tsconfig.json You can also use Sergen defaults by specifying this like "[email protected]"
The root namespace for the target project. It is recommended to have this in sergen.json. If not there, it will be auto calculated from root namespace in CSPROJ file, or derived from project file name by removing .Web suffix. Generated code will be placed under this namespace and project's own types are assumed to be under this namespace as well
If true, generated code will declare and use jFKTable type of constants for expressions in entities
If true, it allows the use of [GenerateFields] attributes on rows, which automatically generates the fields using a source generator. This should only be used when Serenity.Pro.Coder is enabled in the project
If true, it allows the use of [GenerateInterface] attributes on handlers, which automatically generates the interface using a source generator. This should only be used when Serenity.Pro.Coder is enabled in the project
If true, enables RowTemplate class generation. This should only be used when Serenity.Pro.Coder is enabled in the project. Has no effect when EnableGenerateFields is true. EnableGenerateFields should be preferred over this as RowTemplate might cause some issues
End of line character to use in generated files. If not specified, it will be auto detected from the environment. It is recommended to have "lf" for multi platform projects
If true, generated code will use file scoped namespaces
If true, generated code will parse global usings from the current project. Default is true
If specified, generated code will assume these usings are in global using scope
If specified, generated code will assume these usings are not in global using scope even if they are in global using scope
If true, the default schema name, e.g. "dbo" for SQL Server won't be emitted in generated field expressions in Row.cs files. This is true by default only for MySql as in MySql schema names are actually database names
If true, instead of using [Expression] attributes for foreign view fields, it will use Origin(nameof(jFK), nameof(FKRow.ViewField)) if the FKRow is already generated in the project. It will also use ForeignKey(typeof(FKRow)) type of foreign keys instead of strings
If true, generated table options like Identity, Module etc. will be saved to the Connections array in sergen.json after code generation. Default is true
Client types code generation related configuration
2 nested properties
The output directory for generated client types .cs files
If false, the client types source generator in Serenity.Pro.Coder will be disabled
MVC (e.g. view locations) related configuration
7 nested properties
Deprecated, Sergen will always use the root namespace to avoid class name clashes
If true, use namespace {RootNamespace}.MVC instead of a MVC class inside the RootNamespace. ESM helpers will also be generated in this namespace. Default is false. This is useful if to avoid class name clashes with referenced projects. E.g. when add Serenity.Extensions to global usings, its MVC class would clash with the MVC class generated for the current project, sometimes causing issues in Razor views without a @namespace directive. So this is recommended for feature projects like Serenity.Extensions
If true, Use internal instead of public for generated top level class (MVC/ESM)
The output directory for MVC.cs
View paths to search for, defaults to "Modules" and "Views". "ProjectName" is used instead of "Modules" if Razor SDK is used for the project, e.g. a Razor class library
Strip view paths from generated files. Defaults to "Modules", "Views". E.g. a subclass for Modules and Views won't be generated
If false, the view paths source generator in Serenity.Pro.Coder will be disabled
Server typings code generation related configuration
8 nested properties
Assemblies for server typings generation. Specify only if Sergen can't auto determine your project output file
The output directory for generated server typings files. Not used for modules
If true, local texts will be generated
If true, module re-exports will be generated. Defaults to true
Deprecated as only ES modules style code generation is supported now. If true, module typings will be generated. Defaults to true if you have "module" defined in tsconfig.json
Deprecated as only ES modules style code generation is supported now. If true, namespace typings will be generated. Defaults to true if you don't have "module" defined in tsconfig.json
If true, generated typings will use relative paths instead of paths from tsconfig.json, e.g. "../ServerTypes/" instead of "@/ServerTypes/"
If false, the server typings source generator in Serenity.Pro.Coder will be disabled
Deprecated as Sergen no longer supports restoring static content. Sergen restore command related configuration
3 nested properties
List of files (git ignore like) to include while restoring
List of files (git ignore like) to exclude while restoring
Set false to disable namespace typings restore to typings/ folder
2 nested properties
List of entry point globs, default is "Modules//*Page.ts", "Modules//Page.tsx", "Modules//ScriptInit.ts", "Modules//.mts"
Should the list of entry points, e.g. ESM be generated, only available with Serenity.Pro.Coder
List of connections. It is only needed when it is desired to work / generated code based on a connection string that is not in appsettings.json
Deprecated. Path to KDiff3 executable. If not specified, it will be auto detected from the environment
Deprecated. Full path to TypeScript compiler. It is assumed to be in path if not specified
List of base row classes to be used instead of Row. They are matched by list of base properties
The set of foreign fields to generate, default is NameOnly.
None: Don't generate any foreign view fields except the ones explicitly included via IncludeForeignFields All: Generate all the foreign view fields, except ones excluded explicitly via RemoveForeignFields NameOnly: Don't generate any foreign view fields except the Name property of the target row and ones explicitly included via IncludeForeignFields
A list of foreign fields to include in generated code. This could be used to include some additional fields This could be used to include some additional fields. Not so useful if ForeignFieldSelection is All
A list of foreign fields to omit from generated code. This could be used to disable generating code for join fields like CreatedBy, ModifiedBy etc, so properties like CustomerCreatedBy, CustomerModifiedBy etc. won't be generated in OrderRow. Not so useful if ForeignFieldSelection is None or NameOnly
The location of custom templates folder. The files in this folder will override the default scriban templates in Sergen. You may also include additional files to be generated. Their names must match the names at https://github.com/serenity-is/Serenity/tree/master/src/codegenerator/Templates You may also include additional files to be generated
The relative paths of custom generated files
Custom settings to be passed to and used in custom templates
The list of appsettings.json files in order. Default is appsettings.json, appsettings.machine.json
The upgrade / migration related information used by stargen to determine the base version of template used, and already applied upgrades
3 nested properties
Initial type of project. Available options are "Community" e.g. Serene, "Premium" e.g. StartSharp
Version this project is created from. Used to determine which migrations should be applied to project (starting from)
List of already applied upgrades if any
Definitions
Table name
Row identifier without Row suffix
Module name
Permission key
Connection information
Key of connection
Connection string
Provider name
Dialect
The class name
The base class fields that should exists in a table for this base class to be used