命名约定对于部分类文件 [英] Naming Conventions For Partial Class Files

查看:105
本文介绍了命名约定对于部分类文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我生成大量我的ASP.NET MVC脚手架code的。所有生成的文件都使用该标准命名约定部分类。例如,我的员工控制器文件名为EmployeeController.cs。如果我想将EmployeeController习俗,非产生的逻辑延伸,我创建第二部分的类文件名为EmployeeControllerCustom.cs。我单独定制和产生的逻辑到两个不同的文件,所以下一次我产生EmployeeController我的自定义更改不会被覆盖。添加自定义为后缀的文件名似乎是合理的给我,但有我应以下一个更成熟的部分类文件命名约定?

I'm generating the bulk of my ASP.NET MVC scaffolding code. All generated files are partial classes which use standard naming conventions. For example, my employee controller file is named EmployeeController.cs. If I wish to extend the EmployeeController with custom, non-generated logic, I create a second partial class file named EmployeeControllerCustom.cs. I separate the custom and generated logic into two different files so the next time I generate the EmployeeController my custom changes aren't overwritten. Adding the "Custom" suffix to the file name seems reasonable to me, but is there a more established partial class file naming convention which I should be following?

推荐答案

我用 分离 - 例如 EmployeeController.SomeSpecialBehaviour.cs 。我也通过dependentUpon或不管它是在的csproj,使其巢下的文件(在Solution Explorer)整齐地链接入项目树。你所要做的是手工(编辑的csproj),或通过插件,虽然,例如:

I use . separation - for example EmployeeController.SomeSpecialBehaviour.cs. I also link it into the project tree via "dependentUpon" or whatever it is in the csproj, so that it nests under the file (in solution explorer) neatly. You have to do that by hand (edit the csproj) or with an addin, though; for example:

<Compile Include="Program.cs" />
<Compile Include="Program.Foo.cs">
  <DependentUpon>Program.cs</DependentUpon>
</Compile>

显示为:


  • 的Program.cs

    • Program.Foo.cs

    • Program.cs
      • Program.Foo.cs

      这篇关于命名约定对于部分类文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