Visual Studio 2017 New Features

Welcome to another article on VS2017. I’m sure that you have already read my article on installation of VS2017. If not, then read it here.

In this article, I will demonstrate some new features of Visual Studio 2017 IDE, which will help a lot in your day to day development.

Creating new project with VS2017

Open VS2017 and you will be shown a welcome page.


There are two ways to create a new project in VS2017.

You can write the type of project, which you want to create in the textbox below “New Project” header.

You will be shown the type of projects as and when you type in the textbox.

e.g. writing “console”:

When you write WPF:

There is also another way to create a new project. Click More project templates link just below the textbox. You will be shown a familiar dialog box to create new projects.


What’s new in Visual Studio IDE

Let’s start by creating a console Application. I will introduce some of the new features in VS2017.

Improved code navigation

After creating a console Application, go to Solution Explorer and right click on the project to add new class.

Let’s say that we are adding new Customer class given below.


Now, save the Customer.cs file and go to Program.cs.

Write Customer in the Main function, press either Ctrl + T (Control key followed by T key) or Ctrl + , (Control button followed by, key).

On the top right, you will be shown a pop-down dialog, which will help you quickly locate the referenced element. Notice that it will quickly launch the “Customer.cs” file too.


In this way, you can have a look at a referenced class and its properties quickly without the need to open the relevant file in IDE. You can simply press ESC key, the dialog, file and both will close.

“Fuzzy” matching

VS2017 introduces a new feature called “fuzzy matching”, which means when you type a name and even if you misspell it, VS2017 will show you the results, which are based on fuzzy match.

To experience it, let’s go to Program.cs -> Main method again.

Type “Cstomer” and see.

VS2017 will automatically suggest you “Customer” class and highlights it for you


Changes in References window

Write the line given below in Main method.

 

  1. Customer cust = new Customer();  

 

Now, place the mouse cursor on “Custmer” word, press “Shift” + “F12” keys.

You will be shown a new “references” Window, which has been modified compared to “Find Symbol Results” Window in VS2015.


Notice in the “references” Window, there are many new things here like Filtering (on left side), Group by, Search, “Keep Results” button, Sorting and Colorization.

Let’s see each of them one by one.

Filtering references

In VS2015, when you find all the references on a class or property, you will be shown all the refenced results with no option to filter them. Now, in VS2017, you have filtering option in references Window.

See on the left side that there is a dropdown and by default Entire Solution is selected.

You can filter the references; based on which area you want to see and VS2017 will only show you the relevant references.


Grouping

With the “Group By” feature, you can change how the references are being displayed. It provides you the options given below, which helps you in quickly navigating to the reference; you are looking for,


Let’s say you select “Definition, Project then Path” option and you will see the references group, as shown below.



Search

On the top right section of “references” Window, you can search inside the “references” results.


Keep results

This is a new interesting feature. Remember in VS2015 when you are already looking at one references result and you want to find another class or property reference too. If you search in another class reference, your previous result will be overwritten. You can see only one reference result at a time.

If you press “Keep Results” button on the references Window and you search for another term, then your original result will be preserved and you will be shown references in a new Window.

Let’s say that you create a new “Order” class and reference it from Main method.

Press “Keep Results” button on the references Window of customer results, go to Order class and press Shift + F12. You will be shown references in another Window.


At the bottom of the Wndow, you will be able to find a tab for “Customer” references too.

Sorting

You can now click on the results column headers like Code, File, Line, Col and Project to have your references result sorted by these columns, which were missing in VS2015.


Colorization

Notice the references are displayed in different colors to help you in clear understanding of the references.

Structure Guide Lines

A dotted vertical line now runs between the curly braces to identify scope. If you mouse over the dotted line, then you will be shown the current scope.


Code Refactoring enhancements

VS2017 has improved refactoring a lot to make the code more readable.

Let’s consider some new improvements.

Object initialization

If you have written the code step by step to assign the values to an object’s property, VS2017 refactoring will now suggest you to use an object initialization.

Write the code given below in Main method.


Now, place your mouse cursor on Customer and press Cltr + . (Control key followed by .)

VS2017 will give you a message “Object initialization can be simplified”.


Click on the suggestion and your code will be modified, as shown below.


Also, there are some more such enhanced features, which you can try yourself:

Inline Out variable.

Simplify null checks.

Add missing case(s) to a Switch statement.

And much more

There are many more new features of VS2017 but for the scope of this article, I will restrict to above five only.

Go and install Visual Studio 2017 on your PC to find out more by yourself.

Happy coding.