Inside the "Quick Add Reference” extension
World of VS has just released the “Quick Add Reference” extension which should save you time and give you a much more nicer experience when coding with VS.
If you care about the details of how this little beautiful thing is implemented, here are some:
The extension ships with a cache of all types contained in the GAC plus some other non-GACed assemblies which are interesting enough as to have their types also cached. These are the assemblies that will be offered to you when you type in a type name that can be found there.
What about types that are not in our cache? Well, they won’t be offered in the smartag the very first time you type them. But once you’ve added the required assembly reference using the old way (“Add Reference” dialog) we will notice that fact (by listening to a VS “Reference Added” event) and we will grow our cache to include its types. Meaning, no more “Add Reference” dialog for any types in that assembly, ever.
As you can see, as you keep using this extension, it will “understand” more and more types and offer a more complete selection of possible assembly names, and eventually there will be zero or near-zero need to ever go to the “Add Reference” dialog.
We’re also smart enough to look into the framework version and framework profile being used to not offer you types that don’t make sense for the current project. So, if you’re coding a project that targets fx version 2.0 we won’t offer any fx 4.0 version types for example.
How to list (as in what order) the available assemblies where a type match is found is also an interesting question as for some very common type names, like, say, “Button” there maybe a dozen available assembly options… so we decided to list first the ones starting with “System.*”, followed by the ones starting with “Microsoft.*” and then the rest. This should help a quicker selection –most of the time- when a large list of available assemblies is shown.
Lastly, but no least, we’re augmenting a standard smart tag to display the possible assemblies to add. This means you can use either the mouse or the keyboard to quickly select this as you would do with other built-in options as the “Generate Class”, etc.
My favorite is way to use this extension is a quick “Ctrl+.” with the caret under the squiggle where VS is showing me the type is not recognized. That brings up the smarttag UI and from there I just have to press key-down one or a few times to choose what I want. Then ENTER and I’m done.
Usually this takes LESS TIME THAN FOR THE “ADD REFERENCE” DIALOG JUST TO SHOW UP, let alone, browse or search any references in there.
We really appreciate your feedback so if you have any (suggestions, bug reports, etc) please post them in the VS Gallery QA section or just email the WoVS Team if you feel like reaching the team directly.
Some of the stuff that is on our plate for a vnext is: VB support and project-references support. Let us know what *you* would like to see next.
Before I say goodbye, please vote here if you would like this feature to be built-in in the next version of Visual Studio.