From 8300cadca365af347e946c01dd5a69a3027e4fe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20H=C3=B6glinger-Stelzer?= Date: Sat, 17 Aug 2024 10:47:11 +0200 Subject: [PATCH] Fixed comparing wrong property when checking for equality (#62) * Fixed comparing wrong property when checking for equality * Ran code clean-up --- Nefarius.Utilities.DeviceManagement.sln.DotSettings | 1 + README.md | 8 +++----- src/PnP/PnPDevice.cs | 6 ++++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Nefarius.Utilities.DeviceManagement.sln.DotSettings b/Nefarius.Utilities.DeviceManagement.sln.DotSettings index d23ed84..4429ce3 100644 --- a/Nefarius.Utilities.DeviceManagement.sln.DotSettings +++ b/Nefarius.Utilities.DeviceManagement.sln.DotSettings @@ -1,6 +1,7 @@  True True + True True True True diff --git a/README.md b/README.md index d719e86..df9340c 100644 --- a/README.md +++ b/README.md @@ -24,11 +24,9 @@ Managed wrappers around SetupAPI, Cfgmgr32, NewDev and DrvStore native APIs on W ### Generating documentation -```PowerShell -dotnet build -c:Release -dotnet tool install --global Nefarius.Tools.XMLDoc2Markdown -xmldoc2md .\bin\netstandard2.0\Nefarius.Utilities.DeviceManagement.dll .\docs\ -``` +- `dotnet build -c:Release` +- `dotnet tool install --global Nefarius.Tools.XMLDoc2Markdown` +- `xmldoc2md .\bin\netstandard2.0\Nefarius.Utilities.DeviceManagement.dll .\docs\` ## Examples diff --git a/src/PnP/PnPDevice.cs b/src/PnP/PnPDevice.cs index eb7aed5..5b5fa19 100644 --- a/src/PnP/PnPDevice.cs +++ b/src/PnP/PnPDevice.cs @@ -1,4 +1,5 @@ #nullable enable + using System; using System.Diagnostics.CodeAnalysis; using System.IO; @@ -26,7 +27,7 @@ public partial class PnPDevice : IPnPDevice, IEquatable private readonly uint _instanceHandle; /// - /// The used when creating this instance. + /// The used when creating this instance. /// private readonly DeviceLocationFlags _locationFlags; @@ -794,7 +795,8 @@ public bool Equals(PnPDevice other) return true; } - return string.Equals(DeviceId, other.DeviceId, StringComparison.InvariantCultureIgnoreCase); + // Instance ID distinguishes unique instances of devices, even of the same Hardware ID + return string.Equals(InstanceId, other.InstanceId, StringComparison.InvariantCultureIgnoreCase); } ///