المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : C# IDE Tips & Tricks : Part I



BarakaSoft
03-26-2009, 01:11 AM
C# IDE Tips & Tricks: Part I



C# Developers has been spending most their day activities with Visual studio IDE. They may have to understand the following activities to do their job.


Understanding Code: Developer must be able analyze the relationship between classes and what API it is using for implementing the logic.
Navigating Code: Developer may or may not know where he want to navigate to the code and keep track of visited files in the code.
Writing & Modifying Code: Developers may require to modify the existing code like refactoring which involves make the code readable and fix bugs etc
Debugging & Testing: Understanding the using of debugger tools and writing unit test cases.

Visual studio provides the tools for all the activities mentioned above to make the developer efficient and productive. This post speaks about using the tools available in
VS 2008 sp1. It also discusses about the tool coderush express which Microsoft partnering and allows the developers to download and use freely.
Download Coderush for C# (http://msdn.microsoft.com/en-us/vcsharp/dd218053.aspx)
1. One of the short cut for goto definition is F12
For example you have an identifier and you want to know where it is declared just press F12. If the identifier is not your project then it shows the metadata of the identifier. eg we are viewing string class
http://lh3.ggpht.com/_iuwZHhydmEs/Sa1B4yUqQWI/AAAAAAAAAC4/MM5hR6gkaig/clip_image001_thumb.gif?imgmax=800 (http://lh5.ggpht.com/_iuwZHhydmEs/Sa1B3SrePJI/AAAAAAAAAC0/G5Neb9TPG8k/s1600-h/clip_image0013.gif)
2. When you bring the code definition windows by Ctrl + W, D you will see the following picture
http://lh6.ggpht.com/_iuwZHhydmEs/Sa1B6y45kOI/AAAAAAAAADA/RSNXNwZ0tm8/clip_image002_thumb.gif?imgmax=800 (http://lh6.ggpht.com/_iuwZHhydmEs/Sa1B6CB4sSI/AAAAAAAAAC8/OIuDBim5lzI/s1600-h/clip_image0023.gif)
When you move the code on top window it shows the declarations in the code definition ********
You can use Ctrl + Shift, 8 to come back from the declaration. F12 is for go to the definition of window and Ctrl + Shift, 8 is to come back to the origin.
You can also view the Navigation stack by Ctrl -.
3. To find all the references in your project for a particular method or type you can use Shift + 12 which shows the following window in IDE
http://lh3.ggpht.com/_iuwZHhydmEs/Sa1B9YxoRgI/AAAAAAAAADI/QRSBETy2QpE/clip_image003_thumb.gif?imgmax=800 (http://lh4.ggpht.com/_iuwZHhydmEs/Sa1B8R3RKLI/AAAAAAAAADE/jJDH96C5Vl4/s1600-h/clip_image0033.gif)
To navigate to the references list window you can use F8.
4. Some times when you are working on a really big project and you want to know which file you are actively using and you want know where it is in solution explorer. You can find the file in the solution explorer by going to Tools-Options dialogue box and selecting the General option under the projects solutions.
http://lh5.ggpht.com/_iuwZHhydmEs/Sa1B_kLRh2I/AAAAAAAAADQ/3BCEX9b3SZo/clip_image004_thumb.gif?imgmax=800 (http://lh6.ggpht.com/_iuwZHhydmEs/Sa1B-gqqzLI/AAAAAAAAADM/Te9uLjPA6mg/s1600-h/clip_image0043.gif)
You can track the active item in solution explorer by checking the above option.
5. Code rush express short cut when you want to go to the file use
Ctrl + Alt + F you will get the following window
http://lh4.ggpht.com/_iuwZHhydmEs/Sa1CB3FjYZI/AAAAAAAAADY/gJzFzmTup_I/clip_image005_thumb.gif?imgmax=800 (http://lh6.ggpht.com/_iuwZHhydmEs/Sa1CAvNqEcI/AAAAAAAAADU/T6xu06yXsRU/s1600-h/clip_image0053.gif)
It also filters the files based on the input and camel case.
If you want to go to any type or method in your project then you can use coderush shortcut Ctrl + Shift , Q it show the following window
http://lh5.ggpht.com/_iuwZHhydmEs/Sa1CD8VQChI/AAAAAAAAADg/FMp72KbYlvw/clip_image006_thumb.gif?imgmax=800 (http://lh4.ggpht.com/_iuwZHhydmEs/Sa1CCy2n2II/AAAAAAAAADc/jWVEj5AiYl8/s1600-h/clip_image0063.gif)
If you want to see the identifier where it is used in the project you can use
Ctrl + Alt , U. you can use tab key to navigate between the identifiers.
http://lh4.ggpht.com/_iuwZHhydmEs/Sa1CGHwOZPI/AAAAAAAAADo/KfmI7zRLB50/clip_image007_thumb.gif?imgmax=800 (http://lh3.ggpht.com/_iuwZHhydmEs/Sa1CFKV9a0I/AAAAAAAAADk/1zragtSt46A/s1600-h/clip_image0073.gif)
6. To navigate to the open files in the IDE you can use Ctrl + Tab
http://lh5.ggpht.com/_iuwZHhydmEs/Sa1CI-wUY5I/AAAAAAAAADw/eJeP3XySmpg/clip_image008_thumb.gif?imgmax=800 (http://lh4.ggpht.com/_iuwZHhydmEs/Sa1CHmMwc2I/AAAAAAAAADs/MI1bsOeF9rw/s1600-h/clip_image0083.gif)
You can also use Ctrl + Alt + Down to bring the following window
http://lh3.ggpht.com/_iuwZHhydmEs/Sa1CL_iqB9I/AAAAAAAAAD4/bpUm92bV4jc/clip_image009_thumb.gif?imgmax=800 (http://lh4.ggpht.com/_iuwZHhydmEs/Sa1CKtjMtOI/AAAAAAAAAD0/CfFDRs_Ib4U/s1600-h/clip_image0093.gif)
7. Viewing the class designer
http://lh6.ggpht.com/_iuwZHhydmEs/Sa1COdJjkWI/AAAAAAAAAEA/Q9npqGyXLTs/clip_image010_thumb.gif?imgmax=800 (http://lh5.ggpht.com/_iuwZHhydmEs/Sa1CNGQT1yI/AAAAAAAAAD8/2gqgNa-EFPg/s1600-h/clip_image0103.gif)
You can view the class designer of the class and it dynamically updated whenever you change the class in code definition ********
Summarizing what we have learned so far
http://lh4.ggpht.com/_iuwZHhydmEs/Sa1CR4nT8qI/AAAAAAAAAEI/lfHzoKK8YRI/clip_image011_thumb.gif?imgmax=800 (http://lh5.ggpht.com/_iuwZHhydmEs/Sa1CP0Uoy_I/AAAAAAAAAEE/jxhVXyJjtA4/s1600-h/clip_image0113.gif)
http://lh5.ggpht.com/_iuwZHhydmEs/Sa1CUk4Jx1I/AAAAAAAAAEQ/f2ros1_g_8w/clip_image012_thumb.gif?imgmax=800 (http://lh4.ggpht.com/_iuwZHhydmEs/Sa1CTO5G9aI/AAAAAAAAAEM/_2GRez1RDsU/s1600-h/clip_image0123.gif)
In the next post I will explain about more tips.