A Productivity Extension for Microsoft Visual Studio by Devexpress By
Total Page:16
File Type:pdf, Size:1020Kb
coderusha productivity extension for Microsoft Visual Studio by DevExpress by Alex Skorkin (c) 2015 About Author Alex Skorkin is working for DevExpress. His overall experience with Visual Studio productivity tools starts since 2004th. You can reach him at [email protected] and www.skorkin.com. Devex, DevExpress, Developer Express, DXCore, CodeRush and Refactor! are trademarks of Developer Express Inc. All other brands or product names are trademarks and/or service marks of their respective owners. Contents at a Glance Introduction 17 Prerequisites 29 Chapter 1. Duplicate Code Detection and Consolidation 37 Chapter 2. Static code analysis and code issues technology 63 Chapter 3. Code-generation templates 175 Chapter 4. Consume-first code declaration providers 213 Chapter 5. Coding helpers and assistants 247 Chapter 6. Code selection and clipboard tools 275 Chapter 7. Code modification providers 313 Chapter 8. Code navigation utilities 355 Chapter 9. Unit testing service 393 Chapter 10. Code editor visualization 415 Chapter 11. Code refactoring support 435 Chapter 12. CodeRush extensibility 541 Appendix A. Terminology 633 Appendix B. CodeRush Options 639 Table of Contents Introduction 17 DevExpress Visual Studio productivity tools 17 IDE Tools chief architect – Mark Miller 18 IDE Tools documentation and info resources 18 IDE Tools dedicated community 18 IDE environment changes after IDE Tools are installed 18 Settings schemes: FrictionFree and Default modes 20 The “What Happened?” (Feature UI) window 21 Getting up to speed with IDE tools 23 The CodeRush/Refactor! key (shortcut) 25 CodeRush Training window 25 IDE Tools User Guide 27 Prerequisites 29 Supported Visual Studio versions 29 Supported programming languages 29 System requirements 29 How to install the IDE Tools 30 How to install multiple IDE Tools versions side-by-side 33 How to install/uninstall IDE tools in quiet/silent mode 34 How to temporally disable IDE tools (load manually) 34 DevExpress support and knowledge base 35 Chapter 1. Duplicate Code Detection and Consolidation 37 Duplicate Detection and Consolidation overview 37 Duplicate Real-time detection in Visual Studio 39 Duplicate Detection Visual Studio tool window 44 Duplicate Detection using the Stand-alone Application 47 Duplicate Consolidation inside Visual Studio 51 Duplicate Detection analysis options 57 Duplicate Detection versus Code Clone Analysis in Visual Studio 2012 58 Chapter 2. Static code analysis and code issues technology 63 Code Issues technology overview 63 Code Issues types overview 63 Code Issues visual presentation 65 Code Issues fixes and suppression 69 Code Issues navigation techniques 72 Code Issues tool window 75 Code Issues configuration and options 77 Code Issues overview 79 Code Issues hints for declaration and initialization 79 Code Issues hints for expressions 83 Code Issues hints for types and members 89 Code Issues for anonymous methods and lambda expressions 98 Code Issues of the dead code type for qualifiers 101 Code Issues of the dead code type for members and blocks 107 Code Issues for Switch (Select) and Case statements 114 Warning code issues for the IDisposable pattern 118 Complex Member 121 Code Issues specific to declaring types 122 Code Issues specific for static classes 126 Code Issues for interfaces 130 Code Issues specific for declaring variables and constants 133 Code Issues specific to constructors 141 Code Issues specific to partial methods 148 Code Issues for virtual members 151 Code Issues for overridden members 154 Code Issues specific to extension methods 158 Code Issues specific to operators 162 Code Issues specific to C# and VB language keywords 165 Chapter 3. Code-generation templates 175 CodeRush Code Templates overview 175 Templates language and learning basics 178 Dynamic templates and dynamic lists 180 Templates option page 183 Dynamic Lists option page 189 Resolving code template conflicts 192 Importing and Exporting code templates 193 Standard Templates Library 195 Smart Constructor – Generating advanced constructors 197 Creating code templates overview 202 Creating simple templates step by step 205 Chapter 4. Consume-first code declaration providers 213 Declaring type declarations 213 Declare Attribute 213 Declare Class 214 Specific code providers for declaring new classes 215 Declare Struct 218 Declare Interface 220 Declare Delegate 221 Declaring enumeration types and its elements 221 An option for positioning newly declared types 224 Declaring members 225 Declaring methods and constructors 225 Declaring various properties 228 Declaring events and event handlers 235 Declaring locals 237 Declaring fields 239 MVC-specific providers 242 Chapter 5. Coding helpers and assistants 247 Auto Declare 247 Intelligent code lines modification using the Duplicate Line feature 249 Code editor auto-complete features – Intellassist 253 Intellassist configuration and options 256 Smart Parentheses and Smart Brackets 258 Smart Enter 260 Scope Cycle 261 Spell Checker 262 How to add an Open Office dictionary 264 Spell checking the entire solution 265 Toggle Region 267 Toggle Regions Outlining 267 Move to Region 268 Organizing source code and sorting class members 270 Chapter 6. Code selection and clipboard tools 275 Camel Case Navigation and Selection 275 Selection Increase 275 Selection Reduce 276 The support of multi-selection for Visual Studio 276 Wrapping code blocks with the Code Embeddings feature 281 Code Embeddings Options 285 Creating custom Code Embeddings 289 Inverting a code block into its opposite using Selection Inversion 293 Customizing Selection Inversion and its predefined templates 294 Quick Comment/Uncomment 296 Smart Cut and Smart Copy 297 Intelligent Paste 300 Intelligent Paste Options 303 Paste Replace Word 306 Clipboard History 306 Chapter 7. Code modification providers 313 Create Descendant and Create Descendant (with virtual overrides) 313 Create Ancestor 315 Creating interface implementers 315 Implementing the IDisposable pattern 318 Converting methods to functions or procedures 324 Converting unimplemented properties 325 Quick ways to add and remove a set/get property accessor 327 Code fixes for code issues for switch (select) statements 329 Reverse For Loop 331 Add Initialization 331 Changing an explicit cast-expression to an ‘as’ operator and back 333 Working in two-dimensional space 334 Embed Selection 336 Invert Selection 337 Add XML Comments 338 Add Contract 341 Add Missing Constructors code provider 344 Convert to Integer 345 Create Event Trigger 346 Reference Assembly 347 Remove Region Directives 348 Code provider to format the String.Format call output 348 Seal Class 351 Chapter 8. Code navigation utilities 355 Markers 355 Bookmarks 357 Tab to Next Reference 359 Highlighting an identifier and its references 363 Click Identifier 364 Drop Marker Before Jump 365 Quick Navigation 369 Advanced CodeRush Quick Navigation customization 373 Navigation providers overview 374 Navigation providers list 376 Quick File Navigation 377 Open Files tool window 379 Browsing recently accessed files 382 Working with HTML tables 386 Step Into Member 388 Navigating in the abstract source code tree 389 Navigation between expressions of the parsed source tree 389 Chapter 9. Unit testing service 393 Overview 393 Unit testing inside the code editor and the Solution Explorer 394 Machine.Specifications (mspec) testing framework support 397 Managing tests with the Unit Test Runner tool window 400 Shortcuts and actions 403 Configuration and options 406 Code templates for generating unit testing code 409 Silverlight testing framework support 410 Support for XUnit, NUnit, MBUnit, and Visual Studio frameworks 412 Chapter 10. Code editor visualization 415 Structural Highlighting 415 Right Margin Line 416 Line Highlighter 418 Member Icons 420 Show Metrics 422 Flow Break Icons 425 XML Doc Comments Painter 426 Region Painting 429 Comment Highlighter 430 Comment Painter 432 Chapter 11. Code refactoring support 435 Introduction 435 What is refactoring? Benefits of a code refactoring 435 How to perform a code refactoring 436 Refactorings preview hinting 438 Refactorings that change signatures 439 Add Parameter 440 Create Overload 441 Decompose Parameter 445 Introduce Parameter Object 446 Convert to Point 448 Convert to Tuple 449 Convert to Size 451 Converting between static and instance members 451 Promoting locals and constant value expressions into parameters 454 Reordering method parameters 457 Safe rename a public API member and mark it obsolete 460 Remove Parameter 460 Refactorings conditionals 462 Refactoring multi-conditional statements 462 Refactoring ternary expressions into null-coalescing operations 465 Flatten Conditional 467 Refactorings declarations and initializations 470 Refactorings for implicitly-typed local variables 470 Use Named Arguments 472 Name Anonymous Type 473 Refactorings anonymous methods and lambda expressions 475 Refactoring loops and blocks 479 Adding and removing block delimiters in C#/C++ and JavaScript 479 Converting loops: ForEach to For and back 480 Refactoring using statements 482 Lock to Try/Finally 486 Introduce ForEach Action 487 Refactoring Visual Basic With statements 489 Refactoring C++ macros 492 Inline Macro 492 Use Const 492 Use typedef 492 Refactorings for moving and extracting methods 493 Extract Method 493 Inline Method 497 Refactorings for simplifying of parallel computing development 499 Refactorings to execute statements asynchronously 506 Refactoring properties and fields 508 Refactorings specific to auto-implemented