It’s a Bird… it’s a Plane… No it’s the WoVS DevStore!!

Make sure you don’t miss the Announcing the DevStore! post.

Quick and easy buying of extensions for making you more productive inside Visual Studio.

If you’ve already given your iPhone or Android device some love, there is no excuse to share some of that love with your Visual Studio too!

The DevStore is under early beta, so there is still time for you to participate and help shape it, this is the place to send your suggestions.

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.

Add and Remove list of references the ultra simple way

When you use VS to initially create a project based on any of the several templates available like Class Library, WPF Application, Web Application, Office Addin and the list goes on, you already get some of the basic ‘must have’ references for your project automatically added thanks to the templating mechanism, i.e. you get PresentationCore.dll et friends added to your project every time you create a WPF-based project.

Now this is good only as a starting skeleton. You will have to add a few more assemblies as soon as you start coding.

Some of them will be core .NET fx references that the template just didn’t add (i.e. you’ve a WPF based app where you need to use some WinForms bit or viceversa) and some of them will probably include some 3rd party framework you may be using (i.e. log4net, NHibernate, etc).

This adding of references can get a bit tedious over time as you find yourself adding the same set of references over and over again… every time you create a new project…

Even if you’re using the super-cool Search References from which you can easily search and add multiple references with a few clicks, this is still far from being ideal… ideal would be to say add my “Commonly used web stuff” or add my “log4net and NHibernate” (in a single shoot!).

Enter the free World of VS Reference Lists extension. (yes, free, go download it here).

Let’s create a new Web Application project and see how the “References” node looks like:


Let’s now use the ultra cool Search References extension to filter the list of available references to those that start with “system.web” and select the following four assemblies which are not added by default by VS and we supposedly used in every Web App project we develop:


Once we have added these references we will create a named list to group them together:


(Note how the extension is clever enough to find a common prefix for all selected assemblies and offer us “System.Web” as the name for the list to be created)

We won’t choose the “System.Web” suggested name as we want to have a more personalized list name…


We’ve just created our list that we can now use in any other Web App project where these references haven’t been added yet:


The extension also makes it very easy to manage existing lists, let’s say we mistakenly included “System.Web.Routing.dll” to our list, just click on it and remove it from our list:


Pretty cool extension, ugh?

You can download it for free and start creating your list of references today!

And if you would like to have Microsoft to include such a feature in the next version of Visual Studio be sure you vote this suggestion in Connect.

Inside the “Default Browser Switcher” extension

You may have already heard of the recently WoVS extension “Default Browser Switcher” (download from Visual Studio Gallery or from Extension Manager inside VS) that helps in choosing what browser you want to launch from VS while debugging your ASP.NET applications.

You can start by reading the original post from Scott Hanselman where he describes some interesting inner workings of VS related to how it handles the launching of the VS default browser. Note this is the default browser to be launched from VS which may or may not be your default system-wide browser.

If you’re brave enough to survive Scott’s post then you’re ready to enter some even more obscure details: how to package that into an extension for Visual Studio…

We started by defining the set of commands we wanted to support and we ended up with ten commands total. That is a “Set default Browser to X” command multiplied by Internet Explorer, Firefox, Chrome, Safari and Opera and a “View in Browser X” command multiple by the same number of browsers. The first set would go into a VS Toolbar and the second set would go into a sub menu whose parent would be a new “View in Browser” command.

To author the UI we used the very handy and friendly VSPackage Builder which allowed us to quickly design our 10 commands and place them where we wanted inside VS:



(Yes, that’s a DSL for authoring your own custom UI inside VS!)

An interesting bit is that we’ve to make sure the TextChanges flag was set on each command as we wanted the ability to dynamically change the command’s original text at runtime:


We do this so we can show different tooltips at runtime for the same command. We show the “Set X as the default browser” when that browser happens to not be the default one already:


And then we show “X is the default browser” when you hover over the current default one:


From the coding side all what’s needed is to properly set the Text property of the given MenuCommand to whatever text you want. In our case, it looks like this:

command.Text = IsDefaultBrowser ? String.Format("{0} is the default browser", browserName) : String.Format("Set {0} as the default browser", browserName);

We also added a new “View in Browser” command which we wanted to sit next to the built-in one so we had to use a submenu which ended up looking like this:


This was produced using a model like the following:



Where we have a group of commands belonging to our menu which is then placed on different built-in groups, like in the File top-level menu and in the text editor’s context menu.

Besides our fancy UI we also have some black magic code, like the one used to retrieve the currently selected item:

Start by retrieving the selection service:

var selService = GetService(typeof(SVsShellMonitorSelection)) as IVsMonitorSelection;

And call its GetCurrentSelection method which happens to have a lovely signature:

