Book a Demo

Author Topic: C# generator doesn't include namespace?  (Read 5513 times)

metamorphium

  • EA Novice
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
C# generator doesn't include namespace?
« on: June 01, 2010, 06:59:19 pm »
Hello,

I can't make this working. I've created a class model and I am able to generate all files (EA professional). However, the generator doesn't enclose the class in the namespace x.y { } although it's defined in Namespaces and in Tools->Options->C# I have Generate Namespaces set to true.

I've tried to search the doc and forum but it seems it works for everyone else? Could any kind sould direct me what am I doing wrong?

Thanks and best regards!

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: C# generator doesn't include namespace?
« Reply #1 on: June 01, 2010, 07:24:48 pm »
What version are you on?

Geert

metamorphium

  • EA Novice
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Re: C# generator doesn't include namespace?
« Reply #2 on: June 01, 2010, 07:43:19 pm »
8.0.856 (Build 856) - Professional Edition

thanks!

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: C# generator doesn't include namespace?
« Reply #3 on: June 01, 2010, 07:51:27 pm »
You are right, there is something strange happening with the "name space root" setting.
Have you tried removing all "namespaces" from your model? It seems to help. (and treats each package as namespace)

Geert

metamorphium

  • EA Novice
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Re: C# generator doesn't include namespace?
« Reply #4 on: June 01, 2010, 08:31:58 pm »
thanks again. However, even if I delete all namespace from the settings, I'm getting incorrect results.

EA generates correctly folders for each namespace (per package) but the class definition is still wrong. I even tried to modify class template but I'm getting stack overflow error and the EA crashed so I reverted to original definition (which IMO doesn't contain namespace block).

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: C# generator doesn't include namespace?
« Reply #5 on: June 01, 2010, 08:46:53 pm »
Hmm, must be something that is kept on the class.
What happens if you try the same on a fresh model, with new classes?
Anyway, I would report this as a bug if I were you.

Geert

metamorphium

  • EA Novice
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Re: C# generator doesn't include namespace?
« Reply #6 on: June 01, 2010, 08:50:48 pm »
I started a new project. Added a single class with one attribute and did the export. Again no namespace was exported.

Submitting as bug now, thanks for your help.

Till

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: C# generator doesn't include namespace?
« Reply #7 on: June 01, 2010, 10:07:29 pm »
Also ensure that the "Generate Namespaces" flag is set in the EA options.

(1) Go to "Tools" > "Options"
(2) Under "Source Code Engineering" select "C#"
(3) Set "Generate Namespaces" to "True" under "Options for the current user"

Moreover, make sure that the namespace root is set to the absolute root package, for example, if you have a package structure as follows

- C# Model
-- Logic
--- Ifc
--- Implementation

your namespace root should be set on "C# Model", yielding namespaces "Logic", "Logic.Ifc", and "Logic.Implementation", respectively.

Cheers,

Till

metamorphium

  • EA Novice
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Re: C# generator doesn't include namespace?
« Reply #8 on: June 01, 2010, 10:16:27 pm »
Hi Till,

THANK YOU!!!

I had to create nested packages and it works now!



Till

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: C# generator doesn't include namespace?
« Reply #9 on: June 02, 2010, 05:50:25 am »
Glad I could help.  :) Happy modelling!

Cheers,

Till