I suggest you ...

Allow #Region in methods..

To complement comments by marking out that section the comment relates to.

Example

Public Sub MyMagicMethod()
#Region "Locally Scoped Variables."
#End Region
End Sub

Additionally this would also allow sections of the method to be code-folded.

18 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    Adam SpeightAdam Speight shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →
    Anonymous shared a merged idea: #Region in methods  ·   · 
    completed  ·  Visual Studio teamAdminVisual Studio team (Product Team, Microsoft) responded  · 

    Hey everyone,

    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.

    Regards,

    Anthony D. Green, Program Manager, Visual Basic & C# Languages Team

    11 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • Anonymous commented  ·   ·  Flag as inappropriate

        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]Anthony D. Green [MSFT] commented  ·   ·  Flag as inappropriate

        PavlinII,

        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.

        Regards,

        -ADG

      • Visual Studio teamAdminVisual Studio team (Product Team, Microsoft) commented  ·   ·  Flag as inappropriate

        Adam,

        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!

        Regards,

        Anthony D. Green | Program Manager | Visual Basic & C# Languages Team

      • PavlinIIPavlinII commented  ·   ·  Flag as inappropriate

        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.

      • David Blaine FullertonDavid Blaine Fullerton commented  ·   ·  Flag as inappropriate

        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.

      • SLaksSLaks commented  ·   ·  Flag as inappropriate

        That's a sign that your method is too big, and should be refactored into multiple smaller methods.

      • PavlinIIPavlinII commented  ·   ·  Flag as inappropriate

        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.

      Feedback and Knowledge Base