exception refine

This commit is contained in:
Lightczx
2024-05-24 17:16:33 +08:00
parent 9cbb36f3e6
commit 492e867391
4 changed files with 4 additions and 4 deletions

View File

@@ -33,7 +33,7 @@ internal sealed class HotKeyMessageWindow : IDisposable
atom = RegisterClassW(&wc);
}
ArgumentOutOfRangeException.ThrowIfEqual<ushort>(atom, 0);
ArgumentOutOfRangeException.ThrowIfZero(atom);
HWND = CreateWindowExW(0, WindowClassName, WindowClassName, 0, 0, 0, 0, 0, default, default, default, default);

View File

@@ -38,7 +38,7 @@ internal sealed class NotifyIconMessageWindow : IDisposable
atom = RegisterClassW(&wc);
}
ArgumentOutOfRangeException.ThrowIfEqual<ushort>(atom, 0);
ArgumentOutOfRangeException.ThrowIfZero(atom);
// https://learn.microsoft.com/zh,cn/windows/win32/shell/taskbar#taskbar,creation,notification
WM_TASKBARCREATED = RegisterWindowMessageW("TaskbarCreated");

View File

@@ -25,7 +25,7 @@ internal sealed class GameScreenCaptureMemoryPool : MemoryPool<byte>
public override IMemoryOwner<byte> Rent(int minBufferSize = -1)
{
ArgumentOutOfRangeException.ThrowIfLessThan(minBufferSize, 0);
ArgumentOutOfRangeException.ThrowIfNegative(minBufferSize);
lock (syncRoot)
{

View File

@@ -46,7 +46,7 @@ internal static class CookieExtension
private static bool TryGetValuesToCookie(this Cookie source, in ReadOnlySpan<string> keys, [NotNullWhen(true)] out Cookie? cookie)
{
ArgumentOutOfRangeException.ThrowIfLessThanOrEqual(keys.Length, 0, "Empty keys is not supported");
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(keys.Length);
SortedDictionary<string, string> cookieMap = [];
foreach (ref readonly string key in keys)