Menu: Edit -> IntelliSense -> Generate -> New Type
Command: Edit.GenerateNewType; EditorContextMenus.CodeWindow.Generate.GenerateNewType
Versions: 2010
Published: 1/21/2010
Code: vstipEdit0011
I'm a big fan of Test Driven Development (TDD) so I absolutely love this tip as it is a big step toward enabling the TDD folks in Visual Studio. The idea behind it is simple, it allows you to use classes and members before you define them. There are some slight differences between the C# and VB implementations so let's take a look:
VB
1. Start by using a class that you haven't created yet:

2. Obviously, you will get an error.

3. But wait. When you click the Error Correction Options you get something new:

4. Click on "Generate 'Class Dollar' " and you get a new file called Dollar.vb with a class stub inside:

5. The error is gone and you are ready to start using the class. You basically repeat the process for members that you create for the new class as you use them.
C#
1. Start by using a class that doesn't exist:
2. Here you have a couple of options. You can right-click and choose Generate -> Class or you can click on the Smart Tag and choose "Generate class for 'Dollar' ". They both do the same thing and I show both options here:


3. You get a new file called Dollar.cs with a class stub inside:
4. The error is gone and you are ready to start using the class. You basically repeat the process for members that you create for the new class as you use them.
SPECIAL NOTE: Once you get the hang of this and actually start using this feature for TDD activities you will NOT use the examples I gave but will instead choose the "Generate New Type" option. The dialog is the same for VB and C# and looks like this:
Notice you have the ability to set Access, Kind, and-most importantly, Location. It's the Location option that TDD folks will use to put the classes into the proper project outside of their test project.