How to extend CodeLens - visual-studio

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.

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.

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.

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).

Related

Visual Studio Add-in: How to get selected items in window

Let a "Breakpoints" window (by default opened by Debug>Windows>Breakpoints [ctrl+B, D]) serve as an example. Basically I select few breakpoints in it and I would like to know in my add-in which elements in this window are selected. I am aware that I can get collection of breakpoints in project but I would like to know what elements are selected in "Breakpoints" window.
"Is it possible to get selected items in window or even access its content at all?"
Also I am not sure whenever or not should I post a separate question for this but is there actually a way to capture user activity in IDE like for example capturing an event when user sets (adds) a breakpoint?
Originally I also asked if is it possible to achieve certain things in Visual Studio Express Edition. But this part is irrevelant.
Conclusion:
(after reading jessehouwing's answer)
I guess it is not possible using an Add-ins. Use VSPackages isntead. Also Add-ins are deprecated as of Visual Studio 2013 version.
As mentioned in my comments, what you're trying to accomplish is explicitly prohibited in the Visual Studio Express edition and is a violation of it's license. To extend the product, you need to have at least Visual Studio Professional Edition. many of the extensibility points will actively refuse any communication with 3rd party add-ins.
Almost all the things you're asking are possible using Visual Studio Extensibility once you've installed the professional edition. Products like OzCode show that almost everything is possible. Remember that most features inside visual studio are themselves extensions of the product.
Your question, indeed a whole list of questions, is indeed not the way to ask something on StackOverflow. I can give you some pointers to the documentation, which you've probably already found, and maybe to some open source products that themselves extend parts of Visual Studio that can serve as examples, but from there you'll have to piece something together until you're able to ask more specific questions.
Events you can subscribe to, the breakpoints are a CommandEvents I suspect.
Manipulating windows inside Visual Studio
Projects that extend the debugger that might serve as an example:
PyTools (debugger for Python inside Visual Studio)
Node.js tools for Visual studio (extending the Immediate Window)
But there is no easy answer to your question that fits inside this window. I'd suggest you use a tool like Reflector to look at how Microsoft accomplishes certain things (most of Visual Studio Extensibility is written in .NET anyways) and to look at open source projects that extend visual studio behavior. There are quite a few out there on Codeplex.
I'm not entirely sure what you're trying to accomplish and how it's different from the Breakpoints features inside Visual Studio Professional and up.
I suggest you ask your question in the Visual Studio Extensibility forums over on MSDN, which is in a collaborative forum format, instead of a Q&A format, allowing people to answer your question bit by bit.

Visual Studio Find All Not Referenced

In Visual Studio is there an automatic way to search over file(s) and find all classes/properties/methods that aren't referenced. Essentially abandoned code.
I don't want to manually have to right click on each and select "Find All References"
This is not a feature of Visual Studio in the current version. Using Roslyn you could code and Inspector yourself, but Roslyn doesn't offer one out of the box either at the moment. The walk-through on Semantic analysis should get you started. The roslyn forum is a good place to seek help or find examples, and there's a well monitored tag on StackOverflow as well of course.
Productivity plugins like Resharper and Code Rush offer this for sure. There are other similar tools that might have this feature JustCode, VisualAssist, CodeItRight are likely candidates.
You can also use something like Visual NDepend to detect unused methods. Their new command Linq to Code features should make it relatively easy to build a commandline tool that fishes out all unused calls.
A bit late but if you install SSDT (Sql Server Data Tools) this also add grayed reference count to each method in visual studio.
Note: This is actually "code lens" which is no longer available for VS2015. Installing the SSDT is the way you can have "code lens" in VS2015.

"Scope Highlight" feature in Visual Studio? (same as seen in BlueJ for java)

I would like to know (as I've failed so far in finding such a feature in the VS's options),
if there is a feature which allow for scope highlighting same as seen in the BlueJ IDE for java,
here is an example:
Note how the code blocks are all highlighted with color,
when learning java using blueJ i found it to be extremely easy on the eye when looking at code,
and everything felt a lot more organized,
moving to C# and working on MS visual studio, its all text with some highlighting, Class names, keywords etc etc,
but in general it still feel like a black text on a white background and lacking that organized feeling i sorely miss from blueJ,
i noticed there is a similar question here referring to eclipse,
Eclipse IDE Scope Highlighting?
just to be on the safe side, ill ask again referring to Visual studio,
is there such a feature in VS? is there an add-on \ plugin for VS which allows it?
Thanks in advance for your answer.
Microsoft provides a free Productivity Power Tools extension for Visual Studio 2013 and 2015. This has a "Structure Visualizer" feature similar to the CodeRush plugin. Both are more subtle than the BlueJ style, but should make scopes a little clearer.
Productivity Power Tools 2013
Productivity Power Tools 2015
Update
Visual Studio 2017 integrated a version of this into the core application for C#, Visual Basic, F#, and XAML (as Structure Guide Lines). However, C++ still requires an extension.
Look at the DevExpress CodeRush plugin, there is a 30-day trial version.
The function it provides is called "Structural highlighting", and I think its even better than what you want (and its customizable).
CodeRush Express
CodeRush Documentation

Favourite Features of VS 2010

With the general public release of Visual Studio 2010 Beta 2 today, this latest version has created a lot of hype and interest.
Indeed, the opinion I've gauged is that VS 2010 has resolved a great deal of the minor flaws left over from previous versions, as well as added some particularly useful new code editor and project development tools (in particular the Premium/Ultimate versions).
My question here is: what are you favourite new features in VS 2010 that have really got you excited? Or similarly, what are the flaws of VS 2008 that you are most glad to have resolved?
There is a wealth of changes in VS 2010, of course, but these are some of the ones that have interested me most (about which I know!).
Integrated support for F# (with multi-targeting for .NET 2.0 - 4.0)/
Much improved WPF designer. The VS 2008 was more than a bit buggy at times.
Great improvements to the code editor, such as call hierarchy viewing.
A decent add-in framework.
A greatly expanded testing framework (now capable of database testing, for example) in Premium/Ultimate.
Project planning and modelling features in Premium/Ultimate.
If I could request one point/feature per post, I think that would be best, so we could vote them individually.
Visual Studio 2010's true Multi-Monitor Support sounds pretty fantastic.
The feature I'm most looking forward to having a decent play with is actually more .net 4 than visual studio. Parallel Extensions looks like it will be very interesting.
The new, clean web.config should make my managers happy.
"Just change the option in the web.config"
"Where is it?"
"Under 'AppSettings.'"
"Ugh ... there's so much junk in that file."
The built in profiler and historical debugger!
The 'Navigate To' window (Ctrl+,) is fantastic. Eclipse has something similar, and I've always thought Visual Studio needed it. Now if they would just add a 'Collapse All' button to the Solution Explorer...
One-click web publishing will be handy.
Favorite feature? Requiring 4 gigs of RAM to run it's bloat.
I liked many features
Deployment
Gated checkin
Parallel Programming
Faster debugging
Separate debugger for x86 and x64
These are just few.... The more you explore VS2010 the more you will get. Try to go through the videos by microsoft.
Thanks,
Sunil Agarwal

Recommended add-ons/plugins for Microsoft Visual Studio [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Can anyone recommend any good add-ons or plugins for Microsoft Visual Studio?
Freebies are preferred, but if it is worth the cost then that's fine.
SmartPaster - (FREE) Copy/Paste code generator for strings
AnkhSvn - (FREE) SVN Source Control Integration for VS.NET
VisualSVN Server - (FREE) Source Control
ReSharper - IDE enhancement that helps with refactoring and productivity
CodeRush - Code gen macros on steroids
Refactor - Code refactoring aid
CodeMaid (FREE) - Code cleanup, organization and complexity analysis
CodeSmith - Code Generator
GhostDoc - (FREE) Simple code commenting tool
DXCore (FREE) and its many awesome plugins: DxCore Community Plugins, CR_Documentor, CodeStyleEnforcer, RedGreen
TestDriven.Net - (FREE/PAY) Unit Testing Aid
Reflector - (PAY) Feature rich .Net Disassembler Reflector AddIn's
Web Deployment Projects - Provides additional functionality to build and deploy Web sites and Web applications (source).
StudioTools - (FREE) Navigation assistant, code metrics tool, incremental search, file explorer in visual studio and tear off editor windows. Moved from old site (archive.org) to new site and discontinued.
Not free, but ReSharper is definitely one recommendation.
Whole Tomato's Visual Assist X. I absolutely swear by it. I would like to see a better plug in for Lint than Visual Lint by Riverblade, but since that will eventually be moved onto the build server I don't mind running it every couple of days manually.
PowerCommands is a Microsoft-created plugin that offers a variety of new features that one would think probably should have been in Visual Studio in the first place.
These include
Copying/Pasting project references!
"Open Containing Folder" to jump straight to the hard-drive location of a file or project
Automatic reorganizig and sorting of using statements
"Open Command Prompt Here" to open a command prompt in any of your project folders.
Collapse Projects
RockScroll is awesome, and free.
Addendum
As #Andrei points out, MetalScroll is a better alternative. It's Open Source, and corrects some annoying things about RS.
I'm a big fan of CodeRush and Refactor! Pro by DevExpress. I've been using them for a number of years, and without a doubt it makes me a faster developer. Also, both are built on a free framework called DXCore that allows you to develop your own plug-ins for Visual Studio, and the sky is the limit there...
Resharper
Resharper MbUnit Test Runner Add-On
SQL Prompt for Database Projects (works inside your SQL Management Studio as well)
Ankh SVN 2.0+ for free SVN support (v1.x pales in comparison)
TeamCity plug-in to monitor your builds, personal builds, and bug tracking
I find Ghost Doc to be very useful.
GhostDoc is a free add-in for Visual Studio that automatically generates XML
documentation comments for C#. Either by using existing documentation inherited
from base classes or implemented interfaces, or by deducing comments from
name and type of e.g. methods, properties or parameters.
If you use SVN for source control, definitely get VisualSVN. It enables TortoiseSVN interactions from within the Visual Studio IDE.
I also echo the Resharper comment. Retail price is a little steep, but if you're a student or otherwise educationally affiliated, it's actually pretty cheap.
+1 Visual Assist.
It's unfortunate that you need a plugin to get really good intellisense but it's definitely worth paying for.
LinqPad is great for testing linq to objects/xml/sql. Free download.
What about IncrediBuild? This is a nice distributed build system with visual studio integration.
Clipboard Manager
Maintains your clipboard data through removal of lines, a few other nice items but that one alone makes me happy.
Regionerate
While some have problems with regions I think if you use them, this tool is for you. Automatically region'izes your code into appropriate region blocks. Fully configurable for custom items etc.
VSCommands 2010
from the website:
Latest version supports:
Manage Reference Paths
Prevent accidental Drag & Drop in Solution Explorer
Prevent accidental linked file delete
Apply Fix (automatically fix build errors/warnings)
Open PowerShell
Show Assembly Details
Create Code Contract
Cancel Build when first project fails
Debug Output - custom formatting
Build Output - custom formatting
Search Output - custom formatting
Configure WPF Rendering
Configure Fusion Logs
Configure IE for debugging
Locate Source File
Thumbnails in IDE Navigator
Extended support for xaml, aspx, css, js and html files
Disable Ctrl + Mouse Wheel Zoom
Zoom to Mouse Pointer
Configurability
Attach to local IIS
Copy Full Path
Build Startup Projects
Open Command Prompt
Search Online
Build Statistics
Group linked items
Copy/Paste Reference
Copy/Paste as Link
Collapse Solution
Group items directly from user interface (DependantUpon)
Open In Expression Blend
Locate in Solution
Edit Project File
Edit Solution File
Show All Files
and others, so try it now!
http://trolltech.com/products/qt/">Qt Cross-Platform Application Framework
Qt is a cross-platform application framework for desktop and embedded development. It includes an intuitive API and a rich C++ class library, integrated tools for GUI development and internationalization, and support for Java™ and C++ development
They have a plug-in for Visual Studio that costs a bit of money, but it is worth every penny.
I've been using Visual Assist X for nearly two years now, and I find it so useful I can honestly say that if my employer didn't provide it, I'd have to pay for it myself.
I also use Cool Commands and SlickEdit (the free version), whose File Explorer and Command Spy tools are quite useful.
+1 for Visual Assist
And I will add VLH (Visual Local History) which provides a kind of local source control system. Every time you save a file, the plugin add a copy in the local repository.
ViEmu
vi/vim support inside VS
I found this site called Visual Studio Gallery - it has a lot of visual studio add-ins. I'm browsing it right now and I recommend everyone to visit it.
Consolas font
Free font from MS designed for reading code.
Try MetalScroll!! It's better than Rockscroll
Sonic File Finder for when you have loads of files in your solutions and searching for them in the solution explorer becomes a pain in the wrist.
You might also find DPack interesting. Several tools and enhancements rolled into one neat package.
MZTools is great too.
+1 for CodeRush & Refactor Pro. I've been using CodeRush since its Delphi incarnations, and it's utterly wonderful. The mantra of "Code at the speed of thought" is very close to reality ;)
Microsoft StyleCop provides code style checking for C#, we use it all the time and love it (free)
Axialis IconWorkshop has a Visual Studio add-in which is now free for VS2008 users.
Resharper Yes another vote, because I can't upvote everyone who suggests it :)
Workspace Whiz for C++, I used to live by Workspace Whiz but haven't used it in VS2008 as I hadn't realised there was an update. Will have to give it a try again.
If you're doing C++ coding, hands down Visual Assist.
I love CopySourceAsToHTML as a cool little addin. It's great if you want to copy code blocks for blogging and the like while maintaining your syntax formatting.
I think this is still the url.. you have to do some manual work to set it up with 08.
http://www.jtleigh.com/people/colin/software/CopySourceAsHtml/
For the laptop bound or for those with vi/vim key bindings burned into the brain I would recommend ViEmu.
If you have not tried editing with vi key bindings here is why you may want to try "Why, oh WHY, do those #?#! nutheads use vi?"
AtomineerUtils Pro Documentation - automatic DocXml/Doxygen/JavaDoc/Qt doc-comment generation/updating (similar to GhostDoc, but more powerful & flexible, and supports C#, C++, C++/CLI, C, Java and Visual Basic code).
The style of the generated comments is very configurable, and automatic re-formatting (such as whitespace control and word wrapping) can be optionally applied to keep the comments as readable as possible. It also has many helpers to allow users to read and convert most legacy doc-comments into any of the above formats.
(I'm the author, but I believe the above is an accurate and objective description. This add-in was free when this answer was first added, but to cover the costs of hosting, supporting, and continuing to improve the addin in monthly releases, it is now $10 with a 30-day free trial)
I'm always amazed that more people don't know about/use NDepend - it shows all dependencies at every level of your code, and will even draw pretty box and arrow pictures showing how confused your architecture really is :) Together with TestDriven.Net, I can't imagine working without it any more. Free/cheap.

Resources