diff --git a/PInvoke/Security/AdvApi32/Evntrace.cs b/PInvoke/Security/AdvApi32/Evntrace.cs
index 6537d7f2..a33945b8 100644
--- a/PInvoke/Security/AdvApi32/Evntrace.cs
+++ b/PInvoke/Security/AdvApi32/Evntrace.cs
@@ -6829,7 +6829,7 @@ public static partial class AdvApi32
public static TRACEHANDLE NULL => new(0);
/// Gets a value indicating whether this instance is invalid.
- public bool IsInvalid => handle == 0 || handle == 0x00000000FFFFFFFF;
+ public bool IsInvalid => handle is 0 or 0x00000000FFFFFFFF;
/// Gets a value indicating whether this instance is a null handle.
public bool IsNull => handle == 0;
@@ -7025,7 +7025,7 @@ public static partial class AdvApi32
/// Gets a value indicating whether this instance is invalid.
/// true if this instance is invalid; otherwise, false.
- public bool IsInvalid => handle == 0 || handle == 0x00000000FFFFFFFF;
+ public bool IsInvalid => handle is 0 or 0x00000000FFFFFFFF;
/// Performs an implicit conversion from to .
/// The safe handle instance.
diff --git a/PInvoke/Shared/WTypes/CY.cs b/PInvoke/Shared/WTypes/CY.cs
index 28f8b452..dc570325 100644
--- a/PInvoke/Shared/WTypes/CY.cs
+++ b/PInvoke/Shared/WTypes/CY.cs
@@ -18,7 +18,7 @@ public struct CY : IEquatable, IComparable, IEquatable, ICompar
/// The value.
public CY(long value)
{
- if (value > (long.MaxValue / 10000) || value < (long.MinValue / 10000))
+ if (value is > (long.MaxValue / 10000) or < (long.MinValue / 10000))
throw new ArgumentOutOfRangeException();
int64 = value * 10000;
}
diff --git a/PInvoke/Shared/WinDef/COLORREF.cs b/PInvoke/Shared/WinDef/COLORREF.cs
index 0379d328..ca72bbe9 100644
--- a/PInvoke/Shared/WinDef/COLORREF.cs
+++ b/PInvoke/Shared/WinDef/COLORREF.cs
@@ -71,7 +71,7 @@ public struct COLORREF : IEquatable
///
public COLORREF Darken(float percent)
{
- return percent < 0 || percent > 1.0
+ return percent is < 0 or > (float)1.0
? throw new ArgumentOutOfRangeException(nameof(percent))
: (new(Conv(R), Conv(G), Conv(B)) { Value = Value });
byte Conv(byte c) => (byte)(c - (int)(c * percent));
@@ -96,7 +96,7 @@ public struct COLORREF : IEquatable
///
public COLORREF Lighten(float percent)
{
- return percent < 0 || percent > 1.0
+ return percent is < 0 or > (float)1.0
? throw new ArgumentOutOfRangeException(nameof(percent))
: (new(Conv(R), Conv(G), Conv(B)) { Value = Value });
byte Conv(byte c) => (byte)(c + (int)((255f - c) * percent));
diff --git a/PInvoke/Shared/WinGdi/WinGdi.LOGFONT.cs b/PInvoke/Shared/WinGdi/WinGdi.LOGFONT.cs
index aaec9147..d763f30a 100644
--- a/PInvoke/Shared/WinGdi/WinGdi.LOGFONT.cs
+++ b/PInvoke/Shared/WinGdi/WinGdi.LOGFONT.cs
@@ -407,7 +407,7 @@ public struct LOGFONT
public short lfWeight
{
get => (short)_lfWeight;
- set => _lfWeight = value >= 0 && value <= 1000 ? value : throw new ArgumentOutOfRangeException(nameof(lfWeight), @"Font weight must be a value in the range 0 through 1000.");
+ set => _lfWeight = value is >= 0 and <= 1000 ? value : throw new ArgumentOutOfRangeException(nameof(lfWeight), @"Font weight must be a value in the range 0 through 1000.");
}
/// Gets or sets the font pitch.
diff --git a/UnitTests/CSharpRunner/SuccessfulConstraint.cs b/UnitTests/CSharpRunner/SuccessfulConstraint.cs
index c06c17cc..f12ac122 100644
--- a/UnitTests/CSharpRunner/SuccessfulConstraint.cs
+++ b/UnitTests/CSharpRunner/SuccessfulConstraint.cs
@@ -214,13 +214,13 @@ public class ValidHandleConstraint : OpConstraint
case IHandle ih:
val = ih.DangerousGetHandle();
var l = val.ToInt64();
- success = l != 0 && l != -1;
+ success = l is not 0 and not (-1);
break;
case IntPtr p:
val = p;
l = val.ToInt64();
- success = l != 0 && l != -1;
+ success = l is not 0 and not (-1);
break;
default: