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

2

7

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?

Administrative answered 25/6, 2009 at 11:43 Comment(1)
I don't think it works with the linked file... sorry...Tremulant
T
10

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)

Tremulant answered 25/6, 2009 at 11:47 Comment(1)
Thanks, worked... Still little problem with a linked file, see edit above.. Any idea about this?Administrative
R
3

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

Reconstructive answered 25/6, 2009 at 14:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.