Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get VS2008 to "tree-indent" partial classes (like code-behind files)

I have created a multi plattform project, and everything works nicely, except one little things. When I add a specific plattform file, like:

  • ServiceImpl.cs
  • ServiceImpl.Desktop.cs

it does not show up nicely in a tree fashion like in this article:

Multi-Targeting (check the last image in the article to understand what I mean)..

Any ideas how to "teach" VS 2008 to do this? With normal XAML and Code-Behind it works as usual...


Ok, the answer worked perfect for a normal situation. Now, there is still a little problem with the silverlight project. The file is originally located in the desktop project, so there the solution works. However, if the "parent" file is a link, it seems to cause a problem (no effect at all)... See this code:

<Compile Include="..\Messaging\Services\MessagingService.cs">
  <Link>Services\MessagingService.cs</Link>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\MessagingService.Silverlight.cs">
      <DependentUpon>MessagingService.cs</DependentUpon>
</Compile>

Any ideas for this situation?

like image 290
Christian Ruppert Avatar asked Jun 25 '09 11:06

Christian Ruppert


2 Answers

It doesn't always do it automatically (although it spots things like .Designer.), but you can edit the csproj by hand to do this (it is just xml). There are also a few add-ins that provide this, but the one I use has been removed. You want DependentUpon...

<Compile Include="ServiceImpl.cs" />
<Compile Include="ServiceImpl.Desktop.cs">
  <DependentUpon>ServiceImpl.cs</DependentUpon>
</Compile>

(note they must be in the same folder; you don't specify the folder in DependentUpon)

like image 72
Marc Gravell Avatar answered Nov 04 '22 09:11

Marc Gravell


You can use this plugin http://mokosh.co.uk/vscommands/ to group items in solution explorer from VS (without editing project file).

like image 30
Jarek Kardas Avatar answered Nov 04 '22 10:11

Jarek Kardas