Friday, March 5, 2010

Disabling StyleCop for a single file

I am working on implementing an interface that is not finalized yet. Lot of things are in flux. But I want to continue to implement and make changes later on as things progress. The main problem for me right now is not the code but StyleCop. It keeps complaining about lack of documentation in my code. But I don’t want to write the documentation just yet as things can change too much and fix them all later. And, my build is failing. Not a pretty sight.

So in order to overcome this issue, I wanted to disable the StyleCop only for my CS file but leave it working for other files.

The easy way to do this is to put the following lines at the top of the file.

//------------------------------------------------------------------------------

// <auto-generated>

// This code was generated by a tool.

// </auto-generated>

//------------------------------------------------------------------------------

StyleCop does not complain anymore and my build is successful.

Cool, huh?

Later on I can go back and fix those documentation.

Namaskara,

Harsha

3 comments:

  1. This is worst solution

    ReplyDelete
  2. Whats the best solution then?

    ReplyDelete
  3. You should add a 'ExcludeFromStyleCop' tag to your source file in csproj. See http://blogs.msdn.com/b/sourceanalysis/archive/2008/11/11/introducing-stylecop-on-legacy-projects.aspx.

    ReplyDelete