Regions & Outlining
Posted: Wed Mar 29, 2023 11:09 am
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
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