Visual Studio 2013 CodeLens – Inline Method Info

Posted: June 27, 2013 in Visual Studio

CodeLens gives us a quick overview of each of our methods, including what other methods reference this one, who modified the method last, and what changes they made, and also the unit tests we have that use the method.

CodeLens is available on every method, and is automatically added to new methods. CodeLens appears to take up a line in the code editor just above the method name, however it doesn’t actually consume a line in the document, so you won’t be able to accidently arrow up onto that line for example, and it won’t mess up line numbering.

  • References – Displays a count of methods that make a call to the selected method. Click on this to display the list of referring methods, and select one to navigate directly to the method.
  • Unit Tests – Displays a total of passed unit tests out of total unit tests for the selected method. If there are any failed unit tests, a red ‘x’ will appear beside it so you can easily identify that this method may be causing a unit test to fail. Click on this to see the list of unit tests for the method, and which one(s) failed if applicable. You can also click on one of the unit tests to navigate directly to the definition.
  • Last Modified By – Displays the name of the person who last touched this method. This requires TFS 2013 source control. Click on the name to view the change set they checked in when modifying this method, and when the changes were done.
  • Changes – Displays a count of the number of changes made to the current method by the last modified by. Clicking on this opens a comparison window which shows exactly what changes were made to the method.

There is also an option to send an email to the person who last modified the method, which automatically generates a hyperlink to a portable view comparing their changes, which does not require Visual Studio to open. This can be useful if you are reviewing code and need to ask someone about recent changes.

When writing new unit tests, your CodeLens’s will automatically update when you build your solution, so you will immediately be able to see if your unit tests have failed when viewing the CodeLens for a method.

  1. Holger says:

    Thanks for this brief summary.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s