visual studio2012 tipsandtricks
DESCRIPTION
TRANSCRIPT
![Page 1: Visual studio2012 tipsandtricks](https://reader036.vdocuments.site/reader036/viewer/2022081602/54cc351c4a795905188b477c/html5/thumbnails/1.jpg)
Microsoft Visual Studio 2012|Code TipsUsman ur Rehman AhmedAudience Marketing Manager (AMM), Microsoft Pakistan
![Page 2: Visual studio2012 tipsandtricks](https://reader036.vdocuments.site/reader036/viewer/2022081602/54cc351c4a795905188b477c/html5/thumbnails/2.jpg)
Code Pointers
NAMEDREGIONS
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
![Page 3: Visual studio2012 tipsandtricks](https://reader036.vdocuments.site/reader036/viewer/2022081602/54cc351c4a795905188b477c/html5/thumbnails/3.jpg)
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();
![Page 4: Visual studio2012 tipsandtricks](https://reader036.vdocuments.site/reader036/viewer/2022081602/54cc351c4a795905188b477c/html5/thumbnails/4.jpg)
# 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
NAMEDREGIONS
![Page 5: Visual studio2012 tipsandtricks](https://reader036.vdocuments.site/reader036/viewer/2022081602/54cc351c4a795905188b477c/html5/thumbnails/5.jpg)
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
![Page 6: Visual studio2012 tipsandtricks](https://reader036.vdocuments.site/reader036/viewer/2022081602/54cc351c4a795905188b477c/html5/thumbnails/6.jpg)
Select a code block (highlight it)
Drag and Drop to Toolbox (recommended: rename)
![Page 7: Visual studio2012 tipsandtricks](https://reader036.vdocuments.site/reader036/viewer/2022081602/54cc351c4a795905188b477c/html5/thumbnails/7.jpg)
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
![Page 8: Visual studio2012 tipsandtricks](https://reader036.vdocuments.site/reader036/viewer/2022081602/54cc351c4a795905188b477c/html5/thumbnails/8.jpg)
CTRL + SPACE
Display IntelliSense
![Page 9: Visual studio2012 tipsandtricks](https://reader036.vdocuments.site/reader036/viewer/2022081602/54cc351c4a795905188b477c/html5/thumbnails/9.jpg)
QUICK LAUNCH Ctrl + Q
Ctrl + Q
Menus@menu
Most Recently Used
@mru
Options@opt
Open Document
@doc
![Page 10: Visual studio2012 tipsandtricks](https://reader036.vdocuments.site/reader036/viewer/2022081602/54cc351c4a795905188b477c/html5/thumbnails/10.jpg)
Solution Explorer -> Preview Selected Items
PREVIEW TAB
![Page 11: Visual studio2012 tipsandtricks](https://reader036.vdocuments.site/reader036/viewer/2022081602/54cc351c4a795905188b477c/html5/thumbnails/11.jpg)
Solutions Explorer -> Search & Sync– Enter keyword to Search for
results within the project
SEARCH AND SYNC
– Sync Solutions Explorer to the currently active tab
![Page 12: Visual studio2012 tipsandtricks](https://reader036.vdocuments.site/reader036/viewer/2022081602/54cc351c4a795905188b477c/html5/thumbnails/12.jpg)
![Page 13: Visual studio2012 tipsandtricks](https://reader036.vdocuments.site/reader036/viewer/2022081602/54cc351c4a795905188b477c/html5/thumbnails/13.jpg)
![Page 14: Visual studio2012 tipsandtricks](https://reader036.vdocuments.site/reader036/viewer/2022081602/54cc351c4a795905188b477c/html5/thumbnails/14.jpg)
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
![Page 15: Visual studio2012 tipsandtricks](https://reader036.vdocuments.site/reader036/viewer/2022081602/54cc351c4a795905188b477c/html5/thumbnails/15.jpg)
Double Click a Clone Entry
![Page 16: Visual studio2012 tipsandtricks](https://reader036.vdocuments.site/reader036/viewer/2022081602/54cc351c4a795905188b477c/html5/thumbnails/16.jpg)
Code Clones in Entire Solution
– "Analyze solution for Code Clones" is only available in Ultimate and Premium editions of Visual Studio 2012
![Page 17: Visual studio2012 tipsandtricks](https://reader036.vdocuments.site/reader036/viewer/2022081602/54cc351c4a795905188b477c/html5/thumbnails/17.jpg)
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
![Page 18: Visual studio2012 tipsandtricks](https://reader036.vdocuments.site/reader036/viewer/2022081602/54cc351c4a795905188b477c/html5/thumbnails/18.jpg)
PROP / PROPFULL
– prop• public string Name{get; set;}
– propfull• private string _Name;
public string Name {
get { return _Name; } set { _Name=value; } }
AUTO – IMPLEMENTED
PROPERTIES
![Page 19: Visual studio2012 tipsandtricks](https://reader036.vdocuments.site/reader036/viewer/2022081602/54cc351c4a795905188b477c/html5/thumbnails/19.jpg)
GO TO DEFINITION
![Page 20: Visual studio2012 tipsandtricks](https://reader036.vdocuments.site/reader036/viewer/2022081602/54cc351c4a795905188b477c/html5/thumbnails/20.jpg)
Seeing is Believing
– Visualize Code– Point and click your way through
complex code hierarchy
CODE MAP
![Page 21: Visual studio2012 tipsandtricks](https://reader036.vdocuments.site/reader036/viewer/2022081602/54cc351c4a795905188b477c/html5/thumbnails/21.jpg)
Ctrl + K,S
SURROUND WITH
![Page 22: Visual studio2012 tipsandtricks](https://reader036.vdocuments.site/reader036/viewer/2022081602/54cc351c4a795905188b477c/html5/thumbnails/22.jpg)
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
![Page 23: Visual studio2012 tipsandtricks](https://reader036.vdocuments.site/reader036/viewer/2022081602/54cc351c4a795905188b477c/html5/thumbnails/23.jpg)
Tools -> Options -> Text Editor -> All Languages -> Line Numbers
DISPLAY NUMER OF LINES
![Page 24: Visual studio2012 tipsandtricks](https://reader036.vdocuments.site/reader036/viewer/2022081602/54cc351c4a795905188b477c/html5/thumbnails/24.jpg)
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
![Page 25: Visual studio2012 tipsandtricks](https://reader036.vdocuments.site/reader036/viewer/2022081602/54cc351c4a795905188b477c/html5/thumbnails/25.jpg)
Ctrl + g
– Specify the line number– You will be jumped to that line
automatically
GO TO SPECIFIC LINE NUMBER
![Page 26: Visual studio2012 tipsandtricks](https://reader036.vdocuments.site/reader036/viewer/2022081602/54cc351c4a795905188b477c/html5/thumbnails/26.jpg)
Pascal Case Methods
– Type initials of every pascal case methods
– E.g. BookAnotherFlight will be accessible by BAF
PASCAL CASE TYPING
![Page 27: Visual studio2012 tipsandtricks](https://reader036.vdocuments.site/reader036/viewer/2022081602/54cc351c4a795905188b477c/html5/thumbnails/27.jpg)
Noun-Verb Convention
– Use verbs or verb cases to name methods
– Verbs describe the action– Use Pascal Case
• RemoveAll() • GetCharArray() • GroupedItem()
METHOD NAMING
![Page 28: Visual studio2012 tipsandtricks](https://reader036.vdocuments.site/reader036/viewer/2022081602/54cc351c4a795905188b477c/html5/thumbnails/28.jpg)
Invoke Multiple Method Calls
– Core concept behind it is to allow for better readability
– Reduces the amount of code
METHOD CHAINING
![Page 29: Visual studio2012 tipsandtricks](https://reader036.vdocuments.site/reader036/viewer/2022081602/54cc351c4a795905188b477c/html5/thumbnails/29.jpg)
Offline Help Content
– Help ->– Set Help Preferences ->– Launch in Help Viewer
– Help -> View Help
OFFLINE HELP
![Page 30: Visual studio2012 tipsandtricks](https://reader036.vdocuments.site/reader036/viewer/2022081602/54cc351c4a795905188b477c/html5/thumbnails/30.jpg)
![Page 31: Visual studio2012 tipsandtricks](https://reader036.vdocuments.site/reader036/viewer/2022081602/54cc351c4a795905188b477c/html5/thumbnails/31.jpg)
Highlight text vertically
ALT + HIGHLIGHT
![Page 32: Visual studio2012 tipsandtricks](https://reader036.vdocuments.site/reader036/viewer/2022081602/54cc351c4a795905188b477c/html5/thumbnails/32.jpg)
Comment Chunks of Code
–COMMENT:• Ctrl + KC
–UNCOMMENT:• Ctrl + KU
– /// <summary>
COMMENT CODE BLOCK
![Page 33: Visual studio2012 tipsandtricks](https://reader036.vdocuments.site/reader036/viewer/2022081602/54cc351c4a795905188b477c/html5/thumbnails/33.jpg)
Page up / page down Key
USE PHYSICAL KEYBOARD ON
EMULATOR
![Page 34: Visual studio2012 tipsandtricks](https://reader036.vdocuments.site/reader036/viewer/2022081602/54cc351c4a795905188b477c/html5/thumbnails/34.jpg)
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();
![Page 35: Visual studio2012 tipsandtricks](https://reader036.vdocuments.site/reader036/viewer/2022081602/54cc351c4a795905188b477c/html5/thumbnails/35.jpg)
THANK YOU