CodeLens in Visual Studio 2013

Roshan Mehta, 29 June 2013

With the release of Visual Studio 2013 come two great new features – CodeLens and CodeMap. Both features solve common problems encountered by developers on a day to day basis and greatly improve productivity when building solutions using Visual Studio. These features are available in the preview release of Visual Studio 2013 for public download.

CodeLens in Visual Studio 2013 appears above a method and allows developers to quickly view all references to a piece of code. This is useful when asking the question “what could possibly break if I was to make a code change here?”
There is no need to work with the test explorer as CodeLens also displays the total number of unit tests for the method and the number of passing tests. A red icon is displayed if there are failed unit tests. When you run unit tests from CodeLens, Visual Studio will run tests for the selected method before running other unit tests.

I will definitely be making use of the CodeLens feature when I switch over to Visual Studio 2013!

CodeLens in Visual Studio 2013

Another feature of CodeLens is that it displays who made the last modifications to the method before you started working on it. When you click on the person’s name, CodeLens displays a list of the most recent changes that were made by that developer. Clicking on the person’s name opens a new e-mail message with a link to a preview version of the change set, meaning that the developer doesn’t need to be working within Visual Studio to see it.

CodeLens in Visual Studio 2013

Hitting F6 will automatically build, discover, and run unit tests then provide an indicator of the test results on the CodeLens panel.

When defining new methods in your code, the CodeLens indicator panel appears automatically once you press ENTER after defining the method signature. Navigating through lines of code using the UP or DOWN arrow skips over the indicator panel so you don’t have to worry about CodeLens getting in your way.

Developers can make use of useful shortcuts with CodeLens. Numbers will appear above each indicator when you press and hold the ALT key. You can then press any of the number keys on your keyboard to execute the indicator, or press ESC to go back to the editor.

CodeLens in Visual Studio 2013

I will definitely be making use of the CodeLens feature when I switch over to Visual Studio 2013!