views:

120

answers:

2

Some problems that I recall (there may be more):

  1. Includes regions
  2. Does not use this. prefix for member 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.

+1  A: 

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.

Joey
That is a good start. How do you do that? I was hoping to be able to control what gets generated to a degree.
Hamish Grubijan
The WF designer also doesn't emit the [GeneratedCode] attribute. It can be added by hand.
Hans Passant
+2  A: 

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.

haarrrgh