CodeLens in Visual Studio 2013

    Visual Studio 2013 introduced many new features. You can familiarize with some of them from articles on a habr . Some of these features have been long awaited by the community, and in general they do not bring anything new to the functionality of the environment, they just make it a little more convenient, such as an options window, the size of which can be changed. But there are also opportunities that, 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 in a concise form directly in the program text show important information that will then come in handy when working with 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 configure the display of these indicators through the settings of the main environment Tools > Options > Text Editor > All Languages > Code Information Indicators .

    Visual Studio 2013 Ultimate comes with 8 indicators:

    1. Test Status - displays the status of the unit test for the function
    2. References - displays the number of links to the function in other sections of the code. How many times this function is called.
    3. Tested By - displays specific unit tests in the indicator window that test this function
    4. Authors - Displays the author of the changes in the code.
    5. Changes - displays links to the latest changes in the code
    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 related to the type of indicator.
    You can call up a window of detailed information for each indicator simply by clicking on it with the mouse or by pressing the Alt- {indicator number} keys at the same time. Some of the indicators have many additional features.

    Code Link Indicator

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

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

    Indicators of code blame 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 history of changes: The

    number of changes that affect the current section of code in the current brunch can be displayed by pressing the Alt +5 key :

    Please note that the indicator has a + sign. This means that the current version is “behind” the version that is already on the version control server, and it is quite likely that you will have to resort to the merging of changes (merging).
    In the same indicator window, you can compare the current version of the file with the selected one:

    Thus, in advance to find out about potential conflicts.

    Indicators of links with bugs, tasks and other work items

    Any change in code (changeset) can be associated with work items in Team Foundation Server. The indicators of bugs and work items display the number of such links, and when the indicator window is called up, they allow you to quickly jump to information in the work item.

    Example links with bugs:

    Example links with tasks:

    Test indicators

    Unit tests that check the current function are displayed in the 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 details window, you can quickly get to the place where the test was defined:

    In addition, an additional indicator appears on the test itself, which displays detailed information about test results:

    Lync Integration

    If your organization uses Lync, then in addition to the above functions, you also have a status icon. This allows you to quickly contact the author of the changes in the code or the owner of the task to quickly resolve any issues:

    Empowering Indicators

    It is likely that additional indicators will soon appear that will expand the current capabilities of Visual Studio 2013 Ultimate.
    The first one can already be installed from the Visual Studio Gallery website . This additional indicator shows “code cleanliness” by counting code parameters recognized in the development industry, such as Maintanability Index , Lines of Code , Cyclomatic Complexity and Halstead Volume .


    We hope that many developers will like CodeLens technology and 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.

    Also popular now: