Visual Studio 2019 Tricks and Techniques

Book description

Harness the full power of the Visual Studio IDE to take your coding skills to the next level by learning about IDE productivity practices and exclusive techniques

Key Features

  • Increase your productivity by leveraging Visual Studio 2019's improvements and features
  • Explore powerful editing, code intelligence, and source code control features to increase productivity
  • Delve into VS's powerful, untapped features such as custom project templates and extensions

Book Description

Visual Studio 2019 (VS 2019) and Visual Studio Code (VS Code) are powerful professional development tools that help you to develop applications for any platform with ease. Whether you want to create web, mobile, or desktop applications, Microsoft Visual Studio is your one-stop solution. This book demonstrates some of the most sophisticated capabilities of the tooling and shows you how to use the integrated development environment (IDE) more efficiently to be more productive.

You'll begin by gradually building on concepts, starting with the basics. The introductory chapters cover shortcuts, snippets, and numerous optimization tricks, along with debugging techniques, source control integration, and other important IDE features that will help you make your time more productive. With that groundwork in place, more advanced concepts such as the inner workings of project and item templates are covered. You will also learn how to write quality, secure code more efficiently as well as discover how certain Visual Studio features work 'under the hood'.

By the end of this Visual Studio book, you'll have learned how to write more secure code faster than ever using your knowledge of the extensions and processes that make developing successful solutions more enjoyable and repeatable.

What you will learn

  • Understand the similarities and differences between VS 2019 and VS Code
  • Get to grips with numerous keyboard shortcuts to improve efficiency
  • Discover IDE tips and tricks that make it easier to write code
  • Experiment with code snippets that make it easier to write repeating code patterns
  • Find out how to customize project and item templates with the help of hands-on exercises
  • Use Visual Studio extensions for ease and improved productivity
  • Delve into Visual Studio's behind the scene operations

Who this book is for

This book is for C# and .NET developers who want to become more efficient and take advantage of features they may not be aware of in the IDE. Those looking to increase their productivity and write quality code more quickly by fully utilizing the power of the Visual Studio IDE will also find this book useful.

Publisher resources

Download Example Code

