Inside of a namespace, classes defined within a together block are not recognized outside of the block

0 votes
asked Feb 2, 2018 in Bug by djerius (120 points)

In a larger diagram I'm trying to improve layout of  like classes using together blocks.  The together blocks and other code are inside of a namespace.  The problem I'm running into is that relationships defined outside of the together block (but still inside of the namespace) create new classes, rather than using the ones already defined in the together blocks. Here's a snippet of code:

namespace Observation {

   together {
       abstract class BadPix {

       class Role::BadPix <<role>> {


   class Base {


   BadPix *-- Role::BadPix
   Base <|-- Role::BadPix


and here's what it looks like:

If I remove the namespace, things work:

1 Answer

0 votes
answered Feb 4, 2018 by plantuml (295,000 points)
Thanks for the feedback.

We're going to investigate this, not sure that this is easy to solve. In some (near?) future, we are going to simplify the difference between namespace and package within PlantUML because this is really confusing for users.

Note that your example is working fine with package

commented Feb 7, 2018 by djerius (120 points)

I'm using namespace rather than package because of  the ability to have similarly named classes in different namespaces, which package doesn't allow.   This maps directly onto namespaces in C++ (which is nice!) and also leads to less visual clutter, as the top-level name in the class hierarchy name doesn't have to appear in every class.  (But I'm sure you already know that!)