Skip to content

Commit

Permalink
Use .NET 8
Browse files Browse the repository at this point in the history
- Drop support for Windows 8/8.1/Server 2012/Server 2012 R2/Server 2016 (EOL)
  • Loading branch information
dorssel committed Sep 23, 2023
1 parent c456c45 commit fc298a6
Show file tree
Hide file tree
Showing 42 changed files with 143 additions and 260 deletions.
7 changes: 4 additions & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ SPDX-License-Identifier: GPL-3.0-only
<Platform>x64</Platform>

<!-- Use the latest .NET SDK -->
<!-- This product requires Windows 8 or higher -->
<TargetFramework>net7.0-windows8.0</TargetFramework>
<!-- This product requires Windows 10 (Windows Server 2019) or higher -->
<TargetFramework>net8.0-windows10.0.17763</TargetFramework>
<EnableWindowsTargeting>true</EnableWindowsTargeting>

<!-- Use the latest C# language standard -->
<LangVersion>11.0</LangVersion>
<LangVersion>12.0</LangVersion>

<!-- Be very strict -->
<WarningLevel>5</WarningLevel>
Expand Down
12 changes: 6 additions & 6 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ SPDX-License-Identifier: GPL-3.0-only
<PackageVersion Include="GitVersion.MsBuild" Version="5.12.0" />

<!-- Usbipd -->
<PackageVersion Include="Microsoft.Extensions.Configuration.Ini" Version="7.0.0" />
<PackageVersion Include="Microsoft.Extensions.Hosting.WindowsServices" Version="7.0.1" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Ini" Version="8.0.0-rc.1.23419.4" />
<PackageVersion Include="Microsoft.Extensions.Hosting.WindowsServices" Version="8.0.0-rc.1.23419.4" />
<PackageVersion Include="Microsoft.Windows.CsWin32" Version="0.3.46-beta" />
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />

<!-- UsbIds -->
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.7.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0-beta1.23420.2" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0-1.final" />

<!-- Usbipd.PowerShell -->
<PackageVersion Include="PowerShellStandard.Library" Version="5.1.1" />
<PackageVersion Include="System.Text.Json" Version="7.0.3" />
<PackageVersion Include="System.Text.Json" Version="8.0.0-rc.1.23419.4" />

<!-- Installer -->
<PackageVersion Include="WixToolset.DifxApp.wixext" Version="4.0.2" />
Expand All @@ -35,7 +35,7 @@ SPDX-License-Identifier: GPL-3.0-only
<PackageVersion Include="Moq" Version="4.20.69" />
<PackageVersion Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageVersion Include="MSTest.TestFramework" Version="3.1.1" />
<PackageVersion Include="System.IO.Pipelines" Version="7.0.0" />
<PackageVersion Include="System.IO.Pipelines" Version="8.0.0-rc.1.23419.4" />
<PackageVersion Include="coverlet.collector" Version="6.0.0" />
</ItemGroup>
</Project>
Binary file removed Drivers/VBoxUSB/VBoxUSB_Legacy.cat
Binary file not shown.
3 changes: 0 additions & 3 deletions Drivers/VBoxUSB/VBoxUSB_Legacy.cat.license

This file was deleted.

Binary file removed Drivers/VBoxUSBMon/VBoxUSBMon_Legacy.cat
Binary file not shown.
3 changes: 0 additions & 3 deletions Drivers/VBoxUSBMon/VBoxUSBMon_Legacy.cat.license

This file was deleted.

