Inspecting Objects

Visual Studio 2015 implements several improvements to the Solution Explorer from earlier versions that directly improve your ability to find and interact with objects within a solution. For instance, although the top-level hierarchies shown within the Solution Explorer are based on physical files (for example, solution files that reference project files that reference C# code files), you can also drill down directly into object definitions.


Note

A quick historical note: for those of you who have been using Visual Studio throughout the years, you may have noticed that—starting with Visual Studio 2012—the Solution Explorer window changed significantly over prior versions. The Solution Explorer window in Visual Studio 2012 is actually not a refinement of the Visual Studio 2010 Solution Explorer, but rather is a refinement of the popular Solution Navigator tool (a Visual Studio 2010 extension made available for download by Microsoft within the Productivity Power Tools pack).

If you need to still work in Visual Studio 2010, using the Solution Navigator add-on will give you nearly 100% of the functionality of the Visual Studio 2015 Solution Explorer.


Figure 5.4 illustrates how we can directly access a class, and class members, that are implemented within a specific code file. In this case, we can see three classes that are all implemented within the Integration.cs code file: MessageMapper, MessageBus, and ContextToken.

Image

FIGURE 5.4 Examining class members.

Further expanding a class shows its properties, private fields, methods, and nested classes. If you click any of these, a code editor window opens, and you will be placed directly within the class on that specific line of code.


Note

The Visual Studio 2015 Solution Explorer provides an improved and speedier way to open items in an editor window. “Item Preview” mode let’s you open the editor for any item in the project by simply clicking on the item; there’s no need to double-click or select and then press Enter. This mode is enabled by default, but can be turned on and off by using the Preview Selected Item button at the top of the Solution Explorer window.


Searching the Solution

The Solution Explorer search box allows you to quickly locate files and code based on simple string searches. Just type your search string into the box (using the Ctrl+; hotkey combination will get you there quickly), and as you type Solution Explorer automatically starts filtering the contents of the window to only those items that match your string.

Search can be limited to just filenames or to files and their content/code. It will even search files that are external to the solution (for example, external dependencies). The option of what to search is controlled by the search box drop-down (see Figure 5.5).

Image

FIGURE 5.5 Searching the solution.


Tip

The search box directly supports camel casing and Pascal casing of strings. The way that it works is subtle and could be missed on initial examination. To search the contents of the solution for matches based on exact character casing, enter the string cased precisely the way that you want. For example: a class called AboutBox would be found using the search string AboutB. If you type in a search string without casing, camel casing will not be used and the search algorithm will ignore the casing entirely. Typing in aboutb, for example, would also locate that same AboutBox class.

The search box also supports Pascal-casing breaks. This allows you to type AB and get any element Pascal cased with a capital A followed by a capital B. The AboutBox class name fits this pattern and as a result would be returned by a search of AB.


Using View Scopes and Additional Windows

Search is one way to limit the scope of what is displayed in the Solution Explorer window. There are also three other mechanisms for filtering the contents of the window to only those things you care about. By right-clicking any project or project item, you can select Scope to This in the context menu and filter the contents of the window to only that item or the things that the item contains. Scoping to a project will only show that project and its content, and scoping to a code file will only show that code file and its methods/properties (and so on, and so forth). Every time you scope to a different item within the window, it is just as if another view of the Solution Explorer were added as a “page.” You can then use the Back, Forward, and Home buttons on the Solution Explorer toolbar to move through these scope pages or bring you back to home, which essentially removes all scopes and shows you the entire solution again.

The second way to constrain the list of items shown in the solution explorer is via the files filter. This is toggled using the filter button on the Solution Explorer toolbar. You can select from three modes: the Pending Changes filter will show only those files that have uncommitted changes; the Open Files filter will show only those files that are currently open in the IDE; and the Errors filter will show only those files that have current compile errors associated with them.

Finally, you can also scope to an element and launch that view within a completely separate, new Solution Explorer window. This is done by right-clicking an item (for instance, a project) and then selecting New Solution Explorer View. This is a great productivity feature if you have a lot of screen real estate on your monitor or if you have multiple monitors. You can take a complex solution, grab the project or class that you want to focus on, and create a new Solution Explorer view, which can be floated anywhere on your screen or docked within the IDE. Figure 5.6 shows two Solution Explorer windows, one docked and one floating, existing side by side.

Image

FIGURE 5.6 Creating a new Solution Explorer view.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset