Click here to Skip to main content
13,451,980 members (51,600 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


4 bookmarked
Posted 7 May 2010

Tips & Tricks: Faster Code Generation in Visual Studio 2010

Rate this:
Please Sign up or sign in to vote.
Faster code generation in Visual Studio 2010

Before discussing this feature with you, let me ask you a question “Are you using TDD, i.e., Test Driven Development?”. If so, you will not only find this feature useful but very much attractive. So, what is that? Wait, let's ask ourselves another question “How to write code while doing Test Driven Development?”. Thinking? Right, you have to implement the skeleton of the class & methods first and then you have to write the Unit Test cases to implement the actual logic. VS2010 came up with the excellent feature of generating codes for you. Have a look at the following snapshot:


As you can see, I don’t have a class named “Person” in my project and hence it is marking it as UNKNOWN by highlighting it in Red. If you look into the first snapshot in depth, you can find out that though the class is not present in my namespace or even in the project, it is creating the class reference in the intellisense. Great, right? Wait a minute. If you now place your cursor on top of “Person” and press F10 while holding down ALT+Shift, you will see a dropdown comes up on the screen with two menu items asking you to either generate the class for you or generate a new type.

You can find the first option easy. If you chose that, it will generate a class file named “Person” for you in the project. Let's go for the second choice where you will get more options & will find it much more interesting. This will open up a new dialog “Generate New Type” for you. There, you can choose which access modifier you need (private/public/protected/internal), you can choose different types of code to generate (enum/class/struct/interface), you can also modify the location of the class file. You can either put it in the same project or you can choose a different project available in the solution. Not only that, you can also create a new file for the class or append the class in another file. In short, this feature gives you various options to customize.


The same thing is applicable while generating methods. Have a look into that.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Kunal Chowdhury «IN»
Software Developer (Senior)
India India
Kunal Chowdhury is a Microsoft "Windows Platform Development" MVP (Most Valuable Professional), a Codeproject Mentor, Telerik Developer Expert, Nokia Developer Champion, Windows 10 Champion, Microsoft Rockstar, Speaker in various Microsoft events, Author, passionate Blogger and a Software Engineer by profession.

He is currently working in an MNC located in India. He has a very good skill over XAML, C#, Silverlight, Windows Phone, WPF and Windows Store (WinRT) app development. He posts his findings, articles, tutorials in his technical blog and CodeProject.

Book authored:

Connect with me on:

My CodeProject Awards/Prizes:

You may also be interested in...


Comments and Discussions

GeneralReason for my vote of 3 simple Pin
Luyến Hà16-Dec-10 21:29
memberLuyến Hà16-Dec-10 21:29 
QuestionHow did I miss this? Pin
Doug Hackerott18-Aug-10 19:22
memberDoug Hackerott18-Aug-10 19:22 
AnswerRe: How did I miss this? Pin
KunalChowdhury19-Aug-10 6:33
mentorKunalChowdhury19-Aug-10 6:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.180318.3 | Last Updated 8 May 2010
Article Copyright 2010 by Kunal Chowdhury «IN»
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid