【发布时间】:2012-05-21 17:34:07
【问题描述】:
我正在开发一个 ASP.NET 项目。投影当然有一个 Global.asax 文件。在 Global.asax.cs 文件中,它包含以下每个方法,[Application_Start 除外] 并非真正为空,但不需要实际实现:
protected void Application_Start(object sender, EventArgs e){ }
protected void Session_Start(object sender, EventArgs e){ }
protected void Session_End(object sender, EventArgs e){ }
protected void Application_Error(object sender, EventArgs e){ }
我一直在慢慢启用 Visual Studio 2008 必须提供的每个 FxCop 规则,最近遇到了与上述方法有关的冲突。我遇到的第一个错误是 CA2109
CA2109 : Microsoft.Security : Consider making 'Global.Application_Error(object, EventArgs)' not externally visible.
每个方法都会显示此错误。由于我没有手动调用任何这些方法,因此我可以通过将每个方法设置为private 来消除此警告。执行此操作并重新运行代码分析后,我收到错误 CA1811:
CA1811 : Microsoft.Performance : 'Global.Application_Error(object, EventArgs)' appears to have no upstream public or protected callers.
我对 Stack Overflow 社区世界中的所有人的问题是:我应该听哪个警告,应该禁止哪个警告?有没有办法同时满足这两个警告?
我是否正确假设安全胜过一切,因此我应该听 CA2109 并抑制 CA1811?
【问题讨论】:
标签: asp.net performance security global-asax fxcop