简体   繁体   English

需要验证参数的FxCop自定义规则

[英]FxCop custom rule requiring validation of parameters

I'm trying to make a custom FxCop rule that will test for calls to the indexer getter of Request.QueryString without a previous call (in the same method) to a certain validation method from our project's Utilities module. 我正在尝试制作一个自定义FxCop规则,该规则将测试对Request.QueryString的索引器getter的调用,而无需从项目的Utilities模块中对某个验证方法进行先前的调用(在同一方法中)。

The documentation I've found is not in-depth enough to get me where I need to go. 我发现的文档不够深入,无法让我到达我需要去的地方。 Is there some doc that I'm missing? 我缺少一些文档吗? Or is it time for trial and error? 还是该试错了?

What I've seen: 我所看到的:

http://www.binarycoder.net/fxcop/ http://www.binarycoder.net/fxcop/

http://blog.tatham.oddie.com.au/2010/01/06/custom-code-analysis-rules-in-vs2010-and-how-to-make-them-run-in-fxcop-and-vs2008-too/ http://blog.tatham.oddie.com.au/2010/01/06/custom-code-analysis-rules-in-vs2010-and-how-to-make-them-run-in-fxcop-and- VS2008太/

http://blogs.msdn.com/b/codeanalysis/ http://blogs.msdn.com/b/codeanalysis/

http://msdn.microsoft.com/en-us/magazine/cc163930.aspx http://msdn.microsoft.com/en-us/magazine/cc163930.aspx

As well as all SO posts tagged FxCop with the word custom. 以及所有SO帖子都标有FxCop的单词custom。

Any ideas? 有任何想法吗?

There is no official SDK for FxCop rules. 没有用于FxCop规则的官方SDK。 The most complete single resource is http://www.binarycoder.net/fxcop/ . 最完整的单一资源是http://www.binarycoder.net/fxcop/ Pretty much all the available resources are geared toward helping one get started with the "wrapper" mechanics of creating rules. 几乎所有可用资源都是为了帮助我们开始创建规则的“包装”机制。 None of them really cover the finicky details of how to create specific rule logic. 它们都没有真正涵盖如何创建特定规则逻辑的细节。 For that sort of thing, your best bet is to grab a decompiler like Reflector so that you can see how the Microsoft-supplied rules are built. 对于这种事情,最好的选择是使用像Reflector这样的反编译器,以便您可以看到Microsoft提供的规则是如何构建的。 Another helpful technique is to run your embryonic rules under the debugger so that you can see the objects and properties that are available at runtime. 另一个有用的技术是在调试器下运行您的胚胎规则,以便您可以看到运行时可用的对象和属性。 If you get stuck with some particular part of a rule implementation, you can always ask about it either here or on the FxCop forum maintained by Microsoft . 如果您对规则实现的某些特定部分感到困惑,您可以随时在此处或在Microsoft维护FxCop论坛上询问此问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM