From 72a4a2cc8c62d832c992e04989d9c1a1a9e0caca Mon Sep 17 00:00:00 2001 From: Ian Griffiths Date: Wed, 15 Nov 2023 08:04:14 +0000 Subject: [PATCH] Run tests on .NET 8.0 (#2039) * Run tests on .NET 8.0 * Add .NET 8.0 installation to build pipeline --- .../Integration/LinuxTests/LinuxTests.csproj | 4 +- .../WindowsDesktopTests.csproj | 4 +- Rx.NET/Source/Directory.build.targets | 4 +- .../Tests.System.Reactive.csproj | 2 +- .../Tests/Linq/Observable/ToLookupTest.cs | 12 ++++- azure-pipelines.rx.yml | 47 +++++++++++++++++-- 6 files changed, 60 insertions(+), 13 deletions(-) diff --git a/Rx.NET/Integration/LinuxTests/LinuxTests.csproj b/Rx.NET/Integration/LinuxTests/LinuxTests.csproj index 237b4f433d..8547c0758b 100644 --- a/Rx.NET/Integration/LinuxTests/LinuxTests.csproj +++ b/Rx.NET/Integration/LinuxTests/LinuxTests.csproj @@ -1,6 +1,6 @@  - net6.0;net7.0 + net6.0;net7.0;net8.0 $(NoWarn);CS0618 latest Tests.System.Reactive @@ -12,7 +12,7 @@ $(DefineConstants); - + $(DefineConstants);LINUX diff --git a/Rx.NET/Integration/WindowsDesktopTests/WindowsDesktopTests.csproj b/Rx.NET/Integration/WindowsDesktopTests/WindowsDesktopTests.csproj index dc511dfec3..74cc7e587b 100644 --- a/Rx.NET/Integration/WindowsDesktopTests/WindowsDesktopTests.csproj +++ b/Rx.NET/Integration/WindowsDesktopTests/WindowsDesktopTests.csproj @@ -1,6 +1,6 @@  - net6.0;net6.0-windows10.0.19041;net7.0;net7.0-windows10.0.19041 + net6.0;net6.0-windows10.0.19041;net7.0;net7.0-windows10.0.19041;net8.0;net8.0-windows10.0.19041 $(NoWarn);CS0618 latest Tests.System.Reactive @@ -9,7 +9,7 @@ ..\..\Source\ReactiveX.snk - + true true $(DefineConstants);HAS_TRACE;HAS_WINRT;PREFER_ASYNC;HAS_TPL46;NO_REMOTING;HAS_WINFORMS;HAS_WPF;HAS_DISPATCHER;DESKTOPCLR;WINDOWS;CSWINRT diff --git a/Rx.NET/Source/Directory.build.targets b/Rx.NET/Source/Directory.build.targets index ea47a0a5bb..640738d8c0 100644 --- a/Rx.NET/Source/Directory.build.targets +++ b/Rx.NET/Source/Directory.build.targets @@ -16,10 +16,10 @@ $(DefineConstants);HAS_WINRT;NO_NULLABLE_ATTRIBUTES - + $(DefineConstants);HAS_TRIMMABILITY_ATTRIBUTES - + $(DefineConstants);HAS_WINRT;HAS_WINFORMS;HAS_WPF;HAS_DISPATCHER;DESKTOPCLR;WINDOWS;CSWINRT diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests.System.Reactive.csproj b/Rx.NET/Source/tests/Tests.System.Reactive/Tests.System.Reactive.csproj index 65eb48bada..00d1d52dcc 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests.System.Reactive.csproj +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests.System.Reactive.csproj @@ -1,7 +1,7 @@  - net472;net6.0;net7.0;net6.0-windows10.0.19041 + net472;net6.0;net7.0;net6.0-windows10.0.19041;net8.0;net8.0-windows10.0.19041 $(NoWarn);CS0618 diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/ToLookupTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/ToLookupTest.cs index 4f64850073..77b678dee4 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/ToLookupTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/ToLookupTest.cs @@ -206,8 +206,16 @@ public void ToLookup_Contains() public void ToLookup_Hides_Internal_List() { var d1 = Observable.Range(1, 10).ToLookup(x => (x % 2).ToString()).First(); - Assert.False(d1["0"] is ICollection); - Assert.False(d1["0"] is IList); + + // Up to .NET 7.0, the wrapper returned by LINQ to Objects' Skip (which is + // what Rx uses today to hide the list) used not to implement IList or + // ICollection. As of .NET 8.0 it does, but we can check we don't have + // access to the underlying list by checking that we are unable to modify + // it. Before .NET 8.0, these tests succeed because the wrapped list + // doesn't implement the interfaces. On .NET 8.0 they succeed because it + // provides a read-only implementation of them. + Assert.False(d1["0"] is ICollection coll && !coll.IsReadOnly); + Assert.False(d1["0"] is IList list && !list.IsReadOnly); } [TestMethod] diff --git a/azure-pipelines.rx.yml b/azure-pipelines.rx.yml index 3ebd298290..4b1bb9c183 100644 --- a/azure-pipelines.rx.yml +++ b/azure-pipelines.rx.yml @@ -34,11 +34,26 @@ stages: steps: - task: UseDotNet@2 - displayName: Use .NET Core 7.0.x SDK + displayName: Use .NET 8.0.x SDK inputs: - version: 7.0.x + version: 8.0.x performMultiLevelLookup: true + # We need .NET 7.0 and 6.0 to be able to run all tests. + # For .NET 7.0, the runtime package is sufficient because we don't need to build anything. + # That doesn't work for 6.0, because we need the desktop framework, and the only way to + # get that into a build agent seems to be to install the SDK. + - task: UseDotNet@2 + displayName: Use .NET 7.0 runtime + inputs: + version: '7.0.x' + packageType: runtime + + - task: UseDotNet@2 + displayName: Use .NET 6.0 SDK + inputs: + version: '6.0.x' + - task: DotNetCoreCLI@2 inputs: command: custom @@ -120,9 +135,16 @@ stages: steps: - task: UseDotNet@2 inputs: - version: 7.0.x + version: 8.0.x + + - task: UseDotNet@2 + displayName: Use .NET 7.0 SDK + inputs: + version: '7.0.x' + packageType: runtime - task: UseDotNet@2 + displayName: Use .NET 6.0 SDK inputs: version: '6.0.x' packageType: runtime @@ -151,6 +173,13 @@ stages: custom: restore arguments: --configfile $(System.DefaultWorkingDirectory)/Rx.NET/Integration/NuGet.Config + - task: DotNetCoreCLI@2 + inputs: + command: test + projects: $(System.DefaultWorkingDirectory)/Rx.NET/Integration/LinuxTests/LinuxTests.csproj + arguments: -c $(BuildConfiguration) -f net8.0 --filter "TestCategory!=SkipCI" + displayName: Run 8.0 Tests on Linux + - task: DotNetCoreCLI@2 inputs: command: test @@ -177,9 +206,19 @@ stages: steps: - task: UseDotNet@2 inputs: - version: 7.0.x + version: 8.0.x performMultiLevelLookup: true + - task: UseDotNet@2 + displayName: Use .NET 7.0 SDK + inputs: + version: '7.0.x' + + - task: UseDotNet@2 + displayName: Use .NET 6.0 SDK + inputs: + version: '6.0.x' + - task: DotNetCoreCLI@2 inputs: command: custom