Developer, Former MVP, now at Microsoft - Best of 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
// no comments on the content of the method pleasepublic void SomeMethod(bool b, object o) { if (b) { ((EventHandler)o).Invoke(null, EventArgs.Empty); } else { ((EventHandler)o).BeginInvoke(null, EventArgs.Empty, null, null); }}
CA1800 : Microsoft.Performance : 'o', a parameter, is cast to type 'System.EventHandler' multiple times in method Class1.SomeMethod(Boolean, Object):Void. Cache the result of the 'as' operator or direct cast in order to eliminate the redundant castclass instruction.
The type or namespace name 'CodeAnalysis' does not exist in the namespace 'System.Diagnostics' (are you missing an assembly reference?)
namespace System.Diagnostics.CodeAnalysis { public class SuppressMessageAttribute : Attribute { public SuppressMessageAttribute(string category, string checkId) {} }}