14 changes: 3 additions & 11 deletions Installer/Drivers.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@ SPDX-License-Identifier: GPL-3.0-only
<Fragment>
<DirectoryRef Id="Drivers" FileSource="$(var.DriversDir)">
<Directory Id="VBoxUSB" Name="VBoxUSB">
<Component Id="VBoxUSB.cat" Condition="WINDOWS_10_OR_HIGHER">
<Component Id="VBoxUSB.cat">
<File Name="VBoxUSB.cat" />
</Component>
<Component Id="VBoxUSB_Legacy.cat" Guid="{160CBFA1-3F76-440E-B587-641D67297588}" Condition="NOT WINDOWS_10_OR_HIGHER">
<File Id="VBoxUSB_Legacy.cat" Name="VBoxUSB.cat" Source="$(var.DriversDir)\VBoxUSB\VBoxUSB_Legacy.cat" KeyPath="yes" />
</Component>
<Component Id="VBoxUSB.sys" Bitness="always64">
<File Name="VBoxUSB.sys" />
</Component>
Expand All @@ -42,11 +39,8 @@ SPDX-License-Identifier: GPL-3.0-only
<Fragment>
<DirectoryRef Id="Drivers" FileSource="$(var.DriversDir)">
<Directory Id="VBoxUSBMon" Name="VBoxUSBMon">
<Component Id="VBoxUSBMon.cat" Condition="WINDOWS_10_OR_HIGHER">
<File Name="VBoxUSBMon.cat" ShortName="VBoxMon1.cat" />
</Component>
<Component Id="VBoxUSBMon_Legacy.cat" Guid="{90DA5BCB-01CB-4CDA-813D-062C95AACA84}" Condition="NOT WINDOWS_10_OR_HIGHER">
<File Id="VBoxUSBMon_Legacy.cat" Name="VBoxUSBMon.cat" ShortName="VBoxMon2.cat" Source="$(var.DriversDir)\VBoxUSBMon\VBoxUSBMon_Legacy.cat" KeyPath="yes" />
<Component Id="VBoxUSBMon.cat">
<File Name="VBoxUSBMon.cat" />
</Component>
<Component Id="VBoxUSBMon.sys" Bitness="always64">
<File Name="VBoxUSBMon.sys" />
Expand All @@ -62,7 +56,6 @@ SPDX-License-Identifier: GPL-3.0-only
<ComponentGroup Id="VBoxUSB">
<ComponentRef Id="README.md" />
<ComponentRef Id="VBoxUSB.cat" />
<ComponentRef Id="VBoxUSB_Legacy.cat" />
<ComponentRef Id="VBoxUSB.sys" />
<ComponentRef Id="VBoxUSB.inf" />
</ComponentGroup>
Expand All @@ -71,7 +64,6 @@ SPDX-License-Identifier: GPL-3.0-only
<ComponentGroup Id="VBoxUSBMon">
<ComponentRef Id="README.md" />
<ComponentRef Id="VBoxUSBMon.cat" />
<ComponentRef Id="VBoxUSBMon_Legacy.cat" />
<ComponentRef Id="VBoxUSBMon.sys" />
<ComponentRef Id="VBoxUSBMon.inf" />
</ComponentGroup>
Expand Down
14 changes: 2 additions & 12 deletions Installer/Installer.wixproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ SPDX-License-Identifier: GPL-3.0-only
<OutputName>usbipd-win</OutputName>
<PublishDir>..\Usbipd\bin\publish</PublishDir>
<PowerShellDir>..\Usbipd.PowerShell\bin\$(Configuration)\netstandard2.0\win</PowerShellDir>
<UcrtDir>$(MSBuildProgramFiles32)\Windows Kits\10\Redist\10.0.22621.0\ucrt\DLLs\x64</UcrtDir>
<DefineConstants>PublishDir=$(PublishDir);UcrtDir=$(UcrtDir);PowerShellDir=$(PowerShellDir);DriversDir=..\Drivers;Year=$([System.DateTime]::UtcNow.ToString("yyyy"))</DefineConstants>
<DefineConstants>PublishDir=$(PublishDir);PowerShellDir=$(PowerShellDir);DriversDir=..\Drivers;Year=$([System.DateTime]::UtcNow.ToString("yyyy"))</DefineConstants>
<!-- Suppress WIX1130: DifxApp Driver is deprecated -->
<!-- Suppress WIX1076: Allow components with with same target file, as they *are* mutually exclusive -->
<SuppressSpecificWarnings>1130;1076</SuppressSpecificWarnings>
<SuppressSpecificWarnings>1130</SuppressSpecificWarnings>
<Pedantic>true</Pedantic>
</PropertyGroup>
<ItemGroup>
Expand All @@ -37,14 +35,6 @@ SPDX-License-Identifier: GPL-3.0-only
<ComponentGroupName>PowerShell</ComponentGroupName>
<PreprocessorVariable>var.PowerShellDir</PreprocessorVariable>
</HarvestDirectory>
<HarvestDirectory Include="$(UcrtDir)" Visible="false">
<DirectoryRefId>APPLICATIONFOLDER</DirectoryRefId>
<SuppressRootDirectory>true</SuppressRootDirectory>
<SuppressCOM>true</SuppressCOM>
<SuppressRegistry>true</SuppressRegistry>
<ComponentGroupName>UCRT</ComponentGroupName>
<PreprocessorVariable>var.UcrtDir</PreprocessorVariable>
</HarvestDirectory>
</ItemGroup>
<ItemGroup>
<PackageReference Include="WixToolset.DifxApp.wixext" />
Expand Down
28 changes: 0 additions & 28 deletions Installer/Product.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,6 @@ SPDX-License-Identifier: GPL-3.0-only
/>
</Property>

