Skip to content

Commit b4819c2

Browse files
committed
refactor: use 'is' when comparing to constants
style: remove unnecessary parentheses
1 parent 1ddff98 commit b4819c2

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

deadlock-dotnet-sdk/DeadLock.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ public List<FileLockerEx> FindLockingHandles(HandlesFilter filter, ref List<Warn
242242
List<FileLockerEx> fileLockers = new();
243243
warnings = new();
244244

245-
if (filePaths.Length == 1)
245+
if (filePaths.Length is 1)
246246
{
247247
fileLockers.Add(FindLockingHandles(filePaths[0], filter, out WarningException? warningException));
248248
if (warningException != null) warnings.Add(warningException);

deadlock-dotnet-sdk/Domain/ProcessInfo.ProcessQueryHandle.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ public ProcessQueryHandle(SafeProcessHandle processHandle, PROCESS_ACCESS_RIGHTS
3232
/// </exception>
3333
/// <remarks>
3434
/// - If processId == Process.GetCurrentProcess().Id, use Process.GetCurrentProcess().SafeHandle property instead.
35-
/// - If Windows.Win32.PInvoke.IsDebugModeEnabled() == true, the requested access is granted regardless of the security descriptor. See GetSecurityInfo();
35+
/// - If Windows.Win32.PInvoke.IsDebugModeEnabled() is true, the requested access is granted regardless of the security descriptor. See GetSecurityInfo();
3636
/// </remarks>
3737
public static ProcessQueryHandle OpenProcessHandle(int processId, PROCESS_ACCESS_RIGHTS accessRights)
3838
{
3939
var h = OpenProcess_SafeHandle(accessRights, false, (uint)processId);
40-
return h is null ? throw new Win32Exception() : (new(h, accessRights));
40+
return h is null ? throw new Win32Exception() : new(h, accessRights);
4141
}
4242

4343
public static implicit operator SafeProcessHandle(ProcessQueryHandle v) => v.Handle;

deadlock-dotnet-sdk/Domain/SafeFileHandleEx.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ internal SafeFileHandleEx(SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX sysHandleEx) : base(
110110
const string errUnableMsg = "Unable to query " + nameof(IsFileHandle) + "; ";
111111
if (IsClosed)
112112
return isFileHandle = (null, new NullReferenceException(errUnableMsg + errHandleClosedMsgSuffix));
113-
return HandleObjectType.v == "File"
113+
return HandleObjectType.v is "File"
114114
? (isFileHandle = (true, null))
115115
: (isFileHandle = (null, new Exception("Failed to determine if this handle's object is a file/directory; Failed to query the object's type.", HandleObjectType.ex)));
116116
}

deadlock-dotnet-sdk/Domain/SafeHandleEx.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public unsafe (string? v, Exception? ex) ObjectName
168168
}
169169

170170
OBJECT_NAME_INFORMATION oni = buffer.Read<OBJECT_NAME_INFORMATION>(0);
171-
if (oni.Name.Buffer.Value == null)
171+
if (oni.Name.Buffer.Value is null)
172172
return objectName = (null, new NullReferenceException(errFailedMsg + "Bad data was copied to the buffer. The string pointer is null."));
173173

174174
return status.IsSuccessful

0 commit comments

Comments
 (0)