力的WinForms再生了.Designer.cs文件 [英] Force WinForms to regenerate .designer.cs files

查看:147
本文介绍了力的WinForms再生了.Designer.cs文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个包含在我们的应用中使用的许多控件的控制工程。有这些控制许多旧的和大量的冗余特性,几乎他们都没有(()如默认值特别是)在他们指定的属性。

We have a controls project that contains many controls used throughout our applications. There are many old and many redundant properties on these controls, and almost none of them have attributes specified on them (such as DefaultValue() in particular).

至于清除它们,我们增加属性的属性的努力的一部分,并打算删除冗余的。

As part of the effort to clean them up, we have added attributes to the properties, and are looking to remove the redundant ones.

我们愿意做,因为这部分是清洗从的WinForms设计师生成的代码( xxxxxx.designer.cs XXXXXX .designer.vb 文件)。一些属性是直拆除,为此,我们可以使用grep和sed来删除有问题的线路,但我们正在寻找一种方法,使Visual Studio中(或东西)来重新生成的文件。

What we would like to do as part of this is to clean the generated code from the winforms designer (the xxxxxx.designer.cs and xxxxxx.designer.vb files). Some of the properties are straight removal, for which we were able to use Grep and Sed to remove the offending lines, but we are looking for a way to make Visual Studio (or something) to regenerate the files.

由于我们有多种形式100的,这是不可行的手动打开每一个,并修改他们做到这一点。

As we have 100's of forms, it is infeasible to manually open each one and modify them to do this.

有谁知道一个办法做到这一点。

Does anyone know of a way to do this?

编辑:

要澄清一下,我意思是不要删除属性直线距离,而到了 DesignerSerializationVisibity()属性应用到他们告诉设计师不写他们。那么一旦我们更新了所有设计文件,我们可以删除属性。

To clarify, what I mean is not to remove the properties straight away, but to apply the DesignerSerializationVisibity() attribute to them to tell the designer to not write them. Then once we have updated all the designer files, we can delete the properties.

另请参见:

自动重生的设计文件

推荐答案

不可能的话,你不能让设计师解析的InitializeComponent()时,它包含了属性赋值为已删除或重命名属性。它解析它,才可以重新生成代码。

Not possible, you can't get the designer to parse InitializeComponent() when it contains property assignments for properties that you have removed or renamed. It has to parse it before it can regenerate the code.

唯一真正的方法是将[DesignerSerializationVisibility]属性先向老属性,因此它不再写财产分配。然后加载每个窗体,使一个简单的编辑得到它再生的InitializeComponent(),目前没有财产分配。然后你就可以将其删除。直接编辑方法可能会更快。

The only real approach is to first apply the [DesignerSerializationVisibility] attribute to the old property so it no longer writes the property assignment. Then load each form and make a trivial edit to get it to regenerate InitializeComponent(), now without the property assignment. Then you can remove them. Directly editing the method could be quicker.

这篇关于力的WinForms再生了.Designer.cs文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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