Visual studio2012 tipsandtricks

6,551 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
6,551
On SlideShare
0
From Embeds
0
Number of Embeds
5,620
Actions
Shares
0
Downloads
25
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • The green highlighting shows the last items that were added to the map. The green arrow shows your cursor’s position in the code. Arrows between items represent different relationships. You can get more info about items on the map by examining their tooltips.the Visual Studio suite of products utilizes an XML language called Directed Graph Markup Language (DGML) to describe and define graphs. DGML is used to generate Code Maps in Visual Studio 2012.
  • Visual studio2012 tipsandtricks

    1. 1. Microsoft Visual Studio 2012|Code Tips Usman ur Rehman Ahmed Audience Marketing Manager (AMM), Microsoft Pakistan
    2. 2. Code Pointers NAMED REGIONS DRAG & DROP CODE INTELLISENSE CTRL + SPACE QUICK LAUNCH Ctrl + Q PREVIEW TAB SEARCH AND SYNC CODE CLONE ANALYSIS AUTO – IMPLEMENTED PROPERTIES GO TO DEFINITION CODE MAP SURROUND WITH
    3. 3. LINES OF CODE DISPLAY NUMER OF LINES ALL IN ONE CODE FRAMEWORK GO TO SPECIFIC LINE NUMBER PASCAL CASE TYPING METHOD NAMING METHOD CHAINING OFFLINE HELP ALT + HIGHLIGHT COMMENT CODE BLOCK USE PHYSICAL KEYBOARD ON EMULATOR Equals(object); GetHashCode(); GetType(); ToString();
    4. 4. # region # endregion – lets you specify a block of code that you can expand or collapse – #region name – name is the name you want to give to the region – The region block must be terminated with a #endregion directive NAMED REGIONS
    5. 5. Paste Code Blocks in Toolbox – You can reuse the code without having to type over and over again – Place it in a toolbox under one of the sections or create your own one – Drag and drop as required – It will now be available in all your projects DRAG & DROP CODE
    6. 6. Select a code block (highlight it) Drag and Drop to Toolbox (recommended: rename)
    7. 7. Ctrl Key – IntelliSense provides an array of options that make language references easily accessible. – Auto - suggestions – Hold down the Ctrl key to see through the code hidden behind the IntelliSense INTELLISENSE
    8. 8. CTRL + SPACE Display IntelliSense
    9. 9. QUICK LAUNCH Ctrl + Q Ctrl + Q Menus @menu Most Recently Used @mru Options @opt Open Document @doc
    10. 10. Solution Explorer -> Preview Selected Items PREVIEW TAB
    11. 11. Solutions Explorer -> Search & Sync – Enter keyword to Search for results within the project SEARCH AND SYNC – Sync Solutions Explorer to the currently active tab
    12. 12. Similar fragments of code – Separate fragments of code that are very similar – Find clones and refactor them – Find clones of a specific fragment or find all clones in your solution CODE CLONE ANALYSIS
    13. 13. Double Click a Clone Entry
    14. 14. Code Clones in Entire Solution – "Analyze solution for Code Clones" is only available in Ultimate and Premium editions of Visual Studio 2012
    15. 15. What is Found? • Renamed Identifiers • Insert and delete statements added • Rearranged statements What is Not Found? • Type declarations are not compared • Analyze Solution for Code Clones will not find clones that are less than 10 statements long. However, you can apply Find matching clones in solution to shorter fragments • InitializeComponent methods
    16. 16. PROP / PROPFULL – prop • public string Name{get; set;} – propfull • private string _Name; public string Name { get { return _Name; } set { _Name=value; } } AUTO – IMPLEMENTED PROPERTIES
    17. 17. GO TO DEFINITION
    18. 18. Seeing is Believing – Visualize Code – Point and click your way through complex code hierarchy CODE MAP
    19. 19. Ctrl + K,S SURROUND WITH
    20. 20. One Job for One Method – There should be only one job for one method – Ideally, seven to thirty lines of code in one method LINES OF CODE
    21. 21. Tools -> Options -> Text Editor -> All Languages -> Line Numbers DISPLAY NUMER OF LINES
    22. 22. Group related code together – Code related to one instance should be together – E.g. properties related to one TextBlock should be together ALL IN ONE CODE FRAMEWORK
    23. 23. Ctrl + g – Specify the line number – You will be jumped to that line automatically GO TO SPECIFIC LINE NUMBER
    24. 24. Pascal Case Methods – Type initials of every pascal case methods – E.g. BookAnotherFlight will be accessible by BAF PASCAL CASE TYPING
    25. 25. Noun-Verb Convention – Use verbs or verb cases to name methods – Verbs describe the action – Use Pascal Case • RemoveAll() • GetCharArray() • GroupedItem() METHOD NAMING
    26. 26. Invoke Multiple Method Calls – Core concept behind it is to allow for better readability – Reduces the amount of code METHOD CHAINING
    27. 27. Offline Help Content – Help -> – Set Help Preferences -> – Launch in Help Viewer – Help -> View Help OFFLINE HELP
    28. 28. Highlight text vertically ALT + HIGHLIGHT
    29. 29. Comment Chunks of Code –COMMENT: • Ctrl + KC –UNCOMMENT: • Ctrl + KU –/// <summary> COMMENT CODE BLOCK
    30. 30. Page up / page down Key USE PHYSICAL KEYBOARD ON EMULATOR
    31. 31. OBJECT Class – Ultimate base class of all classes, all classes derived from it (parent class of every other class) – Inheritance not required to be declared as it is implicit. – FOUR methods of OBJECT class available by default in a class’s object • Equals(Object) – Determines whether the specified object is equal to the current object. • GetHashCode() – Generates a number corresponding to the value of the object to support the use of a hash table. • GetType() – Gets the Type of the current instance. • ToString() – Returns a string that represents the current object. Equals(object); GetHashCode(); GetType(); ToString();

    ×