Book a Demo

Author Topic: C# code generation  (Read 4465 times)

Walter_Leinert

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
C# code generation
« on: April 30, 2004, 08:43:20 am »
Hi all,

recently i started with EA and i am quite impressed by its overall features. I did some reengineering of my C# project code and created several diagrams quickly.

Now i started creating new classes and interfaces and to generate or sychronize the code.

But for several classes i got no class body or no interfaces at all.

What do i have to change in the designer to create complete source code?

How do i specifiy the namespaces to generate?

Thanks in advance, Walter

wombat

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: C# code generation
« Reply #1 on: May 01, 2004, 05:44:09 pm »
Hi, I'm also a newbie  ;), i can help you with your namespace question, basically all you need to do is to create a 'Package' then group your classes under the package (unless there's another way, but this works for me).  To create package:
- Right click on the node of of your view, then Insert/NewPackage

You can then drag your existing classes and drop them in the package and that's it.  Hope that's help  :)

On the same subject though - Is there a way to disable Code Gen. to generate destructor for C#?  It doesn't cause any compiling problem - it's just annoying.
« Last Edit: May 01, 2004, 05:49:08 pm by wombat »

Walter_Leinert

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: C# code generation
« Reply #2 on: May 02, 2004, 02:39:43 am »
Hi,

thanks for the feedback. Recently i learned a lot about forward / reverse engeneering working in parallel with the VS.NET IDE and EA.

Destructor generation (or finalizers in c#) is disabled in EA on the Tools -> Options -> Generations -> C# Specifications tab; you can also disable the generation of Dispose methods.

Regards, Walter

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: C# code generation
« Reply #3 on: May 02, 2004, 04:05:15 pm »
Walter,

What version are you using?  I am having the same problem (I think) in 726.  

IMO It seems to be something about the attributes of the base view (i.e. view below the project root node).  I have fired off a question to Sparx about it - if there is an reason  I will post it here.

If I move the class into a different package - one of the Sparx EABase "views" packages - the code is generated correctly.  If I then move it back to one of the views I created the code wont generate.   ???


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.

Walter_Leinert

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: C# code generation
« Reply #4 on: May 02, 2004, 11:35:50 pm »
Hi Bruce,

i'm using the build 726.

Now all works. Most of my problem arised from lack if knowledge or short documentation.

I move my project from the notebook to my pc and plyed around with local directories and shared ids. During my first attempts i did not understand the full concept of shared ids; i tried to set local environment variables and so on ...

I had problems with code generations and was not able to change to root of the project to a local root on my pc.

The reason was that i defined a shared id on my notebook for a subdirectory of my project and did not get rid of this shared (notebook) id on my pc. I solved the problem by saving the project in xml/xmi and corrected all codepath attributes and changed the shared id to my new shared id (it's not for beginners, puhh ...)


But now it works and i understand the idea of shared ids and local directories. A shared id is like an evironment variable which is set for the root of the source tree. When pressing the Expand button the shared id is replaced by the corresponding local directory and results in absolute local paths. The Apply button reverses the operation and replaces the local directory (prefix) by the shared id (you can see the effect when saving the project as xml after the operations).

You must use the Apply button to inject the shared ids BEFORE using the EA project on another pc with a local directory. On the new pc you must set the same shared id to the corresponding local directory and afterwards use the Expand button to change all codepaths to the local directory.

I did not understand this by my first reading of the documentation, but may be my first tries were not the typical ones.

Now all works, but i am a little bit cautious ...

Regards, Walter

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: C# code generation
« Reply #5 on: May 02, 2004, 11:51:10 pm »
Ah, this is not the same problem as mine then.

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.

MichaelHanson

  • EA User
  • **
  • Posts: 31
  • Karma: +0/-0
  • EA is the best
    • View Profile
Re: C# code generation
« Reply #6 on: May 05, 2004, 11:19:15 am »
I have been tinkering with the C# Code Generation features and had similar troubles getting the Name Space to generate correctly

I resolved the problem by doing the following

Create a Package to contain all of the physical classes you want to generate I chose my to place mine in a a package named after my company, which I placed package called Physical Model below the Component View folder

Right click this package and choose Package Control, Set as Namespace Root

Organise your physical classes in the Namespace Root package, optionally in packages of their own.

Select your NameSpace Root in the Project Explorer then initiate Code Generation from the toolbar or contect menu (Right Click choose Code Engineering, Generate Source Code...

Generate the code and you should find Namespaces are correctly organized based on package heirarchy

Hope this helps
Mike Hanson
Mike Hanson
Microsoft Technology Specialist