AddSourceCode returns always false

Nov 5, 2010 at 12:24 PM

Hello I want to use the StyleCop Sdk in order to analyse my projects, I have tried to create a simple console application where I put simply a project path and a *.cs file path like this example: StyleCop from Your Code

I have put the same code but the console.Core.Environment.AddSourceCode(project, filePath, null)) always returns false.

I don´t know what´s happening maybe the styleCop doesn´t have permission to add the source file (I´m launching Visual Studio as Administrator)

I´m using VS2010 Ultimate and a Windows Server 2008 R2 Enterprise.

Any ideas?

Nov 5, 2010 at 4:25 PM


Could you please describe your problem more detaily?
What is printed to the console when you run your app?

Best regards,
Oleg Shuruev 

Nov 8, 2010 at 7:43 AM


The console shows 'No violations encountered'.

The problem is that the method AddSourceCode returns always false.

I have downloaded the source code of StyleCop. It seems that the instuction ICollection<SourceParser> parserList = this.GetParsersForFileType(extension) which is inside the AddSourceCode method doesn´t return any parser.

Nov 8, 2010 at 8:09 AM

Hello, again I have solved it.

I need to put in my project the reference for the StyleCop C# Parser and the Rules.

Nov 8, 2010 at 9:42 AM
Edited Nov 8, 2010 at 9:44 AM

Yeah, now it's clear - you tried to run "empty" StyleCop without parsers and analyzers ;)

Glad you solved it!

P.S. I will include this tip in the "Running StyleCop from Your Code" documentation (under the link you mentioned).

Best regards,
Oleg Shuruev