Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Feature Requests
 Proper understanding of namespaces

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
KRG Posted - Oct 15 2025 : 1:20:01 PM
I filed a ticket on this around 3+ years ago and I'm still waiting. It would be great if VAX could understand namespaces and nested namespaces.

if I have something like this:


namespace Some::Nested::Namespace
{
    struct Foo
    {
        enum class Bar
        {
            A,
            B,
            C
        };

        Bar GetBar() const;
    };
}


then if I generate an implementation for GetBar, I end up with this mess:


namespace Some::Nested::Namespace
{
    Some::Nested::Namespace::Foo::Bar Foo::GetBar() const
    {

    }
}


If I try to autogenerate a switch statement for the enum, then I get this mess:


namespace Some::Nested::Namespace
{
    Some::Nested::Namespace::Foo::Bar Foo::GetBar() const
    {
        Bar varBar;

        switch ( varBar )
        {
            case Some::Nested::Namespace::Foo::Bar::A:
            break;
            case Some::Nested::Namespace::Foo::Bar::B:
            break;
            case Some::Nested::Namespace::Foo::Bar::C:
            break;
            default:
            break;
        }
    }
}


VAX obviously has some understanding of namespaces as it will create the definition of the function in the correct namespace block but it seems to fail when generating the types within those blocks.

what I would like is this:


namespace Some::Nested::Namespace
{
    Foo::Bar Foo::GetBar() const
    {
        Bar varBar;

        switch ( varBar )
        {
            case Bar::A:
            break;
            case Bar::B:
            break;
            case Bar::C:
            break;
            default:
            break;
        }
    }
}

5   L A T E S T    R E P L I E S    (Newest First)
feline Posted - Oct 21 2025 : 11:00:38 AM
I have the files, thank you for those. I am starting to think the problem is something else in the solution, since in a new test solution the problem always shows up, but in my main test solution it doesn't show up reliably at all. It doesn't seem to be a problem with any other code in the files, so not sure what is effecting this.

case=144606
KRG Posted - Oct 20 2025 : 5:04:39 PM
Sent you and email with the requested files.

Thanks!
feline Posted - Oct 20 2025 : 11:59:06 AM
So... I have one pair of files where VA works as expected, and one pair of files where VA completely ignores the namespace in the cpp file. In neither case do I get what you get. Off to experiment with something further up the file having an effect on things.

Is this a small test solution, or did you add these files to an existing solution? If this is a test solution, would you be able to send me a copy?

Also can you please export your VA and IDE settings and send them to me:

VA Options -> Advanced -> Logging and Recovery -> Export Settings
IDE tools menu -> Import and Export Settings -> Export selected environment settings

I can then import them here and see if I can reproduce the problem. Not sure where to look for the triggers that must exist to explain the different effects in different places.

Please send me the files via email:

[email protected]

including this thread ID or URL in the description, so we can match it up.
KRG Posted - Oct 17 2025 : 8:22:59 PM
Latest visual studio and latest VAX.

And it's absolutely not doing that for me:

here's a video of what it does for me: https://youtu.be/ts_Bx_Lyufg
feline Posted - Oct 16 2025 : 11:48:01 AM
Which IDE and version of VA are you using?

Just starting with the first bit, I am assuming you are triggering Create Implementation on the class member function "GetBar" in the header file, and the cpp file already contains the empty nested namespace block. In this situation, VA is generating the expected code:

namespace Some::Nested::Namespace
{

	Bar Foo::GetBar() const
	{

	}

}

for me. This is testing using VS2022 and VA 2568.0

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000