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 = SafeNativeMethods.CreateSolidBrush(ColorTranslator.ToWin32(Color)); if (nativeHandle == IntPtr.Zero) // Don't use Debug.Assert, DbgUtil.GetLastErrorStr would always be evaluated. { Debug.Fail("CreateSolidBrush failed : " + DbgUtil.GetLastErrorStr()); } NativeHandle = nativeHandle; // sets the handle value in the base class. }
protected override void CreateBrush() { IntPtr nativeHandle = Gdi32.CreateSolidBrush(ColorTranslator.ToWin32(Color)); // Don't use Debug.Assert, DbgUtil.GetLastErrorStr would always be evaluated. if (nativeHandle == IntPtr.Zero) { Debug.Fail("CreateSolidBrush failed : " + DbgUtil.GetLastErrorStr()); } HBrush = nativeHandle; }