[英]When I use WinForms (C#) designer in VS2010, it still generates code that StyleCop complains about
Some problems that I recall (there may be more): 我记得的一些问题(可能还有更多):
this.
this.
prefix for member variables and methods Includes comments like the one below ( having //
by itself catches the eye of StyleCop) 包括下面的评论(
//
本身就能吸引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. 我听说但是没有亲自遇到类似WPF的问题。 How did / would you fix that?
怎么/你会解决这个问题?
Thanks. 谢谢。
There are several ways to make StyleCop ignore generated code: 有几种方法可以让StyleCop忽略生成的代码:
StyleCop: How To Ignore Generated Code StyleCop:如何忽略生成的代码
As I recall it, ignoring generated code is the default setting (at least, it ignores my VS 2008 generated code with the standard settings). 我记得,忽略生成的代码是默认设置(至少,它忽略了我的 VS 2008生成的代码与标准设置)。
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. 我不使用VS 2010,所以我不知道他们是否以某种方式改变了设计器生成的文件,因此StyleCop不再将它们识别为已生成。
Maybe the link helps you to figure that out in your code. 也许该链接可以帮助您在代码中找到答案。
StyleCop can be instructed to ignore generated source files. 可以指示StyleCop忽略生成的源文件。 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.
代码生成器肯定不在乎。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.