Book a Demo

Author Topic: Where is the "Property" template???  (Read 6036 times)

pocketom

  • EA User
  • **
  • Posts: 97
  • Karma: +0/-0
    • View Profile
Where is the "Property" template???
« on: April 02, 2010, 12:18:31 am »
Transformation Templates -> C# -> Attribute__Property

It points to a template "Property" in the last line.
Code: [Select]
%if classStereotype=="enumeration"%
%endTemplate%

$type=%CONVERT_TYPE("C#",attType)%
%Property(attName,$type)%
This template isn't availble from the list of templates. When I try to "Add a new custom" template called "Property", I get:

'A template with that name already exists'


Is it hardcoded? I need to edit that to finally add a"virtual" tag when the property operations are created >:(
« Last Edit: April 02, 2010, 01:20:20 am by pocketom »

pocketom

  • EA User
  • **
  • Posts: 97
  • Karma: +0/-0
    • View Profile
Re: Where is the "Property" template???
« Reply #1 on: April 06, 2010, 10:00:16 pm »
Please respond ASAP, I need to know if I can access that template somehow or not. I'm running out of time!

pocketom

  • EA User
  • **
  • Posts: 97
  • Karma: +0/-0
    • View Profile
Re: Where is the "Property" template???
« Reply #2 on: April 06, 2010, 10:19:58 pm »
The problem seems also to apply to the C# code generation. I cannot find where the property code is generated. The only thing I find are templates Property, Property Declaration, Property Notes, but there I cannot identify any line that generates the code I see in the output (return ..., value = ...), only some EASL_GET() methods that seem to hide what's behind.

Seems that the code generation template behind also cannot be accessed??? What's wrong with those properties, why keeping the generation logic hidden from the EA users? And why isn't that mentioned in the documentation?

pocketom

  • EA User
  • **
  • Posts: 97
  • Karma: +0/-0
    • View Profile
Re: Where is the "Property" template???
« Reply #3 on: April 06, 2010, 10:21:23 pm »

pocketom

  • EA User
  • **
  • Posts: 97
  • Karma: +0/-0
    • View Profile
Re: Where is the "Property" template???
« Reply #4 on: April 21, 2010, 06:44:38 pm »
No Ideas? Perhaps the thread should be closed as properties seem to be created by god and he won't answer here ;-)

Makulik

  • EA User
  • **
  • Posts: 400
  • Karma: +0/-0
    • View Profile
Re: Where is the "Property" template???
« Reply #5 on: April 21, 2010, 07:27:30 pm »
Just to have someone else writing on this thread here  ;) ...
Yes it seems that property handling for C# code generation doesn't work very well, I've seen several threads about this topic.
Getter / setter code generation based on the <<property>> stereotype for C++ classes doesn't work well for me also  :-/. I'm simply not using the <<property>> stereotype, though it would be the right thing to apply. But to get properties right in C#, you'll need to use it, fiddly  :P ...

WBR
g.

Nizam Mohamed

  • EA User
  • **
  • Posts: 193
  • Karma: +1/-0
    • View Profile
Re: Where is the "Property" template???
« Reply #6 on: April 22, 2010, 02:23:21 pm »
Pocketom

unfortunately there was an issue with "Property" transformation template which has now been fixed.

W.r.t Code generation templates, the  "Operation Declaration" "property" stereotype override renders the C# properties.(the Property, Property Declaration, Property Notes are all behavioral code generation specific templates to handle UML properties)

To ensure readily compilable code for C# classes(with Properties),
Please ensure you check the "Capitalized Attribute Name for Properties" option in Code Options.
This will create distinct names for attributes and the associated Properties.


Nizam Mohamed

  • EA User
  • **
  • Posts: 193
  • Karma: +1/-0
    • View Profile
Re: Where is the "Property" template???
« Reply #7 on: April 22, 2010, 02:38:14 pm »
As an interim workaround for "Property" transformation template, you might as well Add New Custom Template with a different name and use the following code

Code: [Select]
$attName=$parameter1
$type=$parameter2
$propertyName=$attName
$propertyName=%REMOVE_PREFIX($propertyName,genOptPropertyPrefix)%
%if genOptGenCapitalisedProperties=="T"%
$propertyName=%CONVERT_NAME($propertyName, "camel case", "pascal case")%
%endIf%
Operation
{
  %TRANSFORM_REFERENCE()%
  name=%qt%$propertyName%qt%
  stereotype="property"
  scope="Public"
  type=%qt%$type%qt%
  Tag{name="attribute_name" value=%qt%$attName%qt%}
}

and also update the "Attribute__Property" template to use that.

This should work the same and there should be no issues with synchronization, etc.
(NB: Enable "Capitalized Attribute Name for Properties"  to ensure compilable code generation)

pocketom

  • EA User
  • **
  • Posts: 97
  • Karma: +0/-0
    • View Profile
Re: Where is the "Property" template???
« Reply #8 on: April 23, 2010, 06:35:12 pm »
Hi, thanx to all for your answers. I'll try out the fix you provided soon.

I also got an answer from the support team:

Quote
We can confirm this as an issue that the "Property" template is not currently accessible from the transformation template editor.  This is currently scheduled to be resolved in the next build of Enterprise Architect 8 (build 856).