Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to group partial class files in Solution Explorer VS2010 [duplicate]

Possible Duplicate:
Group files in Visual Studio

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 dependant files.

But my classes are shown in two rows below each other:

> 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?

EDIT

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

like image 546
BitKFu Avatar asked Sep 01 '10 19:09

BitKFu


People also ask

Can partial class have different names in different files?

Any method, interface, and function declared on a partial class is available for all the other parts. The source file name for each part of the partial class can be different, but each partial class's name must be the same.

What is file nesting?

That is, any file with the same name and extension as another file plus an additional extension on the end is nested under the other file.

How do I add a partial class in Visual Studio?

Open Visual Studio from "Start" -> "All programs" -> "Microsoft Visual Studio". Then, go to "File" -> "New" -> "Project..." then select "Visual C#" -> "Windows" -> "Console application". Then, specify the name such as Partial class or whatever name you wish and the location of the project and click on the "OK" button.


1 Answers

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).

like image 67
Rob Avatar answered Oct 20 '22 05:10

Rob