
- •Table of Contents
- •About the Author
- •About the Technical Reviewer
- •Acknowledgments
- •Introduction
- •Installing Visual Studio
- •Visual Studio 2022 System Requirements
- •Operating Systems
- •Hardware
- •Supported Languages
- •Additional Notes
- •Visual Studio Is 64-Bit
- •Full .NET 6.0 Support
- •Using Workloads
- •The Solution Explorer
- •Toolbox
- •The Code Editor
- •New Razor Editor
- •What’s Available?
- •Hot Reload
- •Navigating Code
- •Navigate Forward and Backward Commands
- •Navigation Bar
- •Find All References
- •Find Files Faster
- •Reference Highlighting
- •Peek Definition
- •Subword Navigation
- •Features and Productivity Tips
- •Track Active Item in Solution Explorer
- •Hidden Editor Context Menu
- •Open in File Explorer
- •Finding Keyboard Shortcut Mappings
- •Clipboard History
- •Go To Window
- •Navigate to Last Edit Location
- •Multi-caret Editing
- •Sync Namespaces to Match Your Folder Structure
- •Paste JSON As Classes
- •Enable Code Cleanup on Save
- •Add Missing Using on Paste
- •Features in Visual Studio 2022
- •Visual Studio Search
- •Solution Filters
- •Visual Studio IntelliCode
- •Whole Line Completions
- •Visual Studio Live Share
- •Summary
- •Visual Studio Project Types
- •Various Project Templates
- •Console Applications
- •Windows Forms Application
- •Windows Service
- •Web Applications
- •Class Library
- •MAUI
- •Creating a MAUI Application
- •Pairing to Mac for iOS Development
- •Consuming REST Services in MAUI
- •The Complete Weather App
- •The Target Platforms
- •The Required NuGet Package
- •The Weather Models
- •The WeatherService
- •The MainViewModel
- •Registering Dependencies
- •Building the MainPage View
- •Using SQLite in a MAUI Application
- •The ToDoItem Model
- •The ToDoService
- •The MainViewModel
- •Registering Dependencies
- •Building the MainPage View
- •Managing NuGet Packages
- •Using NuGet in Visual Studio
- •Hosting Your Own NuGet Feeds
- •Managing nmp Packages
- •Creating Project Templates
- •Creating and Using Code Snippets
- •Creating Code Snippets
- •Using Bookmarks and Code Shortcuts
- •Bookmarks
- •Code Shortcuts
- •Adding Custom Tokens
- •The Server Explorer
- •Running SQL Queries
- •Visual Studio Windows
- •C# Interactive
- •Code Metrics Results
- •Maintainability Index
- •Cyclomatic Complexity
- •Class Coupling
- •Send Feedback
- •Personalizing Visual Studio
- •Adjust Line Spacing
- •Document Management Customizations
- •The Document Close Button
- •Modify the Dirty Indicator
- •Show Invisible Tabs in Italics in the Tab Drop-Down
- •Colorize Document Tabs
- •Tab Placement
- •Visual Studio Themes
- •Summary
- •Setting a Breakpoint
- •Step into Specific
- •Run to Click
- •Run to Cursor
- •Force Run to Cursor
- •Conditional Breakpoints and Actions
- •Temporary Breakpoints
- •Dependent Breakpoints
- •Dragging Breakpoints
- •Manage Breakpoints with Labels
- •Exporting Breakpoints
- •Using DataTips
- •Visualizing Complex Data Types
- •Bonus Tip
- •Using the Watch Window
- •The DebuggerDisplay Attribute
- •Evaluate Functions Without Side Effects
- •Format Specifiers
- •dynamic
- •hidden
- •results
- •Diagnostic Tools
- •CPU Usage
- •Memory Usage
- •The Events View
- •The Right Tool for the Right Project Type
- •Immediate Window
- •Attaching to a Running Process
- •Attach to a Remote Process
- •Remote Debugger Port Assignments
- •Remote Debugging
- •System Requirements
- •Download and Install Remote Tools
- •Running Remote Tools
- •Start Remote Debugging
- •Summary
- •Creating and Running Unit Tests
- •Create and Run a Test Playlist
- •Testing Timeouts
- •Using Live Unit Tests
- •Using IntelliTest to Generate Unit Tests
- •Focus IntelliTest Code Exploration
- •How to Measure Code Coverage in Visual Studio
- •Summary
- •Create a GitHub Account
- •Create and Clone a Repository
- •Create a Branch from Your Code
- •Creating and Handling Pull Requests
- •Multi-repo Support
- •Compare Branches
- •Check Out Commit
- •Line Staging
- •Summary
- •Index

About the Author
Dirk Strauss has over 17 years of experience programming with C# and Visual Studio. Working for various companies throughout his career, he has been privileged to work with and learn from some of the most brilliant developers in the industry. He has authored several books on topics ranging from Visual Studio and C# to ASP.NET Core. Passionate about writing code, he loves learning new tech and imparting what he learns to others.
xi