<!--
Detect if we are on Windows 10 or later.
NOTE: We cannot use VersionNT, as msiexec.exe on Windows 10 always runs in Windows 8.1 compatibility mode.
-->
<Property Id="WINDOWS_10_OR_HIGHER">
<RegistrySearch Id="CurrentMajorVersionNumber"
Root="HKLM"
Key="SOFTWARE\Microsoft\Windows NT\CurrentVersion"
Name="CurrentMajorVersionNumber"
Type="raw"
/>
</Property>

<!--
If the product is currently installed and the APPLICATIONFOLDER has not been set yet, then preserve the current installation directory.
This allows users to:
Expand Down Expand Up @@ -125,21 +112,6 @@ SPDX-License-Identifier: GPL-3.0-only
>
<ComponentGroupRef Id="Usbipd" />
<ComponentRef Id="usbipd.exe" />
<Feature
Id="UCRT"
Level="1"
AllowAdvertise="no"
Display="expand"
AllowAbsent="yes"
Title="Universal C Runtime."
Description="Required only if not already installed as a Windows Update."
>
<!--
Windows 10 / Server 2016 or higher always uses the system UCRT.
-->
<Level Value="0" Condition="WINDOWS_10_OR_HIGHER"/>
<ComponentGroupRef Id="UCRT" />
</Feature>
<Feature
Id="Drivers"
Level="1"
Expand Down
1 change: 1 addition & 0 deletions NetStandard.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ SPDX-License-Identifier: GPL-3.0-only
<Platform>AnyCPU</Platform>
<PlatformTarget>AnyCPU</PlatformTarget>
<TargetFramework>netstandard2.0</TargetFramework>
<IsTrimmable>false</IsTrimmable>
</PropertyGroup>

</Project>
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Windows software for sharing locally connected USB devices to other machines, in

## How to install

This software requires Microsoft Windows 8.1 x64 / Microsoft Windows Server 2012 or newer;
This software requires Microsoft Windows 10 (x64 only) / Microsoft Windows Server 2019, version 1809 or newer;
it does not depend on any other software.

