Find code changes and other history with CodeLens
Stay focused on your work while you find out what happened to your code - without leaving the editor (requires Visual Studio Ultimate). Find references and changes to your code, linked bugs, work items, code reviews, and unit tests.
Contact your team about these changes without leaving the editor:
To choose which indicators that you want to see, go to Tools, Options, Text Editor, All Languages, CodeLens.
You'll need:
-
Visual Studio Ultimate
-
Visual C# .NET or Visual Basic .NET code
-
The most recent Visual Studio 2013 update so that you can work with solutions that share code across multiple apps
-
Choose the references indicator (Alt + 2):
When you have 0 references, you have no references from Visual C# or Visual Basic code. This doesn't include references from other items, like XAML and ASPX files.
-
To view the referencing code, move your mouse on top of the reference or double-click it:
-
To see relationships between this code and its references, create a code map.
Review your code's history to find out what happened to your code. Or, review changes before they're merged into your code, so you can better understand how changes in other branches might affect your code.
You'll need:
-
Visual Studio Ultimate
-
Team Foundation Server (same version) or Visual Studio Online
-
Visual C# .NET or Visual Basic .NET code that's checked into Team Foundation Server or Visual Studio Online using Team Foundation version control (TFVC) or Git. If your Git repository is hosted in TfGit, then you can also find links to TFS work items.
-
The most recent Visual Studio 2013 update so that you can also find changes in other branches and work with solutions that share code across multiple apps
-
Lync 2013, Lync Basic 2013, or Lync 2010 to contact your team from the editor
Find who changed your code (Alt + 4) either in Team Foundation version control (TFVC):
Or in Git where you can also see when changes were last made.
To get more details about a change, right-click that item, then click View Details. Those details appear in Team Explorer.
Suppose your team has multiple branches - a main branch and a child development - to reduce the risk of breaking stable code:
Find how many changes were made to your code (Alt + 6) in your main branch:
Or how many people changed your code (Alt + 4):
If a plus sign (+) and another number appear next to the changes indicator or authors indicator, then your code has more recent changes in your current branch of TFS.
|
Icon |
Where did the change come from? |
|---|---|
|
The current branch |
|
The parent branch |
|
A child branch |
|
A peer branch |
|
A branch further away than a parent, child, or peer |
|
A merge from the parent branch to a child branch |
|
A merge from a child branch to the parent branch |
|
A merge from an unrelated branch (baseless merge) |
Find out more about unit tests that exist for your code without opening Test Explorer. You'll need:
-
Visual Studio Ultimate
-
Visual C# .NET or Visual Basic .NET code
-
A unit test project that has unit tests for your application code
-
The most recent Visual Studio 2013 update so that you can find changes in other branches and work with solutions that share code across multiple apps
-
Go to application code that has unit tests.
-
Review the tests for that code (Alt + 3).
-
If you see a warning icon
, run the tests.
-
To review a test's definition, double-click the test.
-
Review the test’s results. Choose the test status indicator (
or
), or press Alt + 1.
-
To see how many people changed this test, who changed this test, or how many changes were made to this test, find the code's history.
A: CodeLens appears only in Visual C# .NET and Visual Basic .NET code at the method, class, indexer, and property level.
-
Make sure CodeLens is turned on. Go to Tools, Options, Text Editor, All Languages, CodeLens.
-
If your code is stored in TFS, make sure that code indexing is turned on by using the CodeIndex command with the TFS Config command.
-
TFS-related indicators appear only when work items are linked to the code and when you have permissions to open linked work items. Confirm that you have team member permissions.
-
Unit test indicators don't appear when application code doesn't have unit tests. Test status indicators appear automatically in test projects. If you know that your application code has unit tests, but the test indicators don't appear, try building the solution (Ctrl + Shift + B).
A: This might happen because CodeLens can't find the work items in TFS. Check that you're connected to the team project that has those work items and that you have permissions to see those work items. This might also happen if the commit description has incorrect information about the work item IDs in TFS.
A: They don't appear if you're not signed into Lync, don't have it installed, or don't have a supported Lync configuration. But you can still send mail:
Which Lync configurations are supported?
-
Lync 2013 (32-bit or 64-bit), either alone or with Office 2013
-
Lync Basic 2013 alone (32-bit or 64-bit, but not with Windows 8.1)
-
Lync 2010 alone (32-bit or 64-bit)
CodeLens doesn't support having different versions of Lync installed. Lync might not be localized for all localized versions of Visual Studio.
A: Go to Tools, Options, Environment, Fonts and Colors.
To use the keyboard:
-
Press Alt + T + O to open the Options box.
-
Press Up Arrow or Down Arrow to go to the Environment node, then press Left Arrow to expand the node.
-
Press Down Arrow to go to Fonts and Colors.
-
Press TAB to go to the Show settings for list, and then press Down Arrow to select CodeLens.
A: This depends on the indicator:
-
References: This indicator updates automatically when the code changes. If you have this indicator docked as a separate window, refresh the indicator manually here:
-
Team: Refresh these indicators manually here:
-
Test: Run all the tests or specific tests to refresh this indicator.
A: Yes, if your code is in TFS, use the CodeIndex command with the TFS Config command.
to dock CodeLens as a window.