How to extend CodeLens
Asked Answered
G

3

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.

Gave answered 9/1, 2014 at 22:2 Comment(6)
It is not currently supported. I suggest you request it on the VS User Voice site (and/or send-a-frown inside vs) visualstudio.uservoice.com/forums/121579-visual-studioCaird
Vote here visualstudio.uservoice.com/forums/121579-visual-studio/…Quinate
Cheers. I'm pretty sure I already voted on that, but it's good to have the link here.Gave
It seems there are (at least) two suggestions regarding this topic - this one has more upvotes.Higgs
Fortunately both user voice topics were merged last week (so both links above are now targeting the same topic). :-)Higgs
You could decompile "Microsoft CodeLens Code Health Indicator" to see, how the API could be used.Universalism
F
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.

Folacin answered 9/1, 2014 at 22:52 Comment(3)
Thank your for the hint on the *CodeSense*.dll assemblies!Higgs
After 3-4 years it is still not possible in VS2017?Cryology
No change. And the people who originally created code lens have moved to New positions or left Microsoft.Folacin
A
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.

Atalanta answered 20/4, 2020 at 11:27 Comment(0)
L
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).

Loftin answered 9/1, 2014 at 22:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.