Visual Studio 2017: Display method references

C#Visual StudioVisual Studio-2017

C# Problem Overview


How can I display the references on top of a method declaration?
I looked for it in the Visual Studio properties, but could not find it.

C# Solutions


Solution 1 - C#

In Visual Studio Professional or Enterprise you can enable CodeLens by doing this:

Tools → Options → Text Editor → All Languages → CodeLens

This is not available in some Community Edition versions

Solution 2 - C#

For display references on the top of method you have to enabled the CodeLens option in Visual Studio Professional and Visual Studio Enterprise.

Use below steps to enabled it.

1. Go to Tools and then select Options :

enter image description here

2. Then Select Text Editor -> All Languages -> CodeLens

enter image description here

3. Click on check box to Enable Code Lens: enter image description here

Now you can see the references on the top of methods.

This will not work for VS - Community Edition.

Solution 3 - C#

No luck with Code lens in Community editions.

Press Shift + F12 to find all references.

Solution 4 - C#

CodeLens is not available in the Community editions. You need Professional or higher to switch it on.

In VS2015, one way to "get" CodeLens was to install the SQL Server Developer Tools (SSDT) but I believe this has been rectified in VS2017.

Still you can get all method reference by right clicking on the method and "Find All references"

enter image description here

Solution 5 - C#

For anyone who looks at this today after 2 years, Visual Studio 2019 (Community edition as well) shows the references

Solution 6 - C#

In previous posts I have read that this feature is available on VS 2015 community if you first install SQL Server express (free) and then install VS. I have tried it and it worked.

I just had to reinstall Windows and am going through the same procedure now and it did not work, so I will try again. I know it worked 6 months ago when I tried.

Solution 7 - C#

For anyone who is looking to enable this on the Mac version, it is not available. Developers of Visual Studio stated they will include it in their roadmap.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionFADI1987View Question on Stackoverflow
Solution 1 - C#ISHIDAView Answer on Stackoverflow
Solution 2 - C#Laxman GiteView Answer on Stackoverflow
Solution 3 - C#Janis S.View Answer on Stackoverflow
Solution 4 - C#Muhammed AfsalView Answer on Stackoverflow
Solution 5 - C#KavoView Answer on Stackoverflow
Solution 6 - C#Ed LandauView Answer on Stackoverflow
Solution 7 - C#VetukaView Answer on Stackoverflow