E N D
1. Visual Studio Productivity
2. About Me – Jeff Klawiter Senior .Net Developer at Sierra Bravo Corp
http://www.jeffklawiter.com
Professional developer for over 10 years
Former PHP/Linux Zealot
Freelanced websites for many local bands and two national: American Head Charge and The Commodores (yes, “Brick House”, “Easy” Commodores)
At Sierra Bravo for 4 years, 1 day and about 1 hour
MCPD: Web and MCTS: Windows
3. How do we become Productive? Taking advantage of tools provided for us
Graphical Designers
Command line Utilities
Code Generators
Writing our own tools
Macros
Scripts
DSLs
Learning from our peers
4. Is Visual Studio really that great? One of the oldest graphical development environments still in use
A Shell that was written to be completely context aware and language agnostic
Build your own IDE using the
With Visual Studio .NET multiple products were combined into one common place
VC++, VB, VJ++, VC# and more
VS 2010 moving to WPF for the benefit of us all
5. What Does Visual Studio Offer? Default keyboard schemes for many popular present and past IDEs
Fully customizable interface and keyboard shortcut system
Macros
Visual Studio Integration Packages (aka Add-ons/Addins/Extensions/thing-a-ma-jigs/)
Visual Designers
Snippets
Custom Tools
And much more
6. Snippets: Macro/Template/Intellisense Introduced in Visual Studio 2005
Quick way to implement common coding structures
Currently Limited to C#, VB, J#, XML
VS2010 adding HTML/ASPX and WPF
Two main modes: insert and surrounds
Accessing a snippet
VC#:
Right Click->Insert Snippet.
Shows up in the Intellisense List
VB:
2005: right click insert snippet, some Intellisense support.
2008: C# like Intellisense support, plus ability to re-enable snippet mode after exiting it
Task Basked Snippets
7. Snippet Internals Simple XML Schema
<CodeSnippets>- Schema declaration
<CodeSnippet> - Snippet root tag, 1 file can contain many snippets
<Header> - contains meta data like the shortcut, description, type and keywords
<Snippet> - Contains the replacement declarations, code and language type
8. Snippet <Header> <Author>
<Title>
<Description>
<HelpUrl> – Link to your Help documentation
<Keywords> – Keywords used for searching purposes
<Shortcut> – The Intellisense shortcut used
<SnippetTypes>
SurroundsWith
Expansion
Refactoring
9. Snippet - <Snippet> <Imports> – Namespaces to import/using into the current code file
<References> – Assemblies to reference into the project
<Code> – The code of the snippet
<Declarations> – Variables declared in the snippet
10. Snippet - <Snippet><Code> Attributes
Language
Kind – Where the snippet is available
method body/method decl/type decl/page/file/any
Delimiter – What character(s) around delimit the declared replacement variables.
Defaults to $
11. Snippet - <Snippet><Code> Two reserved keywords
$end$ - Denotes where you want the cursor to go when the user is done using the snippet
$selection$ - Used in the SurroundsWith type, will be replaced with anything the user had selected when invoking the snippet
12. Snippet - <Snippet><Declarations> <Literal> - A basic replacement, can be anything. An object, a string, a keyword
<Object> - Requires a Type that confines the replacement to an object that implements
Both have an Attribute “Editable” – Defaults to True. Useful when you want to have a declaration that runs a function
13. Snippet - <Snippet><Declarations> <ID>
<Default> - Default value, if empty will show the replacement variable name
<Function> - Use with Editable=False
GenerateSwitchCases(EnumerationLiteral) - switch
GetClassName() – Gets class name in current context - ctor
SimpleTypeName(Type) – Reduces type to smallest output given current context of Imports/Usings - cw
<Type> - Only used with Object declaration
<ToolTip> - Tooltip displayed over the replacement variable
14. Editing Snippets Snippet Designer – Integrates with Visual Studio
Can export existing code to a snippet
Edit existing Snippets
Search for Snippets
http://www.codeplex.com/SnippetDesigner
Snippet Editor – Standalone Snippet program
Better interface than Designer
VS 2010 support
Can add custom snippet paths to work with
http://snippeteditor.codeplex.com/
15. Visual Studio Customization Customizing Keyboard Shortcuts
Tools – Environment - Keyboard
Customizing Layout
Tools – Customize
Customize Context Menus
16. Visual Studio Tips and Tricks Dynamic Help – Context Sensitive help
Show SmartTag – Ctrl + . (or Alt+Shift+F10)
Display Intellisense for Members – Ctrl + J
Resize Code Completion Window
Cursor Back/Forward – Ctrl + - and Ctrl + Shift + -
Insert Snippet – Ctrl+K,Ctrl+X
Surround Snippet – Ctrl+K,Ctrl+S
Incremental Search – Ctrl+I then type, then Ctrl+I to move next
17. Visual Studio Tips and Tricks Exceptions Window – Debug – Exceptions
Use the Watch Window
Use TracePoints – Like Trace.Writeline without the clutter
Customize your Find Results windowhttp://blogs.msdn.com/saraford/archive/2006/03/30/565002.aspx
Reduce Window Clutter
18. Cleaning Your Code CR_ClassCleaner
http://www.codeplex.com/CRClassCleaner
Requires DXCore
http://www.devexpress.com/Downloads/Visual_Studio_Add-in/DXCore/
Can automatically group your code into regions and alphabetize.
19. Resources Sara Fords blog http://blogs.msdn.com/saraford/
Visual Studio Tips and Tricks bookhttp://www.mspress.sg/product_detail.aspx?pid=393
Scott Cate – Doing videos demonstrating Sara Fords tips and trickshttp://scottcate.com/tricks/
Code Snippets on MSDN
http://msdn.microsoft.com/en-us/library/ms165392.aspx