Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display a file hierarchically under another file in Visual Studio [duplicate]

In Visual Studio, I'd like to show a hierarchical relationship between certain files.

A typical ASP.NET WebForms application provides an example of what I want. Say that I have a file named Page.aspx. Files named Page.aspx.cs and Page.aspx.designer.cs would typically appear hierarchically below Page.aspx in Solution Explorer.

like image 686
amethyst_deceiver Avatar asked Jul 15 '15 13:07

amethyst_deceiver


People also ask

How do I display hierarchy in Visual Studio?

Select the "Show the Supertype Hierarchy" from the toolbar to see a hierarchy showing the type's parent elements including implemented interfaces. This view shows the results in the reverse hierarchy.

How do I enable nesting in Visual Studio?

The precedence for merging file nesting settings is: Visual Studio > Solution > Project. You can tell Visual Studio to ignore solution-specific and project-specific settings, even if the files exist on disk, by enabling the option Ignore solution and project settings under Tools > Options > ASP.NET Core > File Nesting.

What is file nesting?

Another new feature that catched my interest was the experimental support for file nesting. This feature lets you visually “nest”/group related files under a “root” file in the same directory. For example, say you have a main.ts file and next to it you have main.js , main.d.ts and main.js.map .


1 Answers

If you want File A to appear hierarchically under File B in Solution Explorer, do the following:

Open your project file, go to the <Content Include> (or <None Include>, or what have you) node for File A and add a <DependentUpon>File B</DependentUpon> child to it. The result should look similar to this:

<Content Include="File A">
  <DependentUpon>File B</DependentUpon>
</Content>`
like image 91
amethyst_deceiver Avatar answered Oct 04 '22 16:10

amethyst_deceiver