Overview of Visual Studio 2017 and Updates for .NET Developers

Kasey Uhlenhuth

Visual Studio 2017 first released in March of this year. Since then, there have been five updates with each bringing more improvements and capabilities. Every improvement is geared towards making you more productive and this post aims to give you an overview of the culmination of features to date. Read on to see how you can get started working on your projects quickly and write better code faster.

Download Visual Studio 2017 Preview today.

New Install Experience, Performance and Reliability

The first thing you’ll notice with Visual Studio 2017 is the new install experience which lets you pick and choose which development tools you want installed. To help you get started working on your projects quickly, Visual Studio 2017 Preview version 15.5 has parallelized initialization to make your solutions load fast and get you to writing code as soon as possible. Other performance improvements include moving computation –like code analysis—out of the main Visual Studio process to keep your typing speed unimpeded.

Smart Code Editor

Visual Studio has a deep understanding of your code via the Roslyn compiler to provide you with smart editing features like syntax colorization, code completion, completion list filtering, spell-checking mistyped variables, unimported type resolution, outlining, structure visualizers, CodeLens, call hierarchy, hover-able quick info, parameter help, as well as tools for refactoring, applying quick actions, and generating code. The latest update to Visual Studio 2017 includes smart variable naming suggestions and expand/contract selection (Ctrl+W/Ctrl+Shift+W in Default Profile, Shift+Alt+=/Shift+Alt+- in C# Profile).

Smart Code Editor

Pro Tips:

  • Use Quick Launch (Ctrl+Q) to search all Visual Studio settings.

Quickly navigate your .NET code by jumping to any file, type, member, or symbol declaration with the redesigned Go To All shortcut (Ctrl+T or Ctrl+,). Find all the references of a symbol or literal in your code, including references across .NET languages, and use the redesigned results window to organize your references by definition, project, and/or path (Shift+F12). And don’t forget to try targeted navigation commands to help you jump directly to symbol definitions (F12, or now also Ctrl+click) or implementations (Ctrl+F12).

Navigate Your Code

Pro tips:

  • Use “f”, “t”, “m”, and “#” as prefixes in your Go To All (Ctrl+T) search to filter results down to files, types, members, or symbols respectively.
  • Use the gear icon in the Go To All dialog to move its position from the right-hand corner of the code editor to the middle.
  • Use the “lock” icon in the Find All References (Shift+F12) window to save your search. Subsequent Find All Reference calls will open a new results tab.

Live Code Analysis

Visual Studio has live code analyzers to help you improve your code quality by detecting errors and potentially problematic code. We provide quick-actions (Ctrl+.) to resolve detected problems across your document, project, or solution. Also invoke the Ctrl+. shortcut to access code suggestions (marked by faded gray dots under the first characters of an expression), learn best practices, stub or generate code, refactor code, and adopt new language features.

Learn more about available quick actions and refactorings in our documentation. Some of the ones added in the latest Visual Studio 2017 update are: sort modifiers, move declaration near reference, convert lambda to C# 7.0 local function, fade and remove unreachable code, add missing file banner, use C# 7.0 pattern matching, simplify with C# 7.1 inferred tuple name, and more.

Live Code Analysis

Pro tips:

  • Enable full-solution analysis to find issues across your entire solution even if you don’t have those files open in the editor: Tools > Options > Text Editor > [C# / Basic] > Advanced > Enable full solution analysis.
  • Errors, warnings, and suggestions appear in the editor scroll bar to give you visuals into where errors are in your open file.
  • Code issues can be suppressed individually using the Ctrl+. shortcut or in-bulk by selecting the issues in the Error list and right-click > Suppress.
  • Have Visual Studio offer to install NuGet packages and add references to unimported types by going to Tools > Options > Text Editor > [C# / Basic] > Advanced > Add using for types in NuGet/reference assemblies.
  • Some code refactorings requires code snippet selections, like Extract Method and Introduce Local Variable.
  • For more code diagnostics and fixes related to best practices, API design, and performance improvements, install our Microsoft Code Analysis 2017 extension.

Code Consistency and Maintenance

Visual Studio 2017 enables coding convention configuration, detects coding style violations, and provides quick-fixes to remedy style issues with the Ctrl+. shortcut. Configure and enforce your team’s formatting, naming, and code style conventions across a repository—allowing overriding values at the project and file level—using EditorConfig. For any given file, the EditorConfig file in the closest containing folder will be enforced.

Code Consistency and Maintenance

Pro Tips:

  • Configure settings for your machine in Tools > Options > Text Editor > [C# / Basic] > Code Style. Override these settings in your repository with an EditorConfig file.
  • Grab an example .editorconfig file from the corefx repository, https://github.com/dotnet/corefx.
  • Use Format Document (Ctrl+K,D or Ctrl+E,D) to clean up formatting violations based on the configuration in your .editorconfig file or in the absence of that, Tools>Options settings.

Unit Testing

Run and debug your unit tests based on the MSTest, NUnit, or XUnit testing frameworks for any application targeting .NET Framework, .NET Standard, or .NET Core. Explore and review your tests in the Test Explorer or immediately see how code changes impact your unit tests inside the editor with Live Unit Testing (Enterprise SKU only).

Unit Testing

Pro Tips:

  • Use Live Unit Testing with MSTestv1 in the latest Visual Studio 2017 update.
  • Include or exclude test projects, or even specific tests, from the set of unit tests run “live” by right-clicking on the test project in Solution Explorer (or on the test itself) and selecting Live Unit Testing > [Include / Exclude].
  • Enable fast test discovery in the Test Explorer with the experimental feature, Real-Time Test Discovery.

Debugging

Visual Studio 2017 improves upon it’s top-notch debugger to allow you to debug your .NET applications targeting the .NET Framework, .NET Standard, and .NET Core. New features in 2017 include the ability to reattach to processes in one click, visibility into which expression returns null with the new Exception Helper, Run to Click, and the ability to Step Back with IntelliTrace (Enterprise SKU only).

If your service runs in Azure, use Snapshot debugging to diagnose issues on your live, deployed cloud applications in Visual Studio 2017 Enterprise.

Debugging

Pro Tips:

  • Hold the CTRL button to transform Run to Click into Set Next Statement.
  • Take a look at the checkbox options in the new Exception Helper, you will find that you can ignore breaking on exceptions thrown from specific libraries.
  • Open the Diagnostic Tools window while debugging and notice a new summary page that allows you to take snapshots, enable CPU profiling, and view Exception events.
  • Right-click and use Step Into Specific to choose which nested function you want to “step into” in the given line of code.

.NET Core-Specific Features

Projects targeting .NET Core and .NET Standard involve the new, lightweight project features in Visual Studio 2017. These include file globbing support, a smaller .csproj file—meaning fewer merge conflicts—and the ability to directly edit the new .csproj file without having to unload and reload a project.

Pro Tip:

  • Add NuGet packages directly to your project by adding the tag: <PackageReference Include=”<PACKAGE_NAME” Version=”PACKAGE_VERSION” />

Modern C# and Visual Basic

Visual Studio 2017 ships with C# 7.0 and Visual Basic 15, version 15.3 ships with C# 7.1, and the latest release ships with C# 7.2. By default, Visual Studio projects support the latest major version of the language (in this case, C# 7.0 and VB 15) with options to allow only older language features or to embrace new language features at the minor version cadence. Notable new language features, include:

  • C# 7.0 : tuples, pattern-matching, local functions, and out var
  • C# 7.1 : async Main, support, inferred tuple element names, and default literals
  • C# 7.2 : Span<T>, non-trailing named arguments, private protected, readonly structs, and in parameters
  • Visual Basic 15 brings tuples and digit separators

Follow the C# and Visual Basic language design discussion on the csharplang and vblang GitHub repositories.

Pro Tips:

  • Change your language adoption cadence by right-clicking your project in Solution Explorer and selecting Properties > Build > Advanced > Language version. If you use a language feature that is not supported by your project’s language version, you can use the shortcut Ctrl+. to upgrade your project language from within the editor.

 

Try out Visual Studio 2017 Preview today to enhance your workflow with productivity features and enhancements. Share the Pro-tips outlined in this article with your teammates and let us know if something is blocking your productivity by reporting a problem in Visual Studio. Happy coding!

Over ‘n’ out,

0 comments

Discussion is closed.

Feedback usabilla icon