Concepts - Task based code generation

Preface

LLBLGen Pro uses a very modular code generator. In fact, it's not a code generator per se, it's a task based engine which executes tasks and one of them can be a task to generate code. When you have defined some entities or other elements in a project, you can generate the project. When you start the generating process, LLBLGen Pro presents you a window which will allow you to select a couple of things important for the generation process: the target language, the target platform, the template group to use and the presets of tasks to run for this generation cycle (which is fully configurable).

This section describes briefly the tasks and preset concepts, which are stored in .tasks and .preset files resp.

Tasks, task groups, .tasks and .preset files

The generator engine works by executing tasks defined in a given order. Which tasks and in which order is defined in a so called preset, stored in a .preset file and which you can create in the Code generation configuration window's 3rd tab.

Presets define a specific order of task definitions and per task the parameter values for that task. Tasks can be nested into task groups which can be nested into each other. Each task group is executed before the next one, and they are executed in the order they appear. Tasks and taskgroups are stored in .tasks files. Both .tasks and .preset files are stored in the Tasks folder of the LLBLGen Pro installation, or in the additional Tasks folder specified in the project properties. LLBLGen Pro ships with a variety of tasks and preset files so you can get started right away. If you want to create your own, you can, they're simple XML files which use .xsd schemas defined in the Tasks\Xsds folder. Which tasks and the order in which they're executed are fully controllable by you. You don't want an app.config file being generated? Remove the task from the run queue or disable it and it won't be executed.
Task performers
Each task is performed by the assembly and class specified with the task in the task definition. The generator loads the assembly specified and creates an instance of the task performer class. The task performer class has to implement a known interface, ITaskPerformer, which allows the generator to execute the task performer, and has to derive itself from a supplied base class, which already implements the interface in question. This way, creating your own task performer is very easy and can be plugged into the generator process without much effort. The complete project definition is available to the task performer class so it can do whatever it wants with it. Also, there's a global cache to store values which should be communicated to other task performers. For example, the CodeEmitter task performer of LLBLGen Pro is stored in the cache created once, so it doesn't have to load itself each time a new class has to be generated. Task performers can signal the generator to abort the complete generation process, or simply signal that they failed but that the total process should continue.
Task parameters
Each task can have an unlimited number of parameters with a name-value structure. These parameters are supplied to the task performer instance when the task is executed. The task performers shipped with LLBLGen, DirectoryCreator and CodeEmitter, use parameters to do their job. If you look at the supplied .tasks and .preset files you get an idea what's possible with the shipped task performers. For details about these parameters, how to create your own task performer class and how to tweak the generator process in general, please see the LLBLGen Pro SDK, which is a free download for LLBLGen Pro customers.

LLBLGen Pro v2.6 documentation. ©2002-2008 Solutions Design