From e4d75ab25d97a25fe0af877c6e8ca0099317b7e8 Mon Sep 17 00:00:00 2001 From: elachlan <2433737+elachlan@users.noreply.github.com> Date: Thu, 28 Jul 2022 11:06:39 +1000 Subject: [PATCH] changes from discussions in #624 --- src/Microsoft.Windows.CsWin32/templates/BOOL.cs | 9 ++------- src/Microsoft.Windows.CsWin32/templates/BOOLEAN.cs | 9 ++------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/Microsoft.Windows.CsWin32/templates/BOOL.cs b/src/Microsoft.Windows.CsWin32/templates/BOOL.cs index 706854ee..a7816728 100644 --- a/src/Microsoft.Windows.CsWin32/templates/BOOL.cs +++ b/src/Microsoft.Windows.CsWin32/templates/BOOL.cs @@ -1,11 +1,6 @@ partial struct BOOL { - internal unsafe BOOL(bool value) => this.Value = value ? 1 : 0; - public static unsafe implicit operator bool(BOOL value) - { - sbyte v = checked((sbyte)value.Value); - return *(bool*)&v; - } - + internal BOOL(bool value) => this.Value = value ? 1 : 0; + public static implicit operator bool(BOOL value) => this.value != 0; public static implicit operator BOOL(bool value) => new BOOL(value); } diff --git a/src/Microsoft.Windows.CsWin32/templates/BOOLEAN.cs b/src/Microsoft.Windows.CsWin32/templates/BOOLEAN.cs index 80481937..c3c0a92b 100644 --- a/src/Microsoft.Windows.CsWin32/templates/BOOLEAN.cs +++ b/src/Microsoft.Windows.CsWin32/templates/BOOLEAN.cs @@ -1,11 +1,6 @@ partial struct BOOLEAN { - internal unsafe BOOLEAN(bool value) => this.Value = value ? 1 : 0; - public static unsafe implicit operator bool(BOOLEAN value) - { - byte v = checked((byte)value.Value); - return *(bool*)&v; - } - + internal BOOLEAN(bool value) => this.Value = value ? 1 : 0; + public static implicit operator bool(BOOLEAN value) => this.value != 0; public static implicit operator BOOLEAN(bool value) => new BOOLEAN(value); }