Skip to content

Latest commit

 

History

History
233 lines (173 loc) · 16.3 KB

Entity-CodeGeneration-Config.md

File metadata and controls

233 lines (173 loc) · 16.3 KB

'CodeGeneration' object (entity-driven)

The CodeGeneration object defines global properties that are used to drive the underlying entity-driven code generation.


Example

A YAML configuration example is as follows:

refDataNamespace: My.Hr.Common.Entities
refDataText: true
eventSubjectRoot: My
eventActionFormat: PastTense
entities:

Property categories

The CodeGeneration object supports a number of properties that control the generated code output. These properties are separated into a series of logical categories.

Category Description
DotNet Provides the .NET configuration.
RefData Provides the Reference Data configuration.
Entity Provides the Entity class configuration.
Events Provides the Events configuration.
WebApi Provides the Web API (Controller) configuration.
Manager Provides the Manager-layer configuration.
Data Provides the generic Data-layer configuration.
Database Provides the Database Data-layer configuration.
EntityFramework Provides the Entity Framewotrk (EF) Data-layer configuration.
Cosmos Provides the CosmosDB Data-layer configuration.
OData Provides the OData Data-layer configuration.
HttpAgent Provides the HTTP Agent Data-layer configuration.
gRPC Provides the gRPC configuration.
Path Provides the Path (Directory) configuration.
Namespace Provides the .NET Namespace configuration.
Auth Provides the Authorization configuration.
Collections Provides related child (hierarchical) configuration.

The properties with a bold name are those that are more typically used (considered more important).


DotNet

Provides the .NET configuration.

Property Description
withResult Indicates whether to use CoreEx.Results (aka Railway-oriented programming).
† Defaults to true. This can be overridden within the Entity(s) and/or Operation(s).
preprocessorDirectives Indicates whether to use preprocessor directives in the generated output.

RefData

Provides the Reference Data configuration.

