Sparx Systems Forum

Enterprise Architect => General Board => Topic started by: metamorphium on June 01, 2010, 06:59:19 pm

Title: C# generator doesn't include namespace?
Post by: metamorphium 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!
Title: Re: C# generator doesn't include namespace?
Post by: Geert Bellekens on June 01, 2010, 07:24:48 pm
What version are you on?

Geert
Title: Re: C# generator doesn't include namespace?
Post by: metamorphium on June 01, 2010, 07:43:19 pm
8.0.856 (Build 856) - Professional Edition

thanks!
Title: Re: C# generator doesn't include namespace?
Post by: Geert Bellekens 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
Title: Re: C# generator doesn't include namespace?
Post by: metamorphium 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).
Title: Re: C# generator doesn't include namespace?
Post by: Geert Bellekens 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
Title: Re: C# generator doesn't include namespace?
Post by: metamorphium 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.
Title: Re: C# generator doesn't include namespace?
Post by: Till 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
Title: Re: C# generator doesn't include namespace?
Post by: metamorphium on June 01, 2010, 10:16:27 pm
Hi Till,

THANK YOU!!!

I had to create nested packages and it works now!


Title: Re: C# generator doesn't include namespace?
Post by: Till on June 02, 2010, 05:50:25 am
Glad I could help.  :) Happy modelling!

Cheers,

Till