title: How to exclude MFC code from VS2008 Code Analysis
body: <p>I have a C++/CLI project that uses CWinFormsControl and CWinFormsView to create .NET controls in my MFC views. To do this I need to #include "afxwinforms.h".</p>
  
  <p>When I run Code Analysis on the project, I always get warnings about some of the MFC classes I've included. Examples:</p>
  
  <pre><code>3&gt;Running Code Analysis...
  3&gt;c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxwinforms.h(87) : warning: CA1704 : Microsoft.Naming : In method 'CWin32Window::CWin32Window(HWND__*)', correct the spelling of 'Wnd' in parameter name 'hWnd' or remove it entirely if it represents any sort of Hungarian notation.
  3&gt;c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxwinforms.h(87) : warning: CA1704 : Microsoft.Naming : In method 'CWin32Window::CWin32Window(HWND__*)', correct the spelling of 'h' in parameter name 'hWnd' or remove it entirely if it represents any sort of Hungarian notation.
  3&gt;warning: CA1051 : Microsoft.Design : Because field 'CWinFormsEventsHelper::m_pControl' is visible outside of its declaring type, change its accessibility to private and add a property, with the same accessibility as the field has currently, to provide access to it.
  3&gt;warning: CA1051 : Microsoft.Design : Because field 'CWinFormsEventsHelper::m_pSink' is visible outside of its declaring type, change its accessibility to private and add a property, with the same accessibility as the field has currently, to provide access to it.
  3&gt;c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxwinforms.inl(60) : warning: CA1704 : Microsoft.Naming : In method 'CWinFormsEventsHelper::OnHandleCreated(Object^, EventArgs^)', consider providing a more meaningful name than parameter name 'o'.
  3&gt;c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxwinforms.inl(60) : warning: CA2109 : Microsoft.Security : Consider making 'CWinFormsEventsHelper::OnHandleCreated(Object^, EventArgs^)' not externally visible.
  3&gt;c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxwinforms.inl(67) : warning: CA1704 : Microsoft.Naming : In method 'CWinFormsEventsHelper::OnHandleDestroyed(Object^, EventArgs^)', consider providing a more meaningful name than parameter name 'o'.
  3&gt;c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxwinforms.inl(67) : warning: CA2109 : Microsoft.Security : Consider making 'CWinFormsEventsHelper::OnHandleDestroyed(Object^, EventArgs^)' not externally visible.
  3&gt;c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxwinforms.inl(54) : warning: CA1704 : Microsoft.Naming : Correct the spelling of 'Unadvise' in member name 'CWinFormsEventsHelper::Unadvise(IHandleEvents*)' or remove it entirely if it represents any sort of Hungarian notation.
  3&gt;warning: CA1823 : Microsoft.Performance : It appears that field 'context_node_base::_Needs_Context' is never used or is only ever assigned to. Use this field or remove it.
  3&gt;warning: CA1812 : Microsoft.Performance : 'context_node&lt;char const *,System::String ^&gt;' is an internal class that is apparently never instantiated. If so, remove the code from the assembly. If this class is intended to contain only static methods, consider adding a private constructor to prevent the compiler from generating a default constructor.
  3&gt;c:\program files\microsoft visual studio 9.0\vc\include\msclr\marshal.h(366) : warning: CA2201 : Microsoft.Usage : 'context_node&lt;char const *,System::String ^&gt;::context_node&lt;char const *,System::String ^&gt;(const char*&amp;, String^)' creates an exception of type 'OutOfMemoryException', an exception type that is reserved by the runtime and should never be raised by managed code. If this exception instance might be thrown, use a different exception type.
  </code></pre>
  
  <p>Obviously I would like to suppress these MFC warnings so I can see my own ones more clearly. But how? I don't want to disable any warnings from my own code just to get around this issue.</p>