Reliability Warnings


For the latest documentation on Visual Studio 2017 RC, see Visual Studio 2017 RC Documentation.

Reliability warnings support library and application reliability, such as correct memory and thread usage.

CA2000: Dispose objects before losing scopeBecause an exceptional event might occur that will prevent the finalizer of an object from running, the object should be explicitly disposed before all references to it are out of scope.
CA2001: Avoid calling problematic methodsA member calls a potentially dangerous or problematic method.
CA2002: Do not lock on objects with weak identityAn object is said to have a weak identity when it can be directly accessed across application domain boundaries. A thread that tries to acquire a lock on an object that has a weak identity can be blocked by a second thread in a different application domain that has a lock on the same object.
CA2003: Do not treat fibers as threadsA managed thread is being treated as a Win32 thread.
CA2004: Remove calls to GC.KeepAliveIf you are converting to SafeHandle usage, remove all calls to GC.KeepAlive (object). In this case, classes should not have to call GC.KeepAlive, assuming they do not have a finalizer but rely on SafeHandle to finalize the OS handle for them.
CA2006: Use SafeHandle to encapsulate native resourcesUse of IntPtr in managed code might indicate a potential security and reliability problem. All uses of IntPtr must be reviewed to determine whether use of a SafeHandle, or similar technology, is required in its place.