Visual Studio’s Solution Explorer “Search”

Reading Time: 2 minutes

I’m taking a leaf out of Rob Miles’ book and blogging something I found useful.

It’s perfectly simple – in Visual Studio 2013 (and I’ve noticed in 2012 also) the solution explorer has a “Search Solution Explorer” function. Initially I assumed it just found files but no, it quite happily finds properties, methods, all sorts.

Visual Studio Solution Explorer Search
VS Solution Explorer Search

There are currently 32 projects in our Command and Control solution, as I wrote much of it I know pretty much where everything is but sometimes even I get a bit lost. For new people coming onto the project it must be a real struggle. This could help enormously.

Of course, one could fire up a copy of Cygwin and grep for it, but that’s really not the point!

    find -name \*.cs -exec grep -H MessageSource "{}" \; | less

This is one of the hazards of being in the industry – the Solution Explorer in VS2005 was pretty useless (so everyone used an alternative version). At some point I will have upgraded VS and noticed that the Solution Explorer in the new version was now quite usable. I will have scanned the media on the latest VS release but either I missed or didn’t appreciate the significance of the news about the search function.

Every now and again this happens in the industry – something useful just goes flying past and you don’t realise until months or even years later.

3 thoughts on “Visual Studio’s Solution Explorer “Search””

  1. I have to admit to an edit – originally the bash was
    find . -name \*.cs -print0 | while read -d $’\0′ file;
    grep -H MessageSource “$file” ;
    done | less
    This is not the best way of doing it, as Colin pointed out to me on FB.

  2. I find that sometimes it finds methods and sometimes it does not. I have not found the pattern for this behavior. Have you seen this?

    • I’ve not seen it fail to find anything. It is however case sensitive. I suspect it’s using the same data graph as the new (2012) “peek inside” feature that allows you to drill down into the contents of the file. Perhaps if there were parse or build problems with the file this might go awry? Similarly the graph has to be built so I can imagine if that were in progress perhaps search wouldn’t work. Alas I am only guessing though.

Comments are closed.