Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
fddc013
Opt into Microsoft Testing Platform (MTP) (#452)
AArnott Dec 7, 2025
f761f0f
Push to nuget.org before pushing to github release
AArnott Dec 7, 2025
e403560
Update to MTP v2 (#455)
AArnott Dec 7, 2025
a28d540
Update all MTP related packages at once (457)
AArnott Dec 7, 2025
f355f00
Fix test result publishing to AzDO (458)
AArnott Dec 7, 2025
3304d79
Update .NET SDK to v10.0.101 (#459)
renovate[bot] Dec 10, 2025
63de086
Drop package dependencies that MTP does not require
AArnott Dec 10, 2025
70e71e9
Merge pull request #460 from AArnott/dropOldDependencies
AArnott Dec 10, 2025
70980c3
Fix MTP test failure for MTP-incompatible projects under the test folder
AArnott Dec 10, 2025
07aab27
Merge remote-tracking branch 'origin/main' into microbuild_mtp
AArnott Dec 11, 2025
307d5e3
Fix testing regression from last commit
AArnott Dec 11, 2025
3eb31c2
Merge branch 'main' into microbuild_mtp
AArnott Dec 11, 2025
5c9d625
Adjust how we use IsTestProject
AArnott Dec 11, 2025
a352939
Merge branch 'main' into microbuild_mtp
AArnott Dec 11, 2025
bacb8ec
Merge branch 'microbuild_mtp' of https://github.com/aarnott/Library.T…
AArnott Dec 11, 2025
c3770c5
All tests build
AArnott Dec 11, 2025
adf181a
Fix tests that fail due to Xunit's trace assertion failure listener
AArnott Dec 11, 2025
fb63f88
Adapt to Xunit removing its `AsyncTestContext` SynchronizationContext
AArnott Dec 11, 2025
887c2df
Adapt IsolatedTestHost to xunit.v3
AArnott Dec 11, 2025
c9c1f37
Improve test stability (JoinAsyncShouldCompleteWithoutUIThreadAfterCa…
AArnott Dec 11, 2025
d29bfbe
Extend test timeout
AArnott Dec 11, 2025
f7daee0
Fix MTP test run error
AArnott Dec 11, 2025
12f888b
Merge remote-tracking branch 'origin/main' into dev/andarno/xunitv3
AArnott Dec 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 9 additions & 14 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
<MicrosoftTestingPlatformVersion>2.0.2</MicrosoftTestingPlatformVersion>
<MicroBuildVersion>2.0.208</MicroBuildVersion>
<CodeAnalysisVersion>3.11.0</CodeAnalysisVersion>
<CodeAnalysisVersionForTests>4.13.0</CodeAnalysisVersionForTests>
<CodefixTestingVersion>1.1.2</CodefixTestingVersion>
<CodeAnalysisAnalyzerVersion>3.11.0-beta1.25076.3</CodeAnalysisAnalyzerVersion>
</PropertyGroup>
Expand Down Expand Up @@ -36,22 +36,17 @@
<PackageVersion Include="System.Runtime.CompilerServices.Unsafe" Version="6.1.0" />
<PackageVersion Include="System.Threading.Tasks.Extensions" Version="4.6.0" />
<PackageVersion Include="System.ValueTuple" Version="4.6.1" />
<PackageVersion Include="xunit.abstractions" Version="2.0.3" />
<PackageVersion Include="Xunit.Combinatorial" Version="1.6.24" />
<PackageVersion Include="Xunit.SkippableFact" Version="1.5.23" />
<PackageVersion Include="Xunit.StaFact" Version="1.2.69" />
</ItemGroup>
<ItemGroup Condition="'$(IsTestProject)'=='true'">
<PackageVersion Update="Microsoft.CodeAnalysis" Version="$(CodeAnalysisVersionForTests)" />
<PackageVersion Update="Microsoft.CodeAnalysis.Common" Version="$(CodeAnalysisVersionForTests)" />
<PackageVersion Update="Microsoft.CodeAnalysis.CSharp" Version="$(CodeAnalysisVersionForTests)" />
<PackageVersion Update="Microsoft.CodeAnalysis.VisualBasic" Version="$(CodeAnalysisVersionForTests)" />
<PackageVersion Include="xunit.v3.core.mtp-v2" Version="3.2.1" />
<PackageVersion Include="Xunit.Combinatorial" Version="2.0.24" />
<PackageVersion Include="Xunit.StaFact" Version="3.0.13" />
</ItemGroup>
<ItemGroup Label="Library.Template">
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageVersion Include="Microsoft.Testing.Extensions.CodeCoverage" Version="18.1.0" />
<PackageVersion Include="Microsoft.Testing.Extensions.CrashDump" Version="$(MicrosoftTestingPlatformVersion)" />
<PackageVersion Include="Microsoft.Testing.Extensions.HangDump" Version="$(MicrosoftTestingPlatformVersion)" />
<PackageVersion Include="Microsoft.Testing.Extensions.TrxReport" Version="$(MicrosoftTestingPlatformVersion)" />
<PackageVersion Include="Microsoft.VisualStudio.Internal.MicroBuild.NonShipping" Version="$(MicroBuildVersion)" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
<PackageVersion Include="xunit" Version="2.9.3" />
<PackageVersion Include="xunit.v3.mtp-v2" Version="3.2.1" />
</ItemGroup>
<ItemGroup>
<GlobalPackageReference Include="Microsoft.CodeAnalysis.ResxSourceGenerator" Version="$(CodeAnalysisAnalyzerVersion)" />
Expand Down
1 change: 1 addition & 0 deletions azure-pipelines/Merge-CodeCoverage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 0 additions & 4 deletions src/Microsoft.VisualStudio.Threading/ListOfOftenOne`1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
/// </summary>
internal bool Any()
{
foreach (KeyValuePair<WeakKeyDictionary<TKey, TValue>.WeakReference<TKey>, TValue> item in this.dictionary)
foreach (KeyValuePair<WeakReference<TKey>, TValue> item in this.dictionary)
{
if (item.Key.IsAlive)
{
Expand Down
3 changes: 3 additions & 0 deletions test/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion test/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<Import Project="$([MSBuild]::GetPathOfFileAbove($(MSBuildThisFile), $(MSBuildThisFileDirectory)..))" />

<PropertyGroup>
<IsTestProject>true</IsTestProject>
<IsPackable>false</IsPackable>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>
</PropertyGroup>

<ItemGroup>
Expand Down
6 changes: 6 additions & 0 deletions test/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<ItemGroup Condition="'$(IsTestProject)' != 'false'">
<PackageReference Include="Microsoft.Testing.Extensions.CodeCoverage" />
<PackageReference Include="Microsoft.Testing.Extensions.CrashDump" />
<PackageReference Include="Microsoft.Testing.Extensions.HangDump" />
<PackageReference Include="Microsoft.Testing.Extensions.TrxReport" />
</ItemGroup>
<ItemGroup>
<Content Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" Condition="Exists('xunit.runner.json')" />
</ItemGroup>
Expand Down
14 changes: 14 additions & 0 deletions test/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<Import Project="$([MSBuild]::GetPathOfFileAbove($(MSBuildThisFile), $(MSBuildThisFileDirectory)..))" />

<PropertyGroup>
<CodeAnalysisVersionForTests>4.13.0</CodeAnalysisVersionForTests>
</PropertyGroup>
<ItemGroup>
<PackageVersion Update="Microsoft.CodeAnalysis" Version="$(CodeAnalysisVersionForTests)" />
<PackageVersion Update="Microsoft.CodeAnalysis.Common" Version="$(CodeAnalysisVersionForTests)" />
<PackageVersion Update="Microsoft.CodeAnalysis.CSharp" Version="$(CodeAnalysisVersionForTests)" />
<PackageVersion Update="Microsoft.CodeAnalysis.VisualBasic" Version="$(CodeAnalysisVersionForTests)" />
</ItemGroup>
</Project>
19 changes: 1 addition & 18 deletions test/IsolatedTestHost/App.config
Original file line number Diff line number Diff line change
@@ -1,29 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.1.0" newVersion="4.2.1.0" />
</dependentAssembly>
</assemblyBinding>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="xunit.core" publicKeyToken="8d05b1bb7a6fdb6c" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.9.3.0" newVersion="2.9.3.0" />
</dependentAssembly>
</assemblyBinding>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="xunit.execution.desktop" publicKeyToken="8d05b1bb7a6fdb6c" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.9.2.0" newVersion="2.9.2.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
3 changes: 2 additions & 1 deletion test/IsolatedTestHost/IsolatedTestHost.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net472</TargetFrameworks>
<IsTestProject>false</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="xunit.abstractions" />
<PackageReference Include="xunit.v3.core.mtp-v2" ExcludeAssets="buildTransitive" />
</ItemGroup>

</Project>
4 changes: 1 addition & 3 deletions test/IsolatedTestHost/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Xunit;

namespace IsolatedTestHost;

Expand Down Expand Up @@ -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);
}
Expand Down
25 changes: 14 additions & 11 deletions test/IsolatedTestHost/TestOutputHelper.cs
Original file line number Diff line number Diff line change
@@ -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));
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0</TargetFrameworks>
<IsTestProject>true</IsTestProject>
<OutputType>Exe</OutputType>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
<NoWarn>$(NoWarn);NU1701</NoWarn>
Expand All @@ -25,13 +25,10 @@
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing" />
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic.CodeFix.Testing" />
<PackageReference Include="Microsoft.CodeAnalysis" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Microsoft.VisualStudio.Interop" />
<PackageReference Include="Microsoft.VisualStudio.Shell.15.0" IncludeAssets="None" />
<PackageReference Include="Microsoft.VisualStudio.Shell.Framework" IncludeAssets="None" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio" />
<PackageReference Include="Xunit.SkippableFact" />
<PackageReference Include="xunit.v3.mtp-v2" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="..\..\src\Microsoft.VisualStudio.Threading.Analyzers.CodeFixes\buildTransitive\AdditionalFiles\**"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void Foo() {
await CSVerify.VerifyAnalyzerAsync(test, CSVerify.Diagnostic().WithLocation(0));
}

[SkippableFact]
[Fact]
public async Task DispatcherInvoke_ProducesDiagnostic()
{
var test = @"
Expand All @@ -71,7 +71,7 @@ void Foo() {
await t.RunAsync();
}

[SkippableFact]
[Fact]
public async Task DispatcherBeginInvoke_ProducesDiagnostic()
{
var test = @"
Expand All @@ -90,7 +90,7 @@ void Foo() {
await t.RunAsync();
}

[SkippableFact]
[Fact]
public async Task DispatcherInvokeAsync_ProducesDiagnostic()
{
var test = @"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<OutputType>Exe</OutputType>
<IsTestProject>false</IsTestProject>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.VisualStudio.Threading\Microsoft.VisualStudio.Threading.csproj" />
Expand Down
2 changes: 0 additions & 2 deletions test/Microsoft.VisualStudio.Threading.Tests/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -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)]
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -200,7 +198,7 @@ public async Task WaitAsync_Canceled_Stress()
/// <summary>
/// Verifies that long-lived, uncanceled CancellationTokens do not result in leaking memory.
/// </summary>
[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()
Expand All @@ -222,7 +220,7 @@ public async Task WaitAsync_WithCancellationToken_DoesNotLeakWhenNotCanceled()
/// <summary>
/// Verifies that canceled CancellationTokens do not result in leaking memory.
/// </summary>
[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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Loading