소스 검색

Run tests on .NET 8.0 (#2039)

* Run tests on .NET 8.0
* Add .NET 8.0 installation to build pipeline
Ian Griffiths 1 년 전
부모
커밋
bd4fb9e083

+ 2 - 2
Rx.NET/Integration/LinuxTests/LinuxTests.csproj

@@ -1,6 +1,6 @@
 <Project Sdk="Microsoft.NET.Sdk">
   <PropertyGroup>
-    <TargetFrameworks>net6.0;net7.0</TargetFrameworks>
+    <TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
     <NoWarn>$(NoWarn);CS0618</NoWarn>
     <LangVersion>latest</LangVersion>
     <AssemblyName>Tests.System.Reactive</AssemblyName>
@@ -12,7 +12,7 @@
   <PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
     <DefineConstants>$(DefineConstants);</DefineConstants>
   </PropertyGroup>
-  <PropertyGroup Condition="'$(TargetFramework)' == 'net6.0' or '$(TargetFramework)' == 'net7.0' ">
+  <PropertyGroup Condition="'$(TargetFramework)' == 'net6.0' or '$(TargetFramework)' == 'net7.0' or '$(TargetFramework)' == 'net8.0'">
     <DefineConstants>$(DefineConstants);LINUX</DefineConstants>
   </PropertyGroup>
 

+ 2 - 2
Rx.NET/Integration/WindowsDesktopTests/WindowsDesktopTests.csproj

@@ -1,6 +1,6 @@
 <Project Sdk="Microsoft.NET.Sdk">
   <PropertyGroup>
-    <TargetFrameworks>net6.0;net6.0-windows10.0.19041;net7.0;net7.0-windows10.0.19041</TargetFrameworks>
+    <TargetFrameworks>net6.0;net6.0-windows10.0.19041;net7.0;net7.0-windows10.0.19041;net8.0;net8.0-windows10.0.19041</TargetFrameworks>
     <NoWarn>$(NoWarn);CS0618</NoWarn>
     <LangVersion>latest</LangVersion>
     <AssemblyName>Tests.System.Reactive</AssemblyName>
@@ -9,7 +9,7 @@
     <AssemblyOriginatorKeyFile>..\..\Source\ReactiveX.snk</AssemblyOriginatorKeyFile>
   </PropertyGroup>
 
-  <PropertyGroup Condition="$(TargetFramework.StartsWith('net6.0-windows')) or $(TargetFramework.StartsWith('net7.0-windows'))">
+  <PropertyGroup Condition="$(TargetFramework.StartsWith('net6.0-windows')) or $(TargetFramework.StartsWith('net7.0-windows')) or $(TargetFramework.StartsWith('net8.0-windows'))">
     <UseWPF>true</UseWPF>
     <UseWindowsForms>true</UseWindowsForms>
     <DefineConstants>$(DefineConstants);HAS_TRACE;HAS_WINRT;PREFER_ASYNC;HAS_TPL46;NO_REMOTING;HAS_WINFORMS;HAS_WPF;HAS_DISPATCHER;DESKTOPCLR;WINDOWS;CSWINRT</DefineConstants>

+ 2 - 2
Rx.NET/Source/Directory.build.targets

@@ -16,10 +16,10 @@
   <PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
     <DefineConstants>$(DefineConstants);HAS_WINRT;NO_NULLABLE_ATTRIBUTES</DefineConstants>
   </PropertyGroup>
-  <PropertyGroup Condition="$(TargetFramework.StartsWith('net6.0')) or $(TargetFramework.StartsWith('net7.0'))">
+  <PropertyGroup Condition="$(TargetFramework.StartsWith('net6.0')) or $(TargetFramework.StartsWith('net7.0')) or $(TargetFramework.StartsWith('net8.0'))">
     <DefineConstants>$(DefineConstants);HAS_TRIMMABILITY_ATTRIBUTES</DefineConstants>
   </PropertyGroup>
-  <PropertyGroup Condition="$(TargetFramework.StartsWith('net6.0-windows')) or $(TargetFramework.StartsWith('net7.0-windows'))">
+  <PropertyGroup Condition="$(TargetFramework.StartsWith('net6.0-windows')) or $(TargetFramework.StartsWith('net7.0-windows')) or $(TargetFramework.StartsWith('net8.0-windows'))">
     <DefineConstants>$(DefineConstants);HAS_WINRT;HAS_WINFORMS;HAS_WPF;HAS_DISPATCHER;DESKTOPCLR;WINDOWS;CSWINRT</DefineConstants>
   </PropertyGroup>
 

+ 1 - 1
Rx.NET/Source/tests/Tests.System.Reactive/Tests.System.Reactive.csproj

@@ -1,7 +1,7 @@
 <Project Sdk="MSBuild.Sdk.Extras">
 
   <PropertyGroup>
-    <TargetFrameworks>net472;net6.0;net7.0;net6.0-windows10.0.19041</TargetFrameworks>
+    <TargetFrameworks>net472;net6.0;net7.0;net6.0-windows10.0.19041;net8.0;net8.0-windows10.0.19041</TargetFrameworks>
     <NoWarn>$(NoWarn);CS0618</NoWarn>
   </PropertyGroup>
 

+ 10 - 2
Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/ToLookupTest.cs

@@ -206,8 +206,16 @@ namespace ReactiveTests.Tests
         public void ToLookup_Hides_Internal_List()
         {
             var d1 = Observable.Range(1, 10).ToLookup(x => (x % 2).ToString()).First();
-            Assert.False(d1["0"] is ICollection<int>);
-            Assert.False(d1["0"] is IList<int>);
+
+            // 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<int> coll && !coll.IsReadOnly);
+            Assert.False(d1["0"] is IList<int> list && !list.IsReadOnly);
         }
 
         [TestMethod]

+ 43 - 4
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