如何在Solution Explorer VS2010中对部分类文件进行分组

Bit*_*KFu 54 visual-studio-2010

可能重复:
Visual Studio中的组文件

问题是,我想在解决方案资源管理器中以某种方式对部分类文件进行分组,即Visual Studio在文件名前面显示[+],我可以展开以查看所有其他dependend文件.

但我的课程分为两行.(见下文)

> CustomerServiceDao.cs
> CustomerServiceDao.Query.cs
Run Code Online (Sandbox Code Playgroud)

我希望得到的结果是这样的.

+ CustomerServiceDao.cs
    > CustomerServiceDao.Query.cs
Run Code Online (Sandbox Code Playgroud)

是否有任何命名约定我必须遵循以显示分组的部分文件?

Thx提前

编辑: 它的工作原理.那很棒.但是有没有命名约定?例如ascx默认情况下做...

Rob*_*Rob 73

如果您打开.csproj文本文件(或从项目的解决方案资源管理器中的上下文菜单中选择"卸载项目",然后选择"编辑myproject.csproj"),您可以更改它以在样式的解决方案资源管理器中显示相关文件你希望.

寻找:

<Compile Include="CustomerServiceDao.cs" />
<Compile Include="CustomerServiceDao.Query.cs" />
Run Code Online (Sandbox Code Playgroud)

并将其编辑为:

<Compile Include="CustomerServiceDao.cs" />
<Compile Include="CustomerServiceDao.Query.cs">
    <DependentUpon>CustomerServiceDao.cs</DependentUpon>
</Compile>
Run Code Online (Sandbox Code Playgroud)

在Visual Studio编辑器中无法直接执行此操作,但考虑到VS2k10提供的可扩展性模型,可能不久之后有人会生成某些东西.

更新: 最新版本的VSCommands声称支持为您执行此操作:

最新版本支持从IDE分组项目(因此您不必使用DependentUpon手动破解项目文件).


Dao*_*Dao 26

如果您不想使用繁重且专有的VSCommands扩展来减慢IDE的速度,则可以使用小扩展NestIn.它只能分组/取消组合文件


Mat*_*ell 10

如果手动编辑.csproj文件,则可以实现此目的.

只需右键单击您的项目,点击即可Unload Project.

从那里,右键单击并点击 Edit project.csproj

寻找Compile元素.DependentUpon像这样添加一个子元素:

<Compile Include="CustomerServiceDao.cs" />
<Compile Include="CustomerServiceDao.Query.cs">
    <DependentUpon>CustomerServiceDao.cs</DependentUpon>
</Compile>
Run Code Online (Sandbox Code Playgroud)