开发者

Visual Studio Code Analysis - Does Microsoft follow it themselves?

开发者 https://www.devze.com 2022-12-30 22:50 出处:网络
Did a quick search but could not find anything about this. I guess all of you know that the Visual Studio Code Analysis is quite nitpicking and gives warnings ab开发者_如何转开发out a lot of things.

Did a quick search but could not find anything about this.

I guess all of you know that the Visual Studio Code Analysis is quite nitpicking and gives warnings ab开发者_如何转开发out a lot of things. Does anybody know how well Microsoft follow this themselves..? That is, if I were to run a code analysis on their assemblies, would the warnings be none or very few (perhaps surpress warning with a justification..?).


Most of the things that code analysis (or FXCop) check are closely based on the ".NET Framework Library Design Guidelines" (either the book, or on MSDN).

However those guidelines (especially in the book) have caveats, not all apply in all circumstances.

There are plenty of indications that MS do use these tools, but I assume they do have reasons to not apply all the rules all the time, as any other project does.


There are two core tools used widely at Microsoft for Code Analysis: FXCop for managed code and PreFast for native C++.

Historically, while not every team has thoroughly enforced the use of CA when building their products, there's been a significant upswing over the last 3-4 years in particular in the number of teams that now enforce pretty stringent CA requirements on their feature teams and on the product as a whole.

For example, in Vista, the Windows team essentially took 3 months off product development and SAL-annotated the vast majority of their key method and function declarations. in Win7, they mandated that all new code had to comply with a set of requirements for SAL-annotating key scenarios (primarily to reduce the likelihood of buffer overruns). In Win8 they're going further still and are incorporating new SAL annotations for a number of key scenarios. Combined with improved compilers and tools like PreFast (now build into VS 2010 Pro and up), they and you can find and eliminate potential issues before the product is released.

Note that the warnings issues by CA (whichever CA tool you choose to use) will always require overrides - sometimes, there's a really good reason as to why the code has to do what it does. But you should only override if you're ABSOLUTELY sure it's necessary and appropriate. NEVER turn off a warning because you don't understand it and never turn off a warning if you can't be bothered to fix it.

0

精彩评论

暂无评论...
验证码 换一张
取 消