瀏覽代碼

Further .NET 9.0 SDK updates (#2266)

* Use 9.0 on integration test CI stage
* fix some additional diagnostics that have appeared recently
* Update AsyncRx.NET to .NET 9.0 SDK
* Fix bizarre errors about HttpResponse causing Ix build to fail
Ian Griffiths 2 周之前
父節點
當前提交
b32cb594be

+ 7 - 1
.editorconfig

@@ -258,4 +258,10 @@ csharp_space_between_square_brackets = false
 dotnet_diagnostic.IDE0290.severity = none
 
 # Namespace style.
-csharp_style_namespace_declarations = block_scoped
+csharp_style_namespace_declarations = block_scoped
+dotnet_diagnostic.IDE0290.severity = none
+
+# Target-typed new expressions
+# We will probably adopt these at some point, but for some reason the IDE only just started complaining about them,
+# and I don't want to deal with all these while in the middle of the Slight Deunification.
+dotnet_diagnostic.IDE0090.severity = none

+ 1 - 1
Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs

@@ -63,7 +63,7 @@ namespace Tests
             var res1 = await enumerable.ToListAsync();
             var res2 = await enumerable.ToListAsync();
 
-            res1.Should().BeEquivalentTo(res2);
+            Assert.Equivalent(res1, res2, strict: true);
         }
     }
 }

+ 1 - 1
Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs

@@ -62,7 +62,7 @@ namespace Tests
             var res1 = await enumerable.ToListAsync();
             var res2 = await enumerable.ToListAsync();
 
-            res1.Should().BeEquivalentTo(res2);
+            Assert.Equivalent(res1, res2, strict: true);
         }
 
         protected static IAsyncEnumerable<TValue> Throw<TValue>(Exception exception)

+ 2 - 1
Rx.NET/Source/CodeCoverage.runsettings

@@ -5,7 +5,8 @@
     Workaround for failure to run tests on .NET FX on v3.3.1 MSTest packages
   -->
   <RunConfiguration>  
-    <DisableAppDomain>True</DisableAppDomain>   
+    <DisableAppDomain>True</DisableAppDomain>
+    <ExecutionThreadApartmentState>STA</ExecutionThreadApartmentState>
   </RunConfiguration>
 
   <DataCollectionRunSettings>

+ 2 - 6
Rx.NET/Source/Directory.build.props

@@ -32,11 +32,6 @@
   <ItemGroup>
     <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All"/>
     
-    <!--
-    Nerdbank.GitVersioning 3.6.128 injects a reference to a .proj file that doesn't work inside the
-    UWP test runner project. We don't ship that as a NuGet package, so it doesn't matter what its
-    version number is.
-    -->
     <PackageReference
       Include="Nerdbank.GitVersioning"
       Version="3.8.118"
@@ -119,9 +114,10 @@
               [.. x]. To me, this is less readable, and it doesn't improve performance, as far as we know.
 
     CA1510 - use ArgumentNullException.ThrowIf (not available on all targets)
+    CA1512 - use ArgumentOutOfRangeException.ThrowIfXxx (not available on all targets)
     CA1513 - use ObjectDisposedException.ThrowIf (not available on all targets)
     -->
-    <NoWarn>$(NoWarn);CA1001;CA2213;CA1510;CA1513;IDE0028;IDE0056;IDE0057;IDE0130;IDE0290;IDE0305;IDE0306</NoWarn>
+    <NoWarn>$(NoWarn);CA1001;CA2213;CA1510;CA1512;CA1513;IDE0028;IDE0056;IDE0057;IDE0130;IDE0290;IDE0305;IDE0306</NoWarn>
   </PropertyGroup>
 
   <ItemGroup>

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

@@ -5,7 +5,7 @@
   <PropertyGroup>  
     <Product>$(AssemblyName) ($(TargetFramework))</Product>
   </PropertyGroup>
