Scope of Refactoring in Universal Solutions

At the Build 2014 conference in San Francisco, Microsoft announced availability of Universal Solutions in Visual Studio 2013 Update 2 RC. When you are ready to explore the functionality of this major improvement to the IDE, you’ll want to know how several often-used commands of Visual Assist operate in this new arena.

As a review, a simple Universal Solution is one that has at two or more platform-specific projects, and a shared project that is inherited by the platform-specific projects. The solution can include additional projects that may or many not inherit the shared project.

In a Universal Solution of multiple project types, Find References, Rename, and Change Signature behave as they normally do if you tell the commands to display references from, or search in, all projects. A find for Foo::Bar() in all projects locates the method wherever it’s referenced in your solution—in all project types.

But, the three commands assume new behavior in a Universal Solution when you search only the current project: the three commands assume you wish to search the current project plus those the project inherits, or are inherited by the current project. This slightly broader definition of current project prevents you from inadvertently refactoring code that will break a solution.

For example, if you rename MinPlayableWidth from a reference in a shared project—without telling Rename to search all projects—Visual Assist assumes you also need to rename references in the projects that inherit the shared project.

As another example, if you change signature of Foo::Bar() from a reference in a platform-specific project, Visual Assist assumes you also need to change the signature of Foo::Bar() in the shared project, plus other projects that inherit the shared project.

Even with the broader definition of the current project within a Universal Solution, you still have the opportunity to select/deselect project nodes before committing to a refactoring. If you exploit Rename or Change Signature to “refactor” your code so it references a difference object, e.g. Foo::Bar2(), you might initiate a Rename or Change Signature, then deselect nodes of projects that inherit, or are inherited by, your current project.

In summary, Visual Assist assumes you want your solution to build when you refactor in a Universal Solution. If you’re using refactoring commands for non-refactoring purposes, be mindful of the scope of your changes before you commit to them.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s