About the Technical Reviewer
Sanjaya Prakash Pradhan is a Microsoft Dynamics 365 and Power Apps Business Applications MVP and, at the same time, a Microsoft Certified Trainer (MCT) in
Dynamics 365 CE and Power Apps. He is an experienced senior technical consultant with 13+ years of experience in consulting and training who has worked on numerous business system implementations. Sanjaya is currently
working as the research and development industry solutions lead in an established worldwide business applications
practice. Having led software projects in numerous industries including BFS, health care, retail, and the public sector, he works across all areas of the project life cycle from demonstrations, design, architecture, documentation, customization, and development. Sanjaya gets involved in the technical community through leading the Power Platform and Dynamics 365 user group in India, running technical events, and presenting on technical and functional topics at conferences around the world. In one line, he is an MVP, MCT, community director, UG lead, speaker, trainer, blogger, author, podcaster, business advisor, and senior solution architect.
xiii
Acknowledgments
I would like to thank my wife and children for their support while writing this book. I would not have been able to do it without you by my side.
I would also like to thank the Apress team for supporting this book and for turning my vision into reality. It is a topic I have wanted to write about for a long time.
I also want to thank Sanjaya Prakash for his help during the review of this book. Last but not least, I want to thank you for reading this book. Your passion for
knowing more drives me to learn more and impart what I learn. It’s a symbiotic relationship that benefits us as we grow and become better at what we do.
xv
Introduction
Visual Studio 2022 is the next version of the stellar development tool we love to use. This book is for developers ready to get to know the IDE better. It aims to get you started on the road to exploring Visual Studio 2022, beyond what you are already comfortable with.
The book starts with installing Visual Studio and adding workloads. Then you explore the IDE a bit more before looking at the existing (and some new) features in Visual Studio 2022. After that, a few productivity tips are included for good measure.
Being able to effectively work with different project types and knowing when to use them are explored in a bit more detail in Chapter 2. We will look at the new MAUI project template and how to create cross-platform applications. We then see how to create project templates and then explore using and creating code snippets. This chapter covers many of the basics essential to working with Visual Studio, including using bookmarks, code shortcuts, the Server Explorer, and other Visual Studio Windows.
In Chapter 3, we look at debugging techniques such as using breakpoints, setting conditional breakpoints, breakpoint actions, temporary breakpoints, dependent breakpoints, and labels. We see how to use data tips as well as the DebuggerDisplay attribute. We then take a closer look at Diagnostic Tools and the Immediate Window. Finally, to close off the debugging chapter, we see how to attach to a running process and how to use remote debugging.
The next chapter introduces you to creating and running unit tests. You learn how to create live unit tests, use IntelliTest to generate unit tests, and measure code coverage in Visual Studio.
Finally, we look at working with Git and GitHub. We see how to create a GitHub account and what creating and cloning a repository involves. The new Git features in Visual Studio 2022, such as multi-repo branching, comparing branches, and line staging, are also discussed.
xvii
Introduction
You learn how to commit changes in code to the repository and create a branch of your code when you need to work on a new feature in isolation. Then we look at creating a pull request and how these pull requests are managed. Lastly, we have a look at the benefit of working with stashes.
If you need an excellent reference book that deals exclusively with (and only with) Visual Studio, then look at what this book has to offer you. If you spend any time using Visual Studio or want to learn how working with Visual Studio 2022 can increase your productivity, then this book makes a perfect reference book for your office.
xviii
CHAPTER 1
Getting to Know Visual Studio 2022
Visual Studio is an amazing bit of software. If you have been using Visual Studio for a number of years, you will certainly agree that the IDE offers developers a host of tools and features to make them more productive. You will also be aware that it has grown a lot during the past couple of years and is an absolute powerhouse when it comes to providing tools to develop world-class software.
Initially released as Visual Studio 97 in February 1997, this was the first attempt at using a single development environment for multiple languages. The evolution of Visual Studio is detailed in Table 1-1.
1
© Dirk Strauss 2023
D. Strauss, Getting Started with Visual Studio 2022, https://doi.org/10.1007/978-1-4842-8922-8_1

Chapter 1 Getting to Know Visual Studio 2022
Table 1-1. The Evolution of Visual Studio
Release |
Version |
.NET Framework |
.NET Core |
Release Date |
|
|
|
|
|
Visual Studio 2022 |
17.0 |
3.5, 4.6.0–4.8 |
2.1, 3.1, 5.0, 6.0 |
February 15, 2022 |
Visual Studio 2019 |
16.0 |
3.5–4.8 |
2.1, 2.2, 3.0, 3.1, 5.0 |
April 2, 2019 |
Visual Studio 2017 |
15.0 |
3.5–4.7 |
1.0, 1.1, 2.0, 2.1 |
March 7, 2017 |
Visual Studio 2015 |
14.0 |
2.0–4.6 |
1.0 |
July 20, 2015 |
Visual Studio 2013 |
12.0 |
2.0–4.5.2 |
|
October 17, 2013 |
Visual Studio 2012 |
11.0 |
2.0–4.5.2 |
|
September 12, 2012 |
Visual Studio 2010 |
10.0 |
2.0–4.0 |
|
April 12, 2010 |
Visual Studio 2008 |
9.0 |
2.0, 3.0, 3.5 |
|
November 19, 2007 |
Visual Studio 2005 |
8.0 |
2.0, 3.0 |
|
November 7, 2005 |
Visual Studio .NET 2003 |
7.1 |
1.1 |
|
April 24, 2003 |
Visual Studio .NET 2002 |
7.0 |
1.0 |
|
February 13, 2002 |
Visual Studio 6.0 |
6.0 |
N/A |
|
June 1998 |
Visual Studio 97 |
5.0 |
N/A |
|
February 1997 |
|
|
|
|
|
There is so much to see and learn when it comes to Visual Studio. Therefore, in this chapter, we will start by having a look at the following:
•\ |
Installing Visual Studio |
•\ |
What workloads are |
•\ |
Exploring the IDE (integrated development environment) |
•\ |
Existing and new features available in Visual Studio 2022 |
•\ |
Productivity tips |
If you are using a macOS or a Windows machine, Visual Studio will happily run on both. Let us see where to find the Visual Studio Installer and get going.
2