public static void AssertWin32(bool expression, string message) { #if DEBUG if (!expression) { Debug.Fail(message + "\r\nError: " + DbgUtil.GetLastErrorStr()); } #endif }
[Conditional("DEBUG")] // This code will be compiled into the assembly anyways, it is up to the compiler to ignore the call. private static void AssertWin32Impl(bool expression, string format, object[] args) { #if DEBUG if (!expression) { string message = string.Format(CultureInfo.CurrentCulture, format, args); Debug.Fail(message + "\r\nError: " + DbgUtil.GetLastErrorStr()); } #endif }
protected override void CreateBrush() { IntPtr nativeHandle = IntSafeNativeMethods.CreateSolidBrush(ColorTranslator.ToWin32( this.Color)); if(nativeHandle == IntPtr.Zero) // Don't use Debug.Assert, DbgUtil.GetLastErrorStr would always be evaluated. { Debug.Fail("CreateSolidBrush failed : " + DbgUtil.GetLastErrorStr()); } this.NativeHandle = nativeHandle; // sets the handle value in the base class. }