Solution Explorer Filtering in Visual Studio 2012
Sun, Sep 2 2012 18:39
In prior versions of Visual Studio, the Solution Explorer has been basically static. With Visual Studio 2012, it is much more dynamic with features such as filtering and scoping.
[For information on the scoping features, see this prior blog post.]
The filtering feature allows you to filter the contents of Solution Explorer to files containing the entered text. Depending on your settings, it will find within the file name and within the contents of any code file.
This allows you to focus on specific files or files containing specific classes, properties, or methods. For example, if you are working on an MVVM application, you can filter to "Invoice" to find the model, view, and view/model for the invoice feature.
The filtering uses a "contains" style of matching, so it finds the match anywhere in the file name or in the code file classes, properties, and methods. It can also match using Pascal casing. Typing CFW will match any Pascal-cased string with the entered letters, such as CustomerFindWindow.
Searching for "Customer":
In this example, "Customer" is found in both the file names, such as Customer.cs, and in the contents of the code files, such as the Customer class, the CustomerList property, and the FindCustomers method.
To limit the search to only the file names, turn off the "Search within file contents" by unchecking it in the search options.
You can also uncheck "Search within external items", which turns off searching of external items, such as those in the External Dependencies folders. (I spent some time this afternoon trying to determine what this actually means and did not have a lot of luck. Best I can find, it prevents searching within the C/C++ External Dependencies folder. If anyone has found any more information on this, I'd love to hear about it. Please post in the Comments section of this post.)
Turning off "Search within file contents" provides these results:
Searching for CFW results in:
In this example, any file names, classes, properties, or methods that are Pascal cased to match CFW are included in the filtered list.
Notice, however, the difference between the C# project and the VB project in the above example. This difference is because the filtering does not search through hidden folders/files by default. In VB, the designer file is hidden.
To search through hidden files and folders, select the project and then click the Show All Files button in the Solution Explorer toolbar. Then the VB designer file will be found.
To turn off the results and return to the full list of files, click the Home button on the Solution Explorer toolbar. Solution Explorer is then reset to its original file list.
Use these techniques any time you want to filter Solution Explorer to specific folders, files, classes, methods, or properties in your solution.