diff --git a/Directory.Build.props b/Directory.Build.props index ae960f2..f661519 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -19,6 +19,7 @@ SPDX-License-Identifier: GPL-3.0-only 11.0 + enable 5 diff --git a/UnitTests/UnitTests.csproj b/UnitTests/UnitTests.csproj index bfa8e0d..ed4f531 100644 --- a/UnitTests/UnitTests.csproj +++ b/UnitTests/UnitTests.csproj @@ -7,7 +7,6 @@ SPDX-License-Identifier: GPL-3.0-only - enable True true diff --git a/UsbIds/UsbIdsSourceGenerator.cs b/UsbIds/UsbIdsSourceGenerator.cs index fe9d24f..829938e 100644 --- a/UsbIds/UsbIdsSourceGenerator.cs +++ b/UsbIds/UsbIdsSourceGenerator.cs @@ -2,9 +2,6 @@ // // SPDX-License-Identifier: GPL-3.0-only -using System.Collections.Generic; -using System.IO; -using System.Linq; using System.Text; using System.Text.RegularExpressions; using Microsoft.CodeAnalysis; diff --git a/Usbipd.Automation/AssemblySettings.cs b/Usbipd.Automation/AssemblySettings.cs index 1b5fb6f..6485754 100644 --- a/Usbipd.Automation/AssemblySettings.cs +++ b/Usbipd.Automation/AssemblySettings.cs @@ -2,6 +2,4 @@ // // SPDX-License-Identifier: GPL-3.0-only -using System; - [assembly: CLSCompliant(false)] diff --git a/Usbipd.Automation/BusId.cs b/Usbipd.Automation/BusId.cs index 3deef7c..45a6f33 100644 --- a/Usbipd.Automation/BusId.cs +++ b/Usbipd.Automation/BusId.cs @@ -2,7 +2,6 @@ // // SPDX-License-Identifier: GPL-3.0-only -using System; using System.Text.Json.Serialization; using System.Text.RegularExpressions; diff --git a/Usbipd.Automation/Device.cs b/Usbipd.Automation/Device.cs index 19c5ccd..1d45ab9 100644 --- a/Usbipd.Automation/Device.cs +++ b/Usbipd.Automation/Device.cs @@ -2,7 +2,6 @@ // // SPDX-License-Identifier: GPL-3.0-only -using System; using System.Net; using System.Runtime.Serialization; using System.Text.Json.Serialization; diff --git a/Usbipd.Automation/NullableBusIdJsonConverter.cs b/Usbipd.Automation/NullableBusIdJsonConverter.cs index 817bd87..e4a5e70 100644 --- a/Usbipd.Automation/NullableBusIdJsonConverter.cs +++ b/Usbipd.Automation/NullableBusIdJsonConverter.cs @@ -2,7 +2,6 @@ // // SPDX-License-Identifier: GPL-3.0-only -using System; using System.Text.Json; using System.Text.Json.Serialization; diff --git a/Usbipd.Automation/NullableIPAddressJsonConverter.cs b/Usbipd.Automation/NullableIPAddressJsonConverter.cs index eeaff94..0df7d18 100644 --- a/Usbipd.Automation/NullableIPAddressJsonConverter.cs +++ b/Usbipd.Automation/NullableIPAddressJsonConverter.cs @@ -2,7 +2,6 @@ // // SPDX-License-Identifier: GPL-3.0-only -using System; using System.Net; using System.Text.Json; using System.Text.Json.Serialization; diff --git a/Usbipd.Automation/State.cs b/Usbipd.Automation/State.cs index d5f7858..19cf3d6 100644 --- a/Usbipd.Automation/State.cs +++ b/Usbipd.Automation/State.cs @@ -2,8 +2,6 @@ // // SPDX-License-Identifier: GPL-3.0-only -using System; -using System.Collections.Generic; using System.Runtime.Serialization; using System.Text.Json.Serialization; diff --git a/Usbipd.Automation/UsbIds.cs b/Usbipd.Automation/UsbIds.cs index c25b717..4b87cf6 100644 --- a/Usbipd.Automation/UsbIds.cs +++ b/Usbipd.Automation/UsbIds.cs @@ -2,38 +2,35 @@ // // SPDX-License-Identifier: GPL-3.0-only -using System; +namespace Usbipd.Automation; -namespace Usbipd.Automation +public static partial class UsbIds { - public static partial class UsbIds + static string? FindString(ulong[] array, ulong value) { - static string? FindString(ulong[] array, ulong value) + var index = Array.BinarySearch(array, value); + if (index < 0) { - var index = Array.BinarySearch(array, value); - if (index < 0) + // Negative means the bitwise complement of the first item greater. + index = ~index; + if (index >= array.Length) { - // Negative means the bitwise complement of the first item greater. - index = ~index; - if (index >= array.Length) - { - return null; - } - if ((array[index] & 0xffffffff00000000) != value) - { - return null; - } + return null; + } + if ((array[index] & 0xffffffff00000000) != value) + { + return null; } - var start = (int)(array[index] & 0xffffffff); - var end = Strings.IndexOf('\0', start); - return Strings.Substring(start, end - start); } + var start = (int)(array[index] & 0xffffffff); + var end = Strings.IndexOf('\0', start); + return Strings.Substring(start, end - start); + } - public static (string? Vendor, string? Product) GetNames(VidPid vidPid) - { - var vendor = FindString(VendorLookup, (ulong)vidPid.Vid << 48); - var product = vendor is not null ? FindString(ProductLookup, ((ulong)vidPid.Vid << 48) | ((ulong)vidPid.Pid << 32)) : null; - return (vendor, product); - } + public static (string? Vendor, string? Product) GetNames(VidPid vidPid) + { + var vendor = FindString(VendorLookup, (ulong)vidPid.Vid << 48); + var product = vendor is not null ? FindString(ProductLookup, ((ulong)vidPid.Vid << 48) | ((ulong)vidPid.Pid << 32)) : null; + return (vendor, product); } } diff --git a/Usbipd.Automation/VidPid.cs b/Usbipd.Automation/VidPid.cs index a4f90bc..1bacb71 100644 --- a/Usbipd.Automation/VidPid.cs +++ b/Usbipd.Automation/VidPid.cs @@ -2,7 +2,6 @@ // // SPDX-License-Identifier: GPL-3.0-only -using System; using System.Globalization; using System.Text.Json.Serialization; using System.Text.RegularExpressions; diff --git a/Usbipd.PowerShell/AssemblySettings.cs b/Usbipd.PowerShell/AssemblySettings.cs index 1b5fb6f..6485754 100644 --- a/Usbipd.PowerShell/AssemblySettings.cs +++ b/Usbipd.PowerShell/AssemblySettings.cs @@ -2,6 +2,4 @@ // // SPDX-License-Identifier: GPL-3.0-only -using System; - [assembly: CLSCompliant(false)] diff --git a/Usbipd.PowerShell/GetUsbipdDevice.cs b/Usbipd.PowerShell/GetUsbipdDevice.cs index f6180cc..2c31420 100644 --- a/Usbipd.PowerShell/GetUsbipdDevice.cs +++ b/Usbipd.PowerShell/GetUsbipdDevice.cs @@ -3,11 +3,9 @@ // SPDX-License-Identifier: GPL-3.0-only using System.Diagnostics; -using System.IO; using System.Management.Automation; using System.Runtime.Serialization.Json; using System.Text; -using System.Threading.Tasks; using Usbipd.Automation; namespace Usbipd.PowerShell; diff --git a/Usbipd.PowerShell/Installation.cs b/Usbipd.PowerShell/Installation.cs index b3ca739..d99725a 100644 --- a/Usbipd.PowerShell/Installation.cs +++ b/Usbipd.PowerShell/Installation.cs @@ -2,13 +2,10 @@ // // SPDX-License-Identifier: GPL-3.0-only -using System; using System.Diagnostics; -using System.IO; using System.Management.Automation; using System.Text; using System.Text.RegularExpressions; -using System.Threading.Tasks; namespace Usbipd.PowerShell; diff --git a/Usbipd/AssemblySettings.cs b/Usbipd/AssemblySettings.cs index 4c23e0b..d7ece17 100644 --- a/Usbipd/AssemblySettings.cs +++ b/Usbipd/AssemblySettings.cs @@ -2,7 +2,6 @@ // // SPDX-License-Identifier: GPL-3.0-only -using System; using System.Runtime.CompilerServices; [assembly: CLSCompliant(false)] diff --git a/Usbipd/AttachedClient.cs b/Usbipd/AttachedClient.cs index 08265ca..4b574d8 100644 --- a/Usbipd/AttachedClient.cs +++ b/Usbipd/AttachedClient.cs @@ -2,15 +2,10 @@ // // SPDX-License-Identifier: GPL-3.0-only -using System; using System.Collections.Concurrent; -using System.Collections.Generic; using System.Net; using System.Net.Sockets; -using System.Threading; using System.Threading.Channels; -using System.Threading.Tasks; -using Microsoft.Extensions.Logging; using Usbipd.Automation; using static Usbipd.Interop.Linux; using static Usbipd.Interop.UsbIp; diff --git a/Usbipd/AttachedEndpoint.cs b/Usbipd/AttachedEndpoint.cs index dca4aca..116b8c2 100644 --- a/Usbipd/AttachedEndpoint.cs +++ b/Usbipd/AttachedEndpoint.cs @@ -2,17 +2,10 @@ // // SPDX-License-Identifier: GPL-3.0-only -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; using System.Net; using System.Net.Sockets; using System.Runtime.InteropServices; -using System.Threading; using System.Threading.Channels; -using System.Threading.Tasks; -using Microsoft.Extensions.Logging; using Windows.Win32; using Windows.Win32.Devices.Usb; diff --git a/Usbipd/ClientContext.cs b/Usbipd/ClientContext.cs index 9a5594e..0348da0 100644 --- a/Usbipd/ClientContext.cs +++ b/Usbipd/ClientContext.cs @@ -2,7 +2,6 @@ // // SPDX-License-Identifier: GPL-3.0-only -using System; using System.Net; using System.Net.Sockets; using Usbipd.Automation; diff --git a/Usbipd/CommandHandlers.cs b/Usbipd/CommandHandlers.cs index 3a8a0f1..69d52cc 100644 --- a/Usbipd/CommandHandlers.cs +++ b/Usbipd/CommandHandlers.cs @@ -3,25 +3,15 @@ // // SPDX-License-Identifier: GPL-3.0-only -using System; -using System.Collections.Generic; using System.CommandLine; using System.ComponentModel; using System.Diagnostics; -using System.IO; -using System.Linq; using System.Security.Principal; using System.Text; using System.Text.Encodings.Web; using System.Text.Json; using System.Text.RegularExpressions; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting.WindowsServices; -using Microsoft.Extensions.Logging; using Usbipd.Automation; using Windows.Win32.Security; using static Usbipd.ConsoleTools; diff --git a/Usbipd/ConfigurationManager.cs b/Usbipd/ConfigurationManager.cs index 66bb661..f47bb4b 100644 --- a/Usbipd/ConfigurationManager.cs +++ b/Usbipd/ConfigurationManager.cs @@ -2,14 +2,9 @@ // // SPDX-License-Identifier: GPL-3.0-only -using System; -using System.Collections.Generic; using System.ComponentModel; using System.Globalization; -using System.IO; -using System.Linq; using System.Text.RegularExpressions; -using System.Threading; using Usbipd.Automation; using Windows.Win32; using Windows.Win32.Devices.DeviceAndDriverInstallation; diff --git a/Usbipd/ConfigurationManagerException.cs b/Usbipd/ConfigurationManagerException.cs index c3ac807..402bd74 100644 --- a/Usbipd/ConfigurationManagerException.cs +++ b/Usbipd/ConfigurationManagerException.cs @@ -2,7 +2,6 @@ // // SPDX-License-Identifier: GPL-3.0-only -using System; using System.ComponentModel; using Windows.Win32; using Windows.Win32.Devices.DeviceAndDriverInstallation; diff --git a/Usbipd/ConnectedClient.cs b/Usbipd/ConnectedClient.cs index 0b7765b..0e40421 100644 --- a/Usbipd/ConnectedClient.cs +++ b/Usbipd/ConnectedClient.cs @@ -3,21 +3,13 @@ // // SPDX-License-Identifier: GPL-3.0-only -using System; using System.Buffers.Binary; -using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; -using System.IO; -using System.Linq; using System.Net; using System.Net.Sockets; using System.Runtime.InteropServices; using System.Text; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; using Usbipd.Automation; using Windows.Win32; using Windows.Win32.Devices.DeviceAndDriverInstallation; diff --git a/Usbipd/ConsoleTools.cs b/Usbipd/ConsoleTools.cs index a55508a..bd6c2d5 100644 --- a/Usbipd/ConsoleTools.cs +++ b/Usbipd/ConsoleTools.cs @@ -2,10 +2,7 @@ // // SPDX-License-Identifier: GPL-3.0-only -using System; -using System.Collections.Generic; using System.CommandLine; -using System.Linq; using System.Text; using Microsoft.Win32; using Usbipd.Automation; diff --git a/Usbipd/DeviceFile.cs b/Usbipd/DeviceFile.cs index 3ac5bb5..0c3f0d8 100644 --- a/Usbipd/DeviceFile.cs +++ b/Usbipd/DeviceFile.cs @@ -2,12 +2,9 @@ // // SPDX-License-Identifier: GPL-3.0-only -using System; using System.ComponentModel; using System.Net; using System.Runtime.InteropServices; -using System.Threading; -using System.Threading.Tasks; using Microsoft.Win32.SafeHandles; using Windows.Win32; using Windows.Win32.Foundation; diff --git a/Usbipd/ExportedDevice.cs b/Usbipd/ExportedDevice.cs index aa96734..2b1dc98 100644 --- a/Usbipd/ExportedDevice.cs +++ b/Usbipd/ExportedDevice.cs @@ -2,15 +2,10 @@ // // SPDX-License-Identifier: GPL-3.0-only -using System; using System.Buffers.Binary; -using System.Collections.Generic; using System.ComponentModel; -using System.IO; using System.Runtime.InteropServices; using System.Text; -using System.Threading; -using System.Threading.Tasks; using Usbipd.Automation; using Usbipd.Interop; using Windows.Win32; diff --git a/Usbipd/Interop/UsbIp.cs b/Usbipd/Interop/UsbIp.cs index c6790e4..bc2b66f 100644 --- a/Usbipd/Interop/UsbIp.cs +++ b/Usbipd/Interop/UsbIp.cs @@ -2,13 +2,9 @@ // // SPDX-License-Identifier: GPL-3.0-only -using System; using System.Buffers.Binary; -using System.IO; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using System.Threading; -using System.Threading.Tasks; using Windows.Win32.Devices.Usb; namespace Usbipd.Interop; diff --git a/Usbipd/Interop/VBoxUsb.cs b/Usbipd/Interop/VBoxUsb.cs index 5a0c9ad..39d1d2b 100644 --- a/Usbipd/Interop/VBoxUsb.cs +++ b/Usbipd/Interop/VBoxUsb.cs @@ -2,7 +2,6 @@ // // SPDX-License-Identifier: GPL-3.0-only -using System; using System.Runtime.InteropServices; using Windows.Win32; diff --git a/Usbipd/Interop/WinSDK.cs b/Usbipd/Interop/WinSDK.cs index 0100d2b..9ca3911 100644 --- a/Usbipd/Interop/WinSDK.cs +++ b/Usbipd/Interop/WinSDK.cs @@ -2,7 +2,6 @@ // // SPDX-License-Identifier: GPL-3.0-only -using System; using System.Runtime.InteropServices; using Windows.Win32; using Windows.Win32.Devices.Usb; diff --git a/Usbipd/LogEvents.cs b/Usbipd/LogEvents.cs index d5c5538..3408525 100644 --- a/Usbipd/LogEvents.cs +++ b/Usbipd/LogEvents.cs @@ -2,9 +2,7 @@ // // SPDX-License-Identifier: GPL-3.0-only -using System; using System.Net; -using Microsoft.Extensions.Logging; using Usbipd.Automation; namespace Usbipd; diff --git a/Usbipd/NewDev.cs b/Usbipd/NewDev.cs index df95fe9..3ee94da 100644 --- a/Usbipd/NewDev.cs +++ b/Usbipd/NewDev.cs @@ -2,10 +2,8 @@ // // SPDX-License-Identifier: GPL-3.0-only -using System; using System.ComponentModel; using System.Runtime.InteropServices; -using System.Threading; using Windows.Win32; using Windows.Win32.Devices.DeviceAndDriverInstallation; using Windows.Win32.Foundation; diff --git a/Usbipd/PcapNg.cs b/Usbipd/PcapNg.cs index 4f2d197..6c13d1b 100644 --- a/Usbipd/PcapNg.cs +++ b/Usbipd/PcapNg.cs @@ -2,19 +2,12 @@ // // SPDX-License-Identifier: GPL-3.0-only -using System; using System.Buffers.Binary; using System.Diagnostics; -using System.IO; -using System.Linq; using System.Net; using System.Runtime.CompilerServices; using System.Text; -using System.Threading; using System.Threading.Channels; -using System.Threading.Tasks; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Logging; using Usbipd.Automation; using static Usbipd.Interop.UsbIp; using static Usbipd.Interop.VBoxUsb; diff --git a/Usbipd/ProcessUtils.cs b/Usbipd/ProcessUtils.cs index 3dcfc5b..b0a9ce2 100644 --- a/Usbipd/ProcessUtils.cs +++ b/Usbipd/ProcessUtils.cs @@ -3,14 +3,9 @@ // // SPDX-License-Identifier: GPL-3.0-only -using System; -using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; -using System.Linq; using System.Text; -using System.Threading; -using System.Threading.Tasks; namespace Usbipd; diff --git a/Usbipd/Program.cs b/Usbipd/Program.cs index 77c95ba..42cd188 100644 --- a/Usbipd/Program.cs +++ b/Usbipd/Program.cs @@ -3,8 +3,6 @@ // // SPDX-License-Identifier: GPL-3.0-only -using System; -using System.Collections.Generic; using System.CommandLine; using System.CommandLine.Builder; using System.CommandLine.Completions; @@ -12,10 +10,7 @@ using System.CommandLine.IO; using System.CommandLine.Parsing; using System.Diagnostics; -using System.IO; -using System.Linq; using System.Reflection; -using System.Threading; using Usbipd.Automation; using static Usbipd.ConsoleTools; diff --git a/Usbipd/RegistryUtils.cs b/Usbipd/RegistryUtils.cs index 138ccd8..530020f 100644 --- a/Usbipd/RegistryUtils.cs +++ b/Usbipd/RegistryUtils.cs @@ -2,8 +2,6 @@ // // SPDX-License-Identifier: GPL-3.0-only -using System; -using System.Collections.Generic; using System.Net; using System.Security; using System.Security.AccessControl; diff --git a/Usbipd/Server.cs b/Usbipd/Server.cs index a153134..f640b98 100644 --- a/Usbipd/Server.cs +++ b/Usbipd/Server.cs @@ -2,16 +2,9 @@ // // SPDX-License-Identifier: GPL-3.0-only -using System; using System.Net; using System.Net.Sockets; using System.Runtime.InteropServices; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; using Windows.Win32; using Windows.Win32.Networking.WinSock; using Windows.Win32.Security; diff --git a/Usbipd/Tools.cs b/Usbipd/Tools.cs index 3764806..92d12e2 100644 --- a/Usbipd/Tools.cs +++ b/Usbipd/Tools.cs @@ -2,14 +2,10 @@ // // SPDX-License-Identifier: GPL-3.0-only -using System; using System.ComponentModel; using System.Diagnostics.CodeAnalysis; -using System.IO; using System.Net; using System.Runtime.InteropServices; -using System.Threading; -using System.Threading.Tasks; using Windows.Win32.Devices.Usb; using Windows.Win32.Foundation; diff --git a/Usbipd/UnexpectedResultException.cs b/Usbipd/UnexpectedResultException.cs index 17472e3..f9d4ec8 100644 --- a/Usbipd/UnexpectedResultException.cs +++ b/Usbipd/UnexpectedResultException.cs @@ -2,8 +2,6 @@ // // SPDX-License-Identifier: GPL-3.0-only -using System; - namespace Usbipd; public sealed class UnexpectedResultException : Exception diff --git a/Usbipd/UsbDevice.cs b/Usbipd/UsbDevice.cs index 763b989..08556d9 100644 --- a/Usbipd/UsbDevice.cs +++ b/Usbipd/UsbDevice.cs @@ -2,9 +2,6 @@ // // SPDX-License-Identifier: GPL-3.0-only -using System; -using System.Collections.Generic; -using System.Linq; using System.Net; using Usbipd.Automation; diff --git a/Usbipd/Usbipd.csproj b/Usbipd/Usbipd.csproj index a8473a6..7aaf65f 100644 --- a/Usbipd/Usbipd.csproj +++ b/Usbipd/Usbipd.csproj @@ -4,7 +4,7 @@ SPDX-FileCopyrightText: 2020 Frans van Dorsselaer SPDX-License-Identifier: GPL-3.0-only --> - + Exe diff --git a/Usbipd/VBoxUsb.cs b/Usbipd/VBoxUsb.cs index d6b062d..6b3eab8 100644 --- a/Usbipd/VBoxUsb.cs +++ b/Usbipd/VBoxUsb.cs @@ -2,13 +2,10 @@ // // SPDX-License-Identifier: GPL-3.0-only -using System; using System.ComponentModel; using System.Diagnostics; -using System.IO; using System.Net; using System.Runtime.InteropServices; -using System.Threading.Tasks; using Usbipd.Automation; using static Usbipd.Interop.VBoxUsb; using static Usbipd.Tools; diff --git a/Usbipd/VBoxUsbMon.cs b/Usbipd/VBoxUsbMon.cs index b44f263..e5cd156 100644 --- a/Usbipd/VBoxUsbMon.cs +++ b/Usbipd/VBoxUsbMon.cs @@ -2,12 +2,9 @@ // // SPDX-License-Identifier: GPL-3.0-only -using System; using System.ComponentModel; -using System.Linq; using System.Runtime.InteropServices; using System.ServiceProcess; -using System.Threading.Tasks; using static Usbipd.Interop.VBoxUsbMon; using static Usbipd.Tools; diff --git a/Usbipd/WslDistributions.cs b/Usbipd/WslDistributions.cs index d00d74c..a66064a 100644 --- a/Usbipd/WslDistributions.cs +++ b/Usbipd/WslDistributions.cs @@ -4,18 +4,12 @@ // // SPDX-License-Identifier: GPL-3.0-only -using System; -using System.Collections.Generic; using System.Globalization; -using System.IO; -using System.Linq; using System.Net; using System.Net.NetworkInformation; using System.Net.Sockets; using System.Text; using System.Text.RegularExpressions; -using System.Threading; -using System.Threading.Tasks; using Microsoft.Extensions.Configuration.Ini; namespace Usbipd;