Book a Demo

Author Topic: Code Generating Finalizer  (Read 10032 times)

steven512

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Code Generating Finalizer
« on: August 03, 2005, 02:08:34 pm »
For C#, a finalizer is always generated although it is unchecked in the options. How do I stop the finalizer from being generated?

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Code Generating Finalizer
« Reply #1 on: August 03, 2005, 03:49:31 pm »
I can think of a couple of reasons why it might be being generated.

1. The class level option is set to generate finalizers.  This would be if you changed a class level option while the default was to generate finalizers.  To check open the generate dialog for a single class and click advanced.  Then go to the C# options page and check it.

2. There is actually a finalizer modelled in your class already.  The option is only to auto-generate a finalizer that isn't modelled.

I hope that helps, but if it doesn't let me know and I'll do my best to work out what's going on.

Simon

steven512

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: Code Generating Finalizer
« Reply #2 on: August 04, 2005, 06:49:18 am »
Thanks, but neither of those is true.  This has got to be a bug.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Code Generating Finalizer
« Reply #3 on: August 04, 2005, 03:12:05 pm »
It could be, but we can't really help without being able to replicate it.

Do you have any more details that could help us find what is causing the problem?

Does it happen only on the one model?  Only on your computer?  Add a new class and generate it, is a finalizer generated?

If you are able to, sending a sample model that replicates the problem to us at [email protected] is often the quickest way to find many problems.

Simon

steven512

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: Code Generating Finalizer
« Reply #4 on: August 04, 2005, 04:07:56 pm »
Did you really try to duplicate it? It does it right out of the box. Just create a new class and generate the c# code.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Code Generating Finalizer
« Reply #5 on: August 04, 2005, 07:04:55 pm »
Yes, I did try to duplicate it.

Out of the box the option to generate a finalizer should be true.  Unchecking it resulted in the correct behaviour.  This is running build 768.

What is your build number?

Simon

SWATalk

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Code Generating Finalizer
« Reply #6 on: August 21, 2005, 01:18:17 pm »
I have the same problem...I am using 768 and the forward engineer process always creates a destructor even though I have both check boxes not checked...

I can record you a short video to show you what I am talking about.

steven512

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: Code Generating Finalizer
« Reply #7 on: August 22, 2005, 03:17:00 am »
I found the solution. It's unbelievable to me that somebody at Sparx couldn't answer this...

In the options, go to Generation->Object Lifelines and see the checkbox for 'Generate Destructor', this evidently controls whether a Finalizer is generated.

Of course, it makes no sense that the Lifelines option would control it and not the option in the C# Specification. I'm sure they'll come back with some obscure technical reason tho.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Code Generating Finalizer
« Reply #8 on: August 22, 2005, 04:37:49 am »
Quote
I found the solution. It's unbelievable to me that somebody at Sparx couldn't answer this...

In the options, go to Generation->Object Lifelines and see the checkbox for 'Generate Destructor', this evidently controls whether a Finalizer is generated.

Of course, it makes no sense that the Lifelines option would control it and not the option in the C# Specification. I'm sure they'll come back with some obscure technical reason tho.
Welcome to EA's UI Unique Interface...  ;D

Which may explain why no one at Sparx was able to answer... It's so unique that you can't easily track it down...

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: Code Generating Finalizer
« Reply #9 on: August 22, 2005, 04:18:40 pm »
If you look very carefully, you'll see that its "Object Lifetimes" not lifelines.

Having said that, the way that the class level options, language level options and the options set at generation time override each other is at the very least witchcraft.


bruce
"It is not so expressed, but what of that?
'Twere good you do so much for charity."

Oh I forgot, we aren't doing him are we.

du-it

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Code Generating Finalizer
« Reply #10 on: November 23, 2005, 11:25:09 am »
I'm running 772 and I have to uncheck 'Generate Destructor' for each class separately.
To uncheck this field in Tools-->Options-->Lifelines doesn't work. Using this checkbox solely results in creating finalize methods.

thomaskilian

  • Guest
Re: Code Generating Finalizer
« Reply #11 on: November 23, 2005, 12:08:39 pm »
I noticed that with constructors for my Perl classes but I have not very much so it did not bother me. But this seems to be a new behaviour ???

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Code Generating Finalizer
« Reply #12 on: November 23, 2005, 01:13:24 pm »
Quote
I'm running 772 and I have to uncheck 'Generate Destructor' for each class separately.

This is likely because you've modified the options for those classes when the Generate Destructor option was on.

Rather than modifying each individually, try clearing all the class level options for a package.  (Tree View context menu | Code Engineering | Reset Options for this Package)

Check 'Reset Default Options' in resulting dialog.