Table of contents

  1. Visual Studio 2019 Tricks and Techniques
  2. Why subscribe?
  3. Foreword
  4. Contributors
  5. About the authors
  6. About the reviewers
  7. Packt is searching for authors like you
  8. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Code in Action
    6. Download the color images
    7. Conventions used
    8. Get in touch
    9. Reviews
  9. Section 1: Visual Studio IDE Productivity Essentials
  10. Chapter 1: Flavors of Visual Studio
    1. Technical requirements
    2. Quick reference cheat sheet
    3. Visual Studio 2019 (Windows)
      1. Features of VS 2019 Enterprise edition
    4. Visual Studio 2019 for Mac
    5. GitHub Codespaces
    6. Summary
  11. Chapter 2: Keyboard Shortcuts
    1. Technical requirements
    2. Windows shortcuts
      1. Shortcuts that work in both Windows and Visual Studio
      2. Intermediate-level shortcuts
    3. Keyboard mapping schemes
      1. Choosing a keyboard mapping scheme
    4. Customizing your own keyboard mapping schemes
      1. Creating an individual shortcut
      2. Viewing existing shortcuts
      3. Importing an entire keyboard mapping scheme
    5. Learning keyboard shortcuts
      1. Installing the Learn the Shortcut extension
      2. Default Learn the Shortcut behavior
    6. Justification for investing time
    7. Summary
    8. Further reading
  12. Chapter 3: IDE Tips and Tricks
    1. Technical requirements
    2. Having fun with the file tabs
      1. Pinning documents
      2. Vertical documents
      3. Horizontal and vertical groups
    3. Traversing your solution
      1. Navigating through active windows or tabs
      2. Using Quick Launch
      3. Track Active Item
    4. Live sharing
    5. Preview Features
    6. Faster editing
      1. Column Mode
      2. Multi-caret selects
      3. Toolbox
    7. Cleaner code
      1. Code Formatting
      2. Code Cleanup
    8. Summary
  13. Chapter 4: Working with a Repository
    1. Technical requirements
    2. Automating Git commands
      1. Git commands quick reference
    3. Working with source control
    4. Creating a repository
      1. For Windows
      2. For VS Code
      3. For Mac
    5. Cloning a repository
      1. For Windows
      2. For VS Code
      3. For Mac
    6. Getting updates (Fetch and Pull)
      1. For Windows
      2. For VS Code
      3. For Mac
    7. Adding files
      1. For Windows
      2. For VS Code
      3. For Mac
    8. Creating a .gitignore file
    9. Committing (and pushing) your code
      1. For Windows
      2. For VS Code
      3. For Mac
    10. Stashing (and applying) your code
    11. Understanding branch and merge
      1. Creating a branch
    12. Working with pull requests
    13. Summary
  14. Chapter 5: Working with Snippets
    1. Technical requirements
    2. Snippet basics
    3. Inserting snippets
    4. Code Snippets Manager dialog
      1. Examining a custom snippet's XML definition
    5. Deploying snippets
      1. Importing a custom snippet
    6. Summary
    7. Further reading
  15. Chapter 6: Database Explorers
    1. Technical requirements
    2. Managing databases in Visual Studio 2019 for Windows
      1. Working with SQL Server Object Explorer
    3. Interacting with databases in VS Code
      1. Getting connected
      2. Creating our database
      3. Expanding the database
    4. Summary
  16. Chapter 7: Compiling, Debugging, and Versioning
    1. Technical requirements
      1. Installing Docker
    2. Exploring compilation flags and options
      1. Visual Studio 2019 for Windows
      2. Visual Studio Code
      3. Visual Studio 2019 for Mac
      4. Conditional compilation
      5. Regions
      6. Pre-build and post-build events
    3. Investigating advanced debugging
      1. Breakpoints
      2. The Immediate window
      3. Who's watching?
      4. Remote debugging
      5. Remote debugging Docker in Visual Studio 2019 for Windows
      6. What about remote debugging in VS Code?
      7. Visual Studio 2019 for Mac, too!
    4. Discovering versioning
      1. Versioning in traditional full framework .NET projects
      2. Versioning in .NET Core
    5. Summary
  17. Section 2: Customizing Project Templates and Beyond
  18. Chapter 8: Introduction to Project and Item Templates
    1. Technical requirements
    2. Understanding item templates
    3. Knowing when to use project templates
      1. Template tags
      2. When to use templates
    4. Looking at a sample scenario
      1. Running the project
      2. Examining the project
    5. Valuing templates
    6. Summary
    7. Further reading
  19. Chapter 9: Creating Your Own Templates
    1. Technical requirements
    2. Exporting a custom project template
      1. Using the exported project template
    3. Identifying issues with the project template
    4. Fixing problems in the template definition
      1. Understanding template parameters
    5. Reimporting the fixed template
    6. Exporting project items
    7. Summary
  20. Chapter 10: Deploying Custom Templates
    1. Technical requirements
      1. Installing the Visual Studio SDK component
    2. Introducing the client-server project
      1. Client-server sample code
    3. Creating the VSIX deployment package
      1. Reviewing the deployment project
      2. Examining the template project
      3. Making template wizards
    4. Using the VSIX deployment package
      1. Testing the project template
    5. Publishing to the Visual Studio Marketplace
    6. Distributing instructions for the Dotnet Core CLI
    7. Summary
  21. Section 3: Leveraging Extensions for the Win
  22. Chapter 11: Overviewing Visual Studio 2019 Extensions
    1. Technical requirements
    2. What are extensions?
    3. Visual Studio Marketplace
    4. Creating extensions
      1. Creating extensions in Visual Studio 2019 for Windows
      2. Creating extensions in Visual Studio 2019 for Mac
    5. Roslyn analyzers
    6. Summary
  23. Chapter 12: Overviewing VS Code Extensions
    1. Technical requirements
    2. What are VS Code extensions?
    3. VS Code in the Visual Studio Marketplace
      1. Creating an extension
      2. Generating a basic extension
      3. Making our extension work for us!
    4. Publishing your extension
    5. Summary
  24. Chapter 13: CodeMaid is Your Friend
    1. Technical requirements
    2. A brief history of CodeMaid
      1. Configuring CodeMaid
      2. Reorganizing to reduce merge conflicts
      3. User profile and solution settings
    3. Learning about cleanup actions
      1. The narrowing gap
    4. Exploring CodeMaid Spade
      1. McCabe Cyclomatic Complexity
    5. Build Progress
    6. Summary
  25. Chapter 14: Be Your Team's Hero with CodeGenHero
    1. Technical requirements
    2. Understanding the core concepts of code generation
      1. Metadata and templates
    3. Introducing CodeGenHero™
      1. Installing CodeGenHero™
      2. Example project overview
      3. Scaffolding a solution – .NET Core CLI
    4. The CodeGenHero™ solution
      1. Creating a metadata source
      2. Configuring a blueprint
      3. Choosing templates
      4. Configuring template parameters
      5. Mapping target projects
      6. Integrating generated code
    5. Handling change with CodeGenHero™
      1. How does it work?
      2. Changing the database schema
      3. Merging changes
    6. Summary
  26. Chapter 15: Secure Code with Puma Scan
    1. Technical requirements
    2. Understanding common application security vulnerabilities
      1. A1:2017-Injection
      2. A6:2017-Security Misconfiguration
      3. A7:2017-Cross-Site Scripting (XSS)
      4. A9:2017-Using Components with Known Vulnerabilities
      5. A10:2017-Insufficient Logging and Monitoring
    3. Finding vulnerabilities for fun and profit
    4. Automating vulnerability detection with Puma Scan
      1. Installing Puma Scan in Visual Studio 2019
      2. Installing Puma Scan in VS Code
      3. Running Puma Scan and viewing the results
    5. Extending Puma Scan with custom sinks
    6. Using Puma Scan in a DevSecOps pipeline 
    7. Summary
  27. Appendix
  28. Other Popular Productivity Extensions
    1. Presenting some great Visual Studio 2019 for Windows extensions
      1. Conveyor by Keyoti
      2. Ozcode – Magical C# debugging
      3. Open Command Line
      4. ReSharper
      5. Visual Studio Spell Checker
    2. Sharing our favorite Visual Studio Code extensions
      1. Increment selection
      2. CamelCase
      3. C# extensions
      4. The vscode-icons and vscode-icons-mac extensions
      5. Beautify
      6. The vscode-spotify extension
    3. Choosing useful Visual Studio 2019 for Mac extensions
      1. LiveXAML for Xamarin.Forms
      2. MFractor
      3. NuGet package management extensions
      4. MvvmCross Template Pack
    4. Summary
  29. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Visual Studio 2019 Tricks and Techniques
  • Author(s): Paul Schroeder, Aaron Cure, Ed Price
  • Release date: January 2021
  • Publisher(s): Packt Publishing
  • ISBN: 9781800203525