KnowDotNet NetRefactor

.NET Class Organizer

Add-in for Visual Studio .NET

by Les Smith

.NET Class Organizer is an automated tool for organizing code elements into Regions and Namespaces.

If you have never used #Regions to organize the code in your classes and forms, you are missing one of the great organizational features of Visual Studio .NET.  If you have, then you also know that it would be great if there was a feature within the Integrated Development Environment (IDE) that facilitated moving code into regions and standardizing your regions.

NET Class Organizer is the tool that meets this need.  It is an add-in for Visual Studio .NET that allows you to automate the process of maintaining order for your code within each project item of your project.  .NET Class Organizer has features that allow you to set up the regions that you want for your Classes and Forms so that you can standardize how your code is organized.  It has features that allow you to select and move any block of code to a selected region.  Additionally, it has automatic features that move new code elements into designated regions as well as inserting regions into new classes and forms as they are added to your project.

The following options are supported by .NET Class Organizer:

  • Move Selection to Region
  • Create Region for Selection

  • Insert Regions in Class or Form

  • Customize Your Regions for Classes and Forms

  • Move Class to Namespace

  • Create Namespace for Selected Class(s)

  • Insert Regions into New Classes and Forms

  • Move Form and Control Events to Region as They are Added to Form



  • All features of .NET Class Organizer work with both VB.NET and C# projects in exactly the same manner.  To move a method, enum, property, or structure into a region, you do not have to select the whole method, etc..  Rather, you simply need to place the cursor anywhere in the method, etc., that you desire to move and right-click the mouse to bring up the menu for .NET Class Organizer.  Figure 1 shows the drop down menu for .NET Class Organzier.  All manual features of the organzier are invoked from the menu shown in Figure 1.

    Figure 1 - .NET Class Organizer Context Menu.

    .NET Class Organizer Menu


    Figure 2 shows an automated demo of the Move Selection to Region menu option.  The sequence of events is:

    1. Right-click the mouse cursor in the method to be moved.

    2. .NET Classs Organizer automatically selects the desired method, along with any preceeding comments.

    3. A dialog is displayed showing the regions that are available to move the selection to.  Existing regions will be displayed in Yellow, and other choices are displayed in Green.  Double-click on the desired region.

    4. The selected method is moved to the selected region.  If the selected region was already extant and collapsed, it will remain collapsed, and the cursor will remain where the method used to reside so that you can continue moving through your class, moving selections to the proper region.
    5.   

    Note, that if you have multiple Classes in a code window, the .NET Class Organizer ensures that you are not presented with a region choice that does not reside in the current Class.  To allow you to move a method across Classes or Namespaces amounts to refactoring and would most likely break your code.

    Figure 2 - Automated Demo of .NET Class Organizer.

    DEMO

    You can download a copy of .NET Class Organizer.  The add-in is free, at this time.



    If you find .NET Class Organizer useful and would like to make a donation to
    allow KnowDotNet to continue to provide this type of tool click the button
    below.








    Writing Add-Ins for Visual Studio .NET
    Writing Add-ins for Visual Studio .NET
    by Les Smith
    Apress Publishing