Inconsistent violation check results between VS IDE & StyleCop activity

Apr 1, 2011 at 3:17 PM
Edited Apr 1, 2011 at 4:53 PM

When I use VS IDE, I get 37 warnings.

StyleCop check has been integrated with team foundation build using this extensions. While running the build with the same rules (settings file), I get "No violations encountered"

Below is my input

styleCop

 

 Initial Property Values
AdditionalAddInPaths =
CacheResults = False
FailBuildOnError = False
ForceFullAnalysis = True
LogExceptionStack = False
LogFile = C:\Builds\1\AgileDemo\StyleCopTestBuild\Sources\StyleCopLog.txt
MaximumViolationCount = 100
SettingsFile = C:\Builds\1\AgileDemo\StyleCopTestBuild\Sources\ConsoleApp\ConsoleApp\Settings.StyleCop
ShowOutput = True
SourceFiles = String[] Array
TreatViolationsErrorsAsWarnings = False
TreatWarningsAsErrors = True
XmlOutputFile = C:\temp\StyleCopviolations.xml

 

 

Below is the output I see

 

 

Final Property Values
AdditionalAddInPaths =
CacheResults = False
FailBuildOnError = False
ForceFullAnalysis = True
LogExceptionStack = False
LogFile = C:\Builds\1\AgileDemo\StyleCopTestBuild\Sources\StyleCopLog.txt
MaximumViolationCount = 100
SettingsFile = C:\Builds\1\AgileDemo\StyleCopTestBuild\Sources\ConsoleApp\ConsoleApp\Settings.StyleCop
ShowOutput = True
SourceFiles = String[] Array
Succeeded = True
TreatViolationsErrorsAsWarnings = False
TreatWarningsAsErrors = True
ViolationCount = 0
XmlOutputFile = C:\temp\StyleCopviolations.xml

No violations encountered

Please help me to understand the reason for inconsistency.

Additionally, I dont see any .log fil getting generated.

--SS

Apr 4, 2011 at 3:25 PM

Any thoughts?

Is this a bug or expected behavior...?

Coordinator
Apr 4, 2011 at 3:29 PM

Looks like a bug, but I need to look further. I'll try look tonight.

 

Mike

Apr 4, 2011 at 3:41 PM

Thanks Mike. That would be great.

Is there anyway to activate the logging?

Even I tried using previous stable version, no luck.

--SS

Coordinator
Apr 4, 2011 at 8:43 PM

Hi

I cant repro this.

Are your 37 warnings definitely StyleCop?

Below is my repro which creates the same number of errors and it logs to the path intended.

      <tac1:StyleCop AdditionalAddInPaths="{x:Null}" CacheResults="{x:Null}" FailBuildOnError="{x:Null}" LogExceptionStack="{x:Null}" MaximumViolationCount="{x:Null}" ShowOutput="{x:Null}" Succeeded="{x:Null}" TreatViolationsErrorsAsWarnings="{x:Null}" TreatWarningsAsErrors="{x:Null}" XmlOutputFile="{x:Null}" ForceFullAnalysis="True" sap:VirtualizedContainerService.HintSize="1928,22" LogFile="[SourcesDirectory + &quot;\StyleCopLog.txt&quot;]" SettingsFile="[SourcesDirectory + &quot;\Misc\TestCode\Settings.StyleCop&quot;]" SourceFiles="[New String() {SourcesDirectory}]" ViolationCount="[Violations]" />

 

Mike

Apr 5, 2011 at 3:31 AM

Thanks Mike.

Yes. They are all StyleCop warnings.

The only difference that I could notice is the log file location. I point it to a folder that doesn't exist and expecting it to create that folder at runtime. I may be wrong.

The other perspective to troubleshoot is the procedure that you follow to customize the template, here is what I do.. please suggest if any changes

1/Check-out appropriate Build Process template

2/Load the XAML and Tool box

3/Right click Tool box --> Choose Items --> System.Activities Components --> Browse and choose "Microsoft.StyleCop.dll"

4/Then ideally StyleCop activity would appear in the tool box, drag and drop the activity into the WorkFlow and fillup the parameters.

Is this what you do? or should I refer some other .dlls as well?

Apr 5, 2011 at 1:44 PM
Edited Apr 5, 2011 at 4:46 PM

Hi Mike -

Thanks for the help. Attached the sample project which is driving me nuts.

ConsoleApp is the application which has StyleCop warnings/violations
WorkFlowConsoleApplication1 is the WF console app where I've attempted to reuse your custom activity and get stylecop working. (I tried this as teambuild integration failed miserably)

Please have a look at this and suggest whats wrong in my approach.
This would be really helpful for me to move forward.

Coordinator
Apr 5, 2011 at 4:38 PM

what attachment? can you paste a link to it?

 

Mike

Apr 5, 2011 at 6:01 PM

