Overview of code generation
Overview of C# code generation
The generation of C# code is based on a UML model extended by notes and tagged values specific to C#, in order to generate all the code for C# classes.
Code generation can be customized using the following mechanisms:
· C# generation parameters provide general generation options
· the "CsTypes" package defines parameters used to generate base types and accessors
· C# code generation templates and makefile generation templates are used to completely redefine generation
Introduction to C# generation work products
In order to generate C# code, a C# generation work product has to be created. C# generation work products can be created for packages and classes.
In Objecteering, the C# generation work product provides the commands used to:
C# generation work products are created through the window shown in Figure 30 below.

Figure
30. The C# generation work product creation window
Key:
· "Name": This field is used to specify the name of the C# generation work product.
· "Generation path": This field is used to specify the root directory for the generation of .cs files.
· "Compilation path": This field is used to specify the root directory for the generation of the corresponding .exe or .dll file.
Work products can also be used to administrate the files which have been produced. This means that if you destroy the generation work product, you will also destroy the files produced.
Overview of C# generation work product commands
Objecteering C# Developer provides four commands available on C# generation work products, as shown in Figure 31 below.

Figure 31. Commands available from a C# generation work product
|
The
... command |
is
used to ... |
|
Generate |
generate the C# code for a class (when the work product is linked to a class) or for a set of classes (when the work product is linked to a package). |
|
Visualize the code |
visualize the generated C# code. This action is only carried out for work products linked to a class. |
|
Edit |
edit the generated code. The editor used is the one defined by the "Command invoking the external editor" parameter. This action is only carried out for work products linked to a class. |
|
Update |
incorporate modifications made outside the tool into the generated files in the Objecteering repository. |
Generating types and accessors
A special package named "CsTypes" is used for type mapping and accessor generation. This package is added to the "predefinedTypes" project when Objecteering C# Developer is deployed in a project.
You can modify the mapping of types and the generation of accessors, without
having to re-define Objecteering C# Developer, by either:
· modifying the "CsTypes" package
or by:
· creating a similar package and by modifying the "Types translation/interpretation package" parameter. This parameter designates the package to be used (we recommend this solution).
For more information on the structure of the package and the way it is used, please see "Type and accessor generation".
Propagating a generation work product
When a C# generation work product on a package or a class propagates, a C# code generation work product is automatically created for each package and class at a lower level in the tree.