-    
+
   <PropertyGroup Condition="'$(TargetFramework)' == 'net472'">
     <DefineConstants>$(DefineConstants);HAS_WINFORMS;HAS_WPF;HAS_WINRT;HAS_DISPATCHER;HAS_REMOTING;DESKTOPCLR;NO_NULLABLE_ATTRIBUTES</DefineConstants>
   </PropertyGroup>

+ 4 - 0
Rx.NET/Source/benchmarks/Benchmarks.System.Reactive/Program.cs

@@ -6,6 +6,10 @@ using System;
 using System.Reactive.Linq;
 using BenchmarkDotNet.Running;
 
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+[assembly:DoNotParallelize] // Not really a test project, but the build tools think we are, and complain if we don't state our parallelization policy.
+
 namespace Benchmarks.System.Reactive
 {
     internal class Program

+ 12 - 0
Rx.NET/Source/tests/Tests.System.Reactive.Uwp.DeviceRunner/Tests.System.Reactive.Uwp.DeviceRunner.csproj

@@ -147,6 +147,18 @@
     </PackageReference>
     <PackageReference Include="xunit.assert" Version="2.8.0" />
   </ItemGroup>
+  <ItemGroup>
+    <!--
+    Nerdbank.GitVersioning 3.6.128 injects a reference to a .proj file that doesn't work inside the
+    UWP test runner project. We don't ship that as a NuGet package, so it doesn't matter what its
+    version number is.
+    However, this doesn't seem to work. And excluding this project in the Directory.Build.props file
+    where we add this reference in the first place also doesn't work. I think this is coming in
+    transitively. So we need to work out exactly how .nuget\packages\nerdbank.gitversioning\3.6.143\build\PrivateP2PCaching.proj
+    is getting included, and work out how to stop that.
+    -->
+    <PackageReference Remove="Nerdbank.GitVersioning" />
+  </ItemGroup>
   <ItemGroup>
     <ApplicationDefinition Include="App.xaml">
       <Generator>MSBuild:Compile</Generator>

+ 7 - 0
Rx.NET/Source/tests/Tests.System.Reactive/TestConfiguration.cs

@@ -0,0 +1,7 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT License.
+// See the LICENSE file in the project root for more information. 
+
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+[assembly:Parallelize]

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

@@ -41,4 +41,11 @@
     <ProjectReference Include="..\..\src\Microsoft.Reactive.Testing\Microsoft.Reactive.Testing.csproj" />
   </ItemGroup>
 
+  <ItemGroup>
+    <PackageReference Update="coverlet.collector" Version="6.0.2">
+      <PrivateAssets>all</PrivateAssets>
+      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
+    </PackageReference>
+  </ItemGroup>
+
 </Project>

+ 1 - 0
Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/EventLoopSchedulerTest.cs

@@ -20,6 +20,7 @@ using Assert = Xunit.Assert;
 namespace ReactiveTests.Tests
 {
     [TestClass]
+    [DoNotParallelize] // We've observed hangs since enabling concurrent test execution.
     public class EventLoopSchedulerTest
     {
         private static readonly TimeSpan MaxWaitTime = TimeSpan.FromSeconds(10);

+ 1 - 0
Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/ObserveOnTest.cs

@@ -27,6 +27,7 @@ using Assert = Xunit.Assert;
 namespace ReactiveTests.Tests
 {
     [TestClass]
+    [DoNotParallelize] // We've observed hangs since enabling concurrent test execution.
     public class ObserveOnTest : TestBase
     {
         #region + TestBase +

+ 4 - 4
Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/RefCountTest.cs

@@ -348,14 +348,14 @@ namespace ReactiveTests.Tests
             var connectable = new SerialSingleNotificationConnectable<int>(Notification.CreateOnCompleted<int>());
             var refCount = connectable.RefCount();
 
-            var s1 = refCount.Subscribe();
+            _ = refCount.Subscribe();
             Assert.Equal(1, connectable.Connections.Count);
 
             // Since the source immediately completed, the RefCount goes back to zero subscribers
             // inside the call to Connect, so we expect to be disconnected.
             Assert.True(connectable.Connections[0].Disposed);
 
-            var s2 = refCount.Subscribe();
+            _ = refCount.Subscribe();
             Assert.Equal(2, connectable.Connections.Count);
             Assert.True(connectable.Connections[1].Disposed);
         }
@@ -384,10 +384,10 @@ namespace ReactiveTests.Tests
 
             // We're now back in the initial disconnected state, so nothing more should
             // happen until we get up to minObservers.
-            var s3 = refCount.Subscribe();
+            _ = refCount.Subscribe();
             Assert.Equal(1, connectable.Connections.Count);
 
-            var s4 = refCount.Subscribe();
+            _ = refCount.Subscribe();
             Assert.Equal(2, connectable.Connections.Count);
             Assert.True(connectable.Connections[1].Disposed);
         }

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

@@ -22,7 +22,7 @@ namespace ReactiveTests.Tests
             var ts = Observable.Throw<int>(new Exception("Aaargh!")).ResetExceptionDispatchState();
 
             string stackTrace = null;
-            for (int i = 0; i < 3; i++)
+            for (var i = 0; i < 3; i++)
             {
                 try
                 {
@@ -50,7 +50,7 @@ namespace ReactiveTests.Tests
             var ts = cts.ResetExceptionDispatchState();
 
             string stackTrace = null;
-            for (int i = 0; i < 3; i++)
+            for (var i = 0; i < 3; i++)
             {
                 try
                 {

+ 2 - 0
Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/SelectManyTest.cs

@@ -2,6 +2,8 @@
 // The .NET Foundation licenses this file to you under the MIT License.
 // See the LICENSE file in the project root for more information. 
 
+#pragma warning disable IDE0350 // Simplify lambda - we want to keep the long form for clarity in tests.
+
 using System;
 using System.Collections.Generic;
 using System.Linq;

+ 3 - 2
azure-pipelines.asyncrx.yml

@@ -34,10 +34,11 @@ stages:
 
     steps:
     - task: UseDotNet@2
-      displayName: Use .NET Core 7.0.x SDK
+      displayName: Use .NET 9.0.x SDK
       inputs:
-        version: 7.0.x
+        version: 9.0.x
         performMultiLevelLookup: true
+        includePreviewVersions: true
 
     - task: DotNetCoreCLI@2
       inputs:

+ 15 - 6
azure-pipelines.rx.yml

@@ -132,8 +132,9 @@ stages:
         version: '9.0.x'
 
     - task: UseDotNet@2
+      displayName: Use .NET 8.0 runtime
       inputs:
-        version: 8.0.x
+        version: '8.0.x'
         packageType: runtime
 
     - task: DotNetCoreCLI@2
@@ -164,8 +165,8 @@ stages:
       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
+        arguments: -c $(BuildConfiguration) -f net9.0 --filter "TestCategory!=SkipCI"
+      displayName: Run 9.0 Tests on Linux
 
     - task: DotNetCoreCLI@2
       inputs:
@@ -174,6 +175,13 @@ stages:
         arguments: -c $(BuildConfiguration) -f net9.0 --filter "TestCategory!=SkipCI"
       displayName: Run 9.0 Tests on Linux
 
+    - 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
+
   - job: WindowsDesktop    
     pool:
       vmImage: windows-latest
@@ -185,14 +193,15 @@ stages:
 
     steps:
     - task: UseDotNet@2
+      displayName: Use .NET 9.0 SDK
       inputs:
-        version: 8.0.x
+        version: 9.0.x
         performMultiLevelLookup: true
 
     - task: UseDotNet@2
-      displayName: Use .NET 9.0 SDK
+      displayName: Use .NET 8.0 SDK
       inputs:
-        version: '9.0.x'
+        version: '8.0.x'
 
     - task: DotNetCoreCLI@2
       inputs: