views:

61

answers:

3

I am looking for a way to extract a nested inner class so that it is in a separate file. Is there an easy way to do this in Visual Studio 2008 (eg, using the refactor menu)?

EDIT

Maybe a refactoring menu option isn't necessary if manual refactoring is simple enough.

+1  A: 

if i understand correctly, you can use partial classes http://msdn.microsoft.com/en-us/library/wa80x488(VS.80).aspx

Luiscencio
Not what the OP is talking about
BioBuckyBall
@Lucas Heneks: =)
Luiscencio
It is still helpful. +1
Kimball Robinson
@lucas I think you are probably correct, but it is not clear and this is a reasonable answer to the question as stated
Ben Robinson
+2  A: 

I don't remember there being a built in refactoring for that, but it is available in Resharper.

If you don't have Resharper and have a lot of them you need to refactor, you could always download and use the trial.

BioBuckyBall
+1 to Resharper. Visual Studio is mediocre without it. I can't code without it.
Brian Genisio
A: 

DevExpress offers a free coding assistance tool called CodeRush Express which offers this refactoring. Here's a link to the page showing the refactoring.

I own a license to their full-blown CodeRush w/ Refactor Pro, and I love it.

EDIT

Following the edit of the question, I just wanted to add that I'm able to do that refactoring using the following keystrokes (with the cursor on the name of the nested class)

  1. Ctrl+` (opens refactor menu)
  2. Enter (or arrowing down to the option if it's not already selected)

That automatically creates a new file in the project with the name of the nested class as the name of the file, moves the nested class to that file, removes it from the original location, and drops a marker at the place where the nested class was removed. Hitting Esc takes you back to where the extracted class was removed.

It is a huge time-saver. Granted, my day's not full of extracting nested classes, but it's an example of how saving a couple of minutes here and there can really help remove the friction from some common development tasks.

Eric