⬆️ ⬇️

CodeLens in Visual Studio 2013

In Visual Studio 2013 there are a lot of new features. With some of them you can read from articles on Habré . Some of these features were long awaited by the community, and in general, they do not introduce anything new into the functionality of the environment, they just make it a bit more convenient, such as the options window, which can be resized. But there are also opportunities about which, as soon as you look at them, you immediately want to exclaim "Cool!".

We are talking about CodeLens - information indicators that are displayed in the code and can show in the concise form directly in the program text important information which is then useful when working with the application code.



So what is CodeLens?



As already mentioned, CodeLens are indicators that work directly in the code:





By default, they are included in the environment for VB.NET and C # projects. You can customize the display of these indicators through the settings of the main environment Tools > Options > Text Editor > All Languages > Code Information Indicators .





The delivery package of Visual Studio 2013 Ultimate includes 8 indicators:

')

  1. Test Status - displays the unit test status for the function.
  2. References - displays the number of links to the function in other parts of the code. How many times this function is called.
  3. Tested By - displays specific unit tests in the indicator window that check this function.
  4. Authors - displays the author of changes in the code
  5. Changes - displays links to recent code changes.
  6. Bugs - the number of bugs associated with this feature in Team Foundation Server
  7. Work Items - work items (tasks, bugs) that are associated with this function
  8. Code Review - displays feature reviews


Indicators not only show some information, but also provide an opportunity to learn in more detail the necessary information associated with the type of indicator.

You can bring up a detailed information window for each indicator simply by clicking on it with the mouse or by simultaneously pressing the Alt- {indicator number} keys. Some of the indicators have a lot of additional features.



Code Link Indicator



Shows the number of references to a function or type. If you open the indicator window, then information about the functions that cause the current code will also be displayed:





This indicator is convenient to use paired with the ability to build a map of code dependencies. Just click on the Show on Code Map link and in the additional window you will see a visual representation of the code dependencies:





Indicators of code authorship and recent changes



This indicator displays the last author of the code if the project is placed in the version control system. In addition, this indicator can display the change history:





The number of changes that affect the current code segment in the current branch can be displayed by pressing the Alt +5 key:





Please note that the indicator has a + sign. This means that the current version “lags behind” the one that is already on the version control server, and it is likely that you will have to resort to the merge of changes (merging).

In the same indicator window you can compare the current version of the file with the selected one:





Thereby to learn in advance about potential conflicts.



Indicators of connections with bugs, tasks and other work items



Any change to the code can be associated with work items in Team Foundation Server. Indicators of bugs and work items display the number of such links, and when you call the indicator window, you can quickly access information in the work item.



Example of links to bugs:



Example of links to tasks:





Test Indicators



Unit tests that check the current function are displayed in test indicators. The number of successful and unsuccessful tests is displayed, as well as additional information in the indicator window with links to those tests that checked this function:





From the detail window, you can quickly get to the place where the test is defined:





At the same time, the test itself has an additional indicator that displays detailed information on the test results:





Lync integration



If your organization uses Lync, then in addition to the functions listed above, you also receive a status icon. This allows you to quickly contact the author of changes in the code or the owner of the problem for a quick solution to any questions:





Empowering Indicators



It is likely that additional indicators will soon appear that will expand the current capabilities of Visual Studio 2013 Ultimate.

The first of them can already be installed from the site of Visual Studio Gallery . This additional indicator shows the “purity of the code” by counting parameters of the code recognized in the development industry, such as Maintanability Index , Lines of Code , Cyclomatic Complexity and Halstead Volume .







Conclusion



We hope that CodeLens technology will appeal to many developers, and will make their work even easier. We remind you that you can download Visual Studio 2013 Ultimate from the Microsoft website and try new features today.

Source: https://habr.com/ru/post/198028/



All Articles