diff --git a/Installer/Installer.wixproj b/Installer/Installer.wixproj index 9cdce6dd..fb111cc6 100644 --- a/Installer/Installer.wixproj +++ b/Installer/Installer.wixproj @@ -26,19 +26,11 @@ usbipd-win false ..\UsbIpServer\bin\publish - - EA1D5623-E6A7-4E4A-9259-E397$(GitVersion_MajorMinorPatch.GetHashCode().ToString(X8)) bin\$(Configuration)\ obj\$(Configuration)\ - Debug;PublishDir=$(PublishDir);DriversDir=$(ProjectDir)..\Drivers;ProductId=$(ProductId) + Debug;PublishDir=$(PublishDir);DriversDir=$(ProjectDir)..\Drivers en-US False True @@ -46,7 +38,7 @@ bin\$(Configuration)\ obj\$(Configuration)\ - PublishDir=$(PublishDir);DriversDir=$(ProjectDir)..\Drivers;ProductId=$(ProductId) + PublishDir=$(PublishDir);DriversDir=$(ProjectDir)..\Drivers en-US False True @@ -102,7 +94,7 @@ - + @@ -114,6 +106,16 @@ + + + + del /s /q "$(ProjectDir)..\UsbIpServer\bin\publish" > NUL: diff --git a/UsbIpServer/AttachedClient.cs b/UsbIpServer/AttachedClient.cs index 07311a0c..5a1ccd07 100644 --- a/UsbIpServer/AttachedClient.cs +++ b/UsbIpServer/AttachedClient.cs @@ -16,7 +16,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -using Microsoft.Extensions.Logging; using System; using System.Buffers.Binary; using System.Diagnostics.CodeAnalysis; @@ -25,6 +24,7 @@ You should have received a copy of the GNU General Public License using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; +using Microsoft.Extensions.Logging; using static UsbIpServer.Interop.Usb; using static UsbIpServer.Interop.UsbIp; using static UsbIpServer.Interop.VBoxUsb; @@ -82,10 +82,10 @@ async Task HandleSubmitAsync(UsbIpHeaderBasic basic, UsbIpHeaderCmdSubmit submit urb.type = UsbSupTransferType.USBSUP_TRANSFER_TYPE_BULK; break; case UsbEndpointType.USB_ENDPOINT_TYPE_INTERRUPT: - throw new NotImplementedException("USB_ENDPOINT_TYPE_INTERRUPT"); // TODO: requires queuing reuests and handling USBIP_CMD_UNLINK // urb.type = UsbSupTransferType.USBSUP_TRANSFER_TYPE_INTR; // break; + throw new NotImplementedException("USB_ENDPOINT_TYPE_INTERRUPT"); case UsbEndpointType.USB_ENDPOINT_TYPE_ISOCHRONOUS: throw new NotImplementedException("USB_ENDPOINT_TYPE_ISOCHRONOUS"); } diff --git a/UsbIpServer/ConnectedClient.cs b/UsbIpServer/ConnectedClient.cs index c8c9e8ba..3362b86a 100644 --- a/UsbIpServer/ConnectedClient.cs +++ b/UsbIpServer/ConnectedClient.cs @@ -16,8 +16,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; using System; using System.Buffers.Binary; using System.Diagnostics.CodeAnalysis; @@ -27,6 +25,8 @@ You should have received a copy of the GNU General Public License using System.Text; using System.Threading; using System.Threading.Tasks; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; using UsbIpServer.Interop; using static UsbIpServer.Interop.UsbIp; using static UsbIpServer.Tools; diff --git a/UsbIpServer/DeviceFile.cs b/UsbIpServer/DeviceFile.cs index 545963b3..749ac5e6 100644 --- a/UsbIpServer/DeviceFile.cs +++ b/UsbIpServer/DeviceFile.cs @@ -16,7 +16,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -using Microsoft.Win32.SafeHandles; using System; using System.ComponentModel; using System.IO; @@ -24,6 +23,7 @@ You should have received a copy of the GNU General Public License using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; +using Microsoft.Win32.SafeHandles; using static UsbIpServer.Interop.WinSDK; namespace UsbIpServer @@ -75,7 +75,7 @@ void OnCompletion(uint errorCode, uint numBytes, NativeOverlapped* nativeOverlap } var nativeOverlapped = overlapped.Pack(OnCompletion, new object?[] { input, output }); - fixed (byte *pInput = input, pOutput = output) + fixed (byte* pInput = input, pOutput = output) { if (!NativeMethods.DeviceIoControl(handle, ioControlCode, (IntPtr)pInput, (uint)(input?.Length ?? 0), (IntPtr)pOutput, (uint)(output?.Length ?? 0), out var bytesReturned, (IntPtr)nativeOverlapped)) diff --git a/UsbIpServer/ExportedDevice.cs b/UsbIpServer/ExportedDevice.cs index 2c8011cd..09e9a894 100644 --- a/UsbIpServer/ExportedDevice.cs +++ b/UsbIpServer/ExportedDevice.cs @@ -36,7 +36,7 @@ namespace UsbIpServer sealed class ExportedDevice { public string Path { get; set; } = string.Empty; - public string BusId { get => $"{BusNum}-{DevNum}"; } + public string BusId => $"{BusNum}-{DevNum}"; public uint BusNum { get; set; } public uint DevNum { get; set; } public Linux.UsbDeviceSpeed Speed { get; set; } @@ -197,7 +197,7 @@ public static async Task GetAll(CancellationToken cancellation await hubFile.IoControlAsync(IoControl.IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX, buf, buf); BytesToStruct(buf, 0, out data); - var exportedDevice = new ExportedDevice() + var exportedDevice = new ExportedDevice() { Path = instanceId, BusNum = hubNum, diff --git a/UsbIpServer/Interop/VBoxUsb.cs b/UsbIpServer/Interop/VBoxUsb.cs index 276b5b0f..518af666 100644 --- a/UsbIpServer/Interop/VBoxUsb.cs +++ b/UsbIpServer/Interop/VBoxUsb.cs @@ -91,13 +91,13 @@ public struct UsbFilterField [StructLayout(LayoutKind.Sequential, Pack = 4)] public struct UsbFilter { - private uint u32Magic; - private UsbFilterType enmType; + uint u32Magic; + UsbFilterType enmType; [MarshalAs(UnmanagedType.ByValArray, SizeConst = (int)UsbFilterIdx.END)] public UsbFilterField[] aFields; - private readonly uint offCurEnd; + readonly uint offCurEnd; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] - private byte[] achStrTab; + byte[] achStrTab; public static UsbFilter Create(UsbFilterType type) { @@ -160,7 +160,7 @@ public struct UsbSupGetDevMon [StructLayout(LayoutKind.Sequential, Pack = 1)] public struct UsbSupClaimDev { - private readonly byte bInterfaceNumber; + readonly byte bInterfaceNumber; [MarshalAs(UnmanagedType.U1)] public bool fClaimed; } diff --git a/UsbIpServer/Interop/WinSDK.cs b/UsbIpServer/Interop/WinSDK.cs index 5b2761a6..ca52ad08 100644 --- a/UsbIpServer/Interop/WinSDK.cs +++ b/UsbIpServer/Interop/WinSDK.cs @@ -16,10 +16,10 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -using Microsoft.Win32.SafeHandles; using System; using System.IO; using System.Runtime.InteropServices; +using Microsoft.Win32.SafeHandles; using static UsbIpServer.Interop.Usb; namespace UsbIpServer.Interop @@ -120,7 +120,7 @@ public struct SpDeviceInterfaceData public uint cbSize; public Guid interfaceClassGuid; public uint flags; - private readonly UIntPtr reserved; + readonly UIntPtr reserved; } /// WinSDK: SetupAPI.h: SP_DEVINFO_DATA @@ -130,7 +130,7 @@ public struct SpDevInfoData public uint cbSize; public Guid ClassGuid; public uint DevInst; - private readonly UIntPtr Reserved; + readonly UIntPtr Reserved; } public static class NativeMethods diff --git a/UsbIpServer/Program.cs b/UsbIpServer/Program.cs index c4082bb9..95dfd6e4 100644 --- a/UsbIpServer/Program.cs +++ b/UsbIpServer/Program.cs @@ -16,24 +16,26 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -using Microsoft.Extensions.CommandLineUtils; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; using System; using System.IO; using System.Linq; using System.Reflection; +using Microsoft.Extensions.CommandLineUtils; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; + +[assembly: CLSCompliant(true)] namespace UsbIpServer { static class Program { - static string Product { get => Assembly.GetExecutingAssembly().GetCustomAttribute()!.Product; } - static string Copyright { get => Assembly.GetExecutingAssembly().GetCustomAttribute()!.Copyright; } + static string Product => Assembly.GetExecutingAssembly().GetCustomAttribute()!.Product; + static string Copyright => Assembly.GetExecutingAssembly().GetCustomAttribute()!.Copyright; static void ShowCopyright() { - Console.WriteLine($@"{Product} {GitVersionInformation.FullSemVer} + Console.WriteLine($@"{Product} {GitVersionInformation.MajorMinorPatch} {Copyright} This program is free software: you can redistribute it and/or modify @@ -57,7 +59,7 @@ static int Main(string[] args) { Name = Path.ChangeExtension(Path.GetFileName(Assembly.GetExecutingAssembly().Location), "exe"), }; - app.VersionOption("-v|--version", GitVersionInformation.FullSemVer, GitVersionInformation.InformationalVersion); + app.VersionOption("-v|--version", GitVersionInformation.MajorMinorPatch, GitVersionInformation.InformationalVersion); void DefaultCmdLine(CommandLineApplication cmd) { @@ -69,10 +71,12 @@ void DefaultCmdLine(CommandLineApplication cmd) DefaultCmdLine(app); app.OptionHelp.ShowInHelpText = true; - app.Command("license", (cmd) => { + app.Command("license", (cmd) => + { cmd.Description = "Display license information"; DefaultCmdLine(cmd); - cmd.OnExecute(() => { + cmd.OnExecute(() => + { ShowCopyright(); return 0; }); @@ -91,14 +95,16 @@ void DefaultCmdLine(CommandLineApplication cmd) cmd.Option("-b|--busid=", "Unbind VBoxUsb.sys from device on ", CommandOptionType.SingleValue); }); #endif - app.Command("server", (cmd) => { + app.Command("server", (cmd) => + { cmd.Description = "Run the server stand-alone on the console"; DefaultCmdLine(cmd); cmd.Argument("key=value", ".NET configuration override", true); cmd.OnExecute(() => ExecuteServer(cmd.Arguments.Single().Values.ToArray())); }); - app.OnExecute(() => { + app.OnExecute(() => + { app.ShowRootCommandFullNameAndVersion(); app.ShowHint(); return 0; diff --git a/UsbIpServer/SafeDeviceInfoSetHandle.cs b/UsbIpServer/SafeDeviceInfoSetHandle.cs index 3747dc67..35a9d572 100644 --- a/UsbIpServer/SafeDeviceInfoSetHandle.cs +++ b/UsbIpServer/SafeDeviceInfoSetHandle.cs @@ -28,6 +28,9 @@ public SafeDeviceInfoSetHandle() { } - protected override bool ReleaseHandle() => NativeMethods.SetupDiDestroyDeviceInfoList(handle); + protected override bool ReleaseHandle() + { + return NativeMethods.SetupDiDestroyDeviceInfoList(handle); + } } } diff --git a/UsbIpServer/Server.cs b/UsbIpServer/Server.cs index 9515e607..0365419f 100644 --- a/UsbIpServer/Server.cs +++ b/UsbIpServer/Server.cs @@ -16,14 +16,14 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; using System; using System.Diagnostics.CodeAnalysis; using System.Net.Sockets; using System.Threading; using System.Threading.Tasks; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; using static UsbIpServer.Interop.UsbIp; namespace UsbIpServer diff --git a/UsbIpServer/UsbConfigurationDescriptors.cs b/UsbIpServer/UsbConfigurationDescriptors.cs index 5c2ee61a..3e4dac54 100644 --- a/UsbIpServer/UsbConfigurationDescriptors.cs +++ b/UsbIpServer/UsbConfigurationDescriptors.cs @@ -32,7 +32,7 @@ public UsbEndpoint(UsbEndpointDescriptor descriptor) Descriptor = descriptor; } - public UsbEndpointType TransferType { get => (UsbEndpointType)(Descriptor.bmAttributes & 0x03); } + public UsbEndpointType TransferType => (UsbEndpointType)(Descriptor.bmAttributes & 0x03); public UsbEndpointDescriptor Descriptor { get; } } @@ -67,7 +67,7 @@ public void SetAlternate(byte alternateSetting) CurrentAlternate = alternateSetting; } - public UsbAlternateInterface Current { get => Alternates[CurrentAlternate]; } + public UsbAlternateInterface Current => Alternates[CurrentAlternate]; } sealed class UsbConfiguration diff --git a/UsbIpServer/UsbIpServer.csproj b/UsbIpServer/UsbIpServer.csproj index 21e60423..54b5216d 100644 --- a/UsbIpServer/UsbIpServer.csproj +++ b/UsbIpServer/UsbIpServer.csproj @@ -37,6 +37,9 @@ true enable + AllEnabledByDefault + true + usbipd-win Frans van Dorsselaer Copyright (C) $([System.DateTime]::UtcNow.ToString("yyyy")) $(Company) @@ -53,10 +56,6 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/UsbIpServer/VBoxUsbMon.cs b/UsbIpServer/VBoxUsbMon.cs index fa141089..d130215e 100644 --- a/UsbIpServer/VBoxUsbMon.cs +++ b/UsbIpServer/VBoxUsbMon.cs @@ -171,7 +171,7 @@ public async Task ClaimDevice(ExportedDevice device) } } - private bool IsDisposed; + bool IsDisposed; public void Dispose() { if (!IsDisposed)