Please try to access it here..
https://docs.google.com/leaf?id=0BycEA2mjtXKoN2RkNGNlMjctN2E1Ny00MmY3LWIwMDctNTRmOWYwYjZhOWVk&hl=en&authkey=CLD8m4AP




From: [email removed]
To: [email removed]
Date: Tue, 5 Apr 2011 09:38:51 -0700
Subject: Re: Inconsistent violation check results between VS IDE & StyleCop activity [tfsbuildextensions:252167]

From: mikefourie

what attachment? can you paste a link to it?

Mike
Read the full discussion online.
To add a post to this discussion, reply to this email (tfsbuildextensions@discussions.codeplex.com)
To start a new discussion for this project, email tfsbuildextensions@discussions.codeplex.com
You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.
Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com
Apr 6, 2011 at 5:15 AM

Looks like its something similar to discussion: 220546 - please have a look at it.

Thanks!!

May 4, 2011 at 10:38 AM
Edited May 4, 2011 at 11:15 AM

Hi guys,

What was the outcome of this? I'm having the same problem. I can't get the activity to find any violations. This is my activity:

<tac:StyleCop AdditionalAddInPaths="{x:Null}" CacheResults="False" FailBuildOnError="True" ForceFullAnalysis="True" sap:VirtualizedContainerService.HintSize="269,100" LogExceptionStack="True" LogFile="StyleCopLog.txt" MaximumViolationCount="50" SettingsFile="[SourcesDirectory + &quot;\&quot; + &quot;Settings.StyleCop&quot;]" ShowOutput="True" SourceFiles="[New String() {SourcesDirectory}]" Succeeded="[ScanSucceeded]" TreatViolationsErrorsAsWarnings="False" TreatWarningsAsErrors="True" ViolationCount="[ScanViolationCount]" XmlOutputFile="StyleCopViolations.xml" />

Anything obviously wrong there?

 

(edit: corrected xaml)

May 5, 2011 at 2:36 AM
Guess your process is missing parser and other dependencies...
I did 2 things and it worked.
1. check-in stylecop assemblies
2. provide that path in AdditionalAddInPaths

Please try and share the feedback.

--SS


From: [email removed]
To: [email removed]
Date: Wed, 4 May 2011 03:38:18 -0700
Subject: Re: Inconsistent violation check results between VS IDE & StyleCop activity [tfsbuildextensions:252167]

From: pablocoberly
Hi guys,
What was the outcome of this? I'm having the same problem. I can't get the activity to find any violations. This is my activity:
<tac1:StyleCop AdditionalAddInPaths="{x:Null}" CacheResults="{x:Null}" FailBuildOnError="{x:Null}" LogExceptionStack="{x:Null}" MaximumViolationCount="{x:Null}" ShowOutput="{x:Null}" Succeeded="{x:Null}" TreatViolationsErrorsAsWarnings="{x:Null}" TreatWarningsAsErrors="{x:Null}" XmlOutputFile="{x:Null}" ForceFullAnalysis="True" sap:VirtualizedContainerService.HintSize="1928,22" LogFile="[SourcesDirectory + "\StyleCopLog.txt"]" SettingsFile="[SourcesDirectory + "\Misc\TestCode\Settings.StyleCop"]" SourceFiles="[New String() {SourcesDirectory}]" ViolationCount="[Violations]" />
Anything obviously wrong there?
Read the full discussion online.
To add a post to this discussion, reply to this email (tfsbuildextensions@discussions.codeplex.com)
To start a new discussion for this project, email tfsbuildextensions@discussions.codeplex.com
You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.
Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com
May 12, 2011 at 11:39 AM
Edited May 13, 2011 at 10:55 AM

Thanks for your response.

Yeah I've got the "Microsoft.StyleCop.dll" checked in and provided the path to it in the AdditionalAddInPaths property. I tried the absolute path to the file itself as well as the absolute path to the folder containing the assembly. Still no luck.

I've debugged a test workflow using the activity and I still can't make it work. The files to be scanned are discovered by the activity, but as far as I can tell they aren't being added to the "CodeProject". For example, my test gets to the following line (Line 208, Stylecop.cs):

console.Core.Environment.AddSourceCode(project, fileInDirectory, null);

"AddSourceCode" returns false, which suggested to me that there aren't weren't any parsers loaded for stylecop to use. What addins should I have? I've got:

Microsoft.StyleCop.CSharp.dll
Microsoft.StyleCop.CSharp.Rules.dll

[Edit: Added debug comments]

May 19, 2011 at 9:46 AM
Edited May 19, 2011 at 9:48 AM

Just to follow this up, I discovered that my particular problem was that I had used incorrect assembly versions for my add-ins. I was using 4.4.1.2 assemblies instead of 4.4.0.14.

This meant that no parsers were loaded into the "StyleCopConsole" instance which in turn meant that any calls to "AddSourceCode" returned false.