This article shows how to use file nesting extension in visual studio 2013/2015/2017. File Nesting also gives you the option to automatically nest based on file name and enables developers to nest and un-nest any file manually.
Using visual studio file nesting, you can nest to any files, folders or entire projects.
First, You need to install File Nesting extension by selecting Tools->Extensions and Updates from Visual Studio 2013/2015/2017
Click Download button to install the file nesting extension
Click Install button, then restart your visual studio
Now, Create Student, StudentRepository class and IStudent interface as shown below.
To use the file nesting extension in visual studio, you need to right click on class that you want to group file then select File nesting->Nest item...
You will also see
Select your parent class, similar for StudentRepository class
If you open up the .csproj file, you can see that this is set out as follows:
<ItemGroup>
<Compile Include="IStudent.cs">
<DependentUpon>Student.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Student.cs" />
<Compile Include="StudentRepository.cs">
<DependentUpon>Student.cs</DependentUpon>
</Compile>
</ItemGroup>
Features File Nesting
- Manually nest files
- Manually un-nest files
- Auto-nesting based on naming conventions
- Option to enable auto-nesting when files are added or renamed
- Options to specify which naming conventions to apply
- Keyboard shortcut for manual nesting (Ctrl+Alt+N)