SA0001 & NullReferenceException when disabling analysis of designer.cs files

Nov 12, 2012 at 1:29 PM

I have a project with a customized StyleCop settings file. The settings file has some minor modifications compared to the file installed with v. Among other things the analysis of designer files is disabled, and that seems to cause some problems. I have no problem analyzing my solution through Visual Studio  -neither on my development machine nor on the build server, but with team build and the StyleCop task from MSBuild Extension Pack, I get the following exception on Pass 2:

d:\Builds\267\BuildType\..\Sources\Main\Source\Properties\Resources.Designer.cs - Failed on Line 1. SA0001: An exception occurred while parsing the file: System.NullReferenceException, Object reference not set to an instance of an object. [d:\Builds\267\BuildType\TFSBuild.proj]
   at StyleCop.StyleCopThread.RunAnalyzers(CodeDocument document, SourceParser parser, IEnumerable`1 analyzers) [d:\Builds\267\BuildType\TFSBuild.proj]
   at StyleCop.StyleCopThread.TestAndRunAnalyzers(CodeDocument document, SourceParser parser, IEnumerable`1 analyzers, Int32 passNumber) [d:\Builds\267\BuildType\TFSBuild.proj]
   at StyleCop.StyleCopThread.ParseAndAnalyzeDocument(SourceCode sourceCode, DocumentAnalysisStatus documentStatus) [d:\Builds\267\BuildType\TFSBuild.proj]
   at StyleCop.StyleCopThread.DoWork(Object sender). [d:\Builds\267\BuildType\TFSBuild.proj]

This exception is thrown for the first two designer files and then the analysis is aborted.

If I re-enable analysis of designer files, the analysis is performed (but with hundreds of analysis warnings due to rules that are broken in designer files).

As mentioned I'm running StyleCop v. on both development machine and build server. The only other differences in my settings file compared to the one installed with v. 4.7 is that some rules with regards to documentation.

Any ideas to what is going wrong and what could be different from performing the analysis through Visual Studio?