Run the installer (.msi) from the [latest release](https://github.com/dorssel/usbipd-win/releases/latest)
Expand Down
2 changes: 1 addition & 1 deletion UnitTests/Automation_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ sealed class Automation_Tests
static readonly IPAddress TestClientIPAddress = IPAddress.Parse("1.2.3.4");

static readonly Device TestDevice = new(TestInstanceId, TestDescription, true, TestBusId, TestPersistedGuid, TestStubInstanceId, TestClientIPAddress, true);
readonly Device[] TestDevices = new[] { TestDevice, new() };
readonly Device[] TestDevices = [TestDevice, new()];
const string TestJson = """
{
"Devices": [
Expand Down
10 changes: 4 additions & 6 deletions UnitTests/BusId_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ public void JsonConstructor()

sealed class BusIdData
{
static readonly string[] _Invalid = new[]
{
static readonly string[] _Invalid = [
"",
"1",
"1-",
Expand All @@ -48,15 +47,14 @@ sealed class BusIdData
"1-0",
"1-65536",
"65536-1",
};
];

public static IEnumerable<string[]> Invalid
{
get => from value in _Invalid select new string[] { value };
}

static readonly string[] _Valid = new[]
{
static readonly string[] _Valid = [
"1-1",
"1-2",
"1-65534",
Expand All @@ -73,7 +71,7 @@ public static IEnumerable<string[]> Invalid
"65535-2",
"65535-65534",
"65535-65535",
};
];

public static IEnumerable<string[]> Valid
{
Expand Down
2 changes: 2 additions & 0 deletions UnitTests/ConsoleTools_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ namespace UnitTests;
sealed class ConsoleTools_Tests
{
[TestMethod]
#pragma warning disable CA1861 // Avoid constant arrays as arguments
[DataRow("", 10, new[] { "" })]
[DataRow("1", 10, new[] { "1" })]
[DataRow("123456789", 10, new[] { "123456789" })]
[DataRow("123456789a", 10, new[] { "123456789a " })]
[DataRow("123456789ab", 10, new[] { "123456789ab" })]
[DataRow("12345 789", 10, new[] { "12345 789" })]
[DataRow("12345 789a", 10, new[] { "12345", "789a" })]
#pragma warning restore CA1861 // Avoid constant arrays as arguments
public void Wrap(string input, int width, string[] expected)
{
var result = ConsoleTools.Wrap(input, width);
Expand Down
2 changes: 1 addition & 1 deletion UnitTests/DeviceFile_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void IoControlAsync_Success()
{
using var deviceFile = new DeviceFile(TemporaryPath);
var rangeBuffer = new FILE_ALLOCATED_RANGE_BUFFER();
var outputBuffer = Array.Empty<byte>();
byte[] outputBuffer = [];
var result = deviceFile.IoControlAsync(TEST_IOCTL.FSCTL_QUERY_ALLOCATED_RANGES, Tools.StructToBytes(rangeBuffer), outputBuffer).Result;
Assert.AreEqual(0u, result);
}
Expand Down
8 changes: 4 additions & 4 deletions UnitTests/ExportedDevice_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ sealed class ExportedDevice_Tests
/// <summary>
/// See <seealso href="https://www.kernel.org/doc/html/latest/usb/usbip_protocol.html"/>.
/// </summary>
static readonly byte[] TestDeviceBytes = new byte[] {
static readonly byte[] TestDeviceBytes = [
// path (256 bytes, text)
(byte)'S', (byte)'O', (byte)'M', (byte)'E', (byte)'\\', (byte)'D', (byte)'e', (byte)'v',
(byte)'i', (byte)'c', (byte)'e', (byte)'\\', (byte)'P', (byte)'a', (byte)'t', (byte)'h',
Expand Down Expand Up @@ -68,17 +68,17 @@ sealed class ExportedDevice_Tests
4,
// bNumInterfaces (1 byte)
2,
};
];

/// <summary>
/// See <seealso href="https://www.kernel.org/doc/html/latest/usb/usbip_protocol.html"/>.
/// </summary>
static readonly byte[] TestDeviceInterfacesBytes = new byte[] {
static readonly byte[] TestDeviceInterfacesBytes = [
// interface: 3 bytes + 1 padding byte
1, 2, 3, 0,
// interface: 3 bytes + 1 padding byte
4, 5, 6, 0,
};
];

[TestMethod]
public void Serialize_NoInterfaces()
Expand Down
10 changes: 4 additions & 6 deletions UnitTests/Interop_UsbIp_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ namespace UnitTests;
[TestClass]
sealed class Interop_UsbIp_Tests
{
static readonly byte[] TestUsbIpHeaderBytes =
{
static readonly byte[] TestUsbIpHeaderBytes = [
0x01, 0x02, 0x03, 0x04, // basic.command
0x11, 0x12, 0x13, 0x14, // basic.seqnum
0x21, 0x22, 0x23, 0x24, // basic.devid
Expand All @@ -30,7 +29,7 @@ sealed class Interop_UsbIp_Tests
0xa3, 0xa4, // cmd_submit.setup.wValue
0xa5, 0xa6, // cmd_submit.setup.wIndex
0xa7, 0xa8, // cmd_submit.setup.wLength
};
];

static readonly UsbIpHeader TestUsbIpHeader = new()
{
Expand Down Expand Up @@ -112,13 +111,12 @@ public void UsbIpHeader_ToBytes_Success()
Assert.IsTrue(bytes.SequenceEqual(TestUsbIpHeaderBytes));
}

static readonly byte[] TestUsbIpIsoPacketDescriptorBytes =
{
static readonly byte[] TestUsbIpIsoPacketDescriptorBytes = [
0x01, 0x02, 0x03, 0x04, // offset
0x11, 0x12, 0x13, 0x14, // length
0x21, 0x22, 0x23, 0x24, // actual_length
0x31, 0x32, 0x33, 0x34, // status
};
];

static readonly UsbIpIsoPacketDescriptor TestUsbIpIsoPacketDescriptor = new()
{
Expand Down
8 changes: 4 additions & 4 deletions UnitTests/PcapNg_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public void DumpPacketIsoRequest_Disabled()
{
using var mockConfiguration = new MockConfiguration(null);
using var pcapNg = new PcapNg(mockConfiguration.Object, MockLogger);
pcapNg.DumpPacketIsoRequest(new(), new(), Array.Empty<UsbIpIsoPacketDescriptor>(), null);
pcapNg.DumpPacketIsoRequest(new(), new(), [], null);
}

[TestMethod]
Expand All @@ -229,15 +229,15 @@ public void DumpPacketIsoRequest_NoData()
{
using var mockConfiguration = new MockConfiguration(TemporaryPath);
using var pcapNg = new PcapNg(mockConfiguration.Object, MockLogger);
pcapNg.DumpPacketIsoRequest(new(), new(), Array.Empty<UsbIpIsoPacketDescriptor>(), null);
pcapNg.DumpPacketIsoRequest(new(), new(), [], null);
}

[TestMethod]
public void DumpPacketIsoReply_Disabled()
{
using var mockConfiguration = new MockConfiguration(null);
using var pcapNg = new PcapNg(mockConfiguration.Object, MockLogger);
pcapNg.DumpPacketIsoReply(new(), new(), new(), Array.Empty<UsbIpIsoPacketDescriptor>(), null);
pcapNg.DumpPacketIsoReply(new(), new(), new(), [], null);
}

[TestMethod]
Expand All @@ -253,7 +253,7 @@ public void DumpPacketIsoReply_NoData()
{
using var mockConfiguration = new MockConfiguration(TemporaryPath);
using var pcapNg = new PcapNg(mockConfiguration.Object, MockLogger);
pcapNg.DumpPacketIsoReply(new(), new(), new(), Array.Empty<UsbIpIsoPacketDescriptor>(), null);
pcapNg.DumpPacketIsoReply(new(), new(), new(), [], null);
}

[TestMethod]
Expand Down
Loading

0 comments on commit fc298a6

Please sign in to comment.