Fun with Code Analysis Rule Sets

Two weeks ago, I introduced you to Visual Studio 2010 September ’08 CTP (Community Technology Preview). This CTP is available as a Virtual PC (VPC) image which can be downloaded at http://go.microsoft.com/fwlink/?LinkId=129231. The goal of the Community Technology Preview is to obtain feedback from our customers on the new scenarios we have enabled.  If you…

5

FxCop 1.36 Released!

We are pleased to announce that we’ve released the next version of FxCop. This release has a number of changes since FxCop 1.36 Beta 2, including, but not limited to, the following: Bug fixes that reduce noise, missing analysis and rule crashes. New portability rule: Use Only API from Targeted Framework.  This rule will fire when…

11

New for Visual Studio 2008 – Custom Dictionaries

Once you turn on the new spelling rules that we’ve added to Visual Studio 2008, you will want to start to customize the words that it fires on; this is where the new custom dictionary support comes in. A custom dictionary in its basic form, similar to the concept in Microsoft Word, allows you to silence the…

11

New for Visual Studio 2008 – Spelling rules

Surprisingly, one the biggest requests for Code Analysis in Visual Studio 2005 was to include the spelling rules that shipped with the FxCop standalone. We had Microsoft consultants tell us that they actually had trouble moving some customers from FxCop to Code Analysis because they were not included. Apparently teams care about spelling. 🙂 Well,…

13

What rules do Microsoft have turned on internally?

I’ve recently received a few requests asking about the Code Analysis rules we run internally against Microsoft’s own code. While it might come as a surprise, we do not actually run every single rule against our own binaries. There are many reasons for this: Applicability. Not every rule is applicable to every project, for example, the…

22

TIP: How to change the (Orcas) Managed Code Analysis naming/design rules to fire on internals

A while ago I mentioned that FxCop (and hence Managed Code Analysis) naming and design rules only fire on publicly visible types and members. As you may recall, there were a couple of reason for this: The .NET Framework Design Guidelines, which FxCop/Managed Code Analysis enforces, only contains guidelines for publicly visible API. What internal Microsoft teams (and you) do with their internal…

1

What resolutions or warnings need to provide more information?

One of things that we are doing for Orcas, is to basically do what we call a resolution scrub. This is where we print out every single possible resolution/warning and read over them to check for consistency, proper grammer and to see if they provide enough information for the user to both understand and fix the issue. Unfortunately,…

9

How to Design Exception Hierarchies

Krzysztof Cwalina, owner of the Framework Design Guidelines, has written a great post on designing exception hierarchies. He gives a great overview on the different categories of exceptions, which are placed under two main buckets he calls usage and system, and the right situations to throw them. This post also goes hand-in-hand with some of the…

0

FAQ: What exception should I throw instead of the reserved exceptions that DoNotRaiseReservedExceptionTypes warns against?

Throwing a general exception type such as System.Exception or System.SystemException in a library or Framework forces consumers to catch all exceptions, including unknown exceptions that they do not know how to handle (see FAQ: Why does FxCop warn against catch(Exception)? for reasons as to why this is bad). Instead, either throw a more derived type that already…

14