0

I'm seeing the following in VS 2017 Enterprise on a csproj, Project1, that's being built on .Net 4.5.2:

18>------ Rebuild All started: Project: Project1, Configuration: Debug Any CPU ------
18>C:\git\27844-2-StyleCop\company\Class1.cs(26,31,26,47): warning CS0169: The field 'Class1.field' is never used
18>C:\git\27844-2-StyleCop\company\Class2.cs(31,48,31,69): warning SA1214: Readonly fields must appear before non-readonly fields
18>C:\git\27844-2-StyleCop\company\Interface1.cs(9,45,9,69): warning SA1127: Generic type constraints must be on their own line
18>  Project1 -> C:\git\27844-2-StyleCop\company\Project1\Project1\bin\Debug\Project1.dll
18>  Running Code Analysis...
18>  Code Analysis Complete -- 0 error(s), 0 warning(s)

Clearly there's 3 warnings there being picked up by a combination of the built-in C# DotNetAnalyzers and version 1.0.2 of the StyleCop.Analyzers. What I'm wondering is why the:

18> Code Analysis Complete - 0 error(s), 0 warning(s)

section is not:

18> Code Analysis Complete - 0 error(s), 3 warning(s)

and why none of these warnings (or errors for that matter, as I've seen this happen with rules treated as errors) are appearing in the code analysis log file, Project1.dll.CodeAnalysisLog.xml

I've tried:

  • Turning off/on Enable Code Analysis on Build in the project properties
  • Turning off/on Treat Warnings as Errors in the project properties
  • Ensuring there's no Suppress warnings in the project properties
  • Ensuring that the ruleset I'm using is running on the Configuration / Platform I'm build on
  • Cleaning / Rebuilding
  • Running Code Analysis explicitly on the project

Am I doing something wrong?

Jesse
  • 33
  • 1
  • 7

1 Answers1

1

Build and Code Analysis are separate steps.

StyleCop Analyzers do not run in the Code Analysis step (as per https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2456 ).

mjwills
  • 23,389
  • 6
  • 40
  • 63
  • This is the correct answer. Although I'd hoped I would be able to see this through build output, it makes more sense why I can't now. Thanks! – Jesse Oct 25 '17 at 18:10