Skip to content

Commit

Permalink
Run tests on .NET 8.0 (#2039)
Browse files Browse the repository at this point in the history
* Run tests on .NET 8.0
* Add .NET 8.0 installation to build pipeline
  • Loading branch information
idg10 authored Nov 15, 2023
1 parent c4b34f3 commit bd4fb9e
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Rx.NET/Integration/LinuxTests/LinuxTests.csproj
Original file line number Diff line number Diff line change
@@ -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>
Expand All @@ -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>

Expand Down
Original file line number Diff line number Diff line change
@@ -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>
Expand All @@ -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>
Expand Down
4 changes: 2 additions & 2 deletions Rx.NET/Source/Directory.build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
Original file line number Diff line number Diff line change
@@ -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>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<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]
Expand Down
47 changes: 43 additions & 4 deletions azure-pipelines.rx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit bd4fb9e

Please sign in to comment.