Code Analyzers in Visual Studio 2015

Code Analyzers in Visual Studio 2015

Introduction

This is the continuation article of Diving into Visual Studio 2015 series. In first article of the series we learnt about Visual Studio’s capability of code suggestions and code optimizations. You can read more about code suggestion in Day #1. In this article we’ll cover another interesting and very useful feature of Visual Studio 2015 i.e. Live Static Code Analysis. The feature’s name in itself is self-explanatory. Visual Studio provides a power to a developer to know about the optimization techniques as well as compile time errors while coding itself i.e. a developer is not supposed to compile the code again and again to know about compile time errors or code optimizations, he can view all of these on the fly while coding and fix it then and there. Let’s cover the topic in detail with practical examples.

 Live Static Code Analysis

Live Static Code Analysis is not a sentence or a phrase, each and every word has a unique meaning that adds value to the overall feature. Live means you can get the code analysis on the fly while you type your code. You get a real time code check facility without even compiling the code explicitly. Static means analyzing the code when it is not in running state. This feature is intended to save a lot of development time while coding. The code is checked through pre-defined analyzers while you type and you don’t have to build/compile the application again and again. Moreover these analyzers apart from just showing errors also provide certain warning or suggestive messages while coding that improves a developer’s coding skills and enable him to follow best coding practices. These in built analyzers work on specific set of rules, and the code when written is validated while typing against these rules.

Analyzers can be availed via Nuget Packages installed in Visual Studio. There are numerous analyzers available in Visual Studio 2015. In earlier versions of Visual Studio there were a very few of them available, but now you can get analyzers for each and every approach that you use in Visual Studio for development. There are analyzers available for Azure, Unit tests, Exception handling, Mocks, ORM etc. You can choose analyzers as per your need.

The best thing that this feature provides is that one can build our own analyzer against the type of code we want.This means we can define our own set of rules for coding, and these rules will be invoked against the live code that you or any other developer is writing. The rules may include warnings, errors, suggestions, automated code fixes etc.Let us see by some examples on how we can leverage this capability. Continue Reading...

To view or add a comment, sign in

More articles by Akhil Mittal

Others also viewed

Explore content categories