Visual Studio: How to group partial class files in Solution Explorer
By FoxLearn 1/24/2021 2:16:01 AM 18.34K
File Nesting helps you automatically nest files based on filenames and allows developers to manually nest and unnest any files.
Opening your Visual Studio, then select Tools =>Extensions and Updates
Searching 'nest file', then download File Nesting.
After you finish downloading the File Nesting, you should close your Visual Studio to begin the installation.
File Nesting supports all versions of Visual Studio 2015, 2017, 2019.
Features
- Manually nest files or un-nest files
- Automatic nested 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)
Partial class allows you to split the definition of a class or a struct, an interface or a method over two or more source files
When working on large projects, spreading a class over separate files enables multiple programmers to work on it at the same time.
Use the partial keyword modifier, as shown here
public partial class Student { public void DoHomeWork() { } } public partial class Student { public Student GetStudentInfo(string id) { } }
How to nest interfaces using File Nesting?
You can create Customer, CustomerBase class and ICustomer interface, then you can use the File Nesting tool to group all classes
namespace NestFiles { public partial class Customer : CustomerBase { } }
namespace NestFiles { public abstract partial class CustomerBase : ICustomer { } }
namespace NestFiles { public interface ICustomer { } }
Right-clicking on your file you want to group, then select File Nesting =>Nest item...
Selecting your parent class, then click OK
You can easily nest and unnest any file.
After you finish nesting, you can can see as the figure below.
File Nesting also gives you the option to automatically nest it based on file naming rules. You can easily apply those rules to any file, folder, or an entire project.
VIDEO TUTORIAL
- How to Optimize your Application using Visual Studio Profiler
- Visual Studio: How to Auto Increment Version Number
- Visual Studio: Auto increment version
- How to Download and Install Visual Studio 2017
- How to fix 'NonComVisibleBaseClass was detected'
- How to fix 'Couldn't process file resx due to its being in the Internet'
- DevExpress: Can't add NuGet Packages
- Adding Custom Prerequisites to Visual Studio Setup Project