Book a Demo

Author Topic: Several namespace generation issues  (Read 3868 times)

legendabre

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Several namespace generation issues
« on: December 07, 2005, 04:46:13 am »
Hi everyone,

I'm having several issues regarding namespaces (C#) in v6.0.788. I tried to modify them using CG editor but since am not $COMMENT="ADVANCED USER!" I've failed. Here is list:

- If you generate class for the first time (CTRL+G) everything works fine. But if you use text editor to open generated file, delete everything, close text editor, and generate class again (with Always synchornize with existing file option checked) you get totally screwed namespaces (one by one).

<example>
namespace MyNamespace
{

namespace TestProject

{


namespace SomeInnerNamespace


{



public class...
</example>


- If you make relation between classes in class diagram and generate code you'll end up with (expected) linked attribute but also with using LinkedClassNameSpace regardless if current namespace of class is same. I guess I need to put %Replace% Function macro to work here but can't seem to find right place to put it ;D
<example>
using MyNamespace.TestProject.SomeInnerNamespace;

namespace MyNamespace.TestProject.SomeInnerNamespace
{
</example>


If you can't look into issue I'll gladly change templates by myself but in that case I need some basic guidence on how namespaces in CG Template are working.

Tnx.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Several namespace generation issues
« Reply #1 on: December 07, 2005, 01:36:26 pm »
The problem with namespaces being generated in that way is because when synchronising EA is cautious about generating the correct namespaces.  I'm not aware of any way to get around this by editing templates.

The issue with the unnecessary using statment being generated is possible to fix, but not easy.  It's being generated by the Import Section and Import templates, but the namespace of the file is not defined at that point.  To compare against it you would need to create and execute a custom list and use the result of that to compare against.

Oh, forget about those comments about not editing a template unless you're an advanced user.  Edit any templates you like in my opinion.

legendabre

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Several namespace generation issues
« Reply #2 on: December 07, 2005, 05:25:06 pm »
Heh... I think that %Advanced user% comment is rather ql. Templates that don't have it are easier to modify ;).

Can't I just remove value of current namespace if it exists in custom list? Isn't there some function to do this? Or can I first generate the namespace of the file (in variable) and then while creating using directives skip it: if (currentUsingDirective == currentFileNamespace) ?

After being able to exposing Linked Attribute throught property in class I thought this will be piece of cake but...

Tnx in advance for your guidance.

woodz

  • EA Novice
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Re: Several namespace generation issues
« Reply #3 on: December 19, 2005, 12:18:34 pm »
Hi,

has anybody figured out that namespace dependency and nesting depends on the position (level) of the related class in the tree of the project viewer? I think, I've done it. I can drag the class to the node Logical View. And if I rename this node to the name of the namespace wanted, EA creates namespaces correctly. But it does not allow more existing nodes on the same level as e.g. the logical view node is. So we can not create new namespaces ad libitum.
I don't understand the base model of EA. It anticipates building new namespaces under the root (Views) directly.
I think it is not a good idea not to differentiate between packages (java) and namespaces (java + c#).
Isn't a package more than a namespace? Can't a package be a whole application and can't it considered as a komponent?
Why can't we create new namespaces via the project tree everywhere we like with a simple folder for each?

thanks

woodz

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Several namespace generation issues
« Reply #4 on: December 19, 2005, 01:18:30 pm »
Hi Woodz,

If you want namespaces generated see this page from the EA help.

http://sparxsystems.com.au/EAUserGuide/index.html?namespaces.htm

The summary is set any package as a namespace root.  Packages under that package will then be namespaces (or java packages since they are treated identically.)

And also, you can create arbitrary views at the Logical View level.  Either right click on the top level node and select 'New View' or click on the package icon in the tree toolbar with the top level node selected.