是否可以像普通警告一样格式化“代码分析”警告? [英] Is it possible to have Code Analysis warnings formatted like normal ones?

查看:77
本文介绍了是否可以像普通警告一样格式化“代码分析”警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我喜欢VS2012中包含的代码分析。但是有点烦人的是,警告只能在代码分析窗口中处理,而不能通过使用 F4 单步执行生成输出来完成。

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)?

我不使用FxCop,因为我正在使用非托管代码。

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

推荐答案

对于非托管代码分析,MSBuild脚本使用<为了防止将结果写入错误列表,请使用code> / analyze:quiet 代替 / analyze 。更改行为的最简单方法是修改 Microsoft.CodeAnalysis.Targets 文件(通常位于 C:\Program Files(x86)) \MSBuild\Microsoft\VisualStudio\v11.0\CodeAnalysis\Microsoft.CodeAnalysis.Targets )以避免指定安静模式。即:更改行

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>

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

这篇关于是否可以像普通警告一样格式化“代码分析”警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