Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extend CodeLens

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.

like image 246
MetaFight Avatar asked Jan 09 '14 22:01

MetaFight


2 Answers

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.

like image 84
jessehouwing Avatar answered Nov 20 '22 22:11

jessehouwing


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.

like image 5
Yitzhak Steinmetz Avatar answered Nov 20 '22 23:11

Yitzhak Steinmetz