Tasks and presets

LLBLGen Pro's generator core uses preset files which contain the order of which tasks to execute with which parameters. The preset files define a subset of tasks from the large group of task definitions available to the generator through the .tasks files.

Presets are stored in .preset files and typically created in the LLBLGen Pro designer using the generator configuration dialog. See for more details how to create your own presets the LLBLGen Pro documentation.

The whole generation process uses a couple of specific files, which are stored in the Tasks folder and the Templates folder. The SDK documentation section Generator and Tasks deals with the files in the Tasks folder. The section Templates and Templatebindings deals with the files in the Templates folder.

The generator core process is very small, it consists of handing over control to the task objects created from the task definition mentioned in the preset chosen. All specified tasks are executed, the task itself has to decide if it has to do anything or not. The tasks itself are not sandboxed, the tasks have access to the complete project tree and can alter / read any information inside the project.

Because of the task / task class performer structure, a user can define his/her own tasks and task performers or new tasks using existing task performers. The only requirement is that the task performers assigned to the tasks defined can be instantiated by LLBLGen Pro's generator process, which is the case when the task performer implements ITaskPerformer. ITaskPerformer is an interface defined in the SD.LLBLGen.Pro.ApplicationCore namespace located in the SD.LLBLGen.Pro.ApplicationCore.dll assembly, shipped with LLBLGen Pro.

The assembly SD.LLBLGen.Pro.GeneratorCore contains a base class implementation of this interface, TaskPerformerBase, which contains all required mechanisms to communicate with the system, e.g. to log feedback into the application output window.

It is recommended that you derive from this class for a general purpose task performer. If you plan to implement a code generation task performer which can consume templates, you can derive from a subclass of TaskPerformerBase instead: CodeGenerationEngineBase. This class has additional helper methods/properties. See the sourcecode archive for the sourcecode of the two code generation engines for ideas/details.

Presets

Presets are sets of tasks/taskgroups and parameter settings, which are used for setting up the generator configuration. For instance, the preset for Adapter, is a set of preset definitions to allow the user to quickly select the tasks for adapter without running the risk of having to set up everything by hand and missing one or two tasks.

Presets can be made sealed, which means that a preset can be loaded but you can't save the preset under the same name. Sealed presets are for example the presets shipped with LLBLGen Pro. A user can save his own presets inside the LLBLGen Pro gui.

A preset can be saved to a file in the Tasks folder, or to the AdditionalTasksFolder set in the project properties. The project will contain the preset most recently used, among all other settings for the tasks, so the user can quickly re-generate a piece of code.

Presets define which tasks/taskgroups are defined in which order in a hierarchy and optionally define values for tag parameters/attributes which will be applied to the original task parameter/values.

So for example if a task has a parameter targetFolder and the value is DatabaseSpecific, a preset can have that same parameter defined and have a value of 'MyFoldersDatabaseSpecific'. When the task is loaded, the parameter value for 'targetFolder' is overwritten with 'MyFoldersDatabaseSpecific'.

Not all settings can be changed in a preset. For a task, a preset can overwrite any parameter value and add additional parameters (i.e.: a parameter not found in the original task is added to the task). For a taskGroup, a preset can define additional tasks, or leave tasks out.

If a task is in the original taskgroup, and the task isn't in the preset for the taskgroup, the task isn't added to the taskgroup in the runqueue. If a task or taskgroup is present in the preset and not in the original taskgroup, the task /taskgroup is added to the taskgroup. If a task or taskgroup is in the preset but marked disabled (enabled=false), it is added to the taskgroup in the runqueue, but will be disabled.

The order in which tasks are defined in the preset for the taskgroup is the order in which LLBLGen Pro will schedule the tasks. If a task is already in the preset list and a taskgrouppreset is added which contains the same task, the task is also in that taskgroup, and executed twice.

Presets are defined in .preset files, and are stored in the Tasks folder or the AdditionalTasksFolder in the project. Every .preset file contains a single preset.

Tasks

If a task is defined inside a taskgroup, it is automatically following the dependencies of the taskgroup, which means that if a dependency is defined on the taskgroup, the dependency is also valid/used for all tasks inside the taskgroup.

If a task or taskgroup has a dependency on a task or taskgroup which is nested inside another taskgroup, the depending task / taskgroup can be placed inside the nesting taskgroup right below the task / taskgroup it depends on, but that's not required. It can also be placed outside the nesting taskgroup altogether. For clarity this is often prefered. Don't nest tasks unless grouping is essential for clarity. Tasks and taskgroups are defined in files with extension .tasks.

Tasks are target language independent. When code generation tasks are defined, they should use template ID's to refer to templates which should be used with the task. Template ID's then are bound to template files by the templatebindings chosen.

Tasks are executed by Task performers, which are classes which are specified with the task definition in the .tasks file the task is defined in. Task performers are classes which handle 1 single task. They expose one single method, which is overloaded: Perform().

Task xml elements can be nested using taskGroup elements which can be nested inside other taskGroup elements. Tasks mentioned in a preset after a taskgroup are executed after the complete set of tasks (and possibly other nested taskgroups) inside the taskgroup are finished.

A task can abort the generation process. It then should throw a GeneratorAbortException. The generator process will then abort the process and will stop executing task performers. Use this exception when a task encounters a fatal error. For example, when you construct a task performer which first checks out all the files in a given solution, and the checkout fails, the generation should fail too.