What I Work On: Code Map

Yesterday, Visual Studio 2012 Update 1 shipped! So I can officially talk about what I just worked on. Much of it has already been available in preview form and CTP releases and such, but you don’t want to get in trouble! 🙂

I joined the Visual Studio team back in April, just as work was finishing up on Visual Studio 2012. As part of that release, the VS team was moving to much more agile release schedule for updates, so here we are, about 4 months after going gold with an update with lots of fixes and cool new features!

The group I work in is called “Developer Visualization”, and is part of the “Application Lifecycle Tools” team. Most of our team’s features are part of Visual Studio Ultimate, but our team is responsible for some of the code that powers the Solution Explorer in all versions of VS. Anyway, the big new thing we worked on for VS Update 1 is called “Code Map”. While looking for a picture of the feature to put up here, I went to the official update web page, and BAM! Code Map is the background image! (I think the technical term is the “hero” image)

VS Update 1
(in that screenshot, i’m directly responsible for the green nodes (results of a query) and the green arrow (the cursor location))

What is Code Map?

Visually graphing code is nothing new, people have been drawing code diagrams of various forms for, well, as long as people have been writing code. Visual Studio has had graphs for a long time as well. Before I joined VS, a lot of the graphing code was re-written for 2012, in order to make it more useful, usable, and scalable. In ultimate, the main entry point to creating graphs was what we call “top down”, via the Architecture menu on the toolbar. You can use it to create a dependency diagram of your entire solution. But it starts a the assembly level. You can see which assemblies reference eachother, and then you can expand the assembly and see the namespaces inside. You can expand the namespaces to see the classes inside, and all the relationships between them. (The technical term for this is “progressive reveal”, which was the old name of our group). Another way to generate these graphs is via the architecture explorer, but that’s a rather advanced tool that not everyone uses. But generating a graph this way means you have a lot of stuff you might not be interested in! You can move stuff, remove stuff, but in a large solution, that would take a lot of time!

In Update 1, the Code Map feature lets you generate diagrams in the other direction (what we call “bottom up”) piece by piece, directly from code, side by side with the code editor (for C# and VB). Have the cursor in the code on a method? Right click, “Show on Code Map”. Poof: the window splits, and a new diagram appears with the method you were on. Put the cursor somewhere else, and use the keyboard shortcut, Ctrl+` (control+backtick), and poof, that method appears on the graph as well; and if the methods call eachother, the graph will automatically have links between the items on the graph. You can add pretty much every code construct to the graph: classes, method, properties, enums, etc, etc, and the links magically appear. You can also add things to code maps by dragging and dropping from solution explorer, or by using Show On Code Map from there.

But Wait, there’s more!

Not only can you then create small diagrams, only containing the things that you want and the relationships between them (a great way to explore unfamiliar code!), but you can explore the code directly from the graph! So you added a method to the graph above. Who calls it? From the code editor, you’d right click and do “Find all references”, and results appear in another window. In the code map, right click, and look at that, “Find all references” is there too! Select it and it will find calling methods, and add those to the map, with links between them. Want to know what class those other methods are inside of? Right click, “show containing class”. Nodes will now be grouped by which classes they are in, and links will be displayed between classes. Want to see the base types of a type on the graph? Derived types? All available! Add some notes, save it, send it around!

Want to see it in action? Go watch this channel 9 video!
Want to use it? Fire up Visual Studio Ultimate (you deserve ultimate! Upgrade today!), install Update 1, and get your Code Map on!

Posted in General Tagged with:

Leave a Reply

Your email address will not be published. Required fields are marked *


XBox GamerCard

Recent Flickr