删除自动生成评论 [英] Remove auto generate comments

查看:147
本文介绍了删除自动生成评论的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用模型优先" EF4x创建了一些类,您可以看到类似的示例在algreat的答案中./p>

我的问题是关于默认注释的生成,如下面的块引用所示

//------------------------------------------------------------------------------
// <auto-generated>
//    This code was generated from a template.
//
//    Manual changes to this file may cause unexpected behavior in your application.
//    Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

是否有避免创建这些评论的方法?或全部删除?

解决方案

如果打开EDMX模型,则可以右键单击并选择添加代码生成项"
这会将T4模板添加到您的项目中(与EDMX模型的默认模板相同).如果您查看此模板后面的代码,则会找到注释.您只需删除它们并保存模板,即可生成代码而无需注释.

您所指的部分实际上在模板中看起来像这样

//------------------------------------------------------------------------------
// <auto-generated>
// <#=GetResourceString("Template_GeneratedCodeCommentLine1")#>
//
// <#=GetResourceString("Template_GeneratedCodeCommentLine2")#>
// <#=GetResourceString("Template_GeneratedCodeCommentLine3")#>
// </auto-generated>
//------------------------------------------------------------------------------

I create some classes using Model First, EF4x as you can see a similar example in this answer from algreat.

My question is about the default comments that are generate as it shows in the block-quote below

//------------------------------------------------------------------------------
// <auto-generated>
//    This code was generated from a template.
//
//    Manual changes to this file may cause unexpected behavior in your application.
//    Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

Is there a way to avoid the creating of those comments? or remove them all?

解决方案

If you open your EDMX model, you can right click and choose "Add code generation item"
This will add a T4 template to your project (which is the same as the default template of your EDMX model). If you take a look at the code behind this template, you will find the comments. You can just remove them and save the template and your code will be generated without the comments.

The part you refer to actually looks like this in the template

//------------------------------------------------------------------------------
// <auto-generated>
// <#=GetResourceString("Template_GeneratedCodeCommentLine1")#>
//
// <#=GetResourceString("Template_GeneratedCodeCommentLine2")#>
// <#=GetResourceString("Template_GeneratedCodeCommentLine3")#>
// </auto-generated>
//------------------------------------------------------------------------------

这篇关于删除自动生成评论的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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