禁用 AND 和 OR 关键字

发布于 2024-08-31 22:02:57 字数 249 浏览 2 评论 0原文

在 VB.net 中,ANDALSOORELSE 关键字基本上始终优先于 ANDOR 关键字。< br> 禁用 AND 和 OR 关键字的最简单方法是什么?
我在想 FXCop(也许有人已经写了这条规则)。
也许只是 VS 中的一些设置(我们目前使用的是 2008 年,并将在夏末转向 2010 年),

我愿意接受所有建议。

In VB.net the ANDALSO and ORELSE keywords should basically always be prefered over the AND and OR keywords.
What is the easiest way to disable the AND and OR keywords?
I'm thinking FXCop (maybe somebody has already written this rule).
Maybe just some setting in VS (we're currently using 2008 and are moving to 2010 end of the summer)

I'm open for all suggestions.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

御守 2024-09-07 22:02:58

呵呵,我想你正在寻找的解决方案叫做C#。

但说真的,使用 VB,您可以使用 FXCop 或类似的代码分析工具来执行某种全面的策略。

但是,当涉及到语言的核心逻辑运算符这样的基本功能时,即使通过策略执行,您也可能不应该扰乱它们。这是一个培训问题,最好通过培训来解决。

检测这些操作符的意外误用或无意使用最好通过单元测试或同行评审来处理。基本运算符行为是任何 VB 初学者指南中第一章的内容,如果程序员尚未掌握该语言的基本语法和运算符,则不应编写真正的生产代码。

Hehe, I think the solution you are looking for is called C#.

But seriously, using VB, you could go with some kind of blanket policy enforcement using FXCop or similar code analysis tools.

But when it comes to such a basic and fundamental feature as the language's core logic operators, you probably shouldn't mess with them even through policy enforcement. This is a training issue, and would be best addressed by training.

Detecting the accidental mis-use or unintentional use of these operators is best handled via unit testing or peer review. Basic operator behaviors are Chapter 1 stuff in any beginner's guide to VB, and no programmer should be working on real production code if they haven't mastered the basic syntax and operators of the language yet.

巡山小妖精 2024-09-07 22:02:58

AndOr 关键字除了布尔运算之外还有其他用途。执行按位运算是由这些关键字完成的,因此除非您可以绝对确定您永远不需要执行按位运算,否则您不想禁用这些关键字。

The And and Or keywords have other uses besides just boolean operations. Performing bitwise operations is done by these keywords, so unless you can be absolutely certain that you will never need to do bitwise operations, you do not want to disable these keywords.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文