Code Generation: C#

Overview

This sample generates a basic C# source file for each Class of a UML input model. The sample generates:

Launch configuration

 
Ruleset com.sodius.mdw.samples.csharp.CSharpGeneration
Rule main
Arguments a UML input model (e.g. models/product13.xmi)

Here is an example of a UML 1.3 based C# generation launch:

Features demonstrated

Feature Example Location Reference
Calling a text template from a rule $CsharpSource(class) CsharpGeneration.mqr template call
Including a text template from another text template [#include Csharpdoc(class)] CsharpSource.tgt include
Trimming to avoid blank lines ${attribute.accessors}[#trim] uml13_Class.tgs trim
Filtering a list of instances based on a criterium self.parameter.reject("kind", RETURN_LITERAL) uml13_Operation.mqs MDWList
Specifying a default value self.returnType.csharpType ? "void" uml13_Operation.mqs default value
Using protected sections to keep user code [#protectedStartTag] uml13_Operation.mqs protected tags