开发者

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):

  1. Includes regions
  2. Does not use this. prefix for me开发者_运维问答mber variables and methods
  3. 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.


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 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