Group files in Visual Studio

前端 未结 5 1247
执念已碎
执念已碎 2020-11-27 15:41

I\'m looking at tidying up my project layout in Visual Studio and I\'m wondering if there is any hack, plugin or trick to associate an .xml file with a .cs file of t

5条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-27 16:16

    Not sure if people are aware, but nesting files like this seemingly breaks VS's ability to rename the root file, at least when your new nested file is also a partial class. For instance here's the tree we created...

    MainWindow.xaml
        MainWindow.xaml.cs
        MainWindow.Commands.cs
    

    MainWindow.Commands.cs is just another partial class of MainWindow, same as MainWindow.xaml.cs. However, if you then try and rename MainWindow.xaml, instead of automatically renaming the dependent files, it throws an exception.

    For completeness, I also tried naming the file MainWindow.xaml.Commands.cs but that didn't work either.

    Without the extra 'commands' file, rename works fine, of course.

    MainWindow.xaml
        MainWindow.xaml.cs
    

    Anyway, this was reason enough for us to abandon nesting files like this. Without the ability to rename, it's just not worth it.

提交回复
热议问题