Book a Demo

Author Topic: How do I control where braces are generated?  (Read 3606 times)

oviron

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
How do I control where braces are generated?
« on: June 09, 2005, 05:47:07 am »
When generating C# code, the default template prefers to use the UNIX style of positioning braces in the code.

This approach is not consistent with the way that Visual Studio generates code.

How do I modify the template to change this behavior?

-Bob

nifsmith

  • EA Novice
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Re: How do I control where braces are generated?
« Reply #1 on: June 10, 2005, 11:09:06 pm »
Don't know if this is the best way or even correct way to do it but this is how I achieved what you want to do.

Open a Project, goto Configuration, Code Generation Templates.. on the menu bar.

Make sure C# is selected in the Code Templates Editor under language.

To get the namespace to look like

   namespace
   {
   }

Select Namespace Body. In the Template window look at the last block of tags begining "{ %PI ....". Put in a newline escape sequence \n before the brace.

   \n{

Follow the same sort of logic for the Class body looking for the braces in the tags and entering the escape sequence. There is definately a hack and probably not the best solution but it worked for me at short notice.

nifsmith

People should not be afraid of their Governments. Governments should be afraid of their people.

V

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: How do I control where braces are generated?
« Reply #2 on: June 21, 2005, 05:53:53 pm »
The best way to do it would be to go to the Namespace template and remove the following line.

%PI=" "%

As a result the default value of PI will appear between the two subsequent lines in that template.

You will also want to do the same thing with the Class and Operation templates.

Simon

tdanz

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Re: How do I control where braces are generated?
« Reply #3 on: January 31, 2006, 02:40:25 am »
Hi!
Aren't there any prebuilt templates to get the same coding style for c# as in Visual Studio?
Thomas

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: How do I control where braces are generated?
« Reply #4 on: January 31, 2006, 01:34:38 pm »
No.  The whole idea of the templates is to allow users to modify them to get the style that they want.

Having said that, I just uploaded a set of templates onto the EA User Group site that does what you want.

Find them here