xsharp.eu • Regions & Outlining
Page 1 of 1

Regions & Outlining

Posted: Wed Mar 29, 2023 11:09 am
by ic2
In order to have a minimal organization of my code having to deal with the chaotic VS way of handling code, I created Regions in on of my programs. What I did next in VS is Edit/Toggle Outlining/Toggle all Outlining (Ctrl M Ctrl L). I then select one or more methods (by just selected the single collapsed method with the + in front) and move these between the #region Someregion and #Endregion Someregion tags.

This is far from working smoothly (as most things in VS). First, this action expands at least one method again on pasting, often also the next method outside the region. But second, in any of the outlined representations, the visibility of the regions seems to be rather random while working on it. Often 1 or more are missing, or there's no plus in front of it while for sure there are methods following that region statement and there's a #endregion beyond the last method.

It seems that when I press Ctrl M Ctrl L and click the + before the namespace, then before the class (there should be an alternative to reach that directly I'd say, who is waiting for a fully collapsed tree anyway) I see the regions. But when I press the plus before a region to expand it's content, it sometimes opens all methods collapsed, as expected, but the last method before the #endregion always shows expanded, without a plus before it.

I have made sure (not knowing if that is required) that I always have an empty line after a #region and before a #endregion, all methods end with End Method and 1 empty line.

So I think there's something not working properly, perhaps beyond the X# team's control?

In C# there's an option in Tools -> Options -> Text Editor -> C# -> Advanced 'Collapse #regions when collapsing to definitions' . This is not available for X#, but I am not sure if this has any influence. I would normally not want regions to collapse anyway.

Does anyone use regions and have the same experience?

Dick

Regions & Outlining

Posted: Wed Mar 29, 2023 11:55 am
by ic2
I add one (unrelated) issue that I came across during moving methods between #Region..#Endregion.

In one program I ended up with 40 compiler errors XS0103 The name xxx does not exist in the current context, just after some moving. The 'missing' defines were all in a file called Defines.vh, included in the solution.

I solved this by adding #include "Defines.vh" at the top of the now faulty program but I am unsure why it didn't give the error until I simply moved some code within the same .prg?

Dick

Regions & Outlining

Posted: Wed Mar 29, 2023 1:39 pm
by Chris
Hi Dick,

Please give us some sample code, or show a screenshot of your code, in order to understand exactly what you are doing.

Regions & Outlining

Posted: Wed Mar 29, 2023 8:32 pm
by ic2
Hello Chris,

Here we go. I pressed Ctrl M Ctrl L and then the + to expand the namespace and the plus to expand the class. So far, so good:
XSRegionsP1.jpg
XSRegionsP1.jpg (19.18 KiB) Viewed 816 times
All regions do now show and I can expand any of them. So I click on the plus on the first one:
XSRegionsP2.jpg
XSRegionsP2.jpg (75.68 KiB) Viewed 816 times
What you now see (red underlined) that all methods show collapsed, expect the last one (within that first region) which shows fully expanded. Also there's no minus in front of the method so I can't even correct (=collapse) it.

During working I had the same issue with other parts of the code, including the region statements itself: no plus in front, missing regions, missing endregion statements (which were actually present) and also disappearing regions. I can't reproduce all of it (yet) but probably if the cause of the described problem is found the other issues may disappear.

Dick

Regions & Outlining

Posted: Wed Mar 29, 2023 8:41 pm
by Chris
Hi Dick,

Thanks, that helps, but is still difficult to reproduce.
Can you please zip and send me that prg file so I can test exactly with it?
Also which X# version are you currently using?

Regions & Outlining

Posted: Wed Mar 29, 2023 9:53 pm
by TerryB1
Hi Dick

It's just a guess, but the offending Method is virtual and will have a different visibility.
It suggests to me that somewhere in your code you are perhaps have not got a suitable USING statement.

Something in cross-referencing.

But as I say it is guesswork

Terry

Regions & Outlining

Posted: Thu Mar 30, 2023 10:10 am
by ic2
Hello Terry,

No, it's the same for every region, regardless the last method. I sent a file to Chris, he confirmed it to be a bug and has logged it.

Hopefully solving that bug also solves some other odd things I saw.

Dick