This extension for StarUML(http://staruml.io) support to generate C# code from UML model. Install this extension from Extension Manager of StarUML. It is based on C# 6.0 specification.
- Click the menu (
Tools > C# > Generate Code...) - Select a base model (or package) that will be generated to C#.
- Select a folder where generated C# source files will be placed.
Below are the rules to convert from UML model elements to C# source codes.
- converted to C# namespace (as a folder).
- converted to
partialC# Class. (as a separate.designer.csfile) visibilityto one of modifierspublic,protected,privateand none.isAbstractproperty toabstractmodifier.isFinalSpecializationandisLeafproperty tosealedmodifier.- All contained types (UMLClass, UMLInterface, UMLEnumeration) are generated as inner type definition.
- Documentation property to C# XML comment as a
<summary>. - Annotation Type is converted to C# attribute class which extends System.Attribute and postfix of class is
Attribute. (cf. class testAttribute:System.Attribute)
- converted to C# Property, unless a stereotype
<<field>>is specified. visibilityproperty to one of modifierspublic,protected,privateand none.nameproperty to property identifier.typeproperty to property type.- if
multiplicityis[0..1], nullable type is used, where applicable. - if
multiplicityis one of0..*,1..*,*, then configurable collection type for ordered or unordered collection is used. - if
multiplicityis exact number > 1, array type[]is used. isStaticproperty tostaticmodifier.isLeafproperty tosealedmodifier.isDerivedproperty to an expression-bodied read-only property.defaultValueproperty as a body for derived properties and initial value for others.- Documentation property to C# XML comment as a
<summary>.
- converted to C# Methods.
visibilityproperty to one of modifierspublic,protected,privateand none.nameproperty to method identifier.isAbstractproperty toabstractmodifier.isStaticproperty tostaticmodifier.- UMLParameter to C# Method Parameters.
- UMLParameter's name property to parameter identifier.
- UMLParameter's type property to type of parameter.
- UMLParameter with
direction=returnto return type of method. When no return parameter,voidis used. - UMLParameter with
isReadOnly=truetosealedmodifier of parameter. - Documentation property to C# XML comment as a
<summary>.
- converted to C# Interface. (as a separate
.csfile) visibilityproperty to one of modifierspublic,protected,privateand none.- Documentation property to C# XML comment as a
<summary>.
- converted to C# enum. (as a separate
.csfile) visibilityproperty to one of modifierspublic,protected,privateand none.- UMLEnumerationLiteral to literals of enum.
- converted to C# Property, unless a stereotype
<<field>>is specified. visibilityproperty to one of modifierspublic,protected,privateand none.nameproperty to property identifier.typeproperty to property type.- if
multiplicityis[0..1], nullable type is used, where applicable. - if
multiplicityis one of0..*,1..*,*, then configurable collection type for ordered or unordered collection is used. - if
multiplicityis exact number > 1, array type[]is used. defaultValueproperty to initial value.- Documentation property to C# XML comment as a
<summary>.
- converted to C# Extends (
:). - Allowed only for UMLClass to UMLClass, and UMLInterface to UMLInterface.
- converted to C# Implements (
:). - Allowed only for UMLClass to UMLInterface.
Licensed under the MIT license (see LICENSE file).