diff --git a/Core/InteropServices/SizeT.cs b/Core/InteropServices/SizeT.cs
index e1e5e068..e1aa1dac 100644
--- a/Core/InteropServices/SizeT.cs
+++ b/Core/InteropServices/SizeT.cs
@@ -1,5 +1,6 @@
using System;
using System.ComponentModel;
+using System.Diagnostics;
using System.Globalization;
using System.Runtime.InteropServices;
@@ -8,6 +9,7 @@ namespace Vanara.PInvoke
/// Managed instance of the SIZE_T type.
[StructLayout(LayoutKind.Sequential), Serializable]
[TypeConverter(typeof(SizeTTypeConverter))]
+ [DebuggerDisplay("{Value}")]
public struct SizeT : IEquatable, IComparable, IConvertible, IComparable
{
/// Represents the smallest possible value of . This field is constant.
@@ -43,7 +45,7 @@ namespace Vanara.PInvoke
/// Performs an implicit conversion from to .
/// The value.
/// The result of the conversion.
- public static implicit operator SizeT(uint value) => new SizeT(value);
+ public static implicit operator SizeT(uint value) => new(value);
/// Performs an implicit conversion from to .
/// The value.
@@ -53,7 +55,7 @@ namespace Vanara.PInvoke
/// Performs an implicit conversion from to .
/// The value.
/// The result of the conversion.
- public static implicit operator SizeT(ulong value) => new SizeT(value);
+ public static implicit operator SizeT(ulong value) => new(value);
/// Performs an implicit conversion from to .
/// The value.
@@ -89,7 +91,7 @@ namespace Vanara.PInvoke
///
/// if the value of is less than the value of ; otherwise, .
///
- public static bool operator <(SizeT s1, SizeT s2) => (s1.CompareTo(s2) < 0) ? true : false;
+ public static bool operator <(SizeT s1, SizeT s2) => s1.CompareTo(s2) < 0;
/// Indicates whether a specified is less than or equal to another specified .
/// The first integral size to compare.
@@ -98,7 +100,7 @@ namespace Vanara.PInvoke
/// if the value of is less than or equal to the value of ;
/// otherwise, .
///
- public static bool operator <=(SizeT s1, SizeT s2) => (s1.CompareTo(s2) <= 0) ? true : false;
+ public static bool operator <=(SizeT s1, SizeT s2) => s1.CompareTo(s2) <= 0;
/// Indicates whether two instances are equal.
/// The first integral size to compare.
@@ -114,7 +116,7 @@ namespace Vanara.PInvoke
///
/// if the value of is greater than the value of ; otherwise, .
///
- public static bool operator >(SizeT s1, SizeT s2) => (s1.CompareTo(s2) > 0) ? true : false;
+ public static bool operator >(SizeT s1, SizeT s2) => s1.CompareTo(s2) > 0;
/// Indicates whether a specified is greater than or equal to another specified .
/// The first integral size to compare.
@@ -123,7 +125,47 @@ namespace Vanara.PInvoke
/// if the value of is greater than or equal to the value of ;
/// otherwise, .
///
- public static bool operator >=(SizeT s1, SizeT s2) => (s1.CompareTo(s2) >= 0) ? true : false;
+ public static bool operator >=(SizeT s1, SizeT s2) => s1.CompareTo(s2) >= 0;
+
+ /// Adds two specified values.
+ /// The first value to add.
+ /// The second value to add.
+ /// The result of adding and .
+ public static SizeT operator +(SizeT s1, SizeT s2) => s1.Value + s2.Value;
+
+ /// Divides two specified values.
+ /// The divident.
+ /// The divisor.
+ /// The result of dividing by .
+ public static SizeT operator /(SizeT s1, SizeT s2) => s1.Value / s2.Value;
+
+ /// Returns the remainder resulting from dividing two specified values.
+ /// The divident.
+ /// The divisor.
+ /// The remainder resulting from dividing by .
+ public static SizeT operator %(SizeT s1, SizeT s2) => s1.Value % s2.Value;
+
+ /// Multiplies two specified values.
+ /// The first value to multiply.
+ /// The second value to multiply.
+ /// The result of multiplying by .
+ public static SizeT operator *(SizeT s1, SizeT s2) => s1.Value * s2.Value;
+
+ /// Subtracts two specified values.
+ /// The minuend.
+ /// The subtrahend.
+ /// The result of subtracting from .
+ public static SizeT operator -(SizeT s1, SizeT s2) => s1.Value - s2.Value;
+
+ /// Increments the by 1.
+ /// The value to increment.
+ /// The value of incremented by 1.
+ public static SizeT operator ++(SizeT s1) => s1.Value += 1;
+
+ /// Decrements the by 1.
+ /// The value to decrement.
+ /// The value of decremented by 1.
+ public static SizeT operator --(SizeT s1) => s1.Value += 1;
///
public int CompareTo(SizeT other) => Value.CompareTo(other.Value);
@@ -158,7 +200,7 @@ namespace Vanara.PInvoke
var ul = Value;
if (ul < (ulong)byte.MaxValue)
return (byte)ul;
- if (ul == uint.MaxValue || ul == ulong.MaxValue)
+ if (ul is uint.MaxValue or ulong.MaxValue)
return byte.MaxValue;
throw new OverflowException();
}
@@ -175,7 +217,7 @@ namespace Vanara.PInvoke
var ul = Value;
if (ul < decimal.MaxValue)
return (decimal)ul;
- if (ul == uint.MaxValue || ul == ulong.MaxValue)
+ if (ul is uint.MaxValue or ulong.MaxValue)
return decimal.MaxValue;
throw new OverflowException();
}
@@ -186,7 +228,7 @@ namespace Vanara.PInvoke
var ul = Value;
if (ul < double.MaxValue)
return ul;
- if (ul == uint.MaxValue || ul == ulong.MaxValue)
+ if (ul is uint.MaxValue or ulong.MaxValue)
return double.MaxValue;
throw new OverflowException();
}
@@ -197,7 +239,7 @@ namespace Vanara.PInvoke
var ul = Value;
if (ul < (ulong)short.MaxValue)
return (short)ul;
- if (ul == uint.MaxValue || ul == ulong.MaxValue)
+ if (ul is uint.MaxValue or ulong.MaxValue)
return short.MaxValue;
throw new OverflowException();
}
@@ -208,7 +250,7 @@ namespace Vanara.PInvoke
var ul = Value;
if (ul < int.MaxValue)
return (int)ul;
- if (ul == uint.MaxValue || ul == ulong.MaxValue)
+ if (ul is uint.MaxValue or ulong.MaxValue)
return int.MaxValue;
throw new OverflowException();
}
@@ -219,7 +261,7 @@ namespace Vanara.PInvoke
var ul = Value;
if (ul < long.MaxValue)
return (long)ul;
- if (ul == uint.MaxValue || ul == ulong.MaxValue)
+ if (ul is uint.MaxValue or ulong.MaxValue)
return long.MaxValue;
throw new OverflowException();
}
@@ -230,7 +272,7 @@ namespace Vanara.PInvoke
var ul = Value;
if (ul < (ulong)sbyte.MaxValue)
return (sbyte)ul;
- if (ul == uint.MaxValue || ul == ulong.MaxValue)
+ if (ul is uint.MaxValue or ulong.MaxValue)
return sbyte.MaxValue;
throw new OverflowException();
}
@@ -241,7 +283,7 @@ namespace Vanara.PInvoke
var ul = Value;
if (ul < float.MaxValue)
return ul;
- if (ul == uint.MaxValue || ul == ulong.MaxValue)
+ if (ul is uint.MaxValue or ulong.MaxValue)
return float.MaxValue;
throw new OverflowException();
}
@@ -255,7 +297,7 @@ namespace Vanara.PInvoke
var ul = Value;
if (ul < (ulong)ushort.MaxValue)
return (ushort)ul;
- if (ul == uint.MaxValue || ul == ulong.MaxValue)
+ if (ul is uint.MaxValue or ulong.MaxValue)
return ushort.MaxValue;
throw new OverflowException();
}
@@ -266,7 +308,7 @@ namespace Vanara.PInvoke
var ul = Value;
if (ul < uint.MaxValue)
return (uint)ul;
- if (ul == uint.MaxValue || ul == ulong.MaxValue)
+ if (ul is uint.MaxValue or ulong.MaxValue)
return uint.MaxValue;
throw new OverflowException();
}
@@ -278,7 +320,7 @@ namespace Vanara.PInvoke
{
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
- if (!(value is SizeT sz)) throw new ArgumentException();
+ if (value is not SizeT sz) throw new ArgumentException();
return base.ConvertTo(context, culture, sz.Value, destinationType);
}