diff --git a/Directory.Packages.props b/Directory.Packages.props
index c5b6b98e8..2cf97ec8a 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -4,9 +4,9 @@
true
true
+ 2.0.2
2.0.208
3.11.0
- 4.13.0
1.1.2
3.11.0-beta1.25076.3
@@ -36,22 +36,17 @@
-
-
-
-
-
-
-
-
-
-
+
+
+
-
+
+
+
+
-
-
+
diff --git a/azure-pipelines/Merge-CodeCoverage.ps1 b/azure-pipelines/Merge-CodeCoverage.ps1
index 32438237e..c552d25f2 100644
--- a/azure-pipelines/Merge-CodeCoverage.ps1
+++ b/azure-pipelines/Merge-CodeCoverage.ps1
@@ -28,6 +28,7 @@ try {
if ($reports) {
$reports |% { $_.FullName } |% {
# In addition to replacing {reporoot}, we also normalize on one kind of slash so that the report aggregates data for a file whether data was collected on Windows or not.
+ Write-Verbose "Processing $_"
$xml = [xml](Get-Content -LiteralPath $_)
$xml.coverage.packages.package.classes.class |? { $_.filename} |% {
$_.filename = $_.filename.Replace('{reporoot}', $RepoRoot).Replace([IO.Path]::AltDirectorySeparatorChar, [IO.Path]::DirectorySeparatorChar)
diff --git a/global.json b/global.json
index a04d4cd45..309bbfd49 100644
--- a/global.json
+++ b/global.json
@@ -1,9 +1,12 @@
{
"sdk": {
- "version": "10.0.100",
+ "version": "10.0.101",
"rollForward": "patch",
"allowPrerelease": false
},
+ "test": {
+ "runner": "Microsoft.Testing.Platform"
+ },
"msbuild-sdks": {
"MSBuild.Sdk.Extras": "3.0.44",
"Microsoft.Build.NoTargets": "3.7.134",
diff --git a/src/Microsoft.VisualStudio.Threading/ListOfOftenOne`1.cs b/src/Microsoft.VisualStudio.Threading/ListOfOftenOne`1.cs
index 6ff984ca1..2549aeb50 100644
--- a/src/Microsoft.VisualStudio.Threading/ListOfOftenOne`1.cs
+++ b/src/Microsoft.VisualStudio.Threading/ListOfOftenOne`1.cs
@@ -3,11 +3,7 @@
using System;
using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using System.Text;
using System.Threading;
-using System.Threading.Tasks;
namespace Microsoft.VisualStudio.Threading;
diff --git a/src/Microsoft.VisualStudio.Threading/WeakKeyDictionary`2.cs b/src/Microsoft.VisualStudio.Threading/WeakKeyDictionary`2.cs
index 562d198aa..5f92e4cc7 100644
--- a/src/Microsoft.VisualStudio.Threading/WeakKeyDictionary`2.cs
+++ b/src/Microsoft.VisualStudio.Threading/WeakKeyDictionary`2.cs
@@ -214,7 +214,7 @@ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
///
internal bool Any()
{
- foreach (KeyValuePair.WeakReference, TValue> item in this.dictionary)
+ foreach (KeyValuePair, TValue> item in this.dictionary)
{
if (item.Key.IsAlive)
{
diff --git a/test/.editorconfig b/test/.editorconfig
index 988129278..04701aea8 100644
--- a/test/.editorconfig
+++ b/test/.editorconfig
@@ -80,3 +80,6 @@ dotnet_diagnostic.SA1401.severity = silent
# SA1133: Do not combine attributes
dotnet_diagnostic.SA1133.severity = silent
+
+# xUnit1051: Use TestContext.Current.CancellationToken
+dotnet_diagnostic.xUnit1051.severity = suggestion
diff --git a/test/Directory.Build.props b/test/Directory.Build.props
index e8b338a78..466be54e4 100644
--- a/test/Directory.Build.props
+++ b/test/Directory.Build.props
@@ -3,9 +3,9 @@
- true
false
true
+ true
diff --git a/test/Directory.Build.targets b/test/Directory.Build.targets
index 9f32cd061..3758bb8c9 100644
--- a/test/Directory.Build.targets
+++ b/test/Directory.Build.targets
@@ -1,5 +1,11 @@
+
+
+
+
+
+
diff --git a/test/Directory.Packages.props b/test/Directory.Packages.props
new file mode 100644
index 000000000..6875d8235
--- /dev/null
+++ b/test/Directory.Packages.props
@@ -0,0 +1,14 @@
+
+
+
+
+
+ 4.13.0
+
+
+
+
+
+
+
+
diff --git a/test/IsolatedTestHost/App.config b/test/IsolatedTestHost/App.config
index e5ab83a70..aed254391 100644
--- a/test/IsolatedTestHost/App.config
+++ b/test/IsolatedTestHost/App.config
@@ -1,29 +1,12 @@
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/test/IsolatedTestHost/IsolatedTestHost.csproj b/test/IsolatedTestHost/IsolatedTestHost.csproj
index b5b95cf1e..353005b37 100644
--- a/test/IsolatedTestHost/IsolatedTestHost.csproj
+++ b/test/IsolatedTestHost/IsolatedTestHost.csproj
@@ -3,10 +3,11 @@
Exe
net472
+ false
-
+
diff --git a/test/IsolatedTestHost/Program.cs b/test/IsolatedTestHost/Program.cs
index 6712fa6e0..a20655442 100644
--- a/test/IsolatedTestHost/Program.cs
+++ b/test/IsolatedTestHost/Program.cs
@@ -7,7 +7,6 @@
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
-using Xunit;
namespace IsolatedTestHost;
@@ -53,8 +52,7 @@ private static ExitCode MyMain(string assemblyFile, string testClassName, string
}
bool fact = testMethod.GetCustomAttributesData().Any(a => a.AttributeType.Name == "FactAttribute");
- bool skippableFact = testMethod.GetCustomAttributesData().Any(a => a.AttributeType.Name == "SkippableFactAttribute");
- if (fact || skippableFact)
+ if (fact)
{
return ExecuteTest(testClass, testMethod);
}
diff --git a/test/IsolatedTestHost/TestOutputHelper.cs b/test/IsolatedTestHost/TestOutputHelper.cs
index b27c20f25..f91502ede 100644
--- a/test/IsolatedTestHost/TestOutputHelper.cs
+++ b/test/IsolatedTestHost/TestOutputHelper.cs
@@ -1,20 +1,23 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-using System;
-using Xunit.Abstractions;
+using System.Globalization;
+using System.Text;
+using Xunit;
namespace IsolatedTestHost;
internal class TestOutputHelper : ITestOutputHelper
{
- public void WriteLine(string message)
- {
- Console.WriteLine(message);
- }
-
- public void WriteLine(string format, params object[] args)
- {
- Console.WriteLine(format, args);
- }
+ private readonly StringBuilder builder = new();
+
+ public string Output => this.builder.ToString();
+
+ public void Write(string message) => this.builder.Append(message);
+
+ public void Write(string format, params object[] args) => this.builder.AppendFormat(format, args);
+
+ public void WriteLine(string message) => this.builder.AppendLine(message);
+
+ public void WriteLine(string format, params object[] args) => this.builder.AppendLine(string.Format(CultureInfo.CurrentCulture, format, args));
}
diff --git a/test/Microsoft.VisualStudio.Threading.Analyzers.Tests/Helpers/CSharpCodeFixVerifier`2+Test.cs b/test/Microsoft.VisualStudio.Threading.Analyzers.Tests/Helpers/CSharpCodeFixVerifier`2+Test.cs
index 18ae7d018..b767fa30e 100644
--- a/test/Microsoft.VisualStudio.Threading.Analyzers.Tests/Helpers/CSharpCodeFixVerifier`2+Test.cs
+++ b/test/Microsoft.VisualStudio.Threading.Analyzers.Tests/Helpers/CSharpCodeFixVerifier`2+Test.cs
@@ -37,7 +37,7 @@ public Test()
#if WINDOWS
project = project.AddMetadataReference(MetadataReference.CreateFromFile(typeof(Dispatcher).Assembly.Location));
#else
- Skip.If(true);
+ Assert.SkipWhen(true, "Windows only");
#endif
}
diff --git a/test/Microsoft.VisualStudio.Threading.Analyzers.Tests/Helpers/VisualBasicCodeFixVerifier`2+Test.cs b/test/Microsoft.VisualStudio.Threading.Analyzers.Tests/Helpers/VisualBasicCodeFixVerifier`2+Test.cs
index 8793d3d8c..c3a1ef718 100644
--- a/test/Microsoft.VisualStudio.Threading.Analyzers.Tests/Helpers/VisualBasicCodeFixVerifier`2+Test.cs
+++ b/test/Microsoft.VisualStudio.Threading.Analyzers.Tests/Helpers/VisualBasicCodeFixVerifier`2+Test.cs
@@ -37,7 +37,7 @@ public Test()
#if WINDOWS
project = project.AddMetadataReference(MetadataReference.CreateFromFile(typeof(Dispatcher).Assembly.Location));
#else
- Skip.If(true);
+ Assert.SkipWhen(true, "Windows only");
#endif
}
diff --git a/test/Microsoft.VisualStudio.Threading.Analyzers.Tests/Microsoft.VisualStudio.Threading.Analyzers.Tests.csproj b/test/Microsoft.VisualStudio.Threading.Analyzers.Tests/Microsoft.VisualStudio.Threading.Analyzers.Tests.csproj
index c77215d0f..50bbac324 100644
--- a/test/Microsoft.VisualStudio.Threading.Analyzers.Tests/Microsoft.VisualStudio.Threading.Analyzers.Tests.csproj
+++ b/test/Microsoft.VisualStudio.Threading.Analyzers.Tests/Microsoft.VisualStudio.Threading.Analyzers.Tests.csproj
@@ -1,7 +1,7 @@
net8.0
- true
+ Exe
true
true
$(NoWarn);NU1701
@@ -25,13 +25,10 @@
-
-
-
-
+
net472
Exe
+ false
diff --git a/test/Microsoft.VisualStudio.Threading.Tests/AssemblyInfo.cs b/test/Microsoft.VisualStudio.Threading.Tests/AssemblyInfo.cs
index da96c1511..194900e3c 100644
--- a/test/Microsoft.VisualStudio.Threading.Tests/AssemblyInfo.cs
+++ b/test/Microsoft.VisualStudio.Threading.Tests/AssemblyInfo.cs
@@ -1,8 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-using Xunit;
-
// Some of our tests measure stress, GC pressure, etc.
// It messes with reliable test results when other threads are doing random stuff.
[assembly: CollectionBehavior(DisableTestParallelization = true)]
diff --git a/test/Microsoft.VisualStudio.Threading.Tests/AsyncAutoResetEventTests.cs b/test/Microsoft.VisualStudio.Threading.Tests/AsyncAutoResetEventTests.cs
index ad1d4431c..c6b0ecc11 100644
--- a/test/Microsoft.VisualStudio.Threading.Tests/AsyncAutoResetEventTests.cs
+++ b/test/Microsoft.VisualStudio.Threading.Tests/AsyncAutoResetEventTests.cs
@@ -4,14 +4,12 @@
using System;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.VisualStudio.Threading;
-using Xunit;
public class AsyncAutoResetEventTests : TestBase
{
private AsyncAutoResetEvent evt;
- public AsyncAutoResetEventTests(Xunit.Abstractions.ITestOutputHelper logger)
+ public AsyncAutoResetEventTests(ITestOutputHelper logger)
: base(logger)
{
this.evt = new AsyncAutoResetEvent();
@@ -200,7 +198,7 @@ public async Task WaitAsync_Canceled_Stress()
///
/// Verifies that long-lived, uncanceled CancellationTokens do not result in leaking memory.
///
- [SkippableFact(Skip = "It always fails after xunit 2.8 update.")]
+ [Fact(Skip = "It always fails after xunit 2.8 update.")]
[Trait("GC", "true")]
[Trait("TestCategory", "FailsInCloudTest")]
public async Task WaitAsync_WithCancellationToken_DoesNotLeakWhenNotCanceled()
@@ -222,7 +220,7 @@ public async Task WaitAsync_WithCancellationToken_DoesNotLeakWhenNotCanceled()
///
/// Verifies that canceled CancellationTokens do not result in leaking memory.
///
- [SkippableFact(Skip = "It always fails after xunit 2.8 update.")]
+ [Fact(Skip = "It always fails after xunit 2.8 update.")]
[Trait("GC", "true")]
[Trait("TestCategory", "FailsInCloudTest")]
public async Task WaitAsync_WithCancellationToken_DoesNotLeakWhenCanceled()
diff --git a/test/Microsoft.VisualStudio.Threading.Tests/AsyncBarrierTests.cs b/test/Microsoft.VisualStudio.Threading.Tests/AsyncBarrierTests.cs
index 5b9c48559..394cf5bee 100644
--- a/test/Microsoft.VisualStudio.Threading.Tests/AsyncBarrierTests.cs
+++ b/test/Microsoft.VisualStudio.Threading.Tests/AsyncBarrierTests.cs
@@ -6,9 +6,6 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft;
-using Microsoft.VisualStudio.Threading;
-using Xunit;
-using Xunit.Abstractions;
public class AsyncBarrierTests : TestBase
{
diff --git a/test/Microsoft.VisualStudio.Threading.Tests/AsyncCountdownEventTests.cs b/test/Microsoft.VisualStudio.Threading.Tests/AsyncCountdownEventTests.cs
index 7c9606aca..2ab242193 100644
--- a/test/Microsoft.VisualStudio.Threading.Tests/AsyncCountdownEventTests.cs
+++ b/test/Microsoft.VisualStudio.Threading.Tests/AsyncCountdownEventTests.cs
@@ -4,9 +4,6 @@
using System;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.VisualStudio.Threading;
-using Xunit;
-using Xunit.Abstractions;
public class AsyncCountdownEventTests : TestBase
{
diff --git a/test/Microsoft.VisualStudio.Threading.Tests/AsyncCrossProcessMutexTests.cs b/test/Microsoft.VisualStudio.Threading.Tests/AsyncCrossProcessMutexTests.cs
index 9c72d1d8a..8872ad9aa 100644
--- a/test/Microsoft.VisualStudio.Threading.Tests/AsyncCrossProcessMutexTests.cs
+++ b/test/Microsoft.VisualStudio.Threading.Tests/AsyncCrossProcessMutexTests.cs
@@ -4,9 +4,6 @@
using System;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.VisualStudio.Threading;
-using Xunit;
-using Xunit.Abstractions;
public class AsyncCrossProcessMutexTests : TestBase, IDisposable
{
diff --git a/test/Microsoft.VisualStudio.Threading.Tests/AsyncLazyInitializerTests.cs b/test/Microsoft.VisualStudio.Threading.Tests/AsyncLazyInitializerTests.cs
index 5c16ba2a6..69eb2dccd 100644
--- a/test/Microsoft.VisualStudio.Threading.Tests/AsyncLazyInitializerTests.cs
+++ b/test/Microsoft.VisualStudio.Threading.Tests/AsyncLazyInitializerTests.cs
@@ -4,9 +4,6 @@
using System;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.VisualStudio.Threading;
-using Xunit;
-using Xunit.Abstractions;
public class AsyncLazyInitializerTests : TestBase
{
diff --git a/test/Microsoft.VisualStudio.Threading.Tests/AsyncLazyTests.cs b/test/Microsoft.VisualStudio.Threading.Tests/AsyncLazyTests.cs
index 0c3e76a21..79fb5b395 100644
--- a/test/Microsoft.VisualStudio.Threading.Tests/AsyncLazyTests.cs
+++ b/test/Microsoft.VisualStudio.Threading.Tests/AsyncLazyTests.cs
@@ -8,11 +8,6 @@
using System.Threading.Tasks;
using Microsoft;
-using Microsoft.VisualStudio.Threading;
-
-using Xunit;
-using Xunit.Abstractions;
-
using NamedSyncContext = AwaitExtensionsTests.NamedSyncContext;
public class AsyncLazyTests : TestBase
@@ -214,7 +209,7 @@ public async Task ValueFactoryReentersValueFactorySynchronously(bool specifyJtf)
Assert.False(executed);
executed = true;
lazy!.GetValueAsync();
- return Task.FromResult
-
-
-
-
+
diff --git a/test/Microsoft.VisualStudio.Threading.Tests/NonConcurrentSynchronizationContextTests.cs b/test/Microsoft.VisualStudio.Threading.Tests/NonConcurrentSynchronizationContextTests.cs
index 26afaae86..650a23f3b 100644
--- a/test/Microsoft.VisualStudio.Threading.Tests/NonConcurrentSynchronizationContextTests.cs
+++ b/test/Microsoft.VisualStudio.Threading.Tests/NonConcurrentSynchronizationContextTests.cs
@@ -2,14 +2,9 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
-using System.Collections.Generic;
using System.Linq;
-using System.Text;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.VisualStudio.Threading;
-using Xunit;
-using Xunit.Abstractions;
public class NonConcurrentSynchronizationContextTests : TestBase
{
diff --git a/test/Microsoft.VisualStudio.Threading.Tests/ProgressWithCompletionTests.cs b/test/Microsoft.VisualStudio.Threading.Tests/ProgressWithCompletionTests.cs
index f2dd306fc..41f1c29f3 100644
--- a/test/Microsoft.VisualStudio.Threading.Tests/ProgressWithCompletionTests.cs
+++ b/test/Microsoft.VisualStudio.Threading.Tests/ProgressWithCompletionTests.cs
@@ -5,9 +5,6 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.VisualStudio.Threading;
-using Xunit;
-using Xunit.Abstractions;
public class ProgressWithCompletionTests : TestBase
{
diff --git a/test/Microsoft.VisualStudio.Threading.Tests/RarelyRemoveItemSetTests.cs b/test/Microsoft.VisualStudio.Threading.Tests/RarelyRemoveItemSetTests.cs
index fb4f79b14..d87d0c071 100644
--- a/test/Microsoft.VisualStudio.Threading.Tests/RarelyRemoveItemSetTests.cs
+++ b/test/Microsoft.VisualStudio.Threading.Tests/RarelyRemoveItemSetTests.cs
@@ -4,9 +4,6 @@
using System;
using System.Linq;
using System.Runtime.CompilerServices;
-using Microsoft.VisualStudio.Threading;
-using Xunit;
-using Xunit.Abstractions;
public class RarelyRemoveItemSetTests : TestBase
{
@@ -36,11 +33,11 @@ public void EnumerationOfOne()
using (RarelyRemoveItemSet.Enumerator enumerator = this.list.EnumerateAndClear().GetEnumerator())
{
Assert.True(enumerator.MoveNext());
- Assert.Equal(1, enumerator.Current.Data);
+ Assert.Equal(1, enumerator.Current.Data);
Assert.False(enumerator.MoveNext());
enumerator.Reset();
Assert.True(enumerator.MoveNext());
- Assert.Equal(1, enumerator.Current.Data);
+ Assert.Equal(1, enumerator.Current.Data);
Assert.False(enumerator.MoveNext());
}
}
@@ -53,15 +50,15 @@ public void EnumerationOfTwo()
using (RarelyRemoveItemSet.Enumerator enumerator = this.list.EnumerateAndClear().GetEnumerator())
{
Assert.True(enumerator.MoveNext());
- Assert.Equal(1, enumerator.Current.Data);
+ Assert.Equal(1, enumerator.Current.Data);
Assert.True(enumerator.MoveNext());
- Assert.Equal(2, enumerator.Current.Data);
+ Assert.Equal(2, enumerator.Current.Data);
Assert.False(enumerator.MoveNext());
enumerator.Reset();
Assert.True(enumerator.MoveNext());
- Assert.Equal(1, enumerator.Current.Data);
+ Assert.Equal(1, enumerator.Current.Data);
Assert.True(enumerator.MoveNext());
- Assert.Equal(2, enumerator.Current.Data);
+ Assert.Equal(2, enumerator.Current.Data);
Assert.False(enumerator.MoveNext());
}
}
diff --git a/test/Microsoft.VisualStudio.Threading.Tests/ReentrantSemaphoreJTFTests.cs b/test/Microsoft.VisualStudio.Threading.Tests/ReentrantSemaphoreJTFTests.cs
index 7ec4ac0d8..6c001e1c2 100644
--- a/test/Microsoft.VisualStudio.Threading.Tests/ReentrantSemaphoreJTFTests.cs
+++ b/test/Microsoft.VisualStudio.Threading.Tests/ReentrantSemaphoreJTFTests.cs
@@ -6,9 +6,6 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft;
-using Microsoft.VisualStudio.Threading;
-using Xunit;
-using Xunit.Abstractions;
public class ReentrantSemaphoreJTFTests : ReentrantSemaphoreTestBase
{
diff --git a/test/Microsoft.VisualStudio.Threading.Tests/ReentrantSemaphoreNonJTFTests.cs b/test/Microsoft.VisualStudio.Threading.Tests/ReentrantSemaphoreNonJTFTests.cs
index 5a1ab9ebd..4935e0b64 100644
--- a/test/Microsoft.VisualStudio.Threading.Tests/ReentrantSemaphoreNonJTFTests.cs
+++ b/test/Microsoft.VisualStudio.Threading.Tests/ReentrantSemaphoreNonJTFTests.cs
@@ -2,9 +2,6 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System.Threading.Tasks;
-using Microsoft.VisualStudio.Threading;
-using Xunit;
-using Xunit.Abstractions;
public class ReentrantSemaphoreNonJTFTests : ReentrantSemaphoreTestBase
{
diff --git a/test/Microsoft.VisualStudio.Threading.Tests/ReentrantSemaphoreTestBase.cs b/test/Microsoft.VisualStudio.Threading.Tests/ReentrantSemaphoreTestBase.cs
index 8e58d4317..494de17d1 100644
--- a/test/Microsoft.VisualStudio.Threading.Tests/ReentrantSemaphoreTestBase.cs
+++ b/test/Microsoft.VisualStudio.Threading.Tests/ReentrantSemaphoreTestBase.cs
@@ -6,9 +6,6 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.VisualStudio.Threading;
-using Xunit;
-using Xunit.Abstractions;
public abstract class ReentrantSemaphoreTestBase : TestBase, IDisposable
{
diff --git a/test/Microsoft.VisualStudio.Threading.Tests/SingleThreadedSynchronizationContextTests.cs b/test/Microsoft.VisualStudio.Threading.Tests/SingleThreadedSynchronizationContextTests.cs
index 7cd17668d..7e9e5ec44 100644
--- a/test/Microsoft.VisualStudio.Threading.Tests/SingleThreadedSynchronizationContextTests.cs
+++ b/test/Microsoft.VisualStudio.Threading.Tests/SingleThreadedSynchronizationContextTests.cs
@@ -4,9 +4,6 @@
using System;
using System.Reflection;
using System.Threading.Tasks;
-using Microsoft.VisualStudio.Threading;
-using Xunit;
-using Xunit.Abstractions;
public class SingleThreadedSynchronizationContextTests : TestBase
{
diff --git a/test/Microsoft.VisualStudio.Threading.Tests/SingleThreadedTestSynchronizationContext.cs b/test/Microsoft.VisualStudio.Threading.Tests/SingleThreadedTestSynchronizationContext.cs
index 6fd9f5646..0bd798d8a 100644
--- a/test/Microsoft.VisualStudio.Threading.Tests/SingleThreadedTestSynchronizationContext.cs
+++ b/test/Microsoft.VisualStudio.Threading.Tests/SingleThreadedTestSynchronizationContext.cs
@@ -8,7 +8,6 @@
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using Microsoft;
-using Microsoft.VisualStudio.Threading;
#if UseWpfContext
using System.Windows.Threading;
#endif
diff --git a/test/Microsoft.VisualStudio.Threading.Tests/TestBase.cs b/test/Microsoft.VisualStudio.Threading.Tests/TestBase.cs
index 5b7b6ff4d..d3a837504 100644
--- a/test/Microsoft.VisualStudio.Threading.Tests/TestBase.cs
+++ b/test/Microsoft.VisualStudio.Threading.Tests/TestBase.cs
@@ -8,9 +8,7 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft;
-using Microsoft.VisualStudio.Threading;
-using Xunit;
-using Xunit.Abstractions;
+using Xunit.Sdk;
public abstract class TestBase
{
@@ -22,7 +20,7 @@ public abstract class TestBase
/// The maximum length of time to wait for something that we expect will happen
/// within the timeout.
///
- protected static readonly TimeSpan UnexpectedTimeout = Debugger.IsAttached ? Timeout.InfiniteTimeSpan : TimeSpan.FromSeconds(10);
+ protected static readonly TimeSpan UnexpectedTimeout = Debugger.IsAttached ? Timeout.InfiniteTimeSpan : TimeSpan.FromSeconds(15);
///
/// The maximum length of time to wait for something that we do not expect will happen
@@ -339,7 +337,7 @@ protected void ExecuteOnDispatcher(Func action)
/// A task whose result is if test execution is already isolated and should therefore proceed with the body of the test,
/// or after the isolated instance of the test has completed execution.
///
- /// Thrown if the isolated test result is a Failure.
+ /// Thrown if the isolated test result is a Failure.
/// Thrown if on a platform that we do not yet support test isolation on.
protected Task ExecuteInIsolationAsync([CallerMemberName] string testMethodName = null!)
{
@@ -355,7 +353,7 @@ protected Task ExecuteInIsolationAsync([CallerMemberName] string testMetho
/// if test execution is already isolated and should therefore proceed with the body of the test,
/// or after the isolated instance of the test has completed execution.
///
- /// Thrown if the isolated test result is a Failure.
+ /// Thrown if the isolated test result is a Failure.
/// Thrown if on a platform that we do not yet support test isolation on.
protected bool ExecuteInIsolation([CallerMemberName] string testMethodName = null!)
{
diff --git a/test/Microsoft.VisualStudio.Threading.Tests/TestBaseTests.cs b/test/Microsoft.VisualStudio.Threading.Tests/TestBaseTests.cs
index 52853bcb0..26ef0eb7f 100644
--- a/test/Microsoft.VisualStudio.Threading.Tests/TestBaseTests.cs
+++ b/test/Microsoft.VisualStudio.Threading.Tests/TestBaseTests.cs
@@ -6,9 +6,6 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft;
-using Microsoft.VisualStudio.Threading;
-using Xunit;
-using Xunit.Abstractions;
using Xunit.Sdk;
public class TestBaseTests : TestBase
@@ -18,10 +15,10 @@ public TestBaseTests(ITestOutputHelper logger)
{
}
- [SkippableFact]
+ [Fact]
public void ExecuteOnSTA_ExecutesDelegateOnSTA()
{
- Skip.IfNot(RuntimeInformation.IsOSPlatform(OSPlatform.Windows));
+ Assert.SkipUnless(RuntimeInformation.IsOSPlatform(OSPlatform.Windows), "Windows only");
bool executed = false;
this.ExecuteOnSTA(delegate
{
@@ -32,10 +29,10 @@ public void ExecuteOnSTA_ExecutesDelegateOnSTA()
Assert.True(executed);
}
- [SkippableFact]
+ [Fact]
public void ExecuteOnSTA_PropagatesExceptions()
{
- Skip.IfNot(RuntimeInformation.IsOSPlatform(OSPlatform.Windows));
+ Assert.SkipUnless(RuntimeInformation.IsOSPlatform(OSPlatform.Windows), "Windows only");
Assert.Throws(() => this.ExecuteOnSTA(() =>
{
throw new ApplicationException();
@@ -90,7 +87,7 @@ public void ExecuteOnDispatcher_PropagatesExceptions()
}));
}
- [SkippableFact]
+ [Fact]
[Trait("TestCategory", "FailsInCloudTest")]
public async Task ExecuteInIsolation_PassingTest()
{
@@ -100,7 +97,7 @@ public async Task ExecuteInIsolation_PassingTest()
}
}
- [SkippableFact]
+ [Fact]
public async Task ExecuteInIsolation_FailingTest()
{
bool executeHere;
diff --git a/test/Microsoft.VisualStudio.Threading.Tests/TestUtilities.cs b/test/Microsoft.VisualStudio.Threading.Tests/TestUtilities.cs
index 28844c1a1..1c7872500 100644
--- a/test/Microsoft.VisualStudio.Threading.Tests/TestUtilities.cs
+++ b/test/Microsoft.VisualStudio.Threading.Tests/TestUtilities.cs
@@ -10,9 +10,7 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft;
-using Microsoft.VisualStudio.Threading;
-using Xunit;
-using Xunit.Abstractions;
+using Xunit.Sdk;
internal static class TestUtilities
{
@@ -69,7 +67,7 @@ internal static T[] ConcurrencyTest(Func action, int concurrency = -1)
concurrency = Environment.ProcessorCount;
}
- Skip.If(Environment.ProcessorCount < concurrency, $"The test machine does not have enough CPU cores to exercise a concurrency level of {concurrency}");
+ Assert.SkipWhen(Environment.ProcessorCount < concurrency, $"The test machine does not have enough CPU cores to exercise a concurrency level of {concurrency}");
// We use a barrier to guarantee that all threads are fully ready to
// execute the provided function at precisely the same time.
@@ -94,11 +92,10 @@ internal static T[] ConcurrencyTest(Func action, int concurrency = -1)
internal static DebugAssertionRevert DisableAssertionDialog()
{
#if NETFRAMEWORK
- DefaultTraceListener? listener = Debug.Listeners.OfType().FirstOrDefault();
- if (listener is object)
- {
- listener.AssertUiEnabled = false;
- }
+ Debug.Listeners.OfType().FirstOrDefault()?.AssertUiEnabled = false;
+
+ // Xunit v3 adds a listener that throws on assertions; remove it so we can test actual runtime functionality of the library.
+ Debug.Listeners.Remove("xUnit.net");
#else
Trace.Listeners.Clear();
#endif
@@ -170,7 +167,7 @@ internal static IDisposable StarveThreadpool()
/// A task whose result is if test execution is already isolated and should therefore proceed with the body of the test,
/// or after the isolated instance of the test has completed execution.
///
- /// Thrown if the isolated test result is a Failure.
+ /// Thrown if the isolated test result is a Failure.
/// Thrown if on a platform that we do not yet support test isolation on.
internal static Task ExecuteInIsolationAsync(object testClass, string testMethodName, ITestOutputHelper logger)
{
@@ -189,7 +186,7 @@ internal static Task ExecuteInIsolationAsync(object testClass, string test
/// A task whose result is if test execution is already isolated and should therefore proceed with the body of the test,
/// or after the isolated instance of the test has completed execution.
///
- /// Thrown if the isolated test result is a Failure.
+ /// Thrown if the isolated test result is a Failure.
/// Thrown if on a platform that we do not yet support test isolation on.
#pragma warning disable CA1801 // Review unused parameters
internal static Task ExecuteInIsolationAsync(string testClassName, string testMethodName, ITestOutputHelper logger)
@@ -248,7 +245,7 @@ internal static Task ExecuteInIsolationAsync(string testClassName, string
switch (t.Result)
{
case IsolatedTestHost.ExitCode.TestSkipped:
- throw new SkipException("Test skipped. See output of isolated task for details.");
+ throw SkipException.ForSkip("Test skipped. See output of isolated task for details.");
case IsolatedTestHost.ExitCode.TestPassed:
default:
Assert.Equal(IsolatedTestHost.ExitCode.TestPassed, t.Result);
@@ -259,7 +256,7 @@ internal static Task ExecuteInIsolationAsync(string testClassName, string
},
TaskScheduler.Default);
#else
- return Task.FromException(new SkipException("Test isolation is not yet supported on this platform."));
+ return Task.FromException(SkipException.ForSkip("Test isolation is not yet supported on this platform."));
#endif
}
diff --git a/test/Microsoft.VisualStudio.Threading.Tests/TestUtilitiesTests.cs b/test/Microsoft.VisualStudio.Threading.Tests/TestUtilitiesTests.cs
index 109fb3b6c..82a530f1d 100644
--- a/test/Microsoft.VisualStudio.Threading.Tests/TestUtilitiesTests.cs
+++ b/test/Microsoft.VisualStudio.Threading.Tests/TestUtilitiesTests.cs
@@ -2,8 +2,6 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System.Threading.Tasks;
-using Microsoft.VisualStudio.Threading;
-using Xunit;
public class TestUtilitiesTests
{
diff --git a/test/Microsoft.VisualStudio.Threading.Tests/ThreadingToolsTests.cs b/test/Microsoft.VisualStudio.Threading.Tests/ThreadingToolsTests.cs
index aec072c82..a670da2c9 100644
--- a/test/Microsoft.VisualStudio.Threading.Tests/ThreadingToolsTests.cs
+++ b/test/Microsoft.VisualStudio.Threading.Tests/ThreadingToolsTests.cs
@@ -5,9 +5,6 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.VisualStudio.Threading;
-using Xunit;
-using Xunit.Abstractions;
public class ThreadingToolsTests : TestBase
{
@@ -118,7 +115,7 @@ public void WithCancellationOfPrecanceledTaskOfT()
Assert.Same(tcs.Task, tcs.Task.WithCancellation(cts.Token));
}
- [SkippableFact]
+ [Fact]
public void WithCancellationAndPrecancelledToken()
{
var tcs = new TaskCompletionSource();
diff --git a/test/Microsoft.VisualStudio.Threading.Tests/TplExtensionsTests.cs b/test/Microsoft.VisualStudio.Threading.Tests/TplExtensionsTests.cs
index aa241bd84..4d0429637 100644
--- a/test/Microsoft.VisualStudio.Threading.Tests/TplExtensionsTests.cs
+++ b/test/Microsoft.VisualStudio.Threading.Tests/TplExtensionsTests.cs
@@ -6,9 +6,6 @@
using System.Threading;
using System.Threading.Tasks;
using System.Threading.Tasks.Sources;
-using Microsoft.VisualStudio.Threading;
-using Xunit;
-using Xunit.Abstractions;
using TplExtensions = Microsoft.VisualStudio.Threading.TplExtensions;
public class TplExtensionsTests : TestBase
@@ -1077,7 +1074,7 @@ public void WithTimeout_MinusOneMeansInfiniteTimeout(bool generic)
{
var tcs = new TaskCompletionSource();
Task? timeoutTask = generic
- ? TplExtensions.WithTimeout(tcs.Task, TimeSpan.FromMilliseconds(-1))
+ ? TplExtensions.WithTimeout(tcs.Task, TimeSpan.FromMilliseconds(-1))
: TplExtensions.WithTimeout((Task)tcs.Task, TimeSpan.FromMilliseconds(-1));
Assert.False(timeoutTask.IsCompleted);
await Task.Delay(AsyncDelay / 2);
diff --git a/test/Microsoft.VisualStudio.Threading.Tests/Usings.cs b/test/Microsoft.VisualStudio.Threading.Tests/Usings.cs
new file mode 100644
index 000000000..f10604229
--- /dev/null
+++ b/test/Microsoft.VisualStudio.Threading.Tests/Usings.cs
@@ -0,0 +1,5 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+global using Microsoft.VisualStudio.Threading;
+global using Xunit;
diff --git a/test/Microsoft.VisualStudio.Threading.Tests/ValidityTests.cs b/test/Microsoft.VisualStudio.Threading.Tests/ValidityTests.cs
index 8af8ab8dc..176e1de45 100644
--- a/test/Microsoft.VisualStudio.Threading.Tests/ValidityTests.cs
+++ b/test/Microsoft.VisualStudio.Threading.Tests/ValidityTests.cs
@@ -2,8 +2,6 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System.Reflection;
-using Microsoft.VisualStudio.Threading;
-using Xunit;
public class ValidityTests
{
diff --git a/test/Microsoft.VisualStudio.Threading.Tests/WeakKeyDictionaryTests.cs b/test/Microsoft.VisualStudio.Threading.Tests/WeakKeyDictionaryTests.cs
index 9c8e17dcf..c533a47cd 100644
--- a/test/Microsoft.VisualStudio.Threading.Tests/WeakKeyDictionaryTests.cs
+++ b/test/Microsoft.VisualStudio.Threading.Tests/WeakKeyDictionaryTests.cs
@@ -5,9 +5,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
-using Microsoft.VisualStudio.Threading;
-using Xunit;
-using Xunit.Abstractions;
///
/// Tests for the weak dictionary class.
diff --git a/tools/artifacts/coverageResults.ps1 b/tools/artifacts/coverageResults.ps1
index 8c68216ed..1aadbb747 100644
--- a/tools/artifacts/coverageResults.ps1
+++ b/tools/artifacts/coverageResults.ps1
@@ -1,25 +1,26 @@
-$RepoRoot = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..")
+$RepoRoot = Resolve-Path "$PSScriptRoot\..\.."
-$coverageFiles = @(Get-ChildItem "$RepoRoot/test/*.cobertura.xml" -Recurse | Where {$_.FullName -notlike "*/In/*" -and $_.FullName -notlike "*\In\*" })
+$coverageFilesUnderRoot = @(Get-ChildItem "$RepoRoot/*.cobertura.xml" -Recurse | Where-Object {$_.FullName -notlike "*/In/*" -and $_.FullName -notlike "*\In\*" })
+
+# Under MTP, coverage files are written directly to the artifacts output directory,
+# so we need to look there too.
+$ArtifactStagingFolder = & "$PSScriptRoot/../Get-ArtifactsStagingDirectory.ps1"
+$directTestLogs = Join-Path $ArtifactStagingFolder test_logs
+$coverageFilesUnderArtifacts = if (Test-Path $directTestLogs) { @(Get-ChildItem "$directTestLogs/*.cobertura.xml" -Recurse) } else { @() }
# Prepare code coverage reports for merging on another machine
-$repoRoot = $env:SYSTEM_DEFAULTWORKINGDIRECTORY
-if (!$repoRoot) { $repoRoot = $env:GITHUB_WORKSPACE }
-if ($repoRoot) {
- Write-Host "Substituting $repoRoot with `"{reporoot}`""
- $coverageFiles |% {
- $content = Get-Content -LiteralPath $_ |% { $_ -Replace [regex]::Escape($repoRoot), "{reporoot}" }
- Set-Content -LiteralPath $_ -Value $content -Encoding UTF8
- }
-} else {
- Write-Warning "coverageResults: Cloud build not detected. Machine-neutral token replacement skipped."
+Write-Host "Substituting $repoRoot with `"{reporoot}`""
+@($coverageFilesUnderRoot + $coverageFilesUnderArtifacts) |? { $_ }|% {
+ $content = Get-Content -LiteralPath $_ |% { $_ -Replace [regex]::Escape($repoRoot), "{reporoot}" }
+ Set-Content -LiteralPath $_ -Value $content -Encoding UTF8
}
if (!((Test-Path $RepoRoot\bin) -and (Test-Path $RepoRoot\obj))) { return }
@{
+ $directTestLogs = $coverageFilesUnderArtifacts;
$RepoRoot = (
- $coverageFiles +
+ $coverageFilesUnderRoot +
(Get-ChildItem "$RepoRoot\obj\*.cs" -Recurse)
);
}
diff --git a/tools/artifacts/testResults.ps1 b/tools/artifacts/testResults.ps1
index 5310fb52a..a841967e8 100644
--- a/tools/artifacts/testResults.ps1
+++ b/tools/artifacts/testResults.ps1
@@ -4,7 +4,8 @@ Param(
$result = @{}
-$testRoot = Resolve-Path "$PSScriptRoot\..\..\test"
+$RepoRoot = Resolve-Path "$PSScriptRoot\..\.."
+$testRoot = Join-Path $RepoRoot test
$result[$testRoot] = (Get-ChildItem "$testRoot\TestResults" -Recurse -Directory | Get-ChildItem -Recurse -File)
$artifactStaging = & "$PSScriptRoot/../Get-ArtifactsStagingDirectory.ps1"
diff --git a/tools/dotnet-test-cloud.ps1 b/tools/dotnet-test-cloud.ps1
index 51919726f..b79fde6ab 100644
--- a/tools/dotnet-test-cloud.ps1
+++ b/tools/dotnet-test-cloud.ps1
@@ -25,6 +25,7 @@ Param(
$RepoRoot = (Resolve-Path "$PSScriptRoot/..").Path
$ArtifactStagingFolder = & "$PSScriptRoot/Get-ArtifactsStagingDirectory.ps1"
+$OnCI = ($env:CI -or $env:TF_BUILD)
$dotnet = 'dotnet'
if ($x86) {
@@ -45,29 +46,60 @@ if ($x86) {
}
$testBinLog = Join-Path $ArtifactStagingFolder (Join-Path build_logs test.binlog)
-$testDiagLog = Join-Path $ArtifactStagingFolder (Join-Path test_logs diag.log)
+$testLogs = Join-Path $ArtifactStagingFolder test_logs
$extraArgs = @()
if ($IsLinux -or $IsMacOS) {
$extraArgs += '-p:Platform=NonWindows'
}
-& $dotnet test $RepoRoot `
- --no-build `
- -c $Configuration `
- --filter "TestCategory!=FailsInCloudTest" `
- --collect "Code Coverage;Format=cobertura" `
- --settings "$PSScriptRoot/test.runsettings" `
- --blame-hang-timeout 60s `
- --blame-crash `
- -bl:"$testBinLog" `
- --diag "$testDiagLog;TraceLevel=info" `
- --logger trx `
- @extraArgs `
+$globalJson = Get-Content $PSScriptRoot/../global.json | ConvertFrom-Json
+$isMTP = $globalJson.test.runner -eq 'Microsoft.Testing.Platform'
+if ($isMTP) {
+ if ($OnCI) { $extraArgs += '--no-progress' }
+ & $dotnet test --solution $RepoRoot `
+ --no-build `
+ -c $Configuration `
+ -bl:"$testBinLog" `
+ --filter-not-trait 'TestCategory=FailsInCloudTest' `
+ --coverage `
+ --coverage-output-format cobertura `
+ --coverage-settings "$PSScriptRoot/test.runsettings" `
+ --hangdump `
+ --hangdump-timeout 60s `
+ --crashdump `
+ --diagnostic `
+ --diagnostic-output-directory $testLogs `
+ --diagnostic-verbosity Information `
+ --results-directory $testLogs `
+ --report-trx `
+ @extraArgs
+
+ $trxFiles = Get-ChildItem -Recurse -Path $testLogs\*.trx
+} else {
+ $testDiagLog = Join-Path $ArtifactStagingFolder (Join-Path test_logs diag.log)
+ & $dotnet test $RepoRoot `
+ --no-build `
+ -c $Configuration `
+ --filter "TestCategory!=FailsInCloudTest" `
+ --collect "Code Coverage;Format=cobertura" `
+ --settings "$PSScriptRoot/test.runsettings" `
+ --blame-hang-timeout 60s `
+ --blame-crash `
+ -bl:"$testBinLog" `
+ --diag "$testDiagLog;TraceLevel=info" `
+ --logger trx `
+ @extraArgs
+
+ $trxFiles = Get-ChildItem -Recurse -Path $RepoRoot\test\*.trx
+}
$unknownCounter = 0
-Get-ChildItem -Recurse -Path $RepoRoot\test\*.trx |% {
- Copy-Item $_ -Destination $ArtifactStagingFolder/test_logs/
+$trxFiles |% {
+ New-Item $testLogs -ItemType Directory -Force | Out-Null
+ if (!($_.FullName.StartsWith($testLogs))) {
+ Copy-Item $_ -Destination $testLogs
+ }
if ($PublishResults) {
$x = [xml](Get-Content -LiteralPath $_)