views:

102

answers:

2

The problem is, that I want to group partial class files in a way in the Solution Explorer, that visual Studio displays a [+] in front of the filename which I than can expand to see all other dependend files.

But my classes are shown in two rows below each other. (see below)

> CustomerServiceDao.cs
> CustomerServiceDao.Query.cs

The result I want to have is something like that.

+ CustomerServiceDao.cs
    > CustomerServiceDao.Query.cs

Is there any naming convention which I have to follow in order to show the partial files grouped?

Thx in advance

EDIT: It works. That's great. But are there any naming conventions? e.g. ascx does it by default ...

+1  A: 

You can achieve this if you manually edit your .csproj file.

Just right click you project, hit 'Unload Project'.

From there, right click and hit 'Edit project.csproj...'

Look for the 'Compile' elements. Add a 'DependentUpon' sub-element like this:

<Compile Include="CustomerServiceDao.cs" />
<Compile Include="CustomerServiceDao.Query.cs">
  <DependentUpon>CustomerServiceDao.cs</DependentUpon>
</Compile>
Matt Brunell
It works. That's great. But are there any naming conventions? e.g. ascx does it by default ...
BitKFu
@BitKFu, Some project types do it by default because that's the way they've been coded. There's no naming convention that will help you here, I'm afraid. I have just found a plug-in (mentioned in my answer), that claims it'll do it for you though! =)
Rob
I really would like to give both of you the reputation. Very good answers, but I have to choose one.
BitKFu
+3  A: 

If you open your .csproj as a text file (or choose "Unload Project" from the context menu in Solution Explorer for the project, followed by "Edit myproject.csproj") you can change it to show the relevant files in Solution Explorer in the style you wish.

Look for:

<Compile Include="CustomerServiceDao.cs" />
<Compile Include="CustomerServiceDao.Query.cs" />

And edit it to be as this:

<Compile Include="CustomerServiceDao.cs" />
<Compile Include="CustomerServiceDao.QUery.cs">
    <DependentUpon>CustomerServiceDao.cs</DependentUpon>
</Compile>

There's no way to do this directly within the Visual Studio editor, but given the extensibility model that VS2k10 provides, it probably won't be long before someone produces something.

Update: The latest version of VSCommands claims to support doing this for you:

Latest version supports grouping items from IDE (so you don't have to hand-hack project file with DependentUpon).

Rob
Correct link for VSCommands is http://visualstudiogallery.msdn.microsoft.com/en-us/d491911d-97f3-4cf6-87b0-6a2882120acf - I'll update the answer with it shortly, once I've checked if it actually works =)
Rob
That's really cool ;) I'm impressed. VSCommands works like a charme.
BitKFu