Code Analysis FAQ
Find answers to commonly asked questions about Visual Studio Code Analysis.
Analysis and Rules
FAQ: Why is file and line information available for some warnings in FxCop but not for others?
FAQ: Why does FxCop warn against catch(Exception)?
FAQ: Why does DoNotExposeGenericLists recommend that I expose Collection<T> instead of List<T>?
FAQ: How do I indicate to DoNotDeclareReadOnlyMutableReferenceTypes that a type is immutable?
FAQ: What exception should I throw instead of the reserved exceptions that DoNotRaiseReservedExceptionTypes warns against?
FAQ: Why do some sources recommend extending ApplicationException while FxCop does not?
FAQ: How do I fix a violation of MovePInvokesToNativeMethodsClass?
FAQ: How do I increase the number of Code Analysis warnings displayed in the Error List?
FAQ: Why does FxCop ignore my in-code (SuppressMessageAttribute) suppressions?
FAQ: What is the GlobalSuppressions.cs/GlobalSuppressions.vb file and why is it needed? Is it possible to change the name of this file?
Configuration and Setup
FAQ: How do I integrate custom rules with Visual Studio?
FAQ: Can I create custom rules that target both Visual Studio and FxCop?
FAQ: How do I debug a custom rule?
FAQ: How do I access the locals of a method in a custom rule?
FAQ: How do I get the SourceContext for a local?
FAQ: When looking at the names of locals in a custom rule, why do I see strange names such as 'CS$1$0000' and 'VB$1$0000'?