Skip to content

Commit bd4fb9e

Browse files
authored
Run tests on .NET 8.0 (#2039)
* Run tests on .NET 8.0 * Add .NET 8.0 installation to build pipeline
1 parent c4b34f3 commit bd4fb9e

File tree

6 files changed

+60
-13
lines changed

6 files changed

+60
-13
lines changed

Rx.NET/Integration/LinuxTests/LinuxTests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
3+
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
44
<NoWarn>$(NoWarn);CS0618</NoWarn>
55
<LangVersion>latest</LangVersion>
66
<AssemblyName>Tests.System.Reactive</AssemblyName>
@@ -12,7 +12,7 @@
1212
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
1313
<DefineConstants>$(DefineConstants);</DefineConstants>
1414
</PropertyGroup>
15-
<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0' or '$(TargetFramework)' == 'net7.0' ">
15+
<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0' or '$(TargetFramework)' == 'net7.0' or '$(TargetFramework)' == 'net8.0'">
1616
<DefineConstants>$(DefineConstants);LINUX</DefineConstants>
1717
</PropertyGroup>
1818

Rx.NET/Integration/WindowsDesktopTests/WindowsDesktopTests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>net6.0;net6.0-windows10.0.19041;net7.0;net7.0-windows10.0.19041</TargetFrameworks>
3+
<TargetFrameworks>net6.0;net6.0-windows10.0.19041;net7.0;net7.0-windows10.0.19041;net8.0;net8.0-windows10.0.19041</TargetFrameworks>
44
<NoWarn>$(NoWarn);CS0618</NoWarn>
55
<LangVersion>latest</LangVersion>
66
<AssemblyName>Tests.System.Reactive</AssemblyName>
@@ -9,7 +9,7 @@
99
<AssemblyOriginatorKeyFile>..\..\Source\ReactiveX.snk</AssemblyOriginatorKeyFile>
1010
</PropertyGroup>
1111

12-
<PropertyGroup Condition="$(TargetFramework.StartsWith('net6.0-windows')) or $(TargetFramework.StartsWith('net7.0-windows'))">
12+
<PropertyGroup Condition="$(TargetFramework.StartsWith('net6.0-windows')) or $(TargetFramework.StartsWith('net7.0-windows')) or $(TargetFramework.StartsWith('net8.0-windows'))">
1313
<UseWPF>true</UseWPF>
1414
<UseWindowsForms>true</UseWindowsForms>
1515
<DefineConstants>$(DefineConstants);HAS_TRACE;HAS_WINRT;PREFER_ASYNC;HAS_TPL46;NO_REMOTING;HAS_WINFORMS;HAS_WPF;HAS_DISPATCHER;DESKTOPCLR;WINDOWS;CSWINRT</DefineConstants>

Rx.NET/Source/Directory.build.targets

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
1717
<DefineConstants>$(DefineConstants);HAS_WINRT;NO_NULLABLE_ATTRIBUTES</DefineConstants>
1818
</PropertyGroup>
19-
<PropertyGroup Condition="$(TargetFramework.StartsWith('net6.0')) or $(TargetFramework.StartsWith('net7.0'))">
19+
<PropertyGroup Condition="$(TargetFramework.StartsWith('net6.0')) or $(TargetFramework.StartsWith('net7.0')) or $(TargetFramework.StartsWith('net8.0'))">
2020
<DefineConstants>$(DefineConstants);HAS_TRIMMABILITY_ATTRIBUTES</DefineConstants>
2121
</PropertyGroup>
22-
<PropertyGroup Condition="$(TargetFramework.StartsWith('net6.0-windows')) or $(TargetFramework.StartsWith('net7.0-windows'))">
22+
<PropertyGroup Condition="$(TargetFramework.StartsWith('net6.0-windows')) or $(TargetFramework.StartsWith('net7.0-windows')) or $(TargetFramework.StartsWith('net8.0-windows'))">
2323
<DefineConstants>$(DefineConstants);HAS_WINRT;HAS_WINFORMS;HAS_WPF;HAS_DISPATCHER;DESKTOPCLR;WINDOWS;CSWINRT</DefineConstants>
2424
</PropertyGroup>
2525

Rx.NET/Source/tests/Tests.System.Reactive/Tests.System.Reactive.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="MSBuild.Sdk.Extras">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net472;net6.0;net7.0;net6.0-windows10.0.19041</TargetFrameworks>
4+
<TargetFrameworks>net472;net6.0;net7.0;net6.0-windows10.0.19041;net8.0;net8.0-windows10.0.19041</TargetFrameworks>
55
<NoWarn>$(NoWarn);CS0618</NoWarn>
66
</PropertyGroup>
77

Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/ToLookupTest.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,16 @@ public void ToLookup_Contains()
206206
public void ToLookup_Hides_Internal_List()
207207
{
208208
var d1 = Observable.Range(1, 10).ToLookup(x => (x % 2).ToString()).First();
209-
Assert.False(d1["0"] is ICollection<int>);
210-
Assert.False(d1["0"] is IList<int>);
209+
210+
// Up to .NET 7.0, the wrapper returned by LINQ to Objects' Skip (which is
211+
// what Rx uses today to hide the list) used not to implement IList or
212+
// ICollection. As of .NET 8.0 it does, but we can check we don't have
213+
// access to the underlying list by checking that we are unable to modify
214+
// it. Before .NET 8.0, these tests succeed because the wrapped list
215+
// doesn't implement the interfaces. On .NET 8.0 they succeed because it
216+
// provides a read-only implementation of them.
217+
Assert.False(d1["0"] is ICollection<int> coll && !coll.IsReadOnly);
218+
Assert.False(d1["0"] is IList<int> list && !list.IsReadOnly);
211219
}
212220

213221
[TestMethod]

azure-pipelines.rx.yml

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,26 @@ stages:
3434

3535
steps:
3636
- task: UseDotNet@2
37-
displayName: Use .NET Core 7.0.x SDK
37+
displayName: Use .NET 8.0.x SDK
3838
inputs:
39-
version: 7.0.x
39+
version: 8.0.x
4040
performMultiLevelLookup: true
4141

42+
# We need .NET 7.0 and 6.0 to be able to run all tests.
43+
# For .NET 7.0, the runtime package is sufficient because we don't need to build anything.
44+
# That doesn't work for 6.0, because we need the desktop framework, and the only way to
45+
# get that into a build agent seems to be to install the SDK.
46+
- task: UseDotNet@2
47+
displayName: Use .NET 7.0 runtime
48+
inputs:
49+
version: '7.0.x'
50+
packageType: runtime
51+
52+
- task: UseDotNet@2
53+
displayName: Use .NET 6.0 SDK
54+
inputs:
55+
version: '6.0.x'
56+
4257
- task: DotNetCoreCLI@2
4358
inputs:
4459
command: custom
@@ -120,9 +135,16 @@ stages:
120135
steps:
121136
- task: UseDotNet@2
122137
inputs:
123-
version: 7.0.x
138+
version: 8.0.x
139+
140+
- task: UseDotNet@2
141+
displayName: Use .NET 7.0 SDK
142+
inputs:
143+
version: '7.0.x'
144+
packageType: runtime
124145

125146
- task: UseDotNet@2
147+
displayName: Use .NET 6.0 SDK
126148
inputs:
127149
version: '6.0.x'
128150
packageType: runtime
@@ -151,6 +173,13 @@ stages:
151173
custom: restore
152174
arguments: --configfile $(System.DefaultWorkingDirectory)/Rx.NET/Integration/NuGet.Config
153175

176+
- task: DotNetCoreCLI@2
177+
inputs:
178+
command: test
179+
projects: $(System.DefaultWorkingDirectory)/Rx.NET/Integration/LinuxTests/LinuxTests.csproj
180+
arguments: -c $(BuildConfiguration) -f net8.0 --filter "TestCategory!=SkipCI"
181+
displayName: Run 8.0 Tests on Linux
182+
154183
- task: DotNetCoreCLI@2
155184
inputs:
156185
command: test
@@ -177,9 +206,19 @@ stages:
177206
steps:
178207
- task: UseDotNet@2
179208
inputs:
180-
version: 7.0.x
209+
version: 8.0.x
181210
performMultiLevelLookup: true
182211

212+
- task: UseDotNet@2
213+
displayName: Use .NET 7.0 SDK
214+
inputs:
215+
version: '7.0.x'
216+
217+
- task: UseDotNet@2
218+
displayName: Use .NET 6.0 SDK
219+
inputs:
220+
version: '6.0.x'
221+
183222
- task: DotNetCoreCLI@2
184223
inputs:
185224
command: custom

0 commit comments

Comments
 (0)