Skip to content

staruml/staruml-csharp

Repository files navigation

C# Extension for StarUML 2

This extension for StarUML(http://staruml.io) support to generate C# code from UML model and to reverse Java code to UML model. Install this extension from Extension Manager of StarUML. It is based on C# 2.0 specification.

C# Code Generation

  1. Click the menu (Tools > C# > Generate Code...)
  2. Select a base model (or package) that will be generated to C#.
  3. Select a folder where generated C# source files will be placed.

Belows are the rules to convert from UML model elements to Java source codes.

UMLPackage

  • converted to C# namespace (as a folder).

UMLClass

  • converted to C# Class. (as a separate .cs file)
  • visibility to one of modifiers public, protected, private and none.
  • isAbstract property to abstract modifier.
  • isFinalSpecification and isLeaf property to sealed modifier.
  • Default constructor is generated.
  • All contained types (UMLClass, UMLInterface, UMLEnumeration) are generated as inner type definition.
  • Documentation property to C#Doc comment.
  • Annotation Type is converted to C# attribute class which extends System.Attribute and postfix of class is Attribute. (cf. class testAttribute:System.Attribute)

UMLAttribute

  • converted to C# Field.
  • visibility property to one of modifiers public, protected, private and none.
  • name property to field identifier.
  • type property to field type.
  • multiplicity property to array type.
  • isStatic property to static modifier.
  • isLeaf property to sealed modifier.
  • defaultValue property to initial value.
  • Documentation property to C#Doc comment.

UMLOperation

  • converted to C# Methods.
  • visibility property to one of modifiers public, protected, private and none.
  • name property to method identifier.
  • isAbstract property to abstract modifier.
  • isStatic property to static modifier.
  • UMLParameter to C# Method Parameters.
  • UMLParameter's name property to parameter identifier.
  • UMLParameter's type property to type of parameter.
  • UMLParameter with direction = return to return type of method. When no return parameter, void is used.
  • UMLParameter with isReadOnly = true to sealed modifier of parameter.
  • Documentation property to C#Doc comment.

UMLInterface

  • converted to C# Interface. (as a separate .cs file)
  • visibility property to one of modifiers public, protected, private and none.
  • Documentation property to C#Doc comment.

UMLEnumeration

  • converted to C# enum. (as a separate .cs file)
  • visibility property to one of modifiers public, protected, private and none.
  • UMLEnumerationLiteral to literals of enum.

UMLAssociationEnd

  • converted to C# Field.
  • visibility property to one of modifiers public, protected, private and none.
  • name property to field identifier.
  • type property to field type.
  • If multiplicity is one of 0..*, 1..*, *, then collection type (List<> when isOrdered = true or HashSet<>) is used.
  • defaultValue property to initial value.
  • Documentation property to JavaDoc comment.

UMLGeneralization

  • converted to C# Extends (:).
  • Allowed only for UMLClass to UMLClass, and UMLInterface to UMLInterface.

UMLInterfaceRealization

  • converted to C# Implements (:).
  • Allowed only for UMLClass to UMLInterface.