From 53ae91581d27109117ee5aa29af0283d5d31393e Mon Sep 17 00:00:00 2001 From: Robin Date: Tue, 4 Dec 2018 14:36:50 +0100 Subject: [PATCH] Some small fixes, these should help to track an issue the tests had. [release] --- src/Dapplo.Windows.Common/Structs/NativeRect.cs | 2 +- src/Dapplo.Windows.Common/Structs/NativeSize.cs | 2 +- src/Dapplo.Windows.Common/Structs/NativeSizeFloat.cs | 2 +- .../Dapplo.Windows.Messages.csproj | 3 ++- src/Dapplo.Windows.Messages/WinProcHandler.cs | 8 ++++---- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Dapplo.Windows.Common/Structs/NativeRect.cs b/src/Dapplo.Windows.Common/Structs/NativeRect.cs index 31f608a1..5d6ad635 100644 --- a/src/Dapplo.Windows.Common/Structs/NativeRect.cs +++ b/src/Dapplo.Windows.Common/Structs/NativeRect.cs @@ -277,7 +277,7 @@ public bool Equals(NativeRect other) /// Checks if this NativeRect is empty /// /// true when empty - public bool IsEmpty => Width * Height == 0; + public bool IsEmpty => unchecked (Width * Height) == 0; /// [Pure] diff --git a/src/Dapplo.Windows.Common/Structs/NativeSize.cs b/src/Dapplo.Windows.Common/Structs/NativeSize.cs index 77771220..d53da8c2 100644 --- a/src/Dapplo.Windows.Common/Structs/NativeSize.cs +++ b/src/Dapplo.Windows.Common/Structs/NativeSize.cs @@ -204,7 +204,7 @@ public NativeSize(int width, int height) /// [Pure] - public int CompareTo(NativeSize other) => (other.Width * other.Height).CompareTo(Width * Height); + public int CompareTo(NativeSize other) => unchecked (other.Width * other.Height).CompareTo(unchecked(Width * Height)); /// [Pure] diff --git a/src/Dapplo.Windows.Common/Structs/NativeSizeFloat.cs b/src/Dapplo.Windows.Common/Structs/NativeSizeFloat.cs index 56e55da5..1db2bd7a 100644 --- a/src/Dapplo.Windows.Common/Structs/NativeSizeFloat.cs +++ b/src/Dapplo.Windows.Common/Structs/NativeSizeFloat.cs @@ -315,7 +315,7 @@ public bool Equals(NativeSizeFloat other) /// [Pure] - public int CompareTo(NativeSizeFloat other) => (other.Width * other.Height).CompareTo(Width * Height); + public int CompareTo(NativeSizeFloat other) => unchecked(other.Width * other.Height).CompareTo(unchecked (Width * Height)); /// [Pure] diff --git a/src/Dapplo.Windows.Messages/Dapplo.Windows.Messages.csproj b/src/Dapplo.Windows.Messages/Dapplo.Windows.Messages.csproj index 1c037e46..2e6ca3e6 100644 --- a/src/Dapplo.Windows.Messages/Dapplo.Windows.Messages.csproj +++ b/src/Dapplo.Windows.Messages/Dapplo.Windows.Messages.csproj @@ -9,9 +9,10 @@ true - + all + diff --git a/src/Dapplo.Windows.Messages/WinProcHandler.cs b/src/Dapplo.Windows.Messages/WinProcHandler.cs index e0372311..8ab03355 100644 --- a/src/Dapplo.Windows.Messages/WinProcHandler.cs +++ b/src/Dapplo.Windows.Messages/WinProcHandler.cs @@ -28,6 +28,7 @@ using System.Linq; using System.Reactive.Disposables; using System.Windows.Interop; +using Dapplo.Log; #endregion @@ -38,6 +39,7 @@ namespace Dapplo.Windows.Messages /// public class WinProcHandler { + private static readonly LogSource Log = new LogSource(); private static HwndSource _hWndSource; /// @@ -64,14 +66,12 @@ private HwndSource MessageHandlerWindow { return _hWndSource; } - if (_hWndSource != null && !_hWndSource.IsDisposed) - { - return _hWndSource; - } // Create a new message window _hWndSource = CreateMessageWindow(); + Log.Verbose().WriteLine("MessageHandlerWindow with handle {0} was created.", _hWndSource.Handle); _hWndSource.Disposed += (sender, args) => { + Log.Verbose().WriteLine("MessageHandlerWindow with handle {0} is disposed.", _hWndSource.Handle); UnsubscribeAllHooks(); }; // Hook automatic removing of all the hooks