Book a Demo

Author Topic: Namespace declarations missing in my generated C#  (Read 3485 times)

johnp

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Namespace declarations missing in my generated C#
« on: February 06, 2007, 08:26:13 am »
How do I get namespace declarations to be generated in my C# classes. I have defined a 'namespace root' at the top level package, but none of the classes inside it have any namespace definitions. What else do I need to do to get this to work please?

Also, what about 'using' statements for namespaces referenced in the class?

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Namespace declarations missing in my generated
« Reply #1 on: February 06, 2007, 09:28:46 am »
You might need to put your class below the package that's set as the namespace root.

Try searching the forum for some hints. There's been some discussion about this, but I don't know how much was specific to C# (or even .Net).
No, you can't have it!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Namespace declarations missing in my generated
« Reply #2 on: February 06, 2007, 01:48:10 pm »
A namespace root means that the package represents the root namespace.  Therefore it will not result in the generation of a namespace.

It is the packages underneath the namespace root package that represent namespaces.  So try clearing you namespaces roots for all packages that you want namespaces for.

johnp

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Namespace declarations missing in my generated
« Reply #3 on: February 07, 2007, 03:24:52 am »
It seems that, because I had embedded spaces in my package names, this was preventing the namespace generation from working (packagePath was a blank string) ;D.

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Namespace declarations missing in my generated
« Reply #4 on: February 07, 2007, 04:13:25 am »
Report this as a but to Sparx, in case it does not get picked up from this (user) forum.

Click the Support link at the top of the forum page and then the Bug Report link on the left-side menu.
No, you can't have it!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Namespace declarations missing in my generated
« Reply #5 on: February 07, 2007, 01:21:22 pm »
Quote
It seems that, because I had embedded spaces in my package names, this was preventing the namespace generation from working (packagePath was a blank string) ;D.

This has been done deliberately because of the number of people that had problems with EA generating invalid code because of namespaces with spaces in the name.

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Namespace declarations missing in my generated
« Reply #6 on: February 07, 2007, 01:57:16 pm »
Quote
This has been done deliberately because of the number of people that had problems with EA generating invalid code because of namespaces with spaces in the name.

That sounds pretty reasonable to me Simon.

Is there any way to warn users about spaces in a name, similar to the way class names are handled? Or would that just move the problem around without solving it?

David
No, you can't have it!