Skip to content

andyqp/StarUML-CSharp

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

85 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C# Extension for StarUML 3+

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.

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.

Below are the rules to convert from UML model elements to C# source codes.

UMLPackage

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

UMLClass

  • converted to partial C# Class. (as a separate .designer.cs file)
  • visibility to one of modifiers public, protected, private and none.
  • isAbstract property to abstract modifier.
  • isFinalSpecialization and isLeaf property to sealed modifier.
  • 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)

UMLAttribute

  • converted to C# Property, unless a stereotype <<field>> is specified.
  • visibility property to one of modifiers public, protected, private and none.
  • name property to property identifier.
  • type property to property type.
  • if multiplicity is [0..1], nullable type is used, where applicable.
  • if multiplicity is one of 0..*, 1..*, *, then configurable collection type for ordered or unordered collection is used.
  • if multiplicity is exact number > 1, array type [] is used.
  • isStatic property to static modifier.
  • isLeaf property to sealed modifier.
  • isDerived property to an expression-bodied read-only property.
  • defaultValue property as a body for derived properties and initial value for others.
  • Documentation property to C# XML comment as a <summary>.

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# XML comment as a <summary>.

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# XML comment as a <summary>.

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# Property, unless a stereotype <<field>> is specified.
  • visibility property to one of modifiers public, protected, private and none.
  • name property to property identifier.
  • type property to property type.
  • if multiplicity is [0..1], nullable type is used, where applicable.
  • if multiplicity is one of 0..*, 1..*, *, then configurable collection type for ordered or unordered collection is used.
  • if multiplicity is exact number > 1, array type [] is used.
  • defaultValue property to initial value.
  • Documentation property to C# XML comment as a <summary>.

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.

Licensed under the MIT license (see LICENSE file).

About

C# extension for StarUML 2

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%