I am currently working in Sparx Enterprise Architect (EA) on the design of a system that will be implemented in C# and WPF.

I am designing the classes and wondered whether there was any way to give a class .NET attributes such as [Serializable] within EA so that when I generate the skeleton C# code from the model, these attributes are automatically applied.

(These are class attributes specific to .NET, defined just before the class definition. Not to be confused with attributes that are properties of the class)

2

There are 2 best solutions below

3
Phil Rogers On

I've worked it out for myself.

The answer is to add a Tag named Attribute and give it the value [Serializable].

0
qwerty_so On

UML is programming language agnostic. That is, you model without targeting a specific programming language. In order to reflect that property in a class you are best off to think about the purpose which then leads to a programmatic attribute like Serializable. If there is a general reason you can well put that in a profile and stereotype a class so it can be recognized by either a coder or a code generator.

Please note that the Tagged Value from EA is legacy. Former UML specs did not have profiles in mind so adding tags was a free form which still exists in EA. It should be deprecated but Sparx doesn't seem to know that concept in general. So you can use it for test purpose but when it's getting serious you need to think about defining a profile for your modeling domain.