Updated with expressions

nullableenabled
David Hall 2023-09-06 09:13:47 -06:00
parent 162dccdd63
commit cf50f7203f
5 changed files with 8 additions and 8 deletions

View File

@ -6829,7 +6829,7 @@ public static partial class AdvApi32
public static TRACEHANDLE NULL => new(0);
/// <summary>Gets a value indicating whether this instance is invalid.</summary>
public bool IsInvalid => handle == 0 || handle == 0x00000000FFFFFFFF;
public bool IsInvalid => handle is 0 or 0x00000000FFFFFFFF;
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
public bool IsNull => handle == 0;
@ -7025,7 +7025,7 @@ public static partial class AdvApi32
/// <summary>Gets a value indicating whether this instance is invalid.</summary>
/// <value><c>true</c> if this instance is invalid; otherwise, <c>false</c>.</value>
public bool IsInvalid => handle == 0 || handle == 0x00000000FFFFFFFF;
public bool IsInvalid => handle is 0 or 0x00000000FFFFFFFF;
/// <summary>Performs an implicit conversion from <see cref="SafeTRACEHANDLE"/> to <see cref="TRACEHANDLE"/>.</summary>
/// <param name="h">The safe handle instance.</param>

View File

@ -18,7 +18,7 @@ public struct CY : IEquatable<CY>, IComparable<CY>, IEquatable<decimal>, ICompar
/// <param name="value">The value.</param>
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;
}

View File

@ -71,7 +71,7 @@ public struct COLORREF : IEquatable<COLORREF>
/// </returns>
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<COLORREF>
/// </returns>
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));

View File

@ -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.");
}
/// <summary>Gets or sets the font pitch.</summary>

View File

@ -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: