Question

I need rapidly adopt myself to existing system written in VB. For some bigger classes of VB forms (2000+ lines) and others, I would like to get their overview containing regions and declarations inside them (methods, functions, properties and class-level variables) which I can print/save for reference.

Currently I can achieve this manually by deleting bodies of methods and removing comments. I am also able to use some advanced regex (regual expression) searches to mark desired lines, then filter the rest out. List of declarations can be obtained using Reflection, but I think it is always without #Region information.

Is there any VisualStudio functionality or external tool which can create such a 'class map' for me?

In other words, I'd like to generate files similar to C/C++ headers but for VB and also including #Region information.

Example of expected output:

Public Class frmXY_Sample1

#Region "Internal Variables" 
#Region "Form Common"
    Private _Connection As SqlClient.SqlConnection
    Private _DataFormType As XYZ.xyzDataFormType
    Private AllowEvents As Boolean
#End Region
#Region "Instance Data"
    Private _Instance As thisEnt
#End Region
#End Region

#Region "Form Events"
    Private Sub frmXY_SomeForm1_Load(sender As Object _
#End Region
#Region "Save..."
    Private Sub ID_Save_Click(sender As System.Object, e As System.EventArgs) Handles ID_Save.Click
#End Region

#Region "FormTabs" 
#Region "Tab 'SampleTab1'"
    Private Sub TS_TAB1_AddNew_Click(sender As System.Object, e As System.EventArgs) _
    Private Sub TS_TAB1_Detail_Click(sender As System.Object, e As System.EventArgs) _
#End Region
#Region "Tab 'SampleTab2'"
    Private Sub TS_TAB2_Detail_Click(sender As System.Object, e As System.EventArgs) _
    Private Sub TS_TAB2_Refresh_Click(sender As System.Object, e As System.EventArgs) _
    Private Sub TAB2_Grid_CellPainting(sender As System.Object _
#End Region

Thank you.

Was it helpful?

Solution

There is nothing exactly like you are looking for in Visual Studio 2012 Professional. If you are working in a C# project, you can automatically get a code map similar to what you are looking for with the "Go To Definition" feature.

Here is a snippet of C# code.

enter image description here

Pressing F12 while the cursor is on the StreamReader class causes the following metadata editor to open.

enter image description here

Use Go To Definition to decode VB class

The VB editor also has a Go To Definition, but it takes you to the Object Browser instead of the metatdata window. But there is a way to get the metadata.

Create a separate C# project. In my example, I made a simple Console application. Add a reference to your VB project Write some code in the C# project to instantiate a type in the VB library and use the C# F12 to get the metadata

Here is a simple VB class.

enter image description here

This is the C# code referring to the Printer class. enter image description here

Here is the metadata from the VB class, from within the C# project.

enter image description here

I know this is not as complete as your example, but it's a start.

Other solutions

There is a Code Map extension you can install from the Tools\Extensions and Updates menu. I don't think it supports the printing option you want however.

Finally, you can create your own Visual Studio extension. This is not a trivial task though. Download the Visual Studio SDK if you want to learn more.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top