Allow #Region in methods..
To complement comments by marking out that section the comment relates to.
Public Sub MyMagicMethod()
#Region "Locally Scoped Variables."
Additionally this would also allow sections of the method to be code-folded.
#Region in methods and do not left align them
THIS WOULD MAKE VB MORE USEFUL
THE LANGUAGE IS IMPOSSIBLE TO DEVELOP IN
If you hadn’t heard already last week at BUILD we announced the PUBLIC release of a Preview of the next version of the Visual Basic language and code editing experience powered by “Roslyn”. You can download this preview and install it on top of Visual Studio 2013 today!
I’m excited to let you know that included in this is a preview of support for #Region inside of methods.
You can read about it and other cool new features here: http://www.codeplex.com/Download?ProjectName=roslyn&DownloadId=824695
Download the End User Preview @ http://msdn.microsoft.com/en-US/vstudio/roslyn
I encourage you all to download it, try it out, and send us your feedback.
Anthony D. Green, Program Manager, Visual Basic & C# Languages Team
IT is great that you did this,
Also add the ability to have it have it justify like the rest of the code
Just a note:
I have given up on VS2013 and I am using 2012 and hating it
there are too many bugs and issues
I have to laugh at the guy using win8 and vs13
he has to reboot at least 8 times a day when vs stops working
Anthony D. Green [MSFT] commented
Even though #Region inside of methods won't be available until the next version of VB you can still manage your large Select Case blocks using a feature already available in Visual Studio since 2010: Hide Selection. Just select the region of code you want to collapse, e.g. from the end of the Case statement to the end of the last statement in the Case block. Then select Edit > Outlining > Hide Selection (Ctrl+M, Ctrl+H). Visual Studio will now collapse everything you selected as if you had wrapped it in a region. This gives you the benefit of #Region with none of the boilerplate. I hope this tip tides you over until we add true #Region support in methods in the next version of VB.
Anthony D. Green [MSFT] commented
Anonymous, allowing #Regions to be indented has been suggested here: http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2345966-allow-region-blocks-to-be-indented-much-like-they
Please, show your support!
YES PLEASE DO THIS
AND STOP MAKING THE REGIONS ALIGN TO THE LEFT MARGIN!
Thanks for your suggestion. Unfortunately we won't be able to get to this in the next release. It is worth saying though that were you to download the Microsoft Roslyn CTP (http://msdn.com/roslyn) and invoke the managed VB parser you'd find that this restriction no longer exists in the managed VB compiler. This is, of course, subject to change and unfortunately I'm unable to comment further on any dates but for what it's worth none of us have any interest in re-implementing this restriction nor have we any reason to :) Thanks!
Anthony D. Green | Program Manager | Visual Basic & C# Languages Team
It's so easy to tell that design is poor. Yes, it's obvious that the design is poor. Please tell me, how do you refactor Select Case based on Enum with 50+ items? (It's not trick question, I'm really interrested in answer to refactor current code).
Enum is given by another assembly and can not be modifed.
Marc Johnston commented
Method too big, poor design
David Blaine Fullerton commented
I so agree. I don't agree with SLAKS. It's how the programmer wants to implement it. I often would like to take out the details unless I need to see them, especially when I know one region works and the other stuff has problems.
This is a simple & easy change that would allow the option of this capability. Then, you could have a checkbox in the particular .NET configuration if people don't want it.
That's a sign that your method is too big, and should be refactored into multiple smaller methods.
I'd like to use feature like this in Select Case statements where dispatching Enum has 50+ items. I would be nice to group them in smaller logical groups and collapse them when not needed.