Author Topic: C# generated property method  (Read 4476 times)

oaf

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
C# generated property method
« on: April 26, 2005, 03:41:51 am »
The default for C# code is like this

public int attB{
get{
return attB;
}
set{
attB = value;
}
}
But I don't like this kind of bracing and want it to look like this
public int attB
               {
get
                       {
return attB;
}
set
                       {
attB = value;
}
}
I've tried to modify the 'Attribute Declaration' template but could not manage to get any change in the generated code, could any kind soul point me in the right direction?

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8085
  • Karma: +118/-20
    • View Profile
Re: C# generated property method
« Reply #1 on: April 26, 2005, 03:09:26 pm »
Look at the operation body with the stereotype override of property. :)

Simon

oaf

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: C# generated property method
« Reply #2 on: April 27, 2005, 12:21:34 am »
Sorry but I could not manage to change the K&R brace style to my preferences. By inserting my special comments into the templates I found that the property method goes as follows
1. operationNotes
2. operationDeclaration
3. operationBody

But I've put in a comment as first entry in operationBody, and it's visible for normal operations but not for the get()/set() for the property, so my question is where is the code generator going?

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8085
  • Karma: +118/-20
    • View Profile
Re: C# generated property method
« Reply #3 on: April 27, 2005, 03:14:39 pm »
The code generator is going to the stereotype override for property.

From the help file.
Quote
The element that is currently being generated is said to be "in scope". If the element in scope is stereotyped EA looks for a template that has been defined for that stereotype. If a match is found, the specialised template is executed. Otherwise the default implementation of the base template is used.  

To edit the specialised property template, open the code template editor to the operation body template for C#.  Now look in the bottom left hand corner of the window.  You should see a list of Stereotype overrides with the feature (in this case read method) column reading property, indexer, event.

Select the property row and edit that template.

Simon
« Last Edit: April 27, 2005, 03:17:14 pm by simonm »

oaf

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: C# generated property method
« Reply #4 on: April 27, 2005, 11:43:07 pm »
The first thing to catch blindness is the eyes. I have not noticed the lower left window, now I'm back in business. Thanks....