Understanding CodeLens
CodeLens is a powerful set of tools that is useful for finding references in code, identifying relationships between your different components, seeing the history of changes in the code, related bugs, code reviews, and unit tests, and so on.
In this section, we will analyze the most important tools of this feature. Let’s start by seeing how we can find references in our code.
Note
You can check if CodeLens is enabled by going to Tools | Options | Text Editor | All Languages | CodeLens, where you can see if the Enable CodeLens option is selected or not.
Finding references in code
CodeLens is presented in our code files from the first time we use VS. We can check this by going to any class, method, or property and verifying that a sentence appears, indicating the number of references in the project about it. In Figure 5.2, we can see that we have opened the WeatherForecastController.cs
file, which shows us that three references have been found...