A nice feature of Visual Studio 2005 is the ability to group source files by dependencies. This is what Visual Studio 2005 does when it creates a Form class or a visual control : a dependent file named from the class name is created and linked to the primary source file (as shown in the picture below).

Dependent Files generated by Visual Studio 2005

Now imagine that you have a very complicated visual control with a lot of properties, methods and events. It would be nice to split all these things in tiny source files, to make the source code browsing easier (as shown in the picture below).

Dependent Files generated by the Addin

Unfortunately, there is no option do apply the same treatment to arbitrary files in the project. That's why I have created a Visual Studio 2005 Addin to allow dependent files for any arbitrary files. It is quite straightforward, but the result is a cleaner project tree and an ease of code navigation.

Here are the steps :

  1. Create the files you want to be dependent, like UserControl1.Properties.cs. I use this convention to mirror what Visual Studio does.
  2. Make sure the new file contains partial definition of the class. The partial definition is a new feature available in the .NET Framework 2.0.
  3. Open the master file. Select the Tools/Add Dependent Files menu. Select one or more dependent files.
  4. The selected files are now dependent of the master file.

Download the Add Dependent Files Addin.