代码之家  ›  专栏  ›  技术社区  ›  Ben Griswold

分部类文件的命名约定

  •  81
  • Ben Griswold  · 技术社区  · 15 年前

    我正在生成我的ASP.NET MVC脚手架代码的大部分。所有生成的文件都是使用标准命名约定的分部类。例如,我的员工控制器文件名为EmployeeController.cs。如果我希望使用自定义的非生成逻辑扩展EmployeeController,我将创建第二个名为EmployeeControllerCustom.cs的部分类文件。我将自定义和生成的逻辑分为两个不同的文件,以便下次生成EmployeeController时不会覆盖自定义更改。在文件名中添加“Custom”后缀对我来说似乎是合理的,但是是否有一个我应该遵循的更为成熟的部分类文件命名约定?

    2 回复  |  直到 15 年前
        1
  •  163
  •   Anton Georgiev    6 年前

    我用 . 分离-例如 EmployeeController.SomeSpecialBehaviour.cs

    <Compile Include="Subfolder/Program.cs" />
    <Compile Include="Subfolder/Program.Foo.cs">
      <DependentUpon>Program.cs</DependentUpon> <!-- Note that I do not reference the subfolder here -->
    </Compile>
    

    • 子文件夹
      • Program.cs
        • Program.Foo.cs
        2
  •  16
  •   Mariano Desanze    4 年前

    更新/免责声明: 回答。


    为了补充Marc Gravell的答案,我遇到了一个子文件夹中的文件和 DependentUpon

    <Compile Include="foo\bar.cs" />
    <Compile Include="foo\bar.baz.cs">
        <DependentUpon>bar.cs</DependentUpon>  <!-- Note that I do not reference the subfolder here -->
    </Compile>