VisualStudio 社区版2015和2017中缺少 CodeLens 引用计数

  1. VisualStudioCommunity 版本中缺少引用计数 (代码镜头)是否有原因?
  2. 是否可以在选项中启用它?

下面是 Visual Studio 2015和2017社区版的截图:

methods without code lens

下面是 Visual Studio 2013的截图:

methods with code lens

来源: Dailydotnettips.com

91193 次浏览

This isn't a generic reference counting feature, it's just one of the features of CodeLens. CodeLens is only available in Visual Studio 2015 Pro and above. In Visual Studio 2013 it was a Ultimate-only feature.

UPDATE

As others have noted, installing SSDT or SSMS 2016 may enable CodeLens as well. That's because VS 2015 Community is Pro, with a different license and some missing extensions like CodeLens. As long as an extension's binaries and settings are installed, Community will activate the extension.

UPDATE 2019

"CodeLens has been a feature found only in Visual Studio Enterprise, but that will change in an upcoming preview of Visual Studio 2019, when it will also be available for the Community edition, likely in 2019" What's New in Visual Studio 2019

I installed the latest SSDT preview for Visual Studio 2015 from the link below on 2 machines I have with VS 2015 Community edition (Update 1), and CodeLens started working for all my projects.

https://msdn.microsoft.com/en-us/library/mt204009.aspx

enter image description here

I have Visual Studio 2015 Community edition and it originally did NOT have CodeLens.

However, after going to Tools -> Extensions and Updates -> Product Updates and then downloading SSDT and installing all options within the SSDT package, my VS 2015 Community Edition now miraculously has access to CodeLens.

This feature has been disabled in Visual Studio Community 2017, although it sounds like it was temporarily available in pre-release versions.

The Visual Studio Team issued this statement on the 14th of March 2017:

An authoring error in the SQL Server Data Tools resulted in the capability temporarily showing up incorrectly in Visual Studio Community when installed; the change you see is a result of correcting that mistake.

Also, on the Compare Visual Studio 2017 Offerings page CodeLens appears to not be available in the Community edition.

I'm not allowed to Comment on R. Richards answer above, so posting this as a separate answer: CodeLens references disappeared for me too when I upgraded my VS Pro to 2017. But only on my Desktop ("same" upgrade behaved differently on my laptop, where CodeLens settings apparently unaffected). Anyway, very easy to resolve just Enable CodeLens under Text Editor : All Languages

An alternative is to just right-click the member and select 'Find All References' or the hot key shift + F12*. Not only you will find the count of references grouped by project, but also the underlying code lines and their classes.

* As per Visual Studio 2017 Community.

On the Tools tab choose Options.

In the open window choose like bellow, and then press ok. Example

Good Luck!!!