tags:

views:

284

answers:

2

I want to model c# class attributes and variable attributes (not UML attributes) in UML and am not sure how to do it.

[AttributeForTheClass]
class SomeClass
{
    [AttributeForTheField]
    int SomeField;

    [AttributeForTheMethod]
    int SomeMethod(
     [AttributeForTheParameter]int someParam)
    {
     ...
    }
}

How do you model:

[AttributeForTheClass] and [AttributeForTheField] and [AttributeForTheMethod]

Currently we use Sparx Enterprise Architect.

I know that c# attributes are a c# language feature but I am not sure they are even defined in UML.

Anyone have a solution?

A: 

What happens when you reverse engineer some C# code which has attributes? Do you get stereotypes or tagged values?

From a modelling view, they should be stereotypes and any parameters of the attributes should be tagged values, but it's easier to go with what the tool supports if it can.

Pete Kirkham
A: 

EA imports attribtues as tagged values with the name "Attribute", and the text of the attributes, concatenated, as the value:

[WebService(Namespace = "http://dataservice/")];[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)];[System.ComponentModel.ToolboxItem(false)]

John Saunders