Using Enterprise Architect (version 7.5), I’m trying to refine the code generation for C#. To make an attribute with an initial value that is a string generate properly, the only way I’ve been successful is with the code below. Does anyone know if a simpler way to do this? It currently seems a little bloated.
%if attType=="string" and attInitial!=""%
= "
%elseIf attInitial!=""%
=
%endIf%
%attInitial ? value%
%if attType=="string" and attInitial!=""%
"
%endIf%
EA’s
attInitialcorresponds to Property.default in UML.So according to UML, if the type of the property is string, then the value
attInitialshould be an expression which evaluates to a string, not the content of a string literal.If you do want it to be a non-UML-complient extension string literal value, you have to write something a bit more complicated that what you have done above to handle escaping.