当我在 VS2010 中使用 WinForms (C#) 设计器时,它仍然生成 StyleCop 抱怨的代码
我记得的一些问题(可能还有更多):
- 包含区域
- 不使用
this.
前缀作为成员变量和方法 包含如下注释(具有
// 本身就吸引了 StyleCop 的注意)
<前><代码>// // 文件名文本框 //
如果我对文本进行了更改,然后再次打开设计器,并且毁掉了我之前完美的劳动成果。您将如何解决这个问题?
我听说过但没有亲身经历过 WPF 的类似问题。你会如何解决这个问题?
谢谢。
Some problems that I recall (there may be more):
- Includes regions
- Does not use
this.
prefix for member variables and methods Includes comments like the one below ( having
//
by itself catches the eye of StyleCop)// // fileNameTextBox //
If I make a change to the text, and then open the designer again, and screws up my previously perfected fruits of hard labor. How did / would you solve this problem?
I heard but did not personally experience a similar problem with WPF. How did / would you fix that?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有多种方法可以让 StyleCop 忽略生成的代码:
StyleCop:如何忽略生成的代码
我记得,忽略生成的代码是默认设置(至少,它会忽略我的 VS 2008 使用标准设置生成的代码)。
我不使用 VS 2010,所以我不知道他们是否以某种方式更改了设计器生成的文件,以便 StyleCop 不再将它们识别为生成的文件。
也许该链接可以帮助您在代码中弄清楚这一点。
There are several ways to make StyleCop ignore generated code:
StyleCop: How To Ignore Generated Code
As I recall it, ignoring generated code is the default setting (at least, it ignores my VS 2008 generated code with the standard settings).
I don't use VS 2010, so I don't know if they changed the designer generated files somehow so that StyleCop doesn't recognize them as generated anymore.
Maybe the link helps you to figure that out in your code.
可以指示 StyleCop 忽略生成的源文件。我不知道为什么设计者生成的文件必须遵守任何任意编码标准 - 唯一应该读取或写入它们的是自动化工具,而不是开发人员。
代码样式主要是为了帮助开发人员。代码生成器当然不在乎。
StyleCop can be instructed to ignore generated source files. I don't know why designer-generated files have to adhere to any arbitrary coding standard – the only thing that should ever read or write them is an automated tool, not the developer.
Code styles are mainly there to help developers. Code generators certainly couldn't care less.