为什么 StyleCop SA1305 不遵守 VS2010(或 MSBuild)中允许的前缀列表?
我刚刚将一个项目从 2008 年升级到 2010 Beta 2,StyleCop 现在正在报告带有前缀“is”的变量名称的 SA1305(匈牙利表示法)警告。 “Is”肯定在允许的前缀列表中。
这是一个已知问题吗?还有其他人遇到过这个问题吗?该代码在 2008 年确实可以在没有任何警告的情况下进行编译。
更新:事实证明,这可以在 Visual Studio 中按预期工作,但随后通过 MSBuild 失败。请参阅下面的答案了解原因。
I just upgraded a project from 2008 to 2010 Beta 2 and StyleCop is now reporting SA1305 (Hungarian notation) warnings on variable names with the prefix 'is'. 'Is' is definitely in the list of allowed prefixes.
Is this a known issue? Has anyone else run across this problem? The code was definitely compiling without any warnings in 2008.
Update: It turns out that this can work as expected in Visual Studio, but then fail through MSBuild. See the answer below for why.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以手动将“is”例外添加到Settings.StyleCop:
You can manually add the "is" exception to Settings.StyleCop:
我现在在使用 msbuild 与在开发人员盒子上构建时遇到了类似的问题。事实证明,安装的默认 Settings.StyleCop (
C:\Program Files (x86)\MSBuild\Microsoft\StyleCop\v4.4
) 实际上包含一堆您需要复制的值在您自己的文件中,如果出现以下任一情况:,或者
具体 - StyleCop 设置编辑器拾取匈牙利符号,从 < em>其他自动文件,无论“设置文件”选项卡显示什么。
I ran across a similar issue now when building with msbuild vs on a developer box. It turns out that the default Settings.StyleCop (
C:\Program Files (x86)\MSBuild\Microsoft\StyleCop\v4.4
) that is installed actually contains a bunch of values you will need to duplicate in your own file if either:or
Specifically - the StyleCop Settings Editor picks up the Hungarian notation excludes from the other file automatically, regardless of what the "Settings Files" tab says.
只需像这样添加:
http://www.thewayithink.co.uk/stylecop/ sa1305.htm
just add it like this:
http://www.thewayithink.co.uk/stylecop/sa1305.htm