2

I'm looking for a free Visual Studio feature, extension or macro. that can help with the following situation.

When I prototype I tend to keep all my classes in one file (bad practice I know, but yeah it a prototype). Then comes the point the where the files is too hard to navigate. So I breakout the classes into separate files inside the project, the folder structure reflecting the namespaces. To achieve the is;- 1. Add new Folder 2. Add new Class 3. Name class 4. Cut and paste corresponding section into new class file.

For me, Steps 2 through 4 are prime fodder for a new Menu entries.

Cut Class as New Class File Cut as New Partial Class File.

I've seen this feature in C# but not VB.net.

So does know any how to achieve this for VB.net?

Adam Speight
  • 712
  • 1
  • 9
  • 21

3 Answers3

2

Here's a macro that does what you want in C#... looking at the code it's probably fairly straight forward to modify it to work in VB...

http://plisky.net/main/macros/documentation

Also, I'm pretty sure all the commercial refactoring tools (Resharper, CodeRush, etc.) support this...

Tollo
  • 505
  • 4
  • 14
Scrappydog
  • 2,864
  • 1
  • 21
  • 23
  • Seem to be stuck in looping want this function to return true. `code` Private Function AttemptToAddCSFile(ByVal name As String) As Boolean Try Dim pi = DTE.ItemOperations.AddNewItem("Visual Basic Items\Code\Class", name + ".vb") Return True Catch ex As COMException Return False End Try End Function `code` – Adam Speight Jun 11 '11 at 00:58
  • I use resharper and I almost exclusively use it for this refactoring, this is awesome! – jcwmoore Sep 15 '11 at 13:27
  • Thanks for posting the link Scrappydog, the macros now live on a new domain so have updated the link. – Tollo Feb 24 '12 at 14:07
0

Resharper can do this using Move Type to Another File or Namespace

MarkJ
  • 30,070
  • 5
  • 68
  • 111
0

I just stumbled across this and can point you to an updated version of the macro that scrappy kindly linked. Its at http://plisky.net/main/plisy.net-visual-studio-productivity-macros.

If you still want it and wish to test it for VB I can happily make the changes to support VB.net but as I don't use VB I'd need a tester :) As its a while since this post you probably have something working already though.

Tollo
  • 505
  • 4
  • 14