14

I'm currently writing a tool to help maintain unit and integration tests (coded tests). I've started extending Visual Studio to make the developer experience nicer, which got me to notice the new-ish CodeLens feature.

The stuff I'm currently showing as a tooltip should probably actually be part of the CodeLens info.

Question: Does anyone know how to extend CodeLens in Visual Studio?

Thanks.

MetaFight
  • 1,295
  • 14
  • 30
  • It is not currently supported. I suggest you request it on the VS User Voice site (and/or send-a-frown inside vs) http://visualstudio.uservoice.com/forums/121579-visual-studio – John Gardner Jan 11 '14 at 00:11
  • 2
    Vote here http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/6518006-expose-an-api-to-be-able-to-extend-or-take-advanta – Andrii Jul 21 '15 at 22:08
  • Cheers. I'm pretty sure I already voted on that, but it's good to have the link here. – MetaFight Jul 21 '15 at 22:10
  • It seems there are (at least) two suggestions regarding this topic - [this one](http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/5743423-provide-an-open-api-to-allow-us-to-extend-code-len) has more upvotes. – CodeFox Oct 21 '15 at 16:05
  • Fortunately both user voice topics were merged last week (so _both_ links above are now targeting the _same_ topic). :-) – CodeFox Oct 26 '15 at 04:14
  • You could decompile "Microsoft CodeLens Code Health Indicator" to see, how the API could be used. – mbx Nov 09 '16 at 13:35

3 Answers3

5

As @RichardBanks says, officially CodeLens is not extensible. Technically I think it may be possible at the moment. Look for *CodeSense*.dll in the visual studio directory for hints. There is no documentation at present and the API can still change going forward.

I suggest you'd venture into this for research purpose only, distributing any 'plugin' seems like a very bad idea until Microsoft opens up the API, which they probably will.

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
5

CodeLens is officially extensible since Visual Studio 2019 was released.

CodeLens for Everyone

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. CodeLens shows the number of references a type or method has, information about unit tests covering the method, and data directly from Application Insights.

In addition, Microsoft has made CodeLens fully extensible1, so third-party extensions can start to add their own experiences on top of it. CodeLens makes key information about your types easy to find, while keeping you in the source code. Lenses for source control history and IntelliTrace are still an Enterprise-only feature.

Looks like this is the best place to start looking at when implementing your own CodeLens extension.


1. Highlight mine.

Community
  • 1
  • 1
4

Code Lens is not currently extensible.

I can't say for sure, but I think there are still some features the team wants to add before they open it up for extension (e.g. git support).

Richard Banks
  • 12,456
  • 3
  • 46
  • 62