Regions & Outlining

This forum is meant for questions and discussions about the X# language and tools
Post Reply
ic2
Posts: 1865
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Regions & Outlining

Post 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
ic2
Posts: 1865
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Regions & Outlining

Post 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
User avatar
Chris
Posts: 4986
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Regions & Outlining

Post 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.
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
ic2
Posts: 1865
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Regions & Outlining

Post 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 913 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 913 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
User avatar
Chris
Posts: 4986
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Regions & Outlining

Post 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?
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
TerryB1
Posts: 306
Joined: Wed Jan 03, 2018 11:58 am

Regions & Outlining

Post 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
ic2
Posts: 1865
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Regions & Outlining

Post 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
Post Reply