diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index d2be1b02..95881e14 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -43,7 +43,7 @@ jobs: - name: Setup .NET Core SDK uses: actions/setup-dotnet@v3 with: - dotnet-version: '8.0.x' + dotnet-version: '9.0.x' - name: Install Workloads run: | diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4327786f..b4fa2d5f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,7 +20,7 @@ jobs: - name: Setup .NET Core SDK uses: actions/setup-dotnet@v3 with: - dotnet-version: '8.0.x' + dotnet-version: '9.0.x' include-prerelease: true - name: Test diff --git a/lib/ShortDev.Microsoft.ConnectedDevices.NearShare/ShortDev.Microsoft.ConnectedDevices.NearShare.csproj b/lib/ShortDev.Microsoft.ConnectedDevices.NearShare/ShortDev.Microsoft.ConnectedDevices.NearShare.csproj index 690b7eb7..cf958247 100644 --- a/lib/ShortDev.Microsoft.ConnectedDevices.NearShare/ShortDev.Microsoft.ConnectedDevices.NearShare.csproj +++ b/lib/ShortDev.Microsoft.ConnectedDevices.NearShare/ShortDev.Microsoft.ConnectedDevices.NearShare.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 diff --git a/lib/ShortDev.Microsoft.ConnectedDevices/Messages/Connection/Authentication/AuthenticationPayload.cs b/lib/ShortDev.Microsoft.ConnectedDevices/Messages/Connection/Authentication/AuthenticationPayload.cs index 5458ae2b..a239512b 100644 --- a/lib/ShortDev.Microsoft.ConnectedDevices/Messages/Connection/Authentication/AuthenticationPayload.cs +++ b/lib/ShortDev.Microsoft.ConnectedDevices/Messages/Connection/Authentication/AuthenticationPayload.cs @@ -15,7 +15,7 @@ private AuthenticationPayload() { } public static AuthenticationPayload Parse(ref EndianReader reader) => new() { - Certificate = new(reader.ReadBytesWithLength().ToArray()), + Certificate = X509CertificateLoader.LoadCertificate(reader.ReadBytesWithLength()), SignedThumbprint = reader.ReadBytesWithLength().ToArray() }; diff --git a/lib/ShortDev.Microsoft.ConnectedDevices/ShortDev.Microsoft.ConnectedDevices.csproj b/lib/ShortDev.Microsoft.ConnectedDevices/ShortDev.Microsoft.ConnectedDevices.csproj index 341487c3..b3c131bf 100644 --- a/lib/ShortDev.Microsoft.ConnectedDevices/ShortDev.Microsoft.ConnectedDevices.csproj +++ b/lib/ShortDev.Microsoft.ConnectedDevices/ShortDev.Microsoft.ConnectedDevices.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 Nullable 0.1.0 true diff --git a/src/NearShare.Android.csproj b/src/NearShare.Android.csproj index d0aef1d9..b225a039 100644 --- a/src/NearShare.Android.csproj +++ b/src/NearShare.Android.csproj @@ -1,6 +1,6 @@  - net8.0-android34.0 + net9.0-android35.0 Exe 21 de.shortdev.nearby_sharing_windows diff --git a/tests/ShortDev.Microsoft.ConnectedDevices.Test/E2E/End2EndTest.cs b/tests/ShortDev.Microsoft.ConnectedDevices.Test/E2E/End2EndTest.cs index b0666382..14b83c1b 100644 --- a/tests/ShortDev.Microsoft.ConnectedDevices.Test/E2E/End2EndTest.cs +++ b/tests/ShortDev.Microsoft.ConnectedDevices.Test/E2E/End2EndTest.cs @@ -4,7 +4,6 @@ using ShortDev.Microsoft.ConnectedDevices.Transports.Bluetooth; using ShortDev.Microsoft.ConnectedDevices.Transports.Network; using System.Net; -using Xunit.Abstractions; namespace ShortDev.Microsoft.ConnectedDevices.Test.E2E; @@ -54,14 +53,14 @@ public async Task TransferUri(bool useTcp1, bool useTcp2) if (useTcp1) UseTcp(device1, tcpPort: 5041, udpPort: 5051); - device1.Discover(cancellationToken: default); + device1.Discover(TestContext.Current.CancellationToken); using var device2 = CreateDevice(network, "Device 2", "81-7A-80-8F-D5-80"); if (useTcp2) UseTcp(device2, tcpPort: 5041, udpPort: 5051); - device2.Advertise(cancellationToken: default); - device2.Listen(cancellationToken: default); + device2.Advertise(TestContext.Current.CancellationToken); + device2.Listen(TestContext.Current.CancellationToken); TaskCompletionSource receivePromise = new(); NearShareReceiver.ReceivedUri += receivePromise.SetResult; @@ -73,7 +72,8 @@ public async Task TransferUri(bool useTcp1, bool useTcp2) await sender.SendUriAsync( device: new("Device 2", DeviceType.Linux, Endpoint: new(Transports.CdpTransportType.Rfcomm, "81-7A-80-8F-D5-80", "ServiceId") - ), new Uri("https://nearshare.shortdev.de/") + ), new Uri("https://nearshare.shortdev.de/"), + TestContext.Current.CancellationToken ); var token = await receivePromise.Task; @@ -99,14 +99,14 @@ public async Task TransferFile(bool useTcp1, bool useTcp2) if (useTcp1) UseTcp(device1, tcpPort: 5041, udpPort: 5051); - device1.Discover(cancellationToken: default); + device1.Discover(TestContext.Current.CancellationToken); using var device2 = CreateDevice(network, "Device 2", "81-7A-80-8F-D5-80"); if (useTcp2) UseTcp(device2, tcpPort: 5041, udpPort: 5051); - device2.Advertise(cancellationToken: default); - device2.Listen(cancellationToken: default); + device2.Advertise(TestContext.Current.CancellationToken); + device2.Listen(TestContext.Current.CancellationToken); var buffer = new byte[Random.Shared.Next(1_000, 1_000_000)]; outputHelper.WriteLine($"[Information]: Generated buffer with size {buffer.LongLength}"); @@ -125,7 +125,8 @@ await sender.SendFileAsync( new(Transports.CdpTransportType.Rfcomm, "81-7A-80-8F-D5-80", "ServiceId") ), CdpFileProvider.FromBuffer("TestFile", buffer), - new Progress() + new Progress(), + TestContext.Current.CancellationToken ); await receivePromise.Task; @@ -140,7 +141,7 @@ await sender.SendFileAsync( void OnFileTransfer(FileTransferToken token) { Assert.Equal("Device 1", token.DeviceName); - Assert.Equal(1, token.Files.Count); + Assert.Single(token.Files); Assert.Equal("TestFile", token.Files[0].Name); Assert.Equal((ulong)buffer.LongLength, token.Files[0].Size); diff --git a/tests/ShortDev.Microsoft.ConnectedDevices.Test/E2E/TestLoggerProvider.cs b/tests/ShortDev.Microsoft.ConnectedDevices.Test/E2E/TestLoggerProvider.cs index 1733432a..55219aad 100644 --- a/tests/ShortDev.Microsoft.ConnectedDevices.Test/E2E/TestLoggerProvider.cs +++ b/tests/ShortDev.Microsoft.ConnectedDevices.Test/E2E/TestLoggerProvider.cs @@ -1,5 +1,4 @@ using Microsoft.Extensions.Logging; -using Xunit.Abstractions; namespace ShortDev.Microsoft.ConnectedDevices.Test.E2E; diff --git a/tests/ShortDev.Microsoft.ConnectedDevices.Test/SerializationTest.cs b/tests/ShortDev.Microsoft.ConnectedDevices.Test/SerializationTest.cs index 20794147..e7f91ba5 100644 --- a/tests/ShortDev.Microsoft.ConnectedDevices.Test/SerializationTest.cs +++ b/tests/ShortDev.Microsoft.ConnectedDevices.Test/SerializationTest.cs @@ -2,8 +2,6 @@ using ShortDev.Microsoft.ConnectedDevices.Messages; using ShortDev.Microsoft.ConnectedDevices.NearShare.Messages; using ShortDev.Microsoft.ConnectedDevices.Serialization; -using System.Diagnostics; -using Xunit.Abstractions; namespace ShortDev.Microsoft.ConnectedDevices.Test; @@ -16,7 +14,7 @@ static SerializationTest() private readonly ITestOutputHelper _output = output; - public static IEnumerable GenerateMsgTypes() + public static IEnumerable> GenerateMsgTypes() { var assembly = typeof(CommonHeader).Assembly; foreach (var type in assembly.DefinedTypes) @@ -26,7 +24,7 @@ public static IEnumerable GenerateMsgTypes() IsOk(typeof(ICdpPayload<>), type) && type.Name != "PresenceResponse" ) - yield return new object[] { type }; + yield return type; } static bool IsOk(Type TInterface, Type TClass) @@ -56,7 +54,7 @@ static void TestRun(Endianness endianness) where T : ICdpSerializable Type type = typeof(T); // allocate - var instance = (T)TestValueGenerator.RandomValue(typeof(T)); + var instance = TestValueGenerator.RandomValue(); // write - 1st pass EndianWriter writer = new(endianness); diff --git a/tests/ShortDev.Microsoft.ConnectedDevices.Test/ShortDev.Microsoft.ConnectedDevices.Test.csproj b/tests/ShortDev.Microsoft.ConnectedDevices.Test/ShortDev.Microsoft.ConnectedDevices.Test.csproj index 3e46f736..748a1018 100644 --- a/tests/ShortDev.Microsoft.ConnectedDevices.Test/ShortDev.Microsoft.ConnectedDevices.Test.csproj +++ b/tests/ShortDev.Microsoft.ConnectedDevices.Test/ShortDev.Microsoft.ConnectedDevices.Test.csproj @@ -1,28 +1,27 @@  - - net8.0 - false - true - + + Exe + net9.0 + false + true + - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - + + + + + all + + + all + + + - - - - + + + + diff --git a/tests/ShortDev.Microsoft.ConnectedDevices.Test/UtilsTest.cs b/tests/ShortDev.Microsoft.ConnectedDevices.Test/UtilsTest.cs index d135e3ff..d86d405d 100644 --- a/tests/ShortDev.Microsoft.ConnectedDevices.Test/UtilsTest.cs +++ b/tests/ShortDev.Microsoft.ConnectedDevices.Test/UtilsTest.cs @@ -1,6 +1,4 @@ -using Xunit.Abstractions; - -namespace ShortDev.Microsoft.ConnectedDevices.Test; +namespace ShortDev.Microsoft.ConnectedDevices.Test; public sealed class UtilsTest(ITestOutputHelper output) { [Theory] @@ -19,7 +17,7 @@ await LongRunningOperationWithThrow(delayMs) }); // Wait for long-running task to complete - await Task.Delay(delayMs * 2); + await Task.Delay(delayMs * 2, TestContext.Current.CancellationToken); } [Theory] @@ -38,7 +36,7 @@ await LongRunningOperationWithThrow(delayMs) }); // Wait for long-running task to complete - await Task.Delay(delayMs * 2); + await Task.Delay(delayMs * 2, TestContext.Current.CancellationToken); } static async Task LongRunningOperationWithThrow(int delayMs)