When I use the WinForms (C #) constructor in VS2010, it still generates code that StyleCop complains about

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

  • Includes Regions
  • Does not use the this. prefix this. for member variables and methods
  • Includes comments like the ones below (the presence of // in itself catches the eye of StyleCop)

     // // fileNameTextBox // 

If I make changes to the text, and then I open the designer again and screw in my previously perfect fruits of hard labor. How did you / solve this problem?

I heard, but personally have not experienced a similar problem with WPF. How did you / fix it?

Thanks.

+4
source share
2 answers

There are several ways to force StyleCop to ignore generated code:
StyleCop: how to ignore generated code

As I recall, ignoring generated code is the default setting (at least it ignores my generated VS 2008 code with default settings).

I do not use VS 2010, so I don’t know how they somehow changed the file created by the constructor so that StyleCop does not recognize them as generated anymore. Perhaps the link will help you understand this in your code.

+3
source

With StyleCop, you can ignore the generated source files. I don’t know why the files created by developers should adhere to any arbitrary coding standard - the only thing that was supposed to be read or written was an automated tool, not a developer.

Code styles mainly help developers. Code generators, of course, could not care.

+2
source

Source: https://habr.com/ru/post/1312142/


All Articles