如何抑制 FxCop 规则“DoNotCatchGeneralExceptionTypes”与抑制消息?
我有可以捕获所有内容并记录下来的代码。我通常不会这样做,但我正在编写一个 HTTP 处理程序并希望返回适当的 HTTP 代码。无论如何,我将以下内容放在方法的顶部:
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "We just log the exception and return an HTTP code")]< /code>
FxCop 似乎忽略了这一点,这非常令人沮丧。特别是因为它也忽略了我所有的复合词覆盖!
知道为什么要这样做吗?我正在使用 FxCop 10,它是 Windows 7/.NET 4 SDK 的一部分。
I've got code that catches everything and logs it. I don't normally do this, but I'm writing an HTTP handler and want to return an appropriate HTTP code. Anyway, I'm putting the following at the top of my method:
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "We just log the exception and return an HTTP code")]
FxCop is seemingly ignoring this, which is very frustrating. Especially as it's also ignoring all of my compound word overrides too!
Any idea why it's doing this? I'm using FxCop 10 which is part of the Windows 7/.NET 4 SDK.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的 SupressMessage 看起来正确,因此它可能是缺少条件编译符号!
希望这有帮助,至少在我的机器上有效;)
再见,汤姆。
来源
Your SupressMessage looks correct, so it could be the missing conditional compilation symbol!
Hope this helps, at least works on my machine ;)
Greetz, Tom.
Source