Property Description
refDataNamespace The namespace for the Reference Data entities (adds as a c# using statement).
† Defaults to Company + . (literal) + AppName + .Business.Entities (literal).
refDataCommonNamespace The namespace for the Reference Data common entities (adds as a c# using statement).
† Defaults to Company + . (literal) + AppName + .Common.Entities (literal).
refDataText Indicates whether a corresponding Text property is added when generating a Reference Data Property for an Entity.
† This is used where serializing within the Web API Controller and the ExecutionContext.IsRefDataTextSerializationEnabled is set to true (which is automatically set where the url contains $text=true). This can be further configured on the Entity and for each Property.
refDataType The Reference Data identifier Type option. Valid options are: int, long, Guid, string.
† Required to identify an entity as being Reference Data. Specifies the underlying .NET Type used for the Reference Data identifier. Results in all underlying entities becoming Reference Data.
refDataWebApiRoute The RouteAtttribute for the Reference Data Web API controller required for named pre-fetching. The WebApiRoutePrefix will be prepended where specified.
refDataCodeDataName The Reference Data Code data name.
† Defaults to Code (literal).
refDataTextDataName The Reference Data Text data name.
† Defaults to Text (literal).
refDataIsActiveDataName The Reference Data IsActive data name.
† Defaults to IsActive (literal).
refDataSortOrderDataName The Reference Data SortOrder data name.
† Defaults to SortOrder (literal).
refDataETagDataName The Reference Data ETag data name.
† Defaults to RowVersion (literal).

Entity

Provides the Entity class configuration.

Property Description
jsonSerializer The JSON Serializer to use for JSON property attribution. Valid options are: SystemText, Newtonsoft.
† Defaults to SystemText. This can be overridden within the Entity(s).
etagJsonName The default JSON name for the ETag property. Valid options are: etag, eTag, _etag, _eTag, ETag, ETAG.
† Defaults to etag. Note that the JsonName can be set individually per property where required.
usingNamespace1 The additional Namespace using statement to be added to the generated Entity code.
† Typically used where referening a Type from a Namespace that is not generated by default.
usingNamespace2 The additional Namespace using statement to be added to the generated Entity code.
† Typically used where referening a Type from a Namespace that is not generated by default.
usingNamespace3 The additional Namespace using statement to be added to the generated Entity code.
† Typically used where referening a Type from a Namespace that is not generated by default.

Events

Provides the Events configuration.

Property Description
eventPublish The layer to add logic to publish an event for a Create, Update or Delete operation. Valid options are: None, DataSvc, Data.
† Defaults to DataSvc. Used to enable the sending of messages to the likes of EventHub, ServiceBus, SignalR, etc. This can be overridden within the Entity(s).
eventSourceRoot The URI root for the event source by prepending to all event source URIs.
† The event source is only updated where an EventSourceKind is not None. This can be extended within the Entity(s).
eventSourceKind The URI kind for the event source URIs. Valid options are: None, Absolute, Relative, RelativeOrAbsolute.
† Defaults to None (being the event source is not updated).
eventSubjectRoot The root for the event Subject name by prepending to all event subject names.
† Used to enable the sending of messages to the likes of EventHub, ServiceBus, SignalR, etc. This can be overridden within the Entity(s).

WebApi

Provides the Web API (Controller) configuration.

Property Description
webApiAuthorize The authorize attribute value to be used for the corresponding entity Web API controller; generally either Authorize or AllowAnonymous.
† This can be overridden within the Entity(s) and/or their corresponding Operation(s).
webApiAutoLocation Indicates whether the HTTP Response Location Header route (Operation.WebApiLocation) is automatically inferred.
† This will automatically set the Operation.WebApiLocation for an Operation named Create where there is a corresponding named Get. This can be overridden within the Entity(s).
webApiRoutePrefix The base (prefix) URI prepended to all Operation.WebApiRoute values.
webApiTags The list of tags to add for the generated WebApi.
† This can be overridden within the Entity(s) and/or their corresponding Operation(s).

Manager

Provides the Manager-layer configuration.

Property Description
managerCleanUp Indicates whether a Cleaner.Cleanup is performed for the operation parameters within the Manager-layer.
† This can be overridden within the Entity(s) and Operation(s).
validationFramework The Validation framework to use for the entity-based validation. Valid options are: CoreEx, FluentValidation.
† Defaults to CoreEx (literal). This can be overridden within the Entity(s), Operation(s) and Parameter(s).

Data

Provides the generic Data-layer configuration.

Property Description
refDataDataCtorParams The list of additional (non-inferred) Dependency Injection (DI) parameters for the generated ReferenceDataData constructor.
† Each constructor parameter should be formatted as Type + ^ + Name; e.g. IConfiguration^Config. Where the Name portion is not specified it will be inferred. Where the Type matches an already inferred value it will be ignored.
autoImplement The data source auto-implementation option. Valid options are: Database, EntityFramework, Cosmos, OData, HttpAgent, None.
† Defaults to None. Indicates that the implementation for the underlying Operations will be auto-implemented using the selected data source (unless explicitly overridden). When selected some of the related attributes will also be required (as documented). Additionally, the AutoImplement can be further specified/overridden per Operation.
etagDefaultMapperConverter The default ETag to/from RowVersion column Mapping Converter used where Operation.AutoImplement is Database or EntityFramework.
† Defaults to StringToBase64Converter.
refDataDefaultMapperConverter The default Reference Data property Converter used by the generated Mapper(s) where not specifically defined. Valid options are: ReferenceDataCodeConverter, ReferenceDataCodeConverter{T}, ReferenceDataCodeConverter<T>, ReferenceDataIdConverter{T, int}, ReferenceDataIdConverter<T, int>, ReferenceDataIdConverter{T, int?}, ReferenceDataIdConverter<T, int?>, ReferenceDataIdConverter{T, long}, ReferenceDataIdConverter<T, long>, ReferenceDataIdConverter{T, long?}, ReferenceDataIdConverter<T, long?>, ReferenceDataIdConverter{T, Guid}, ReferenceDataIdConverter<T, Guid>, ReferenceDataIdConverter{T, Guid?}, ReferenceDataIdConverter<T, Guid?>, ReferenceDataInt32IdConverter, ReferenceDataInt32IdConverter{T}, ReferenceDataInt32IdConverter<T>, ReferenceDataNullableInt32IdConverter, ReferenceDataNullableInt32IdConverter{T}, ReferenceDataNullableInt32IdConverter<T>, ReferenceDataInt64IdConverter, ReferenceDataInt64IdConverter{T}, ReferenceDataInt64IdConverter<T>, ReferenceDataNullableInt64IdConverter, ReferenceDataNullableInt64IdConverter{T}, ReferenceDataNullableInt64IdConverter<T>, ReferenceDataGuidIdConverter, ReferenceDataGuidIdConverter{T}, ReferenceDataGuidIdConverter<T>, ReferenceDataNullableGuidIdConverter, ReferenceDataNullableGuidIdConverter{T}, ReferenceDataNullableGuidIdConverter<T>.
† Defaults to ReferenceDataCodeConverter<T>. Where this value is suffixed by <T> or {T} this will automatically be set to the Type.

Database

Provides the Database Data-layer configuration.

Property Description
databaseType The .NET database type and optional name (used where Operation.AutoImplement is Database).
† Defaults to IDatabase. Should be formatted as Type + ^ + Name; e.g. IDatabase^Db. Where the Name portion is not specified it will be inferred. This can be overridden within the Entity(s).
databaseSchema The default database schema name.
† Defaults to dbo.
databaseProvider The default database schema name. Valid options are: SqlServer, MySQL, Postgres.
† Defaults to SqlServer. Enables specific database provider functionality/formatting/etc. where applicable.
databaseMapperEx Indicates that a DatabaseMapperEx will be used; versus, DatabaseMapper (which uses Reflection internally).
† Defaults to true. The DatabaseMapperEx essentially replaces the DatabaseMapper as it is more performant (extended/explicit); this option can be used where leagcy/existing behavior is required.

EntityFramework

Provides the Entity Framewotrk (EF) Data-layer configuration.

Property Description
entityFrameworkType The .NET Entity Framework type and optional name (used where Operation.AutoImplement is EntityFramework).
† Defaults to IEfDb. Should be formatted as Type + ^ + Name; e.g. IEfDb^Ef. Where the Name portion is not specified it will be inferred. This can be overridden within the Entity(s).

Cosmos

Provides the CosmosDB Data-layer configuration.

Property Description
cosmosType The .NET Cosmos DB type and name (used where Operation.AutoImplement is Cosmos).
† Defaults to ICosmosDb. Should be formatted as Type + ^ + Name; e.g. ICosmosDb^Cosmos. Where the Name portion is not specified it will be inferred. This can be overridden within the Entity(s).

OData

Provides the OData Data-layer configuration.

Property Description
odataType The .NET OData interface name used where Operation.AutoImplement is OData.
† Defaults to IOData. Should be formatted as Type + ^ + Name; e.g. IOData^OData. Where the Name portion is not specified it will be inferred. This can be overridden within the Entity(s).

HttpAgent

Provides the HTTP Agent Data-layer configuration.

Property Description
httpAgentType The default .NET HTTP Agent interface name used where Operation.AutoImplement is HttpAgent.
† Defaults to IHttpAgent. Should be formatted as Type + ^ + Name; e.g. IHttpAgent^HttpAgent. Where the Name portion is not specified it will be inferred. This can be overridden within the Entity(s).

gRPC

Provides the gRPC configuration.

Property Description
grpc Indicates whether gRPC support (more specifically service-side) is required.
† gRPC support is an explicit opt-in model. Must be set to true for any of the subordinate gRPC capabilities to be code-generated. Will require each Entity, and corresponding Property and Operation to be opted-in specifically.

Path

Provides the Path (Directory) configuration.

Property Description
pathBase The base path (directory) prefix for the artefacts; other Path* properties append to this value when they are not specifically overridden.
† Defaults to Company (runtime parameter) + . + AppName (runtime parameter). For example Beef.Demo.
pathCommon The path (directory) for the Database-related artefacts.
† Defaults to PathBase + .Common (literal). For example Beef.Demo.Common.
pathBusiness The path (directory) for the Business-related (.NET) artefacts.
† Defaults to PathBase + .Business (literal). For example Beef.Demo.Business.
pathApi The path (directory) for the API-related (.NET) artefacts.
† Defaults to PathBase + . + ApiName (runtime parameter). For example Beef.Demo.Api.

Namespace

Provides the .NET Namespace configuration.

Property Description
namespaceBase The base Namespace (root) for the .NET artefacts.
† Defaults to Company (runtime parameter) + . + AppName (runtime parameter). For example Beef.Demo.
namespaceCommon The Namespace (root) for the Common-related .NET artefacts.
† Defaults to NamespaceBase + .Common (literal). For example Beef.Demo.Common.
namespaceBusiness The Namespace (root) for the Business-related .NET artefacts.
† Defaults to NamespaceBase + .Business (literal). For example Beef.Demo.Business.
namespaceApi The Namespace (root) for the Api-related .NET artefacts.
† Defaults to NamespaceBase + . + ApiName (runtime parameter). For example Beef.Demo.Api.

Auth

Provides the Authorization configuration.

Property Description
authActionCreate The default Operation.AuthAction for an Operation.Type of Create.
† Defaults to Create.
authActionRead The default Operation.AuthAction for an Operation.Type of Get or GetColl.
† Defaults to Read.
authActionUpdate The default Operation.AuthAction for an Operation.Type of Update.
† Defaults to Update.
authActionDelete The default Operation.AuthAction for an Operation.Type of Delete.
† Defaults to Delete.

Collections

Provides related child (hierarchical) configuration.

Property Description
entities The corresponding Entity collection.

An Entity object provides the primary configuration for an entity, its properties and operations.