How can you force StyleCop to ignore a file?

NickG picture NickG · May 30, 2013 · Viewed 13.2k times · Source

I've included a 3rd party .cs file in my code. It doesn't comply with StyleCop's rules but I desperately need to be able to exclude it from StyleCop's checks but none of the methods I've found so far will work.

Three methods are documented here: http://sethflowers.com/blog/force-stylecop-to-ignore-a-file/ .. but none of these methods seems to work in StyleCop 4.7

The most useful of which looks to be this method in .csproj:

<Compile Include="AViolatingFile.cs">
    <ExcludeFromStyleCop>true</ExcludeFromStyleCop>
</Compile>

But despite having added the files, StyleCop still causes a compilation error when parsing this file.

Answer

user2627366 picture user2627366 · Nov 26, 2014
// <auto-generated/>

Put this at the top of the class

Style cop ignores auto generated code