Book Image

Visual Studio 2019 Tricks and Techniques

By : Paul Schroeder, Aaron Cure
Book Image

Visual Studio 2019 Tricks and Techniques

By: Paul Schroeder, Aaron Cure

Overview of this book

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.
Table of Contents (21 chapters)
1
Section 1: Visual Studio IDE Productivity Essentials
9
Section 2: Customizing Project Templates and Beyond
13
Section 3: Leveraging Extensions for the Win

Visual Studio 2019 (Windows)

Let's start with Visual Studio 2019 (VS 2019), a Windows-based IDE (pronounced AYE-dee-ee). Some people will refer to this product as the full version. This version only runs on Windows (not cross-platform), but it does support both .NET "full framework" and .NET Core (cross-platform) project targets. Something all versions of Visual Studio do exceptionally well is work with diverse programming languages (including C, C++, Visual Basic. NET, C#, F#, JavaScript, TypeScript, Python, Ruby, and Node.js).

Different tiers of features are offered, depending on your needs and budget. Current versions of VS 2019 include a free Community edition as well as paid Professional, Enterprise, and Test Professional versions. The Community and Professional editions are nearly identical when it comes to operational features and, for most development tasks, any version of Visual Studio will work.

The Community version is depicted in the screenshot that follows and you will find virtually no difference between its appearance and that of the other versions:

Figure 1.2 – VS 2019 Community – Windows

Figure 1.2 – VS 2019 Community – Windows

Even with multiple options, choosing a Visual Studio edition is much easier today than in the past. Previously, certain project types could only be loaded in one edition or another, and many add-ins would not run in certain editions. Complex licensing issues compounded these problems, making it more difficult to choose.

Today, even the free Community edition is a powerful environment with much to offer. Many of the popular features, such as peeking at definitions, multi-targeting of release targets, and refactoring are supported in all editions.

More succinctly, the major versions of VS 2019 are as follows:

  • Community – Free for students, open source contributors, and individuals
  • Professional – The best choice for small teams
  • Test Professional – An option for dedicated Quality Assurance (QA) roles
  • Enterprise – Offers extra features (mentioned later in this chapter) and works well for teams of any size

In the past, the Community version, originally labeled "Express," was a very limited version that allowed only basic application development but would not allow for particular target types (such as Visual Studio plugins), and would also not allow a number of plugins to run. While some of these limitations seemed minor, they were enough to create negative perceptions of the platform among some developers and sour development community sentiment on the Community version. In recent years, Microsoft has removed many of the original restrictions and enabled so much functionality in this version that the experience is now very similar to the Professional version.

Traditionally, the Professional version was the lowest tier version for "true" developers. Because of the limitations of other versions, this was the only way to do "actual" development. This version tier is (and always has been) a full-featured IDE with all the bells and whistles you would expect in a professional development tool.

A key difference is that VS 2019 Community is free, while the Professional version retails for about $1,199 for the first year's subscription and $799 annually for renewal thereafter. However, there are license restrictions that limit use of Visual Studio Community to teams of less than five developers. Also, it cannot be used by commercial organizations with over $1 million US dollars in annual revenue.

For those whose focus is purely QA, and not development, Test Professional is another option to consider. It provides an integrated testing toolset for QA teams, but does not include an IDE to build applications. Instead, this product flavor focuses on the creation and execution of tests and test suites. It also integrates nicely with Visual Studio Team Foundation Server (VSTFS) and Azure DevOps (ADO).

Finally, the Enterprise version of VS 2019 is available for organizations with more than 25 developers, or those seeking to take advantage of advanced features only available at this highest tier. This level includes advanced functionality such as memory profilers, Snapshot Debugger, Live Unit Testing, architectural layer diagrams, and architecture validation. An overview of some of these capabilities is provided next.

Features of VS 2019 Enterprise edition

The following provides a brief overview of a few features that are specific to the Enterprise version of VS 2019. These items may help you decide whether this is the right flavor of the IDE for your needs:

  • Performance profiling tools: VS 2019 provides a dozen or more profiling tools that can help diagnose different kinds of performance issues. Common metrics you may want to analyze include CPU usage, memory usage, and database performance. Some of these tools require the Enterprise edition, and some do not. Use this link to investigate the specific tools that match your needs: https://docs.microsoft.com/en-us/visualstudio/profiling/profiling-feature-tour?view=vs-2019.
  • Live Unit Testing: While you are coding, Live Unit Testing automatically runs unit tests in the background and shows your code coverage live in Visual Studio. It provides a line-by-line visual indicator of test coverage as well as the status of passing/failing tests. As you modify code, this feature dynamically executes tests and provides immediate notification when changes cause tests to fail.
  • Snapshot Debugger: If you are using Azure Application Insights, the Snapshot Debugger can be used to capture the state of source code and variables from a live, running, application. This can be helpful for troubleshooting exceptions that occur in a production environment. If you do not have the Enterprise edition of Visual Studio, you can view debug snapshots in the online portal, but using the Enterprise edition provides a more robust debugging experience.
  • Live Dependency Validation: Another feature, only available in the Enterprise edition, is Live Dependency Validation. This lets teams validate architectural dependencies to ensure that they respect defined architectural constraints. In complex multi-layer applications, this can help ensure code dependencies flow in the right direction, which is important for maintainability. This can be useful on project teams with junior developers who may not fully understand the design. Detailed coverage of the Live Dependency Validation feature is beyond the scope of this chapter, but this video link provides a basic overview: https://channel9.msdn.com/Events/Visual-Studio/Visual-Studio-2017-Launch/T123.

    Visual Studio Installer

    To use certain features, like Code Map and Live Dependency Validation components, you must run the Visual Studio Installer, select the Individual components tab, and scroll down to the Code tools section. From there, select the Code Map and Live Dependency Validation components, as shown in the following screenshot. When you are ready, click the Modify button:

Figure 1.3 – Visual Studio Installer

Figure 1.3 – Visual Studio Installer

Note

To be accurate, Visual Studio's Community and Professional editions do allow you to open diagrams that were generated using the Enterprise edition, albeit in read-only mode.

Despite their differences, from a functionality standpoint, the look and feel of all the editions are pretty much the same. Menus, tools, and functional controls are all implemented consistently, perform the same functions, and are mostly indistinguishable from one another.

Use the following link to review specific differences between versions: https://visualstudio.microsoft.com/vs/compare/.

In short, whichever version you choose, the experience should be nearly the same. For most development tasks, it makes no difference which version you are running: they all have the basic software development life cycle tools to create, debug, and run web, mobile, console, library, and just about any other project you can devise.