Search code examples
c#visual-studioxamarinxamarin.formsvisual-studio-mac

File indenting in Visual Studio on the MAC


I have seen some applications where the C# code is split among different files with each file holding a partial class. From what I see it's possible to make these appear indented in Visual Studio on the Mac like in this example:

file1
   file1.data
   file1.commands
   file1.bindings

Can someone tell me how I can achieve this visual effect


Solution

  • Just add a <DependentUpon /> tag in your csproj file.

    <Compile Include="file1.cs" />
    <Compile Include="file1.data.cs">
      <DependentUpon>file1.cs</DependentUpon>
    </Compile>
    <Compile Include="file1.commands.cs">
      <DependentUpon>file1.cs</DependentUpon>
    </Compile>
    <Compile Include="file1. bindings.cs">
      <DependentUpon>file1.cs</DependentUpon>
    </Compile>
    

    I don't believe there is a shortcut to do that in visual-studio unless you install an extension; you will have to manually edit a csproj in a text editor. Also, I don't think there are any plugins available for VS for Mac yet.

    References:

    1. Nesting Files In Visual Studio
    2. Introducing File Nestor for Visual Studio

    EDIT 1 Looks like there is a nesting add-in(beta) available for MonoDevelop - which in turn should be compatible with VS for Mac.