Skip to content

Commit

Permalink
Merge pull request #62 from tmittet/Address_CA2201_Do_not_raise_reser…
Browse files Browse the repository at this point in the history
…ved_exception_types
  • Loading branch information
badcel authored Nov 18, 2023
2 parents 1c687e1 + 0fa887d commit 37e9b42
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/HidApi.Net/Internal/NativeHidApiLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static IEnumerable<string> GetNames()
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
return GetOsxNames();

throw new Exception("Unsupported platform to get hidapi library name");
throw new NotSupportedException("Unsupported platform to get hidapi library name");
}

private static IEnumerable<string> GetLinuxNames()
Expand Down
2 changes: 1 addition & 1 deletion src/HidApi.Net/Internal/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ private static IntPtr Resolve(string libraryName, Assembly assembly, DllImportSe
if (NativeLibrary.TryLoad(library, assembly, searchPath, out libraryHandle))
return libraryHandle;

throw new Exception($"Could not find hidapi library tried: {string.Join(", ", NativeHidApiLibrary.GetNames())}");
throw new DllNotFoundException($"Could not find hidapi library tried: {string.Join(", ", NativeHidApiLibrary.GetNames())}");
}

public static DeviceSafeHandle Open(ushort vendorId, ushort productId, NullTerminatedString serialNumber)
Expand Down
8 changes: 4 additions & 4 deletions src/HidApi.Net/Internal/WCharT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static string GetString(ReadOnlySpan<byte> buffer)
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
return Encoding.UTF32.GetString(buffer);

throw new Exception("Unsupported platform to read from buffer");
throw new NotSupportedException("Unsupported platform to read from buffer");
}

public static unsafe string GetString(byte* ptr)
Expand All @@ -30,7 +30,7 @@ public static unsafe string GetString(byte* ptr)
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
return Utf32.Read(ptr);

throw new Exception("Unsupported platform to read from pointer");
throw new NotSupportedException("Unsupported platform to read from pointer");
}

public static ReadOnlySpan<byte> CreateBuffer(int size)
Expand All @@ -44,7 +44,7 @@ public static ReadOnlySpan<byte> CreateBuffer(int size)
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
return Utf32.CreateBuffer(size);

throw new Exception("Unsupported platform to create a buffer");
throw new NotSupportedException("Unsupported platform to create a buffer");
}

public static NullTerminatedString CreateNullTerminatedString(string str)
Expand All @@ -58,6 +58,6 @@ public static NullTerminatedString CreateNullTerminatedString(string str)
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
return Utf32.CreateNullTerminatedString(str);

throw new Exception("Unsupported platform to create a null terminated string");
throw new NotSupportedException("Unsupported platform to create a null terminated string");
}
}

0 comments on commit 37e9b42

Please sign in to comment.