Is it possible to have Code Analysis warnings formatted like normal ones?

淺唱寂寞╮ 提交于 2019-12-07 22:01:09

问题


I like the code analysis included in VS2012. But it's a bit annoying that the warnings are only processable in the Code Analysis window, and not by stepping through the build output with F4.

Is there a way to overcome this limitation? How could I format the output of the static code analysis like normal compiler output (i.e. don't only print the filename but the correct path to the file being inspected)?

I'm not using FxCop since I'm working with unmanaged code.


回答1:


For unmanaged code analysis, the MSBuild scripts use /analyze:quiet instead of /analyze in order to prevent writing results to the error list. The simplest way to change the behavior would be to modify your Microsoft.CodeAnalysis.Targets file (typically located at C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\CodeAnalysis\Microsoft.CodeAnalysis.Targets) to avoid specifying quiet mode. i.e.: Change the line

<AdditionalOptions Condition="'$(PlatformToolsetVersion)'&gt;='110'">%(ClCompile.AdditionalOptions)  /analyze:quiet</AdditionalOptions>

to

<AdditionalOptions Condition="'$(PlatformToolsetVersion)'&gt;='110'">%(ClCompile.AdditionalOptions)  /analyze</AdditionalOptions>


来源:https://stackoverflow.com/questions/19111524/is-it-possible-to-have-code-analysis-warnings-formatted-like-normal-ones

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!