
How to do it...
- Feature one—VS project templates:
-
- We will find a large number of project templates and samples by going to Menu | File | New Project | Installed.
- Select a project template related to the technology or language you want to develop with.
- We can also download a lot of project templates by going to Menu | File | New Project | Online.
- You can search for a template that matches with a technology.
We want to use all the projects which are not necessarily reliable, so it's up to us to verify that. The New Project dialog box appears:

- Visual Studio Gallery to add extensions:
-
- Let's go to Menu | Tools | Extensions and Updates | Visual Studio Gallery.
- We will find some awesome extensions and tools for many languages and technologies. We can go to Visual Studio Gallery (http://visualstudiogallery.com/) to browse all the available extensions:

-
- An extension can be a VSIX extension, but it can also be an MSI file.
-
- Too many extensions installed make the usage of VS very heavy. You can disable or uninstall any extension you want in the Tools | Extensions and Updates window, shown as follows:

- Searching (classes, methods, interfaces, and many others):
-
- Many options are available for searching. One of the most relevant within VS is searching in the Solution Explorer panel:

-
- If it is not open, we can show it by navigating to View | Solution Explorer:

-
- We can also search in the Object Browser, the Toolbox, or the Class View panel:

-
- We can find the Class View panel by navigating to View | Class View.
- We can find the Object Browser panel by navigating to View | Object Browser:

- Code snippets:
-
- Snippets are a way to reuse code and improve productivity, and thus, they help you save time.
- There are many preregistered snippets in VS. For instance, open a C# code file and place the caret within a method definition.
- Type try, then press the Tab key once:

VS generates a try/catch code block, as follows:

-
- Type if, then press the Tab key once:

VS generates an if code block, as follows:

-
- Type foreach, then press the Tab key once:

VS generates a foreach code block, as follows:

We can replace all the elements of the foreach statement by pressing Tab to navigate between them, then we press Enter to validate.
-
- When selecting code, we can surround it with an existing snippet by typing Ctrl + K and Ctrl + S:

-
- Let's select for, then press the Tab key once:

-
- We can use predefined snippets as well as our own snippets. Right-click and click on Insert Snippet... or press the Ctrl + K / Ctrl + X keys:

We can consult the default code snippets list on MSDN at https://msdn.microsoft.com/en-us/library/z41h7fat.aspx.
-
- We can see the snippet categories as follows:

-
- We can see the snippet list for each category:

-
- We can explore all the snippets from the menu Tools | Code Snippets Manager.
The Code Snippets Manager dialog box, with all the available snippets, is shown as follows:

-
- We can also select a list of snippets by language and, afterward, select a category:

- Code map:
This feature creates a diagram representing the hierarchy of your method calls, including their classes and DLL containers during debugging. This feature is available only in VS 2017 Enterprise Edition.
-
- We can access it by right-clicking on the code and selecting one of these options on the contextual menu:

-
- These diagrams can be saved as .dgml extensions, but also as images to be used in a document or to be sent by email.
Code map allows us to do the following things:
-
-
- Navigate and examine code from the map
- Understand relationships between pieces of code
- Find and fix a problem by examining the map
-

- Analyzers:
There are many analyzers available in NuGet, including Tsql, Azure, and CSharp. Each of them increases the quality of your code, similar to FxCop (a code, analysis tool that gives you advice to correct the code).
Let's explore one of them—code cracker:
-
- Right-click on a project; let's click on Manage NuGet Package and type analyzer in the search input.
- We see all the available analyzers, then select and install the package, CodeCracker.CSharp.
- We can also find it by going to Menu | Tools | Extensions and Updates and searching CodeCracker.CSharp.

-
- Now, when we write code and it doesn't respect one of the rules of the analyzer, we will have warnings on the code and suggestions to correct it.
-
- Code Analysis can be enabled on build in our projects. Right-click on the Solution Explorer, root of the project, Properties | Code Analysis and check Enable Code Analysis on Build:

- Use LINQ and Lambdas in Immediate Window:
-
- Immediate Window appears when selecting the VS menu Debug | Windows | Immediate:

-
- We can access object lists or specific variables using the LINQ or Lambdas expression in this bottom window while debugging, by typing LINQ or Lambdas expressions in it.
- We can type a LINQ expression and see its result in the Immediate Window:

- Perfprmance tips:
We can get performance information in a tooltip, for example:
-
- Create one breakpoint at the beginning of a method
- Create another breakpoint at the end of the method
-
When debugging, we will see, at the second breakpoint, the elapsed time in milliseconds between the first and the second breakpoint:
- Diagnostic Tools:
-
- Diagnostic Tools displays some metrics when you are debugging your application.
- The timeline section indicates events and elapsed time during a debugging session.
- The memory section shows us real-time memory usage (the real one watching private bytes). We also have the ability to take a memory snapshot. The CPU section shows real-time CPU usage:

We can also view the content of the heap:

- Code lens:
Code lens is a new VS 2017 feature which gives us real-time indications about our code in references, unit tests, and code changes. These pieces of information appear above the method names:
-
- Passing the mouse over references, we can see information about where this method is called from:

-
- The second item shows who the last developer that updated this class was:

-
- The third one shows code changes and collaboration information:

- VS 2017 fixes errors for you:
With Visual Studio 2017, we fix coding errors on the fly while writing code:
-
- We can right-click and select Quick Actions... if the little bulb doesn't appear on the left side of our code:

-
- We right-click on the code highlighted in red:

The Quick Actions... menu offers a number of possible actions, depending on the context.
-
- It also offers some solutions to implement:
