Designing C# applications

Rational® Rhapsody® allows you to create models for C# (C Sharp) applications, using standard UML constructs as well as C#-specific constructs, and generate C# code from your model. Existing C# projects in Visual Studio can be reverse engineered into a Rational Rhapsody model.

Starting Rational Rhapsody Developer for C#

The Rational Rhapsody start menu shortcuts include a shortcut for starting IBM® Rational Rhapsody Developer for C#.

Alternatively, you can use the following options at the command line: [install directory]\rhapsody.exe -dev_ed -lang=csharp

Creating C# projects

When you use the New Project dialog, you will see that when you create a new project, the Project Settings field is set to the code-centric C# profile.

Modeling C#

When building models for C# applications, you can use the standard UML constructs as well as C#-specific constructs. These language-specific constructs include:

One important point to keep in mind is that C# models are always set to code-centric mode. This has a number of implications, including:

For more information, see Using the code-centric settings

Modeling partial types

To add a partial type to your model:

  1. Create a class and apply the c# Partial Type stereotype to it.
  2. Create classes to represent each of the classes that will make up the partial type, and apply the c# Partial stereotype to each of these classes.
  3. Draw dependencies from each of the classes that make up the type to the class you created with the c# Partial Type stereotype.
  4. Apply the c# Partial stereotype to each of the dependencies.

When code is generated, the name that you gave to the class with the c# Partial Type stereotype will serve as the name of the partial type. For example:

public partial class vehicle
{
    public int length;
    
    public int weight;
}

public partial class vehicle
{
    public int wheels;
}

Reverse engineering and roundtripping of C# code

In order to reverse engineer or roundtrip changes to C# code, you must have Microsoft Visual Studio 2008 installed.

For instructions on reverse engineering or roundtripping C# code, see Integrating Rational Rhapsody and MS Visual Studio

Generating C# code and building C# applications

When you are designing C# applications, Rational Rhapsody provides the same code generation options as for the other supported programming languages. However, you will notice that when working with C# projects, the various build options in the menu are disabled. After generating code for C# applications, you must create a project in Microsoft Visual Studio 2008 and build the C# application from within Visual Studio.


Feedback