Book a Demo

Author Topic: C# Code Generation - finalize and code layout  (Read 3970 times)

jez

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
C# Code Generation - finalize and code layout
« on: January 08, 2004, 10:13:22 am »
Hi

I am having problems with Enterprise Architect creating 2 destructors - ~Object() (the one we all want) and protected virtual void Finalize (the one we don't!).

Does any one know any easy work around for this?

A couple of other code layout issues.

EA structures a method by closing the block at the end of the declaration i.e

public void Blah(){
}

I prefer the standard

public void Blah()
{
}

Any ideas how to change this?

Thanks in advance
Jez



danman

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: C# Code Generation - finalize and code layout
« Reply #1 on: January 12, 2004, 09:58:27 am »
In order to change the format of generated code, you have to modify the code generation templates.


benc

  • EA Administrator
  • EA User
  • *****
  • Posts: 200
  • Karma: +0/-0
    • View Profile
Re: C# Code Generation - finalize and code layout
« Reply #2 on: January 12, 2004, 02:47:40 pm »
Hi Jez,

Regarding the Finalize : you can turn off the automatic generation of this from the Code Generation options.
Select your class, hit cntrl+G -> Advanced -> C# Specifications. You can change the default setting under Tools | Options | Generation menu.

Regarding the brace style : you will need to customize the code generation templates. In particular, the default Operation template. Replace the line with %PI=""% to %PI="\n"%. You'd also need to update the templates responsible for generating get/set methods in properties etc. The help file has some more info on customizing code templates.

I hope this helps.

Regards,
Ben

Just an update: We'll add a sanity check to the templates so that either a Finalizer or Destructor stub (not both) get auto generated.
« Last Edit: January 12, 2004, 03:12:44 pm by benc »