int GetCurrentSelection(
	out IntPtr ppHier,
	out uint pitemid,
	out IVsMultiItemSelect ppMIS,
	out IntPtr ppSC

Assuming you’ve a previous unmanaged C++ background it is really easy to figure out what each one of these parameters mean <g>. Just in case you don’t, here is the cheat sheet: pointers and pointers to pointers.

ppHier – returns the currently selected hierarchy (or null if it happen to be more than one selected)

pitemid – pointer to the itemid of the selected item (this is just a cookie you can else on another 500 methods to return meaninful information)

These are the two parameters we’re most interested in. if pitemid doesn’t return VSITEMID_SELECTION it means there isn’t a multiple selection, so we can safely grab ppHier as being our target selected item.

Once we have that guy identified we can add a bit more magic to get to an instance of an automation project which will allows us to better examine what the current project is about:

ppHier.GetProperty((uint)Microsoft.VisualStudio.VSConstants.VSITEMID.Root, (int)__VSHPROPID.VSHPROPID_ExtObject, out obj);

Actually before doing so I need to convert my pointer (ppHier IntPtr) to an IVsHierarchy, piece of cake:

var hier = Marshal.GetTypedObjectForIUnknown(ppHier, typeof(IVsHierarchy)) as IVsHierarchy;

And now yes, ask for the VSHPROPID_ExtObject:

var hier = Marshal.GetTypedObjectForIUnknown(ppHier, typeof(IVsHierarchy)) as IVsHierarchy;

You: Victor, are we there yet???
Me: Almost.

Now let’s release the COM interface we don’t want to keep handing around:


And cast the hierarchy to an EnvDTE.Project type:

var project = hier as EnvDTE.Project; 

Just to drop the last bit of magic which will cause a property named Object to return to us a VSProject type:

var vsproject = project.Object as VSLangProj.VSProj;

I could keep going and going but I’m guessing you had enough for now!

We can only hope that all this code gets simplified in the next version of VS by using MEF and nicely designed APIs.

Hope you enjoy this extension!

36 ideas over the weekend for improving Visual Studio

We released WoVS last friday around mid-day. Since then, that is, only two days later, its Community section has received 36 different ideas for new VS features and improvements to existing ones. THIS IS JUST AMAZING!

Some of the more popular submissions so far are VS RoamingStack Overflow integration, and a built-in Chat!.

Even Scott Hanselman submitted an idea for changing the default VS built-in browser! Unfortunately it only received 5 votes so far... looks like Scott may need help from someone popular as me (!?) to help promoting his idea. So here it goes: please vote Scott's idea!

And while you're at it, browse the other ideas available and vote what you find interesting so they get implemented by Clarius (or anyone else!) sooner than later. If you feel brave enough, you can also submit your own idea too of course.

You can keep yourself updated on the latest WoVS news by following @worldofvs and by subscribing to our blog.

 See you there!


Add Reference with Search!

Adds a "Search" textbox to the lovely "Add Reference" dialog allowing you to quickly find the assemblies you're looking for.
Search for references, save time!


Go give it a try!

Posted by vga with no comments
Filed under:

Working with T4 templates?

 A Cyber Monday Sale deal from Clarius:

If you're writing T4 templates for Software Factories, DSLs, ASP.NET MVC, Entity Framework or just doing any other code gen and you're still not running Clarius Visual T4 Editor Pro edition this is your chance to get it at HUGE 70% off, for only $29.99! (Valid only through 11/30)



Regex Editor for Visual Studio 2010

If you are playing with the just released Visual Studio 2010 beta 1 you can’t miss the Regex Editor extension which provides syntax coloring, IntelliSense, support for testing the expression as you write it and support for saving it for reuse from another project. It does also include a built-in list of common expressions ready for use.

You can install it with a few clicks by going to Tools->Extension Manager->Online Gallery and search for “regex”, click “Install” and you’re done.

If you’re an old fashioned guy who likes to be in control of what’s going on in your box, then you can download the VSIX file (btw, this is the new VS 2010 format for deploying extensions) from here (look for the Download button) and double-click on it to install.

I’m including here a few screenshots of how the Regex editor in action:

 regex01 regex02n

regex03  regex04

If you’re into writing VS extensions (or if you’re just curious enough) you can go to the Editor Samples project where you will find source code for this extension (among other extensions) and you can learn about some of the new extensibility points used by the Regex editor.


Customizing generated code in ASP.NET MVC

Just in case you missed the news, the ASP.NET MVC team is using T4 to generate code (yeah!)
The way they have integrated T4 in their own product is not what we would have expected (they wrote their own T4 host) so we took our Visual T4 Editor and Visual T4 Code Generator bits and added them knowledge about this custom host in order to offer the best possible tooling experience.

You can now see properties of their templates appearing in the Properties window, easily set them and preview how the generation will look like with a single click.

Adrian has recorded a quick video of how this is looking like already, watch it here.

We added this support last week so it is not there yet on the public bits, but I promess it will be there soon!

Posted by vga with 1 comment(s)

New Blog About Code Generation With T4 in Visual Studio!

While developing the Visual T4 Code Generator edition my team and I are constantly having discussions on how the best code generation tool in earth should look like and also about more “abstract” code generation chores not necessarily related to the product we’re developing.

So it occurred to me (yes, I’m that clever…) that we should take our internal document drafts from our internal wiki and put all this stuff into a blog (of course we will remove the bad language first) to make our plans more public and gather community feedback while we’re at it.

In this new blog you will find posts by Adrian, Joaquin, Jose and me (and if I get lucky I may get other Clarius people to blog too)

Please subscribe and let us know what do you think, thanks!

Posted by vga with no comments
More Posts Next page »