diff --git a/Coverage.config b/Coverage.config
new file mode 100644
index 00000000000..412f9cc8bd0
--- /dev/null
+++ b/Coverage.config
@@ -0,0 +1,33 @@
+
+
+ True
+ true
+ MissingAll
+
+
+
+ .*doc\.dll$
+ .*customlogger\.dll$
+ .*invalidcustomcheck\.dll$
+ .*portabletask\.dll$
+ .*faultylogger\.dll$
+ .*customcheck\.dll$
+ .*customcheck2\.dll$
+ .*errorcustomcheck\.dll$
+
+
+
+
+ .*\.g\.cs$
+ .*\.sr\.cs$
+
+
+ 120000
+ 1270
+ False
+ True
+ False
+ False
+ True
+
+
diff --git a/Coverage.runsettings b/Coverage.runsettings
deleted file mode 100644
index 4c48352ed69..00000000000
--- a/Coverage.runsettings
+++ /dev/null
@@ -1,43 +0,0 @@
-
-
-
-
-
-
- True
- true
- MissingAll
-
-
-
- .*doc\.dll$
- .*customlogger\.dll$
- .*invalidcustomcheck\.dll$
- .*portabletask\.dll$
- .*faultylogger\.dll$
- .*customcheck\.dll$
- .*customcheck2\.dll$
- .*errorcustomcheck\.dll$
-
-
-
-
- .*\.g\.cs$
- .*\.sr\.cs$
-
-
- 120000
- 1270
- False
- True
- False
- False
- True
-
-
-
-
-
-
diff --git a/CoverageWindowsFull.config b/CoverageWindowsFull.config
new file mode 100644
index 00000000000..3d1d6234965
--- /dev/null
+++ b/CoverageWindowsFull.config
@@ -0,0 +1,42 @@
+
+
+ True
+ true
+ MissingAll
+
+
+
+ .*doc\.dll$
+ .*net472.*
+ .*microsoft\.build\.buildcheck\.unittests\.dll$
+ .*microsoft\.build\.tasks\.unittests\.dll$
+
+
+ .*microsoft\.build\.engine\.unittests\.dll$
+ .*microsoft\.build\.engine\.om\.unittests\.dll$
+ .*microsoft\.build\.framework\.dll$
+ .*microsoft\.build\.framework\.unittests\.dll$
+ .*microsoft\.build\.commandline\.unittests\.dll$
+
+
+
+
+ .*microsoft\.net\.stringtools\.dll$
+ .*microsoft\.net\.stringtools\.unittests\.dll$
+
+
+
+
+ .*\.g\.cs$
+ .*\.sr\.cs$
+
+
+ 120000
+ 1270
+ False
+ True
+ False
+ False
+ True
+
+
diff --git a/CoverageWindowsFull.runsettings b/CoverageWindowsFull.runsettings
deleted file mode 100644
index 145ce8360c2..00000000000
--- a/CoverageWindowsFull.runsettings
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
-
-
-
-
- True
- true
- MissingAll
-
-
-
- .*doc\.dll$
- .*net472.*
- .*microsoft\.build\.buildcheck\.unittests\.dll$
- .*microsoft\.build\.tasks\.unittests\.dll$
-
-
- .*microsoft\.build\.engine\.unittests\.dll$
- .*microsoft\.build\.engine\.om\.unittests\.dll$
- .*microsoft\.build\.framework\.dll$
- .*microsoft\.build\.framework\.unittests\.dll$
- .*microsoft\.build\.commandline\.unittests\.dll$
-
-
-
-
- .*microsoft\.net\.stringtools\.dll$
- .*microsoft\.net\.stringtools\.unittests\.dll$
-
-
-
-
- .*\.g\.cs$
- .*\.sr\.cs$
-
-
- 120000
- 1270
- False
- True
- False
- False
- True
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Directory.Build.props b/Directory.Build.props
index c0fdacba18a..4698f8dc721 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -13,6 +13,15 @@
+ XUnitV3
+ 3.2.2
+ 1.9.1
+ Exe
+
+
+
+ $(NoWarn);xUnit1051
+
net472
diff --git a/eng/Version.Details.props b/eng/Version.Details.props
index 1f14525dfd5..8be2c7b9f8d 100644
--- a/eng/Version.Details.props
+++ b/eng/Version.Details.props
@@ -7,7 +7,7 @@ This file should be imported by eng/Versions.props
10.0.0-beta.26164.1
- 10.0.0-beta.26164.1
+ 10.0.0-beta.26164.1
5.6.0-2.26151.2
@@ -35,7 +35,7 @@ This file should be imported by eng/Versions.props
$(MicrosoftDotNetArcadeSdkPackageVersion)
- $(MicrosoftDotNetXUnitExtensionsPackageVersion)
+ $(MicrosoftDotNetXUnitV3ExtensionsPackageVersion)
$(MicrosoftNetCompilersToolsetPackageVersion)
diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml
index ba1a10cc6a0..25a7f1b3fe5 100644
--- a/eng/Version.Details.xml
+++ b/eng/Version.Details.xml
@@ -118,7 +118,7 @@
https://github.com/dotnet/roslyn
6bdca1d6466c2f9ef46f8e5d3422fbe3568d503c
-
+
https://github.com/dotnet/arcade
e365cfcb58176841c2fb80d1a40926f394776970
diff --git a/eng/dependabot/Directory.Packages.props b/eng/dependabot/Directory.Packages.props
index f1ab6ce820a..553cee36c74 100644
--- a/eng/dependabot/Directory.Packages.props
+++ b/eng/dependabot/Directory.Packages.props
@@ -49,6 +49,9 @@
+
+
+
@@ -56,8 +59,8 @@
-
-
+
+
diff --git a/global.json b/global.json
index df2fbacae9a..79eaaf8fe75 100644
--- a/global.json
+++ b/global.json
@@ -6,6 +6,9 @@
],
"errorMessage": "The .NET SDK could not be found, please run a command-line build with ./build.cmd."
},
+ "test": {
+ "runner": "Microsoft.Testing.Platform"
+ },
"tools": {
"dotnet": "10.0.104",
"vs": {
diff --git a/src/Build.OM.UnitTests/Construction/ProjectFormatting_Tests.cs b/src/Build.OM.UnitTests/Construction/ProjectFormatting_Tests.cs
index 678577ef4a0..0d51bf6a6ea 100644
--- a/src/Build.OM.UnitTests/Construction/ProjectFormatting_Tests.cs
+++ b/src/Build.OM.UnitTests/Construction/ProjectFormatting_Tests.cs
@@ -12,7 +12,6 @@
using Microsoft.Build.Shared;
using Microsoft.Build.UnitTests;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Build.OM.UnitTests/Construction/ProjectMetadataElement_Tests.cs b/src/Build.OM.UnitTests/Construction/ProjectMetadataElement_Tests.cs
index 27b52869ac2..dd679f2c3a0 100644
--- a/src/Build.OM.UnitTests/Construction/ProjectMetadataElement_Tests.cs
+++ b/src/Build.OM.UnitTests/Construction/ProjectMetadataElement_Tests.cs
@@ -8,7 +8,6 @@
using Microsoft.Build.Construction;
using Microsoft.Build.Evaluation;
using Xunit;
-using Xunit.Abstractions;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
#nullable disable
diff --git a/src/Build.OM.UnitTests/Definition/ProjectCollection_Tests.cs b/src/Build.OM.UnitTests/Definition/ProjectCollection_Tests.cs
index 360edefcac2..f1c5834ee82 100644
--- a/src/Build.OM.UnitTests/Definition/ProjectCollection_Tests.cs
+++ b/src/Build.OM.UnitTests/Definition/ProjectCollection_Tests.cs
@@ -14,7 +14,6 @@
using Microsoft.Build.Utilities;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
#nullable disable
diff --git a/src/Build.OM.UnitTests/Definition/Project_Tests.cs b/src/Build.OM.UnitTests/Definition/Project_Tests.cs
index 021fdd8780c..ad02494ee14 100644
--- a/src/Build.OM.UnitTests/Definition/Project_Tests.cs
+++ b/src/Build.OM.UnitTests/Definition/Project_Tests.cs
@@ -17,7 +17,6 @@
using Microsoft.Build.Shared;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
using GlobResultList = System.Collections.Generic.List<(string, string[], System.Collections.Immutable.ImmutableHashSet, System.Collections.Immutable.ImmutableHashSet)>;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
// can't use an actual ProvenanceResult because it points to a ProjectItemElement which is hard to mock.
diff --git a/src/Build.OM.UnitTests/Instance/ProjectInstance_Tests.cs b/src/Build.OM.UnitTests/Instance/ProjectInstance_Tests.cs
index c7278144dae..5fd3942551f 100644
--- a/src/Build.OM.UnitTests/Instance/ProjectInstance_Tests.cs
+++ b/src/Build.OM.UnitTests/Instance/ProjectInstance_Tests.cs
@@ -11,7 +11,6 @@
using Microsoft.Build.Framework;
using Microsoft.Build.Shared;
using Xunit;
-using Xunit.Abstractions;
using ForwardingLoggerRecord = Microsoft.Build.Logging.ForwardingLoggerRecord;
#nullable disable
diff --git a/src/Build.OM.UnitTests/NugetRestoreTests.cs b/src/Build.OM.UnitTests/NugetRestoreTests.cs
index 61d2d5b6516..651bd508f51 100644
--- a/src/Build.OM.UnitTests/NugetRestoreTests.cs
+++ b/src/Build.OM.UnitTests/NugetRestoreTests.cs
@@ -7,7 +7,6 @@
using Microsoft.Build.UnitTests.Shared;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
namespace Microsoft.Build.Engine.OM.UnitTests
{
diff --git a/src/Build.UnitTests/BackEnd/AppHostSupport_Tests.cs b/src/Build.UnitTests/BackEnd/AppHostSupport_Tests.cs
index 87de6e545c2..9666bd0406a 100644
--- a/src/Build.UnitTests/BackEnd/AppHostSupport_Tests.cs
+++ b/src/Build.UnitTests/BackEnd/AppHostSupport_Tests.cs
@@ -11,7 +11,6 @@
using Microsoft.Build.UnitTests;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
@@ -92,6 +91,12 @@ public void ClearBootstrapDotnetRootEnvironment_ClearsVariablesNotInOriginalEnvi
env.SetEnvironmentVariable("DOTNET_ROOT", @"C:\TestDotnet");
env.SetEnvironmentVariable("DOTNET_ROOT_X64", @"C:\TestDotnetX64");
+ // This might seem redundant, but it's not.
+ // ClearBootstrapDotnetRootEnvironment is a production method that alters env variables directly via Environment class.
+ // This clears DOTNET_ROOT_X86 which might have been originally set.
+ // To ensure that DOTNET_ROOT_X86 is restored, we set it to itself so that TestEnvironment.Dispose restores it back.
+ env.SetEnvironmentVariable("DOTNET_ROOT_X86", Environment.GetEnvironmentVariable("DOTNET_ROOT_X86"));
+
// Original environment does NOT have these variables
var originalEnvironment = new Dictionary(StringComparer.OrdinalIgnoreCase);
diff --git a/src/Build.UnitTests/BackEnd/AssemblyTaskFactory_E2E_Tests.cs b/src/Build.UnitTests/BackEnd/AssemblyTaskFactory_E2E_Tests.cs
index 9d86a0eaf47..610c6aca760 100644
--- a/src/Build.UnitTests/BackEnd/AssemblyTaskFactory_E2E_Tests.cs
+++ b/src/Build.UnitTests/BackEnd/AssemblyTaskFactory_E2E_Tests.cs
@@ -8,7 +8,6 @@
using Microsoft.Build.UnitTests.Shared;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
namespace Microsoft.Build.Engine.UnitTests
{
diff --git a/src/Build.UnitTests/BackEnd/BuildManager_Logging_Tests.cs b/src/Build.UnitTests/BackEnd/BuildManager_Logging_Tests.cs
index b1db9f4d040..03abb4b1890 100644
--- a/src/Build.UnitTests/BackEnd/BuildManager_Logging_Tests.cs
+++ b/src/Build.UnitTests/BackEnd/BuildManager_Logging_Tests.cs
@@ -14,7 +14,6 @@
using Microsoft.Build.UnitTests;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
using static Microsoft.Build.UnitTests.ObjectModelHelpers;
#nullable disable
diff --git a/src/Build.UnitTests/BackEnd/BuildManager_Tests.cs b/src/Build.UnitTests/BackEnd/BuildManager_Tests.cs
index 60b95abb446..961abd28ffe 100644
--- a/src/Build.UnitTests/BackEnd/BuildManager_Tests.cs
+++ b/src/Build.UnitTests/BackEnd/BuildManager_Tests.cs
@@ -24,7 +24,6 @@
using Microsoft.Build.Utilities;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
using static Microsoft.Build.UnitTests.ObjectModelHelpers;
using Constants = Microsoft.Build.Framework.Constants;
diff --git a/src/Build.UnitTests/BackEnd/BuildRequestConfiguration_Tests.cs b/src/Build.UnitTests/BackEnd/BuildRequestConfiguration_Tests.cs
index c35fc6a2b3f..1b9f67bedcc 100644
--- a/src/Build.UnitTests/BackEnd/BuildRequestConfiguration_Tests.cs
+++ b/src/Build.UnitTests/BackEnd/BuildRequestConfiguration_Tests.cs
@@ -16,7 +16,6 @@
using Microsoft.Build.Shared;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Build.UnitTests/BackEnd/DebugUtils_tests.cs b/src/Build.UnitTests/BackEnd/DebugUtils_tests.cs
index 24a34de7b81..ead2ac6302b 100644
--- a/src/Build.UnitTests/BackEnd/DebugUtils_tests.cs
+++ b/src/Build.UnitTests/BackEnd/DebugUtils_tests.cs
@@ -20,7 +20,8 @@ public class DebugUtils_Tests
public void DumpExceptionToFileShouldWriteInDebugDumpPath()
{
DebugUtils.ResetDebugDumpPathInRunningTests = true;
- var exceptionFilesBefore = Directory.GetFiles(DebugUtils.DebugDumpPath, "MSBuild_*failure.txt");
+ var exceptionFilesBefore =
+ Directory.Exists(DebugUtils.DebugDumpPath) ? Directory.GetFiles(DebugUtils.DebugDumpPath, "MSBuild_*failure.txt") : Array.Empty();
string[] exceptionFiles = null;
diff --git a/src/Build.UnitTests/BackEnd/LoggingContext_Tests.cs b/src/Build.UnitTests/BackEnd/LoggingContext_Tests.cs
index 020d527ab3f..435f06a0369 100644
--- a/src/Build.UnitTests/BackEnd/LoggingContext_Tests.cs
+++ b/src/Build.UnitTests/BackEnd/LoggingContext_Tests.cs
@@ -5,7 +5,6 @@
using Microsoft.Build.Framework;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Build.UnitTests/BackEnd/MSBuild_Tests.cs b/src/Build.UnitTests/BackEnd/MSBuild_Tests.cs
index ff500550260..6a50d6d4385 100644
--- a/src/Build.UnitTests/BackEnd/MSBuild_Tests.cs
+++ b/src/Build.UnitTests/BackEnd/MSBuild_Tests.cs
@@ -13,7 +13,6 @@
using Microsoft.Build.Utilities;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Build.UnitTests/BackEnd/SdkResolverLoader_Tests.cs b/src/Build.UnitTests/BackEnd/SdkResolverLoader_Tests.cs
index b310fa1bd2a..a3fb0b03274 100644
--- a/src/Build.UnitTests/BackEnd/SdkResolverLoader_Tests.cs
+++ b/src/Build.UnitTests/BackEnd/SdkResolverLoader_Tests.cs
@@ -15,7 +15,6 @@
using Microsoft.Build.UnitTests;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
using Exception = System.Exception;
using SdkResolverBase = Microsoft.Build.Framework.SdkResolver;
using SdkResolverContextBase = Microsoft.Build.Framework.SdkResolverContext;
diff --git a/src/Build.UnitTests/BackEnd/SdkResultOutOfProc_Tests.cs b/src/Build.UnitTests/BackEnd/SdkResultOutOfProc_Tests.cs
index 0baca3b2dad..59de4dcc527 100644
--- a/src/Build.UnitTests/BackEnd/SdkResultOutOfProc_Tests.cs
+++ b/src/Build.UnitTests/BackEnd/SdkResultOutOfProc_Tests.cs
@@ -16,7 +16,6 @@
using Microsoft.Build.Unittest;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
using static Microsoft.Build.UnitTests.ObjectModelHelpers;
#nullable disable
diff --git a/src/Build.UnitTests/BackEnd/TargetEntry_Tests.cs b/src/Build.UnitTests/BackEnd/TargetEntry_Tests.cs
index 8607e64e572..140cbaa94dc 100644
--- a/src/Build.UnitTests/BackEnd/TargetEntry_Tests.cs
+++ b/src/Build.UnitTests/BackEnd/TargetEntry_Tests.cs
@@ -17,7 +17,6 @@
using Microsoft.Build.Framework;
using Microsoft.Build.Shared;
using Xunit;
-using Xunit.Abstractions;
using ElementLocation = Microsoft.Build.Construction.ElementLocation;
#nullable disable
diff --git a/src/Build.UnitTests/BackEnd/TargetUpToDateChecker_Tests.cs b/src/Build.UnitTests/BackEnd/TargetUpToDateChecker_Tests.cs
index a9f0d72ff3a..37b31c7cd0a 100644
--- a/src/Build.UnitTests/BackEnd/TargetUpToDateChecker_Tests.cs
+++ b/src/Build.UnitTests/BackEnd/TargetUpToDateChecker_Tests.cs
@@ -15,7 +15,6 @@
using Microsoft.Build.Shared;
using Microsoft.Win32.SafeHandles;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Build.UnitTests/BackEnd/TaskBuilder_Tests.cs b/src/Build.UnitTests/BackEnd/TaskBuilder_Tests.cs
index cd7a3910c9f..068ec160be6 100644
--- a/src/Build.UnitTests/BackEnd/TaskBuilder_Tests.cs
+++ b/src/Build.UnitTests/BackEnd/TaskBuilder_Tests.cs
@@ -18,7 +18,6 @@
using Microsoft.Build.UnitTests.Shared;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
using ElementLocation = Microsoft.Build.Construction.ElementLocation;
using ILoggingService = Microsoft.Build.BackEnd.Logging.ILoggingService;
using LegacyThreadingData = Microsoft.Build.Execution.LegacyThreadingData;
diff --git a/src/Build.UnitTests/BackEnd/TaskHostCallback_Tests.cs b/src/Build.UnitTests/BackEnd/TaskHostCallback_Tests.cs
index f54cde2470e..6ef2d14d91b 100644
--- a/src/Build.UnitTests/BackEnd/TaskHostCallback_Tests.cs
+++ b/src/Build.UnitTests/BackEnd/TaskHostCallback_Tests.cs
@@ -9,7 +9,6 @@
using Microsoft.Build.UnitTests.Shared;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
namespace Microsoft.Build.UnitTests.BackEnd
{
diff --git a/src/Build.UnitTests/BackEnd/TaskHostFactory_Tests.cs b/src/Build.UnitTests/BackEnd/TaskHostFactory_Tests.cs
index 22178bbe618..a11f0472571 100644
--- a/src/Build.UnitTests/BackEnd/TaskHostFactory_Tests.cs
+++ b/src/Build.UnitTests/BackEnd/TaskHostFactory_Tests.cs
@@ -13,7 +13,6 @@
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
@@ -25,7 +24,9 @@ namespace Microsoft.Build.Engine.UnitTests.BackEnd
///
public sealed class TaskHostFactory_Tests
{
- private static string AssemblyLocation { get; } = Path.Combine(Path.GetDirectoryName(typeof(TaskHostFactory_Tests).Assembly.Location) ?? AppContext.BaseDirectory, "Microsoft.Build.Engine.UnitTests.dll");
+ private static string AssemblyLocation { get; } =
+ typeof(TaskHostFactory_Tests).Assembly.Location
+ ?? Path.Combine(AppContext.BaseDirectory, "Microsoft.Build.Engine.UnitTests.dll");
private ITestOutputHelper _output;
diff --git a/src/Build.UnitTests/BackEnd/TaskHost_MultiThreadableTask_Tests.cs b/src/Build.UnitTests/BackEnd/TaskHost_MultiThreadableTask_Tests.cs
index f1e59ba557b..ccd50d62cab 100644
--- a/src/Build.UnitTests/BackEnd/TaskHost_MultiThreadableTask_Tests.cs
+++ b/src/Build.UnitTests/BackEnd/TaskHost_MultiThreadableTask_Tests.cs
@@ -12,7 +12,6 @@
using Microsoft.Build.Utilities;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
namespace Microsoft.Build.Engine.UnitTests.BackEnd
{
diff --git a/src/Build.UnitTests/BackEnd/TaskRegistry_Tests.cs b/src/Build.UnitTests/BackEnd/TaskRegistry_Tests.cs
index 6c4b7461b8a..b751aef4688 100644
--- a/src/Build.UnitTests/BackEnd/TaskRegistry_Tests.cs
+++ b/src/Build.UnitTests/BackEnd/TaskRegistry_Tests.cs
@@ -20,7 +20,6 @@
using Microsoft.Build.Utilities;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
#nullable disable
diff --git a/src/Build.UnitTests/BackEnd/TaskRouter_IntegrationTests.cs b/src/Build.UnitTests/BackEnd/TaskRouter_IntegrationTests.cs
index fa508369b3d..a5b1b762752 100644
--- a/src/Build.UnitTests/BackEnd/TaskRouter_IntegrationTests.cs
+++ b/src/Build.UnitTests/BackEnd/TaskRouter_IntegrationTests.cs
@@ -13,7 +13,6 @@
using Microsoft.Build.Utilities;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Build.UnitTests/BinaryLogger_Tests.cs b/src/Build.UnitTests/BinaryLogger_Tests.cs
index 3edb919e695..bc51651412b 100644
--- a/src/Build.UnitTests/BinaryLogger_Tests.cs
+++ b/src/Build.UnitTests/BinaryLogger_Tests.cs
@@ -18,7 +18,6 @@
using Microsoft.Build.UnitTests.Shared;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
@@ -102,76 +101,100 @@ public enum BinlogRoundtripTestReplayMode
[InlineData(s_testProject2, BinlogRoundtripTestReplayMode.RawEvents)]
public void TestBinaryLoggerRoundtrip(string projectText, BinlogRoundtripTestReplayMode replayMode)
{
- var binaryLogger = new BinaryLogger();
+ // NOTE:
+ // We want both loggers to see the same value of EnableTargetOutputLogging, otherwise, the last assertion will fail.
+ // See logic around showTargetOutputs.
+ // In short, this controls whether or not the "Target output items:" part is shown.
+ // Traits.Instance is weird, it's not always a singleton, depending on whether or not BuildEnvironmentState.s_runningTests is true.
+ // The s_runningTests check is also not that straightforward.
+ // Calls to ResetInstance_ForUnitTestsOnly (by tests that ran earlier than this test) might end up setting s_runningTests to false.
+ // So the current approach is extremely vulnerable to the order of tests being run, and also for test filters.
+ // When s_runningTests is true, we don't use a singleton, and in this case, one logger shows target outputs while the other doesn't.
+ // When s_runningTests is false, Traits.Instance is truly a singleton and so both see the same value.
+ // To stabilize this specific test, we explicitly set EnableTargetOutputLogging to true so we guarantee that both loggers see the same value.
+ // Long-term, unifying s_runningTests to always be true in unit tests (or even removing it completely, if possible) is the best approach.
+ var initialEnableTargetOutputLogging = Traits.Instance.EnableTargetOutputLogging;
+ using var env = TestEnvironment.Create();
+ try
+ {
+ env.SetEnvironmentVariable("MSBUILDTARGETOUTPUTLOGGING", "1");
+ Traits.Instance.EnableTargetOutputLogging = true;
- binaryLogger.Parameters = _logFile;
+ var binaryLogger = new BinaryLogger();
- var mockLogFromBuild = new MockLogger();
+ binaryLogger.Parameters = _logFile;
- var parallelFromBuildText = new StringBuilder();
- var parallelFromBuild = new ParallelConsoleLogger(Framework.LoggerVerbosity.Diagnostic, t => parallelFromBuildText.Append(t), colorSet: null, colorReset: null);
- parallelFromBuild.Parameters = "NOPERFORMANCESUMMARY";
+ var mockLogFromBuild = new MockLogger();
- // build and log into binary logger, mock logger and parallel console loggers
- // no logging on evaluation
- using (ProjectCollection collection = new())
- {
- Project project = ObjectModelHelpers.CreateInMemoryProject(collection, projectText);
- project.Build(new ILogger[] { binaryLogger, mockLogFromBuild, parallelFromBuild }).ShouldBeTrue();
- }
+ var parallelFromBuildText = new StringBuilder();
+ var parallelFromBuild = new ParallelConsoleLogger(Framework.LoggerVerbosity.Diagnostic, t => parallelFromBuildText.Append(t), colorSet: null, colorReset: null);
+ parallelFromBuild.Parameters = "NOPERFORMANCESUMMARY";
- string fileToReplay;
- switch (replayMode)
- {
- case BinlogRoundtripTestReplayMode.NoReplay:
- fileToReplay = _logFile;
- break;
- case BinlogRoundtripTestReplayMode.Structured:
- case BinlogRoundtripTestReplayMode.RawEvents:
- {
- var logReader = new BinaryLogReplayEventSource();
- fileToReplay = _env.ExpectFile(".binlog").Path;
- if (replayMode == BinlogRoundtripTestReplayMode.Structured)
- {
- // need dummy handler to force structured replay
- logReader.BuildFinished += (_, _) => { };
- }
+ // build and log into binary logger, mock logger and parallel console loggers
+ // no logging on evaluation
+ using (ProjectCollection collection = new())
+ {
+ Project project = ObjectModelHelpers.CreateInMemoryProject(collection, projectText);
+ project.Build(new ILogger[] { binaryLogger, mockLogFromBuild, parallelFromBuild }).ShouldBeTrue();
+ }
- BinaryLogger outputBinlog = new BinaryLogger()
+ string fileToReplay;
+ switch (replayMode)
+ {
+ case BinlogRoundtripTestReplayMode.NoReplay:
+ fileToReplay = _logFile;
+ break;
+ case BinlogRoundtripTestReplayMode.Structured:
+ case BinlogRoundtripTestReplayMode.RawEvents:
{
- Parameters = fileToReplay
- };
- outputBinlog.Initialize(logReader);
- logReader.Replay(_logFile);
- outputBinlog.Shutdown();
- }
- break;
- default:
- throw new ArgumentOutOfRangeException(nameof(replayMode), replayMode, null);
- }
+ var logReader = new BinaryLogReplayEventSource();
+ fileToReplay = _env.ExpectFile(".binlog").Path;
+ if (replayMode == BinlogRoundtripTestReplayMode.Structured)
+ {
+ // need dummy handler to force structured replay
+ logReader.BuildFinished += (_, _) => { };
+ }
+
+ BinaryLogger outputBinlog = new BinaryLogger()
+ {
+ Parameters = fileToReplay
+ };
+ outputBinlog.Initialize(logReader);
+ logReader.Replay(_logFile);
+ outputBinlog.Shutdown();
+ }
+ break;
+ default:
+ throw new ArgumentOutOfRangeException(nameof(replayMode), replayMode, null);
+ }
- var mockLogFromPlayback = new MockLogger();
+ var mockLogFromPlayback = new MockLogger();
- var parallelFromPlaybackText = new StringBuilder();
- var parallelFromPlayback = new ParallelConsoleLogger(Framework.LoggerVerbosity.Diagnostic, t => parallelFromPlaybackText.Append(t), colorSet: null, colorReset: null);
- parallelFromPlayback.Parameters = "NOPERFORMANCESUMMARY";
+ var parallelFromPlaybackText = new StringBuilder();
+ var parallelFromPlayback = new ParallelConsoleLogger(Framework.LoggerVerbosity.Diagnostic, t => parallelFromPlaybackText.Append(t), colorSet: null, colorReset: null);
+ parallelFromPlayback.Parameters = "NOPERFORMANCESUMMARY";
- var binaryLogReader = new BinaryLogReplayEventSource();
- mockLogFromPlayback.Initialize(binaryLogReader);
- parallelFromPlayback.Initialize(binaryLogReader);
+ var binaryLogReader = new BinaryLogReplayEventSource();
+ mockLogFromPlayback.Initialize(binaryLogReader);
+ parallelFromPlayback.Initialize(binaryLogReader);
- // read the binary log and replay into mockLogger2
- binaryLogReader.Replay(fileToReplay);
- mockLogFromPlayback.Shutdown();
- parallelFromPlayback.Shutdown();
+ // read the binary log and replay into mockLogger2
+ binaryLogReader.Replay(fileToReplay);
+ mockLogFromPlayback.Shutdown();
+ parallelFromPlayback.Shutdown();
- // the binlog will have more information than recorded by the text log
- mockLogFromPlayback.FullLog.ShouldContainWithoutWhitespace(mockLogFromBuild.FullLog);
+ // the binlog will have more information than recorded by the text log
+ mockLogFromPlayback.FullLog.ShouldContainWithoutWhitespace(mockLogFromBuild.FullLog);
- var parallelExpected = parallelFromBuildText.ToString();
- var parallelActual = parallelFromPlaybackText.ToString();
+ var parallelExpected = parallelFromBuildText.ToString();
+ var parallelActual = parallelFromPlaybackText.ToString();
- parallelActual.ShouldContainWithoutWhitespace(parallelExpected);
+ parallelActual.ShouldContainWithoutWhitespace(parallelExpected);
+ }
+ finally
+ {
+ Traits.Instance.EnableTargetOutputLogging = initialEnableTargetOutputLogging;
+ }
}
///
diff --git a/src/Build.UnitTests/CLR2TaskHost_E2E_Tests.cs b/src/Build.UnitTests/CLR2TaskHost_E2E_Tests.cs
index 25dc52fff89..2380c4b2879 100644
--- a/src/Build.UnitTests/CLR2TaskHost_E2E_Tests.cs
+++ b/src/Build.UnitTests/CLR2TaskHost_E2E_Tests.cs
@@ -6,7 +6,6 @@
using Microsoft.Build.UnitTests.Shared;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
namespace Microsoft.Build.Engine.UnitTests;
diff --git a/src/Build.UnitTests/ChangeWaves_Tests.cs b/src/Build.UnitTests/ChangeWaves_Tests.cs
index d81e765c3ab..7f5b8d69936 100644
--- a/src/Build.UnitTests/ChangeWaves_Tests.cs
+++ b/src/Build.UnitTests/ChangeWaves_Tests.cs
@@ -8,7 +8,6 @@
using Microsoft.Build.UnitTests;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Build.UnitTests/ConsoleLogger_Tests.cs b/src/Build.UnitTests/ConsoleLogger_Tests.cs
index 139e461cc40..3456745feb2 100644
--- a/src/Build.UnitTests/ConsoleLogger_Tests.cs
+++ b/src/Build.UnitTests/ConsoleLogger_Tests.cs
@@ -17,7 +17,6 @@
using Microsoft.Build.Shared;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
using TaskItem = Microsoft.Build.Execution.ProjectItemInstance.TaskItem;
#nullable disable
@@ -1220,15 +1219,23 @@ public void DoNotDisplayEnvironmentInDetailed()
[Fact]
public void DisplayEnvironmentInDetailed()
{
- SimulatedConsole sc = new SimulatedConsole();
+ var logAllOriginal = Traits.LogAllEnvironmentVariables;
+ try
+ {
+ SimulatedConsole sc = new SimulatedConsole();
- ParallelConsoleLogger cl2 = new ParallelConsoleLogger(LoggerVerbosity.Detailed, sc.Write, null, null);
- EventSourceSink es = new EventSourceSink();
- cl2.Initialize(es);
- cl2.Parameters = "ShowEnvironment";
- cl2.ParseParameters();
+ ParallelConsoleLogger cl2 = new ParallelConsoleLogger(LoggerVerbosity.Detailed, sc.Write, null, null);
+ EventSourceSink es = new EventSourceSink();
+ cl2.Initialize(es);
+ cl2.Parameters = "ShowEnvironment";
+ cl2.ParseParameters();
- WriteEnvironment(cl2, sc, true);
+ WriteEnvironment(cl2, sc, true);
+ }
+ finally
+ {
+ Traits.LogAllEnvironmentVariables = logAllOriginal;
+ }
}
///
@@ -1264,15 +1271,23 @@ public void DoNotDisplayEnvironmentInMinimal()
[Fact]
public void DisplayEnvironmentInMinimal()
{
- SimulatedConsole sc = new SimulatedConsole();
-
- ParallelConsoleLogger cl2 = new ParallelConsoleLogger(LoggerVerbosity.Minimal, sc.Write, null, null);
- EventSourceSink es = new EventSourceSink();
- cl2.Initialize(es);
- cl2.Parameters = "ShowEnvironment";
- cl2.ParseParameters();
+ var logAllOriginal = Traits.LogAllEnvironmentVariables;
+ try
+ {
+ SimulatedConsole sc = new SimulatedConsole();
- WriteEnvironment(cl2, sc, true);
+ ParallelConsoleLogger cl2 = new ParallelConsoleLogger(LoggerVerbosity.Minimal, sc.Write, null, null);
+ EventSourceSink es = new EventSourceSink();
+ cl2.Initialize(es);
+ cl2.Parameters = "ShowEnvironment";
+ cl2.ParseParameters();
+
+ WriteEnvironment(cl2, sc, true);
+ }
+ finally
+ {
+ Traits.LogAllEnvironmentVariables = logAllOriginal;
+ }
}
///
diff --git a/src/Build.UnitTests/Construction/ProjectRootElement_Tests.cs b/src/Build.UnitTests/Construction/ProjectRootElement_Tests.cs
index 13ab48079a4..677322633af 100644
--- a/src/Build.UnitTests/Construction/ProjectRootElement_Tests.cs
+++ b/src/Build.UnitTests/Construction/ProjectRootElement_Tests.cs
@@ -115,6 +115,12 @@ public void ProjectLoadedStrippingCommentsAndWhiteSpaceIsReadOnly()
Assert.Equal(2, children[0].ChildNodes.Count);
Assert.Equal(string.Empty, children[0].ChildNodes[0].Value);
Assert.Equal(string.Empty, children[0].ChildNodes[1].Value);
+
+ // We cleared at the beginning, but then we set MSBUILDLOADALLFILESASREADONLY to 1.
+ // This means that opening the project will cache s_readOnlyFlags as ReadOnlyLoadFlags.LoadAllReadOnly
+ // Keeping the cached ReadOnlyLoadFlags.LoadAllReadOnly can impact subsequent tests that are running in the same process.
+ // So ensure to re-clear.
+ XmlDocumentWithLocation.ClearReadOnlyFlags_UnitTestsOnly();
}
}
diff --git a/src/Build.UnitTests/Construction/SolutionFile_NewParser_Tests.cs b/src/Build.UnitTests/Construction/SolutionFile_NewParser_Tests.cs
index 873cd2d1b5c..3abae4d9a6f 100644
--- a/src/Build.UnitTests/Construction/SolutionFile_NewParser_Tests.cs
+++ b/src/Build.UnitTests/Construction/SolutionFile_NewParser_Tests.cs
@@ -12,7 +12,6 @@
using Microsoft.VisualStudio.SolutionPersistence.Serializer;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Build.UnitTests/Construction/SolutionFile_OldParser_Tests.cs b/src/Build.UnitTests/Construction/SolutionFile_OldParser_Tests.cs
index e471c0373ce..1a58f4ba1c5 100644
--- a/src/Build.UnitTests/Construction/SolutionFile_OldParser_Tests.cs
+++ b/src/Build.UnitTests/Construction/SolutionFile_OldParser_Tests.cs
@@ -12,7 +12,6 @@
using Microsoft.Build.Shared;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Build.UnitTests/Construction/SolutionFilter_Tests.cs b/src/Build.UnitTests/Construction/SolutionFilter_Tests.cs
index 593dc8bf5c0..a779efcc5b1 100644
--- a/src/Build.UnitTests/Construction/SolutionFilter_Tests.cs
+++ b/src/Build.UnitTests/Construction/SolutionFilter_Tests.cs
@@ -20,7 +20,6 @@
using Microsoft.VisualStudio.SolutionPersistence.Serializer;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
namespace Microsoft.Build.Engine.UnitTests.Construction
{
diff --git a/src/Build.UnitTests/Construction/SolutionProjectGenerator_Tests.cs b/src/Build.UnitTests/Construction/SolutionProjectGenerator_Tests.cs
index c57f5ebedb9..6f1a3f1ae91 100644
--- a/src/Build.UnitTests/Construction/SolutionProjectGenerator_Tests.cs
+++ b/src/Build.UnitTests/Construction/SolutionProjectGenerator_Tests.cs
@@ -13,7 +13,6 @@
using Microsoft.Build.UnitTests.Shared;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
using FrameworkLocationHelper = Microsoft.Build.Shared.FrameworkLocationHelper;
using ILoggingService = Microsoft.Build.BackEnd.Logging.ILoggingService;
using InternalUtilities = Microsoft.Build.Internal.Utilities;
diff --git a/src/Build.UnitTests/EndToEndCondition_Tests.cs b/src/Build.UnitTests/EndToEndCondition_Tests.cs
index 042f448a655..cb2925a1e86 100644
--- a/src/Build.UnitTests/EndToEndCondition_Tests.cs
+++ b/src/Build.UnitTests/EndToEndCondition_Tests.cs
@@ -5,7 +5,6 @@
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Build.UnitTests/EscapingInProjects_Tests.cs b/src/Build.UnitTests/EscapingInProjects_Tests.cs
index 90095b266e0..06556aeb12d 100644
--- a/src/Build.UnitTests/EscapingInProjects_Tests.cs
+++ b/src/Build.UnitTests/EscapingInProjects_Tests.cs
@@ -22,7 +22,6 @@
using ResourceUtilities = Microsoft.Build.Shared.ResourceUtilities;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#if FEATURE_COMPILE_IN_TESTS
using Microsoft.Build.Shared;
#endif
diff --git a/src/Build.UnitTests/Evaluation/ExpanderFunction_Tests.cs b/src/Build.UnitTests/Evaluation/ExpanderFunction_Tests.cs
index 4b69b86fe02..6cc460778a7 100644
--- a/src/Build.UnitTests/Evaluation/ExpanderFunction_Tests.cs
+++ b/src/Build.UnitTests/Evaluation/ExpanderFunction_Tests.cs
@@ -7,7 +7,6 @@
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
using ParseArgs = Microsoft.Build.Evaluation.Expander.ArgumentParser;
namespace Microsoft.Build.Engine.UnitTests.Evaluation
diff --git a/src/Build.UnitTests/Evaluation/Expander_Tests.cs b/src/Build.UnitTests/Evaluation/Expander_Tests.cs
index 4a9364feb78..017537189f2 100644
--- a/src/Build.UnitTests/Evaluation/Expander_Tests.cs
+++ b/src/Build.UnitTests/Evaluation/Expander_Tests.cs
@@ -26,7 +26,6 @@
using Microsoft.Win32;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
using Xunit.NetCore.Extensions;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
using ProjectHelpers = Microsoft.Build.UnitTests.BackEnd.ProjectHelpers;
@@ -5133,6 +5132,7 @@ public void ExpandItem_ConvertToStringUsingInvariantCultureForNumberData_Respect
using (var env = TestEnvironment.Create())
{
env.SetEnvironmentVariable("MSBUILDDISABLEFEATURESFROMVERSION", ChangeWaves.Wave17_12.ToString());
+ ChangeWaves.ResetStateForTests();
currentThread.CurrentCulture = svSECultureInfo;
currentThread.CurrentUICulture = svSECultureInfo;
var root = env.CreateFolder();
diff --git a/src/Build.UnitTests/Evaluation/SdkResultEvaluation_Tests.cs b/src/Build.UnitTests/Evaluation/SdkResultEvaluation_Tests.cs
index 9632dce86b3..4c71ffaeedc 100644
--- a/src/Build.UnitTests/Evaluation/SdkResultEvaluation_Tests.cs
+++ b/src/Build.UnitTests/Evaluation/SdkResultEvaluation_Tests.cs
@@ -14,7 +14,6 @@
using Microsoft.Build.Unittest;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Build.UnitTests/EvaluationProfiler_Tests.cs b/src/Build.UnitTests/EvaluationProfiler_Tests.cs
index d78f804d41a..3b780a8c3b7 100644
--- a/src/Build.UnitTests/EvaluationProfiler_Tests.cs
+++ b/src/Build.UnitTests/EvaluationProfiler_Tests.cs
@@ -12,7 +12,6 @@
using Microsoft.Build.Logging;
using Microsoft.Build.UnitTests;
using Xunit;
-using Xunit.Abstractions;
using static Microsoft.Build.UnitTests.ObjectModelHelpers;
#nullable disable
diff --git a/src/Build.UnitTests/ExpressionTreeExpression_Tests.cs b/src/Build.UnitTests/ExpressionTreeExpression_Tests.cs
index bd9f5ac973b..250bee58601 100644
--- a/src/Build.UnitTests/ExpressionTreeExpression_Tests.cs
+++ b/src/Build.UnitTests/ExpressionTreeExpression_Tests.cs
@@ -12,7 +12,6 @@
using Microsoft.Build.Execution;
using Microsoft.Build.Shared.FileSystem;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Build.UnitTests/Graph/GraphLoadedFromSolution_tests.cs b/src/Build.UnitTests/Graph/GraphLoadedFromSolution_tests.cs
index 77e4ffded51..66a0a7b9fc4 100644
--- a/src/Build.UnitTests/Graph/GraphLoadedFromSolution_tests.cs
+++ b/src/Build.UnitTests/Graph/GraphLoadedFromSolution_tests.cs
@@ -13,7 +13,6 @@
using Microsoft.Build.UnitTests;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
using static Microsoft.Build.Graph.UnitTests.GraphTestingUtilities;
using static Microsoft.Build.UnitTests.Helpers;
diff --git a/src/Build.UnitTests/Graph/IsolateProjects_Tests.cs b/src/Build.UnitTests/Graph/IsolateProjects_Tests.cs
index 1da40fe77d3..131d658473b 100644
--- a/src/Build.UnitTests/Graph/IsolateProjects_Tests.cs
+++ b/src/Build.UnitTests/Graph/IsolateProjects_Tests.cs
@@ -11,7 +11,6 @@
using Microsoft.Build.UnitTests;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
using ExpectedNodeBuildOutput = System.Collections.Generic.Dictionary;
using OutputCacheDictionary = System.Collections.Generic.Dictionary;
diff --git a/src/Build.UnitTests/Graph/ProjectGraph_Tests.cs b/src/Build.UnitTests/Graph/ProjectGraph_Tests.cs
index e275395f5f3..5bf891c4707 100644
--- a/src/Build.UnitTests/Graph/ProjectGraph_Tests.cs
+++ b/src/Build.UnitTests/Graph/ProjectGraph_Tests.cs
@@ -17,7 +17,6 @@
using Microsoft.Build.UnitTests;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
using Xunit.NetCore.Extensions;
using static Microsoft.Build.Graph.UnitTests.GraphTestingUtilities;
diff --git a/src/Build.UnitTests/Graph/ResultCacheBasedBuilds_Tests.cs b/src/Build.UnitTests/Graph/ResultCacheBasedBuilds_Tests.cs
index 11033d78af8..fe19764230c 100644
--- a/src/Build.UnitTests/Graph/ResultCacheBasedBuilds_Tests.cs
+++ b/src/Build.UnitTests/Graph/ResultCacheBasedBuilds_Tests.cs
@@ -14,7 +14,6 @@
using Microsoft.Build.UnitTests;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
using static Microsoft.Build.UnitTests.Helpers;
using ExpectedNodeBuildOutput = System.Collections.Generic.Dictionary;
diff --git a/src/Build.UnitTests/Instance/ProjectInstance_Internal_Tests.cs b/src/Build.UnitTests/Instance/ProjectInstance_Internal_Tests.cs
index fd8ba8841d0..2aea8c3eff2 100644
--- a/src/Build.UnitTests/Instance/ProjectInstance_Internal_Tests.cs
+++ b/src/Build.UnitTests/Instance/ProjectInstance_Internal_Tests.cs
@@ -16,7 +16,6 @@
using Microsoft.Build.UnitTests.BackEnd;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
using static Microsoft.Build.Engine.UnitTests.TestComparers.ProjectInstanceModelTestComparers;
#nullable disable
diff --git a/src/Build.UnitTests/InvalidProjectFileException_Tests.cs b/src/Build.UnitTests/InvalidProjectFileException_Tests.cs
index 7a1d62aab19..069a77f41f5 100644
--- a/src/Build.UnitTests/InvalidProjectFileException_Tests.cs
+++ b/src/Build.UnitTests/InvalidProjectFileException_Tests.cs
@@ -6,7 +6,6 @@
using Microsoft.Build.Exceptions;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Build.UnitTests/MSBuildTaskHostTests.cs b/src/Build.UnitTests/MSBuildTaskHostTests.cs
index 2891387495f..0521804c046 100644
--- a/src/Build.UnitTests/MSBuildTaskHostTests.cs
+++ b/src/Build.UnitTests/MSBuildTaskHostTests.cs
@@ -9,7 +9,6 @@
using Microsoft.Build.UnitTests.Shared;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
namespace Microsoft.Build.Engine.UnitTests;
diff --git a/src/Build.UnitTests/Microsoft.Build.Engine.UnitTests.csproj b/src/Build.UnitTests/Microsoft.Build.Engine.UnitTests.csproj
index 39c496de0b3..223f751a367 100644
--- a/src/Build.UnitTests/Microsoft.Build.Engine.UnitTests.csproj
+++ b/src/Build.UnitTests/Microsoft.Build.Engine.UnitTests.csproj
@@ -27,7 +27,7 @@
-
+
all
diff --git a/src/Build.UnitTests/NetTaskHost_E2E_Tests.cs b/src/Build.UnitTests/NetTaskHost_E2E_Tests.cs
index 4e52d3243b0..8098e34353a 100644
--- a/src/Build.UnitTests/NetTaskHost_E2E_Tests.cs
+++ b/src/Build.UnitTests/NetTaskHost_E2E_Tests.cs
@@ -11,7 +11,6 @@
using Microsoft.Build.UnitTests.Shared;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
namespace Microsoft.Build.Engine.UnitTests
{
diff --git a/src/Build.UnitTests/NodeStatus_SizeChange_Tests.cs b/src/Build.UnitTests/NodeStatus_SizeChange_Tests.cs
index de0a9c3210d..6465582ad90 100644
--- a/src/Build.UnitTests/NodeStatus_SizeChange_Tests.cs
+++ b/src/Build.UnitTests/NodeStatus_SizeChange_Tests.cs
@@ -14,7 +14,6 @@
namespace Microsoft.Build.CommandLine.UnitTests;
-[UsesVerify]
[UseInvariantCulture]
public class NodeStatus_SizeChange_Tests
{
diff --git a/src/Build.UnitTests/NodeStatus_Transition_Tests.cs b/src/Build.UnitTests/NodeStatus_Transition_Tests.cs
index 0eb6857ee3e..73d0298a184 100644
--- a/src/Build.UnitTests/NodeStatus_Transition_Tests.cs
+++ b/src/Build.UnitTests/NodeStatus_Transition_Tests.cs
@@ -17,7 +17,6 @@
namespace Microsoft.Build.CommandLine.UnitTests;
-[UsesVerify]
[UseInvariantCulture]
public class NodeStatus_Transition_Tests
{
diff --git a/src/Build.UnitTests/ProjectCache/ProjectCacheTests.cs b/src/Build.UnitTests/ProjectCache/ProjectCacheTests.cs
index f7e7bd70711..05d05fde2dd 100644
--- a/src/Build.UnitTests/ProjectCache/ProjectCacheTests.cs
+++ b/src/Build.UnitTests/ProjectCache/ProjectCacheTests.cs
@@ -22,7 +22,6 @@
using Microsoft.Build.Utilities;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
using Task = System.Threading.Tasks.Task;
namespace Microsoft.Build.Engine.UnitTests.ProjectCache
diff --git a/src/Build.UnitTests/Resources_Tests.cs b/src/Build.UnitTests/Resources_Tests.cs
index acd1d6039be..ecc78f54872 100644
--- a/src/Build.UnitTests/Resources_Tests.cs
+++ b/src/Build.UnitTests/Resources_Tests.cs
@@ -9,7 +9,6 @@
using System.Xml.Linq;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
namespace Microsoft.Build.UnitTests
{
diff --git a/src/Build.UnitTests/TaskHostFactoryLifecycle_E2E_Tests.cs b/src/Build.UnitTests/TaskHostFactoryLifecycle_E2E_Tests.cs
index 464ca7672da..2fe46bf490d 100644
--- a/src/Build.UnitTests/TaskHostFactoryLifecycle_E2E_Tests.cs
+++ b/src/Build.UnitTests/TaskHostFactoryLifecycle_E2E_Tests.cs
@@ -8,7 +8,6 @@
using Microsoft.Build.UnitTests.Shared;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
namespace Microsoft.Build.Engine.UnitTests
{
diff --git a/src/Build.UnitTests/Telemetry/Telemetry_Tests.cs b/src/Build.UnitTests/Telemetry/Telemetry_Tests.cs
index 0361e99ca0d..964d29a49b2 100644
--- a/src/Build.UnitTests/Telemetry/Telemetry_Tests.cs
+++ b/src/Build.UnitTests/Telemetry/Telemetry_Tests.cs
@@ -16,7 +16,6 @@
using Microsoft.Build.UnitTests.BackEnd;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
using static Microsoft.Build.Framework.Telemetry.BuildInsights;
using static Microsoft.Build.Framework.Telemetry.TelemetryDataUtils;
diff --git a/src/Build.UnitTests/TerminalLoggerConfiguration_Tests.cs b/src/Build.UnitTests/TerminalLoggerConfiguration_Tests.cs
index 5a7fe9c2b3d..9242de9c48d 100644
--- a/src/Build.UnitTests/TerminalLoggerConfiguration_Tests.cs
+++ b/src/Build.UnitTests/TerminalLoggerConfiguration_Tests.cs
@@ -8,7 +8,6 @@
using Microsoft.Build.UnitTests.Shared;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
namespace Microsoft.Build.UnitTests;
diff --git a/src/Build.UnitTests/TerminalLogger_Tests.cs b/src/Build.UnitTests/TerminalLogger_Tests.cs
index 68928d9b783..9790afa3140 100644
--- a/src/Build.UnitTests/TerminalLogger_Tests.cs
+++ b/src/Build.UnitTests/TerminalLogger_Tests.cs
@@ -18,7 +18,6 @@
using VerifyTests;
using VerifyXunit;
using Xunit;
-using Xunit.Abstractions;
using Xunit.NetCore.Extensions;
using static VerifyXunit.Verifier;
@@ -132,7 +131,6 @@ void IBuildEventSink.ShutDown()
public void InvokeCustomEventRaised(CustomBuildEventArgs args) => CustomEventRaised?.Invoke(_eventSender, args);
}
- [UsesVerify]
[UseInvariantCulture]
public class TerminalLogger_Tests
{
diff --git a/src/Build.UnitTests/Utilities_Tests.cs b/src/Build.UnitTests/Utilities_Tests.cs
index 880fbe49e59..18e908472c9 100644
--- a/src/Build.UnitTests/Utilities_Tests.cs
+++ b/src/Build.UnitTests/Utilities_Tests.cs
@@ -6,7 +6,6 @@
using System.IO;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
using InternalUtilities = Microsoft.Build.Internal.Utilities;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
using MSBuildApp = Microsoft.Build.CommandLine.MSBuildApp;
diff --git a/src/Build.UnitTests/WarningsAsMessagesAndErrors_Tests.cs b/src/Build.UnitTests/WarningsAsMessagesAndErrors_Tests.cs
index 10ce4eba75b..1d588fda3d5 100644
--- a/src/Build.UnitTests/WarningsAsMessagesAndErrors_Tests.cs
+++ b/src/Build.UnitTests/WarningsAsMessagesAndErrors_Tests.cs
@@ -9,7 +9,6 @@
using Microsoft.Build.UnitTests;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
@@ -19,9 +18,11 @@ public sealed class WarningsAsMessagesAndErrorsTests
{
private const string ExpectedEventMessage = "03767942CDB147B98D0ECDBDE1436DA3";
private const string ExpectedEventCode = "0BF68998";
- private static string TestAssemblyLocation { get; } = Path.Combine(
- Path.GetDirectoryName(typeof(WarningsAsMessagesAndErrorsTests).Assembly.Location) ?? AppContext.BaseDirectory,
- "Microsoft.Build.Engine.UnitTests.dll");
+
+ private static string TestAssemblyLocation { get; } =
+ typeof(WarningsAsMessagesAndErrorsTests).Assembly.Location
+ ?? Path.Combine(AppContext.BaseDirectory, $"Microsoft.Build.Engine.UnitTests.dll");
+
private ITestOutputHelper _output;
public WarningsAsMessagesAndErrorsTests(ITestOutputHelper output)
diff --git a/src/BuildCheck.UnitTests/BuildCheckManagerProviderTests.cs b/src/BuildCheck.UnitTests/BuildCheckManagerProviderTests.cs
index 1cd861e4c98..1f24fe1934f 100644
--- a/src/BuildCheck.UnitTests/BuildCheckManagerProviderTests.cs
+++ b/src/BuildCheck.UnitTests/BuildCheckManagerProviderTests.cs
@@ -14,7 +14,6 @@
using Microsoft.Build.UnitTests;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
using static Microsoft.Build.Experimental.BuildCheck.Infrastructure.BuildCheckManagerProvider;
namespace Microsoft.Build.BuildCheck.UnitTests;
diff --git a/src/BuildCheck.UnitTests/EndToEndTests.cs b/src/BuildCheck.UnitTests/EndToEndTests.cs
index 82472057d0f..646dc27984f 100644
--- a/src/BuildCheck.UnitTests/EndToEndTests.cs
+++ b/src/BuildCheck.UnitTests/EndToEndTests.cs
@@ -14,7 +14,6 @@
using Microsoft.Build.UnitTests.Shared;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
namespace Microsoft.Build.BuildCheck.UnitTests;
diff --git a/src/BuildCheck.UnitTests/TaskInvocationAnalysisDataTests.cs b/src/BuildCheck.UnitTests/TaskInvocationAnalysisDataTests.cs
index 10e6a9fcf9c..12b3f4e3a82 100644
--- a/src/BuildCheck.UnitTests/TaskInvocationAnalysisDataTests.cs
+++ b/src/BuildCheck.UnitTests/TaskInvocationAnalysisDataTests.cs
@@ -13,7 +13,6 @@
using Microsoft.Build.Utilities;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
using static Microsoft.Build.Experimental.BuildCheck.Infrastructure.BuildCheckManagerProvider;
namespace Microsoft.Build.BuildCheck.UnitTests
diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets
index 6314d701be8..7e0d7109693 100644
--- a/src/Directory.Build.targets
+++ b/src/Directory.Build.targets
@@ -2,8 +2,6 @@
$(MSBuildAllProjects);$(MSBuildThisFileFullPath)
-
- true
@@ -18,32 +16,28 @@
-
- Exe
- false
+
+ $(XunitOptions) --filter-not-trait Category=nonwindowstests
-
- $(XunitOptions)
+ $(XunitOptions) --filter-not-trait Category=nonlinuxtests
+ $(XunitOptions) --filter-not-trait Category=netcore-linux-failing
+
+ $(XunitOptions) --filter-not-trait Category=nonosxtests
+ $(XunitOptions) --filter-not-trait Category=netcore-osx-failing
-
- $(XunitOptions) --filter "Category!=nonwindowstests
- $(XunitOptions) --filter "Category!=nonlinuxtests
- --filter "Category!=nonlinuxtests&Category!=netcore-linux-failing
- $(XunitOptions) --filter "Category!=nonosxtests
- --filter "Category!=nonosxtests&Category!=netcore-osx-failing
- $(XunitOptions) --filter "Category!=nonfreebsdtests
+ $(XunitOptions) --filter-not-trait Category=nonfreebsdtests
- $(XunitOptions)&Category!=nonnetcoreapptests
- $(XunitOptions)&Category!=nonnetfxtests
+ $(XunitOptions) --filter-not-trait Category=nonnetcoreapptests
+ $(XunitOptions) --filter-not-trait Category=nonnetfxtests
- $(XunitOptions)&Category!=failing" --Diag $(TargetName).log
+ $(XunitOptions) --filter-not-trait Category=failing
-
- $(XunitOptions) --settings $(RepoRoot)Coverage.runsettings --test-adapter-path $(NuGetPackageRoot)microsoft.codecoverage/18.0.0-preview-25479-103/build/netstandard2.0
+
+ $(XunitOptions) --coverage --coverage-settings $(RepoRoot)Coverage.config
$(XunitOptions)
@@ -59,13 +53,13 @@
9.0.1, causing it to be downloaded and flagged by component governance -->
-
+
+
-
@@ -85,10 +79,6 @@
netstandard
-
-
-
-
diff --git a/src/Framework.UnitTests/FileMatcher_Tests.cs b/src/Framework.UnitTests/FileMatcher_Tests.cs
index c0bea972965..1ec9c7750a8 100644
--- a/src/Framework.UnitTests/FileMatcher_Tests.cs
+++ b/src/Framework.UnitTests/FileMatcher_Tests.cs
@@ -13,7 +13,6 @@
using Microsoft.Build.UnitTests.Shared;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Framework.UnitTests/FileUtilities_Tests.cs b/src/Framework.UnitTests/FileUtilities_Tests.cs
index e276e9ebad4..4160ab4551a 100644
--- a/src/Framework.UnitTests/FileUtilities_Tests.cs
+++ b/src/Framework.UnitTests/FileUtilities_Tests.cs
@@ -549,11 +549,14 @@ public void FileOrDirectoryExistsNoThrow()
}
#if FEATURE_ENVIRONMENT_SYSTEMDIRECTORY
- // These tests will need to be redesigned for Linux
-
- [ConditionalFact(nameof(RunTestsThatDependOnWindowsShortPathBehavior_Workaround4241))]
+ [Fact]
public void FileOrDirectoryExistsNoThrowTooLongWithDots()
{
+ if (!RunTestsThatDependOnWindowsShortPathBehavior_Workaround4241())
+ {
+ Assert.Skip("These tests will need to be redesigned for Linux");
+ }
+
int length = (Environment.SystemDirectory + @"\" + @"\..\..\..\" + Environment.SystemDirectory.Substring(3)).Length;
string longPart = new string('x', 260 - length); // We want the shortest that is > max path.
@@ -566,9 +569,14 @@ public void FileOrDirectoryExistsNoThrowTooLongWithDots()
Assert.False(FileUtilities.FileOrDirectoryExistsNoThrow(inputPath.Replace('\\', 'X')));
}
- [ConditionalFact(nameof(RunTestsThatDependOnWindowsShortPathBehavior_Workaround4241))]
+ [Fact]
public void FileOrDirectoryExistsNoThrowTooLongWithDotsRelative()
{
+ if (!RunTestsThatDependOnWindowsShortPathBehavior_Workaround4241())
+ {
+ Assert.Skip("These tests will need to be redesigned for Linux");
+ }
+
int length = (Environment.SystemDirectory + @"\" + @"\..\..\..\" + Environment.SystemDirectory.Substring(3)).Length;
string longPart = new string('x', 260 - length); // We want the shortest that is > max path.
@@ -619,9 +627,14 @@ public void DirectoryExistsNoThrowTooLongWithDots()
Assert.True(FileUtilities.DirectoryExistsNoThrow(inputPath));
}
- [ConditionalFact(nameof(RunTestsThatDependOnWindowsShortPathBehavior_Workaround4241))]
+ [Fact]
public void DirectoryExistsNoThrowTooLongWithDotsRelative()
{
+ if (!RunTestsThatDependOnWindowsShortPathBehavior_Workaround4241())
+ {
+ Assert.Skip("These tests will need to be redesigned for Linux");
+ }
+
int length = (Environment.SystemDirectory + @"\" + @"\..\..\..\" + Environment.SystemDirectory.Substring(3)).Length;
string longPart = new string('x', 260 - length); // We want the shortest that is > max path.
@@ -655,9 +668,14 @@ public static bool RunTestsThatDependOnWindowsShortPathBehavior_Workaround4241()
NativeMethodsShared.IsMaxPathLegacyWindows();
}
- [ConditionalFact(nameof(RunTestsThatDependOnWindowsShortPathBehavior_Workaround4241))]
+ [Fact]
public void FileExistsNoThrowTooLongWithDots()
{
+ if (!RunTestsThatDependOnWindowsShortPathBehavior_Workaround4241())
+ {
+ Assert.Skip("These tests will need to be redesigned for Linux");
+ }
+
int length = (Environment.SystemDirectory + @"\" + @"\..\..\..\" + Environment.SystemDirectory.Substring(3) + @"\..\explorer.exe").Length;
string longPart = new string('x', 260 - length); // We want the shortest that is > max path.
@@ -670,9 +688,14 @@ public void FileExistsNoThrowTooLongWithDots()
Assert.True(FileUtilities.FileExistsNoThrow(inputPath));
}
- [ConditionalFact(nameof(RunTestsThatDependOnWindowsShortPathBehavior_Workaround4241))]
+ [Fact]
public void FileExistsNoThrowTooLongWithDotsRelative()
{
+ if (!RunTestsThatDependOnWindowsShortPathBehavior_Workaround4241())
+ {
+ Assert.Skip("These tests will need to be redesigned for Linux");
+ }
+
int length = (Environment.SystemDirectory + @"\" + @"\..\..\..\" + Environment.SystemDirectory.Substring(3) + @"\..\explorer.exe").Length;
string longPart = new string('x', 260 - length); // We want the shortest that is > max path.
diff --git a/src/MSBuild.UnitTests/CommandLineSwitches_Tests.cs b/src/MSBuild.UnitTests/CommandLineSwitches_Tests.cs
index 3e81301cd91..139bf827117 100644
--- a/src/MSBuild.UnitTests/CommandLineSwitches_Tests.cs
+++ b/src/MSBuild.UnitTests/CommandLineSwitches_Tests.cs
@@ -1133,6 +1133,7 @@ public void ParameterizedSwitchTargetQuotedChangeWaveTest()
using (TestEnvironment env = TestEnvironment.Create())
{
env.SetEnvironmentVariable("MSBUILDDISABLEFEATURESFROMVERSION", "17.10");
+ ChangeWaves.ResetStateForTests();
CommandLineSwitches switches = new CommandLineSwitches();
switches.SetParameterizedSwitch(CommandLineSwitches.ParameterizedSwitch.Target, "/t:Clean;Build", "\"Clean;Build\"", true, true, false);
diff --git a/src/MSBuild.UnitTests/MSBuildMultithreaded_Tests.cs b/src/MSBuild.UnitTests/MSBuildMultithreaded_Tests.cs
index 3b932d38924..4557bdddab8 100644
--- a/src/MSBuild.UnitTests/MSBuildMultithreaded_Tests.cs
+++ b/src/MSBuild.UnitTests/MSBuildMultithreaded_Tests.cs
@@ -10,7 +10,6 @@
using Microsoft.Build.Utilities;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
namespace Microsoft.Build.Engine.UnitTests
{
diff --git a/src/MSBuild.UnitTests/MSBuildServer_Tests.cs b/src/MSBuild.UnitTests/MSBuildServer_Tests.cs
index 6272a874389..1531c665f54 100644
--- a/src/MSBuild.UnitTests/MSBuildServer_Tests.cs
+++ b/src/MSBuild.UnitTests/MSBuildServer_Tests.cs
@@ -20,7 +20,6 @@
#endif
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
using Path = System.IO.Path;
namespace Microsoft.Build.Engine.UnitTests
diff --git a/src/MSBuild.UnitTests/Microsoft.Build.CommandLine.UnitTests.csproj b/src/MSBuild.UnitTests/Microsoft.Build.CommandLine.UnitTests.csproj
index c6926ff83b0..2e85ead1777 100644
--- a/src/MSBuild.UnitTests/Microsoft.Build.CommandLine.UnitTests.csproj
+++ b/src/MSBuild.UnitTests/Microsoft.Build.CommandLine.UnitTests.csproj
@@ -11,7 +11,7 @@
-
+
diff --git a/src/MSBuild.UnitTests/PerfLog_Tests.cs b/src/MSBuild.UnitTests/PerfLog_Tests.cs
index eadb3226199..87b2ae9bf10 100644
--- a/src/MSBuild.UnitTests/PerfLog_Tests.cs
+++ b/src/MSBuild.UnitTests/PerfLog_Tests.cs
@@ -5,7 +5,6 @@
using Microsoft.Build.UnitTests.Shared;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/MSBuild.UnitTests/XMake_BinlogSwitch_Tests.cs b/src/MSBuild.UnitTests/XMake_BinlogSwitch_Tests.cs
index af764f80e36..a6aba9a1f5f 100644
--- a/src/MSBuild.UnitTests/XMake_BinlogSwitch_Tests.cs
+++ b/src/MSBuild.UnitTests/XMake_BinlogSwitch_Tests.cs
@@ -9,7 +9,6 @@
using Microsoft.Build.UnitTests.Shared;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/MSBuild.UnitTests/XMake_Tests.cs b/src/MSBuild.UnitTests/XMake_Tests.cs
index 0941af26946..9ba8009acbd 100644
--- a/src/MSBuild.UnitTests/XMake_Tests.cs
+++ b/src/MSBuild.UnitTests/XMake_Tests.cs
@@ -22,10 +22,8 @@
using Microsoft.Build.Tasks;
using Microsoft.Build.UnitTests.Shared;
using Microsoft.Build.Utilities;
-using Microsoft.VisualStudio.TestPlatform.Utilities;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Shared/UnitTests/TestAssemblyInfo.cs b/src/Shared/UnitTests/TestAssemblyInfo.cs
index 2654f8f55c8..32da4a07636 100644
--- a/src/Shared/UnitTests/TestAssemblyInfo.cs
+++ b/src/Shared/UnitTests/TestAssemblyInfo.cs
@@ -2,9 +2,13 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System;
+using System.Collections.Generic;
using System.IO;
using System.Linq;
+using System.Reflection;
using System.Runtime.InteropServices;
+using System.Threading;
+using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq;
using Microsoft.Build.Framework;
@@ -13,39 +17,152 @@
using Microsoft.Build.UnitTests;
using Microsoft.Build.UnitTests.Shared;
using Xunit;
+using Xunit.NetCore.Extensions;
+using Xunit.Sdk;
+using Xunit.v3;
#nullable disable
[assembly: CollectionBehavior(CollectionBehavior.CollectionPerAssembly)]
-// Register test framework for assembly fixture
-[assembly: TestFramework("Xunit.NetCore.Extensions.XunitTestFrameworkWithAssemblyFixture", "Xunit.NetCore.Extensions")]
-
-[assembly: AssemblyFixture(typeof(MSBuildTestAssemblyFixture))]
+[assembly: TestPipelineStartup(typeof(MSBuildTestPipelineStartup))]
// Wrap a TestEnvironment around each test method and class so if invariants have changed we will know where
-[assembly: AssemblyFixture(typeof(MSBuildTestEnvironmentFixture), LifetimeScope = AssemblyFixtureAttribute.Scope.Class)]
-[assembly: AssemblyFixture(typeof(MSBuildTestEnvironmentFixture), LifetimeScope = AssemblyFixtureAttribute.Scope.Method)]
+[assembly: TestFramework(typeof(MSBuildTestFramework))]
namespace Microsoft.Build.UnitTests
{
- public class MSBuildTestAssemblyFixture : IDisposable
+ public class MSBuildTestFramework : XunitTestFramework
+ {
+ private sealed class MSBuildDiscoverer : ITestFrameworkDiscoverer
+ {
+ private readonly ITestFrameworkDiscoverer _wrapped;
+
+ public MSBuildDiscoverer(ITestFrameworkDiscoverer wrapped)
+ => _wrapped = wrapped;
+
+ public ITestAssembly TestAssembly => _wrapped.TestAssembly;
+
+ public ValueTask Find(Func> callback, ITestFrameworkDiscoveryOptions discoveryOptions, Type[] types = null, CancellationToken? cancellationToken = null)
+ => _wrapped.Find(testCase => callback(new MSBuildTestCase((IXunitTestCase)testCase)), discoveryOptions, types, cancellationToken);
+ }
+
+ private sealed class MSBuildTestCase : IXunitTestCase, ISelfExecutingXunitTestCase, IXunitSerializable
+ {
+ private IXunitTestCase _wrapped;
+
+ [Obsolete("Called by the de-serializer; should only be called for de-serialization purposes")]
+ public MSBuildTestCase()
+ {
+ }
+
+ public MSBuildTestCase(IXunitTestCase wrapped)
+ => _wrapped = wrapped;
+
+ public Type[] SkipExceptions => _wrapped.SkipExceptions;
+
+ public string SkipReason => _wrapped.SkipReason;
+
+ public Type SkipType => _wrapped.SkipType;
+
+ public string SkipUnless => _wrapped.SkipUnless;
+
+ public string SkipWhen => _wrapped.SkipWhen;
+
+ public IXunitTestClass TestClass => _wrapped.TestClass;
+
+ public int TestClassMetadataToken => _wrapped.TestClassMetadataToken;
+
+ public string TestClassName => _wrapped.TestClassName;
+
+ public string TestClassSimpleName => _wrapped.TestClassSimpleName;
+
+ public IXunitTestCollection TestCollection => _wrapped.TestCollection;
+
+ public IXunitTestMethod TestMethod => _wrapped.TestMethod;
+
+ public int TestMethodMetadataToken => _wrapped.TestMethodMetadataToken;
+
+ public string TestMethodName => _wrapped.TestMethodName;
+
+ public string[] TestMethodParameterTypesVSTest => _wrapped.TestMethodParameterTypesVSTest;
+
+ public string TestMethodReturnTypeVSTest => _wrapped.TestMethodReturnTypeVSTest;
+
+ public int Timeout => _wrapped.Timeout;
+
+ public bool Explicit => _wrapped.Explicit;
+
+ public string SourceFilePath => _wrapped.SourceFilePath;
+
+ public int? SourceLineNumber => _wrapped.SourceLineNumber;
+
+ public string TestCaseDisplayName => _wrapped.TestCaseDisplayName;
+
+ public string TestClassNamespace => _wrapped.TestClassNamespace;
+
+ public int? TestMethodArity => _wrapped.TestMethodArity;
+
+ public IReadOnlyDictionary> Traits => _wrapped.Traits;
+
+ public string UniqueID => _wrapped.UniqueID;
+
+ ITestClass ITestCase.TestClass => TestClass;
+
+ ITestCollection ITestCase.TestCollection => TestCollection;
+
+ ITestMethod ITestCase.TestMethod => TestMethod;
+
+ int? ITestCaseMetadata.TestClassMetadataToken => TestClassMetadataToken;
+
+ int? ITestCaseMetadata.TestMethodMetadataToken => TestMethodMetadataToken;
+
+ public ValueTask> CreateTests() => _wrapped.CreateTests();
+
+ public void PostInvoke() => _wrapped.PostInvoke();
+
+ public void PreInvoke() => _wrapped.PreInvoke();
+ public async ValueTask Run(ExplicitOption explicitOption, IMessageBus messageBus, object[] constructorArguments, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource)
+ {
+ using var _ = TestEnvironment.Create();
+ return await XunitRunnerHelper.RunXunitTestCase(
+ this,
+ messageBus,
+ cancellationTokenSource,
+ aggregator.Clone(),
+ explicitOption,
+ constructorArguments);
+ }
+
+ public void Serialize(IXunitSerializationInfo info)
+ => info.AddValue("wr", _wrapped);
+
+ public void Deserialize(IXunitSerializationInfo info)
+ => _wrapped = info.GetValue("wr");
+ }
+
+ protected override ITestFrameworkDiscoverer CreateDiscoverer(Assembly assembly) => new MSBuildDiscoverer(base.CreateDiscoverer(assembly));
+
+ protected override ITestFrameworkExecutor CreateExecutor(Assembly assembly) => base.CreateExecutor(assembly);
+ }
+
+ public class MSBuildTestPipelineStartup : ITestPipelineStartup
{
private bool _disposed;
private TestEnvironment _testEnvironment;
- public MSBuildTestAssemblyFixture()
+ public MSBuildTestPipelineStartup()
{
// Set field to indicate tests are running in the TestInfo class in Microsoft.Build.Framework.
// See the comments on the TestInfo class for an explanation of why it works this way.
- var frameworkAssembly = typeof(Microsoft.Build.Framework.ITask).Assembly;
+ var frameworkAssembly = typeof(ITask).Assembly;
var testInfoType = frameworkAssembly.GetType("Microsoft.Build.Framework.TestInfo");
- var runningTestsField = testInfoType.GetField("s_runningTests", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);
+ var runningTestsField = testInfoType.GetField("s_runningTests", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static);
runningTestsField.SetValue(null, true);
// Set the field in BuildEnvironmentState - as it might have been already preintialized by the data preparation of data driven tests
testInfoType = frameworkAssembly.GetType("Microsoft.Build.Framework.BuildEnvironmentState");
- runningTestsField = testInfoType.GetField("s_runningTests", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);
+ runningTestsField = testInfoType.GetField("s_runningTests", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static);
runningTestsField.SetValue(null, true);
// BuildEnvironment instance may be initialized in some tests' static members before s_runningTests is set
@@ -110,8 +227,8 @@ public MSBuildTestAssemblyFixture()
fileName: "Directory.Build.targets",
contents: "");
}
-
- public void Dispose()
+
+ public ValueTask StopAsync()
{
if (!_disposed)
{
@@ -119,27 +236,10 @@ public void Dispose()
_disposed = true;
}
- }
- }
- public class MSBuildTestEnvironmentFixture : IDisposable
- {
- private bool _disposed;
- private TestEnvironment _testEnvironment;
-
- public MSBuildTestEnvironmentFixture()
- {
- _testEnvironment = TestEnvironment.Create();
+ return default;
}
- public void Dispose()
- {
- if (!_disposed)
- {
- _testEnvironment.Dispose();
-
- _disposed = true;
- }
- }
+ public ValueTask StartAsync(IMessageSink diagnosticMessageSink) => default;
}
}
diff --git a/src/Shared/UnitTests/TestProgram.cs b/src/Shared/UnitTests/TestProgram.cs
deleted file mode 100644
index ecfb5780562..00000000000
--- a/src/Shared/UnitTests/TestProgram.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-using System;
-using System.Collections.Generic;
-
-internal sealed class Program
-{
- public static int Main(string[] args)
- {
-#if RUNTIME_TYPE_NETCORE
- var newArgs = new List(args);
- newArgs.Insert(0, typeof(Program).Assembly.Location);
-
- int returnCode = Xunit.ConsoleClient.Program.Main(newArgs.ToArray());
-
- // if (showHelp)
- // {
- // TestCommandLine.ShowHelp();
- // }
-
- return returnCode;
-#else
- throw new NotImplementedException();
-#endif
- }
-}
diff --git a/src/Shared/UnitTests/TypeLoader_Tests.cs b/src/Shared/UnitTests/TypeLoader_Tests.cs
index 048ba6ceebd..e691716847e 100644
--- a/src/Shared/UnitTests/TypeLoader_Tests.cs
+++ b/src/Shared/UnitTests/TypeLoader_Tests.cs
@@ -11,7 +11,6 @@
using Microsoft.Build.UnitTests.Shared;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Shared/UnitTests/xunit.runner.json b/src/Shared/UnitTests/xunit.runner.json
index 2677ff464a7..63779c51164 100644
--- a/src/Shared/UnitTests/xunit.runner.json
+++ b/src/Shared/UnitTests/xunit.runner.json
@@ -1,7 +1,5 @@
{
"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
- "shadowCopy": false,
- "appDomain": "required",
"longRunningTestSeconds": 60,
"maxParallelThreads": 1,
"parallelizeTestCollections": false,
diff --git a/src/StringTools.UnitTests/InterningTestData.cs b/src/StringTools.UnitTests/InterningTestData.cs
index 28fc95ac0e2..19f303d0299 100644
--- a/src/StringTools.UnitTests/InterningTestData.cs
+++ b/src/StringTools.UnitTests/InterningTestData.cs
@@ -2,8 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections.Generic;
-
-using Xunit.Abstractions;
+using Xunit.Sdk;
#nullable disable
diff --git a/src/StringTools.UnitTests/StringTools.UnitTests.net35.csproj b/src/StringTools.UnitTests/StringTools.UnitTests.net35.csproj
index 7e01392da19..dc64fa15f1e 100644
--- a/src/StringTools.UnitTests/StringTools.UnitTests.net35.csproj
+++ b/src/StringTools.UnitTests/StringTools.UnitTests.net35.csproj
@@ -10,6 +10,7 @@
true
true
true
+ Exe
false
diff --git a/src/Tasks.UnitTests/AddToWin32Manifest_Tests.cs b/src/Tasks.UnitTests/AddToWin32Manifest_Tests.cs
index 78a8b68d00a..a8ebc64a225 100644
--- a/src/Tasks.UnitTests/AddToWin32Manifest_Tests.cs
+++ b/src/Tasks.UnitTests/AddToWin32Manifest_Tests.cs
@@ -11,7 +11,6 @@
using Microsoft.Build.Utilities;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
namespace Microsoft.Build.Tasks.UnitTests
{
diff --git a/src/Tasks.UnitTests/Al_Tests.cs b/src/Tasks.UnitTests/Al_Tests.cs
index 72960a64e59..faaeea637ae 100644
--- a/src/Tasks.UnitTests/Al_Tests.cs
+++ b/src/Tasks.UnitTests/Al_Tests.cs
@@ -8,7 +8,6 @@
using Microsoft.Build.Utilities;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Tasks.UnitTests/AspNetCompiler_Tests.cs b/src/Tasks.UnitTests/AspNetCompiler_Tests.cs
index 0162f95c94d..e69f076a397 100644
--- a/src/Tasks.UnitTests/AspNetCompiler_Tests.cs
+++ b/src/Tasks.UnitTests/AspNetCompiler_Tests.cs
@@ -11,7 +11,6 @@
using Microsoft.Build.Evaluation;
using Microsoft.Build.Tasks;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Tasks.UnitTests/AssemblyDependency/AssemblyFoldersFromConfig_Tests.cs b/src/Tasks.UnitTests/AssemblyDependency/AssemblyFoldersFromConfig_Tests.cs
index fdda7956108..e493b7d9b11 100644
--- a/src/Tasks.UnitTests/AssemblyDependency/AssemblyFoldersFromConfig_Tests.cs
+++ b/src/Tasks.UnitTests/AssemblyDependency/AssemblyFoldersFromConfig_Tests.cs
@@ -9,7 +9,6 @@
using Microsoft.Build.Utilities;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Tasks.UnitTests/AssemblyDependency/FilePrimary.cs b/src/Tasks.UnitTests/AssemblyDependency/FilePrimary.cs
index 5f0d4ad6f1a..a81f24fc635 100644
--- a/src/Tasks.UnitTests/AssemblyDependency/FilePrimary.cs
+++ b/src/Tasks.UnitTests/AssemblyDependency/FilePrimary.cs
@@ -9,7 +9,6 @@
using Microsoft.Build.Utilities;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Tasks.UnitTests/AssemblyDependency/GlobalAssemblyCacheTests.cs b/src/Tasks.UnitTests/AssemblyDependency/GlobalAssemblyCacheTests.cs
index f320ee47e70..b08a9c21a22 100644
--- a/src/Tasks.UnitTests/AssemblyDependency/GlobalAssemblyCacheTests.cs
+++ b/src/Tasks.UnitTests/AssemblyDependency/GlobalAssemblyCacheTests.cs
@@ -10,7 +10,6 @@
using Microsoft.Build.Tasks;
using Microsoft.Build.Utilities;
using Xunit;
-using Xunit.Abstractions;
using SystemProcessorArchitecture = System.Reflection.ProcessorArchitecture;
#nullable disable
diff --git a/src/Tasks.UnitTests/AssemblyDependency/InstalledSDKResolverFixture.cs b/src/Tasks.UnitTests/AssemblyDependency/InstalledSDKResolverFixture.cs
index cdacfae192e..6a214b373d8 100644
--- a/src/Tasks.UnitTests/AssemblyDependency/InstalledSDKResolverFixture.cs
+++ b/src/Tasks.UnitTests/AssemblyDependency/InstalledSDKResolverFixture.cs
@@ -6,7 +6,6 @@
using Microsoft.Build.Tasks;
using Microsoft.Build.Utilities;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Tasks.UnitTests/AssemblyDependency/Miscellaneous.cs b/src/Tasks.UnitTests/AssemblyDependency/Miscellaneous.cs
index 669d367e140..32a57278a7b 100644
--- a/src/Tasks.UnitTests/AssemblyDependency/Miscellaneous.cs
+++ b/src/Tasks.UnitTests/AssemblyDependency/Miscellaneous.cs
@@ -17,7 +17,6 @@
using Microsoft.Win32;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
using FrameworkNameVersioning = System.Runtime.Versioning.FrameworkName;
using SystemProcessorArchitecture = System.Reflection.ProcessorArchitecture;
diff --git a/src/Tasks.UnitTests/AssemblyDependency/Node/OutOfProcRarNode_Tests.cs b/src/Tasks.UnitTests/AssemblyDependency/Node/OutOfProcRarNode_Tests.cs
index d3427ddeb7f..56a62f79a80 100644
--- a/src/Tasks.UnitTests/AssemblyDependency/Node/OutOfProcRarNode_Tests.cs
+++ b/src/Tasks.UnitTests/AssemblyDependency/Node/OutOfProcRarNode_Tests.cs
@@ -13,7 +13,6 @@
using Microsoft.Build.UnitTests;
using Microsoft.Build.Utilities;
using Xunit;
-using Xunit.Abstractions;
namespace Microsoft.Build.UnitTests.ResolveAssemblyReference_Tests
{
diff --git a/src/Tasks.UnitTests/AssemblyDependency/NonSpecificVersionStrictPrimary.cs b/src/Tasks.UnitTests/AssemblyDependency/NonSpecificVersionStrictPrimary.cs
index 230080b2f31..e445209045a 100644
--- a/src/Tasks.UnitTests/AssemblyDependency/NonSpecificVersionStrictPrimary.cs
+++ b/src/Tasks.UnitTests/AssemblyDependency/NonSpecificVersionStrictPrimary.cs
@@ -7,7 +7,6 @@
using Microsoft.Build.Utilities;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Tasks.UnitTests/AssemblyDependency/Perf.cs b/src/Tasks.UnitTests/AssemblyDependency/Perf.cs
index 57cea08b129..dccccf6f98f 100644
--- a/src/Tasks.UnitTests/AssemblyDependency/Perf.cs
+++ b/src/Tasks.UnitTests/AssemblyDependency/Perf.cs
@@ -9,7 +9,6 @@
using Microsoft.Build.Utilities;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Tasks.UnitTests/AssemblyDependency/ReferenceTests.cs b/src/Tasks.UnitTests/AssemblyDependency/ReferenceTests.cs
index 800790125d1..830f41cdacf 100644
--- a/src/Tasks.UnitTests/AssemblyDependency/ReferenceTests.cs
+++ b/src/Tasks.UnitTests/AssemblyDependency/ReferenceTests.cs
@@ -5,7 +5,6 @@
using Microsoft.Build.Tasks;
using Microsoft.Build.Utilities;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Tasks.UnitTests/AssemblyDependency/ResolveAssemblyReferenceTestFixture.cs b/src/Tasks.UnitTests/AssemblyDependency/ResolveAssemblyReferenceTestFixture.cs
index e6b39fd0e94..ee85b41f383 100644
--- a/src/Tasks.UnitTests/AssemblyDependency/ResolveAssemblyReferenceTestFixture.cs
+++ b/src/Tasks.UnitTests/AssemblyDependency/ResolveAssemblyReferenceTestFixture.cs
@@ -14,7 +14,6 @@
using Microsoft.Build.Utilities;
using Microsoft.Win32;
using Xunit;
-using Xunit.Abstractions;
using FrameworkNameVersioning = System.Runtime.Versioning.FrameworkName;
using NativeMethods = Microsoft.Build.Tasks.NativeMethods;
using SystemProcessorArchitecture = System.Reflection.ProcessorArchitecture;
diff --git a/src/Tasks.UnitTests/AssemblyDependency/SpecificVersionPrimary.cs b/src/Tasks.UnitTests/AssemblyDependency/SpecificVersionPrimary.cs
index c11fc53cfcc..a7fb899d4f8 100644
--- a/src/Tasks.UnitTests/AssemblyDependency/SpecificVersionPrimary.cs
+++ b/src/Tasks.UnitTests/AssemblyDependency/SpecificVersionPrimary.cs
@@ -8,7 +8,6 @@
using Microsoft.Build.Utilities;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Tasks.UnitTests/AssemblyDependency/StronglyNamedDependency.cs b/src/Tasks.UnitTests/AssemblyDependency/StronglyNamedDependency.cs
index 1ef6412f355..64ec1d5dae6 100644
--- a/src/Tasks.UnitTests/AssemblyDependency/StronglyNamedDependency.cs
+++ b/src/Tasks.UnitTests/AssemblyDependency/StronglyNamedDependency.cs
@@ -10,7 +10,6 @@
using Microsoft.Build.Utilities;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Tasks.UnitTests/AssemblyDependency/StronglyNamedDependencyAppConfig.cs b/src/Tasks.UnitTests/AssemblyDependency/StronglyNamedDependencyAppConfig.cs
index c4f0bd34510..90b8ff8caea 100644
--- a/src/Tasks.UnitTests/AssemblyDependency/StronglyNamedDependencyAppConfig.cs
+++ b/src/Tasks.UnitTests/AssemblyDependency/StronglyNamedDependencyAppConfig.cs
@@ -9,7 +9,6 @@
using Microsoft.Build.Utilities;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Tasks.UnitTests/AssemblyDependency/StronglyNamedDependencyAutoUnify.cs b/src/Tasks.UnitTests/AssemblyDependency/StronglyNamedDependencyAutoUnify.cs
index eff546bcd3d..e336ef4febd 100644
--- a/src/Tasks.UnitTests/AssemblyDependency/StronglyNamedDependencyAutoUnify.cs
+++ b/src/Tasks.UnitTests/AssemblyDependency/StronglyNamedDependencyAutoUnify.cs
@@ -9,7 +9,6 @@
using Microsoft.Build.Utilities;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Tasks.UnitTests/AssemblyDependency/SuggestedRedirects.cs b/src/Tasks.UnitTests/AssemblyDependency/SuggestedRedirects.cs
index 2dc93f2fe56..d45e0ff7f38 100644
--- a/src/Tasks.UnitTests/AssemblyDependency/SuggestedRedirects.cs
+++ b/src/Tasks.UnitTests/AssemblyDependency/SuggestedRedirects.cs
@@ -11,7 +11,6 @@
using Microsoft.Build.Utilities;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Tasks.UnitTests/AssemblyDependency/VerifyIgnoreVersionForFrameworkReference.cs b/src/Tasks.UnitTests/AssemblyDependency/VerifyIgnoreVersionForFrameworkReference.cs
index 52277dbbd1f..e6e5f93dd52 100644
--- a/src/Tasks.UnitTests/AssemblyDependency/VerifyIgnoreVersionForFrameworkReference.cs
+++ b/src/Tasks.UnitTests/AssemblyDependency/VerifyIgnoreVersionForFrameworkReference.cs
@@ -6,7 +6,6 @@
using Microsoft.Build.Tasks;
using Microsoft.Build.Utilities;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Tasks.UnitTests/AssemblyDependency/VerifyTargetFrameworkAttribute.cs b/src/Tasks.UnitTests/AssemblyDependency/VerifyTargetFrameworkAttribute.cs
index 7d92fe9e630..ced2b80ac2a 100644
--- a/src/Tasks.UnitTests/AssemblyDependency/VerifyTargetFrameworkAttribute.cs
+++ b/src/Tasks.UnitTests/AssemblyDependency/VerifyTargetFrameworkAttribute.cs
@@ -6,7 +6,6 @@
using Microsoft.Build.Tasks;
using Microsoft.Build.Utilities;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Tasks.UnitTests/AssemblyDependency/VerifyTargetFrameworkHigherThanRedist.cs b/src/Tasks.UnitTests/AssemblyDependency/VerifyTargetFrameworkHigherThanRedist.cs
index 6435b8cddaa..9490dca5559 100644
--- a/src/Tasks.UnitTests/AssemblyDependency/VerifyTargetFrameworkHigherThanRedist.cs
+++ b/src/Tasks.UnitTests/AssemblyDependency/VerifyTargetFrameworkHigherThanRedist.cs
@@ -7,7 +7,6 @@
using Microsoft.Build.Tasks;
using Microsoft.Build.Utilities;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Tasks.UnitTests/AssemblyDependency/WinMDTests.cs b/src/Tasks.UnitTests/AssemblyDependency/WinMDTests.cs
index 285438b8181..2f949c261ec 100644
--- a/src/Tasks.UnitTests/AssemblyDependency/WinMDTests.cs
+++ b/src/Tasks.UnitTests/AssemblyDependency/WinMDTests.cs
@@ -9,7 +9,6 @@
using Microsoft.Build.Utilities;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Tasks.UnitTests/AssignProjectConfiguration_Tests.cs b/src/Tasks.UnitTests/AssignProjectConfiguration_Tests.cs
index 5a84c242c91..f8fe46f30b4 100644
--- a/src/Tasks.UnitTests/AssignProjectConfiguration_Tests.cs
+++ b/src/Tasks.UnitTests/AssignProjectConfiguration_Tests.cs
@@ -8,7 +8,6 @@
using Microsoft.Build.Tasks;
using Microsoft.Build.Utilities;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Tasks.UnitTests/Copy_Tests.cs b/src/Tasks.UnitTests/Copy_Tests.cs
index ab10d6d2f95..2f15765ec17 100644
--- a/src/Tasks.UnitTests/Copy_Tests.cs
+++ b/src/Tasks.UnitTests/Copy_Tests.cs
@@ -20,7 +20,6 @@
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
using Microsoft.Build.UnitTests.Shared;
#nullable disable
diff --git a/src/Tasks.UnitTests/CreateCSharpManifestResourceName_Tests.cs b/src/Tasks.UnitTests/CreateCSharpManifestResourceName_Tests.cs
index a29f5b938fc..0d6ed50ad59 100644
--- a/src/Tasks.UnitTests/CreateCSharpManifestResourceName_Tests.cs
+++ b/src/Tasks.UnitTests/CreateCSharpManifestResourceName_Tests.cs
@@ -10,7 +10,6 @@
using Microsoft.Build.Utilities;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Tasks.UnitTests/CreateItem_Tests.cs b/src/Tasks.UnitTests/CreateItem_Tests.cs
index 90a57722f30..d75da37b32b 100644
--- a/src/Tasks.UnitTests/CreateItem_Tests.cs
+++ b/src/Tasks.UnitTests/CreateItem_Tests.cs
@@ -11,7 +11,6 @@
using Microsoft.Build.Utilities;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Tasks.UnitTests/CreateVisualBasicManifestResourceName_Tests.cs b/src/Tasks.UnitTests/CreateVisualBasicManifestResourceName_Tests.cs
index 567eea82ab6..28c15eb8a90 100644
--- a/src/Tasks.UnitTests/CreateVisualBasicManifestResourceName_Tests.cs
+++ b/src/Tasks.UnitTests/CreateVisualBasicManifestResourceName_Tests.cs
@@ -10,7 +10,6 @@
using Microsoft.Build.Utilities;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Tasks.UnitTests/Exec_Tests.cs b/src/Tasks.UnitTests/Exec_Tests.cs
index 3a820e75421..87fc5dc829c 100644
--- a/src/Tasks.UnitTests/Exec_Tests.cs
+++ b/src/Tasks.UnitTests/Exec_Tests.cs
@@ -15,7 +15,6 @@
using Microsoft.Build.Utilities;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Tasks.UnitTests/FormatUrl_Tests.cs b/src/Tasks.UnitTests/FormatUrl_Tests.cs
index 8cc77f6358a..14d738e5e09 100644
--- a/src/Tasks.UnitTests/FormatUrl_Tests.cs
+++ b/src/Tasks.UnitTests/FormatUrl_Tests.cs
@@ -6,7 +6,6 @@
using Microsoft.Build.Tasks;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
namespace Microsoft.Build.UnitTests
{
diff --git a/src/Tasks.UnitTests/GenerateBindingRedirects_Tests.cs b/src/Tasks.UnitTests/GenerateBindingRedirects_Tests.cs
index 966c283b634..a38fe19755e 100644
--- a/src/Tasks.UnitTests/GenerateBindingRedirects_Tests.cs
+++ b/src/Tasks.UnitTests/GenerateBindingRedirects_Tests.cs
@@ -11,7 +11,6 @@
using Microsoft.Build.Utilities;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Tasks.UnitTests/GetAssembliesMetadata_Tests.cs b/src/Tasks.UnitTests/GetAssembliesMetadata_Tests.cs
index 1c8bcd0ccf3..c02b4a37678 100644
--- a/src/Tasks.UnitTests/GetAssembliesMetadata_Tests.cs
+++ b/src/Tasks.UnitTests/GetAssembliesMetadata_Tests.cs
@@ -13,7 +13,6 @@
using Microsoft.Build.UnitTests.Shared;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
using Xunit.Sdk;
namespace Microsoft.Build.Tasks.UnitTests
diff --git a/src/Tasks.UnitTests/GetCompatiblePlatform_Tests.cs b/src/Tasks.UnitTests/GetCompatiblePlatform_Tests.cs
index d9359ef1a6c..cee0d2f4fa7 100644
--- a/src/Tasks.UnitTests/GetCompatiblePlatform_Tests.cs
+++ b/src/Tasks.UnitTests/GetCompatiblePlatform_Tests.cs
@@ -5,7 +5,6 @@
using Microsoft.Build.Utilities;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Tasks.UnitTests/GetFileHash_Tests.cs b/src/Tasks.UnitTests/GetFileHash_Tests.cs
index c2abb7f0168..119cf3976bc 100644
--- a/src/Tasks.UnitTests/GetFileHash_Tests.cs
+++ b/src/Tasks.UnitTests/GetFileHash_Tests.cs
@@ -8,7 +8,6 @@
using Microsoft.Build.Utilities;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Tasks.UnitTests/GetSDKReference_Tests.cs b/src/Tasks.UnitTests/GetSDKReference_Tests.cs
index f5ff062f87b..eb76a457e9a 100644
--- a/src/Tasks.UnitTests/GetSDKReference_Tests.cs
+++ b/src/Tasks.UnitTests/GetSDKReference_Tests.cs
@@ -11,7 +11,6 @@
using Microsoft.Build.Utilities;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Tasks.UnitTests/HintPathResolver_Tests.cs b/src/Tasks.UnitTests/HintPathResolver_Tests.cs
index 7849b653fdb..a40170b3152 100644
--- a/src/Tasks.UnitTests/HintPathResolver_Tests.cs
+++ b/src/Tasks.UnitTests/HintPathResolver_Tests.cs
@@ -8,7 +8,6 @@
using Microsoft.Build.UnitTests;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Tasks.UnitTests/MSBuildInternalMessage_Tests.cs b/src/Tasks.UnitTests/MSBuildInternalMessage_Tests.cs
index cc020da8904..aa4bf96f007 100644
--- a/src/Tasks.UnitTests/MSBuildInternalMessage_Tests.cs
+++ b/src/Tasks.UnitTests/MSBuildInternalMessage_Tests.cs
@@ -7,7 +7,6 @@
using Microsoft.Build.UnitTests;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
namespace Microsoft.Build.Tasks.UnitTests
{
diff --git a/src/Tasks.UnitTests/MSBuild_Tests.cs b/src/Tasks.UnitTests/MSBuild_Tests.cs
index 9a17e9b848f..30923cc24f4 100644
--- a/src/Tasks.UnitTests/MSBuild_Tests.cs
+++ b/src/Tasks.UnitTests/MSBuild_Tests.cs
@@ -13,7 +13,6 @@
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Tasks.UnitTests/Microsoft.Build.Tasks.UnitTests.csproj b/src/Tasks.UnitTests/Microsoft.Build.Tasks.UnitTests.csproj
index 801e8c76483..1c1696e6440 100644
--- a/src/Tasks.UnitTests/Microsoft.Build.Tasks.UnitTests.csproj
+++ b/src/Tasks.UnitTests/Microsoft.Build.Tasks.UnitTests.csproj
@@ -17,7 +17,7 @@
-
+
diff --git a/src/Tasks.UnitTests/OutputPathTests.cs b/src/Tasks.UnitTests/OutputPathTests.cs
index ea7cfbb1f33..8ccccd3755e 100644
--- a/src/Tasks.UnitTests/OutputPathTests.cs
+++ b/src/Tasks.UnitTests/OutputPathTests.cs
@@ -12,7 +12,6 @@
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Tasks.UnitTests/PortableTasks_Tests.cs b/src/Tasks.UnitTests/PortableTasks_Tests.cs
index cd051c5a90e..b8f3468388d 100644
--- a/src/Tasks.UnitTests/PortableTasks_Tests.cs
+++ b/src/Tasks.UnitTests/PortableTasks_Tests.cs
@@ -8,7 +8,6 @@
using Microsoft.Build.UnitTests.Shared;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Tasks.UnitTests/RegressionTests.cs b/src/Tasks.UnitTests/RegressionTests.cs
index 924a0adb84b..e82e09f9445 100644
--- a/src/Tasks.UnitTests/RegressionTests.cs
+++ b/src/Tasks.UnitTests/RegressionTests.cs
@@ -7,7 +7,6 @@
using Microsoft.Build.Shared;
using Microsoft.Build.UnitTests;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Tasks.UnitTests/RemoveDir_Tests.cs b/src/Tasks.UnitTests/RemoveDir_Tests.cs
index 5e01b3a91de..a4204ece5fc 100644
--- a/src/Tasks.UnitTests/RemoveDir_Tests.cs
+++ b/src/Tasks.UnitTests/RemoveDir_Tests.cs
@@ -8,7 +8,6 @@
using Microsoft.Build.Utilities;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Tasks.UnitTests/ResolveAssemblyReference_CustomCultureTests.cs b/src/Tasks.UnitTests/ResolveAssemblyReference_CustomCultureTests.cs
index c1fc65403fd..dd4ab6216fd 100644
--- a/src/Tasks.UnitTests/ResolveAssemblyReference_CustomCultureTests.cs
+++ b/src/Tasks.UnitTests/ResolveAssemblyReference_CustomCultureTests.cs
@@ -7,7 +7,6 @@
using Microsoft.Build.UnitTests.Shared;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
namespace Microsoft.Build.Tasks.UnitTests
{
diff --git a/src/Tasks.UnitTests/ResolveNonMSBuildProjectOutput_Tests.cs b/src/Tasks.UnitTests/ResolveNonMSBuildProjectOutput_Tests.cs
index 5de1bfcf5fb..7dae22e9b1c 100644
--- a/src/Tasks.UnitTests/ResolveNonMSBuildProjectOutput_Tests.cs
+++ b/src/Tasks.UnitTests/ResolveNonMSBuildProjectOutput_Tests.cs
@@ -8,7 +8,6 @@
using Microsoft.Build.Tasks;
using Microsoft.Build.Utilities;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Tasks.UnitTests/ResourceHandling/GenerateResourceOutOfProc_Tests.cs b/src/Tasks.UnitTests/ResourceHandling/GenerateResourceOutOfProc_Tests.cs
index b9d1c4eae42..dd8eca60be1 100644
--- a/src/Tasks.UnitTests/ResourceHandling/GenerateResourceOutOfProc_Tests.cs
+++ b/src/Tasks.UnitTests/ResourceHandling/GenerateResourceOutOfProc_Tests.cs
@@ -10,7 +10,6 @@
using Microsoft.Build.Utilities;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Tasks.UnitTests/ResourceHandling/GenerateResource_Tests.cs b/src/Tasks.UnitTests/ResourceHandling/GenerateResource_Tests.cs
index 70ac4f19f7b..0f16e5f9287 100644
--- a/src/Tasks.UnitTests/ResourceHandling/GenerateResource_Tests.cs
+++ b/src/Tasks.UnitTests/ResourceHandling/GenerateResource_Tests.cs
@@ -14,7 +14,6 @@
using Microsoft.Build.Utilities;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Tasks.UnitTests/ResourceHandling/MSBuildResXReader_Tests.cs b/src/Tasks.UnitTests/ResourceHandling/MSBuildResXReader_Tests.cs
index 9ebe60a62ee..094891584d6 100644
--- a/src/Tasks.UnitTests/ResourceHandling/MSBuildResXReader_Tests.cs
+++ b/src/Tasks.UnitTests/ResourceHandling/MSBuildResXReader_Tests.cs
@@ -9,7 +9,6 @@
using Microsoft.Build.UnitTests;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Tasks.UnitTests/ResourceHandling/ResGenDependencies_Tests.cs b/src/Tasks.UnitTests/ResourceHandling/ResGenDependencies_Tests.cs
index acd43836a7f..aa5027a4329 100644
--- a/src/Tasks.UnitTests/ResourceHandling/ResGenDependencies_Tests.cs
+++ b/src/Tasks.UnitTests/ResourceHandling/ResGenDependencies_Tests.cs
@@ -12,7 +12,6 @@
using Microsoft.Build.UnitTests;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Tasks.UnitTests/RoslynCodeTaskFactory_Tests.cs b/src/Tasks.UnitTests/RoslynCodeTaskFactory_Tests.cs
index 4885e53ec8d..eb8430cdfab 100644
--- a/src/Tasks.UnitTests/RoslynCodeTaskFactory_Tests.cs
+++ b/src/Tasks.UnitTests/RoslynCodeTaskFactory_Tests.cs
@@ -18,7 +18,6 @@
using VerifyTests;
using VerifyXunit;
using Xunit;
-using Xunit.Abstractions;
using static VerifyXunit.Verifier;
@@ -26,7 +25,6 @@
namespace Microsoft.Build.Tasks.UnitTests
{
- [UsesVerify]
public class RoslynCodeTaskFactory_Tests
{
private const string TaskName = "MyInlineTask";
diff --git a/src/Tasks.UnitTests/TestResources/TestBinary.cs b/src/Tasks.UnitTests/TestResources/TestBinary.cs
index 411637d381e..1a2f96a2e93 100644
--- a/src/Tasks.UnitTests/TestResources/TestBinary.cs
+++ b/src/Tasks.UnitTests/TestResources/TestBinary.cs
@@ -4,7 +4,7 @@
using System;
using System.IO;
using Xunit;
-using Xunit.Abstractions;
+using Xunit.Sdk;
#nullable disable
diff --git a/src/Tasks.UnitTests/Unzip_Tests.cs b/src/Tasks.UnitTests/Unzip_Tests.cs
index 1b7de792757..74efe833a40 100644
--- a/src/Tasks.UnitTests/Unzip_Tests.cs
+++ b/src/Tasks.UnitTests/Unzip_Tests.cs
@@ -178,9 +178,14 @@ public static bool NotRunningAsRoot()
return process.StandardOutput.ReadToEnd().Trim() != "0";
}
- [ConditionalFact(nameof(NotRunningAsRoot))] // root can write to read-only files
+ [Fact]
public void LogsErrorIfReadOnlyFileCannotBeOverwitten()
{
+ if (!NotRunningAsRoot())
+ {
+ Assert.Skip("root can write to read-only files");
+ }
+
using (TestEnvironment testEnvironment = TestEnvironment.Create())
{
TransientTestFolder source = testEnvironment.CreateFolder(createFolder: true);
diff --git a/src/Tasks.UnitTests/VerifyFileHash_Tests.cs b/src/Tasks.UnitTests/VerifyFileHash_Tests.cs
index 4cf2f372704..2827a47fe9f 100644
--- a/src/Tasks.UnitTests/VerifyFileHash_Tests.cs
+++ b/src/Tasks.UnitTests/VerifyFileHash_Tests.cs
@@ -7,7 +7,6 @@
using Microsoft.Build.Tasks.UnitTests.TestResources;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Tasks.UnitTests/WriteLinesToFile_Tests.cs b/src/Tasks.UnitTests/WriteLinesToFile_Tests.cs
index 55f0efb9870..2ea0830290a 100644
--- a/src/Tasks.UnitTests/WriteLinesToFile_Tests.cs
+++ b/src/Tasks.UnitTests/WriteLinesToFile_Tests.cs
@@ -14,7 +14,6 @@
using Microsoft.Build.Utilities;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Tasks.UnitTests/XamlDataDrivenToolTask_Tests.cs b/src/Tasks.UnitTests/XamlDataDrivenToolTask_Tests.cs
index 060a42bb9a3..ad62f4af2b8 100644
--- a/src/Tasks.UnitTests/XamlDataDrivenToolTask_Tests.cs
+++ b/src/Tasks.UnitTests/XamlDataDrivenToolTask_Tests.cs
@@ -12,7 +12,6 @@
using Microsoft.Build.Utilities;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/UnitTests.Shared/Microsoft.Build.UnitTests.Shared.csproj b/src/UnitTests.Shared/Microsoft.Build.UnitTests.Shared.csproj
index 73c968b3d22..a10bd888634 100644
--- a/src/UnitTests.Shared/Microsoft.Build.UnitTests.Shared.csproj
+++ b/src/UnitTests.Shared/Microsoft.Build.UnitTests.Shared.csproj
@@ -4,14 +4,11 @@
Microsoft.Build.UnitTests.Shared
true
false
- false
true
-
-
-
+
+
diff --git a/src/UnitTests.Shared/MockEngine.cs b/src/UnitTests.Shared/MockEngine.cs
index 9b21b43cf90..08b4cf2732f 100644
--- a/src/UnitTests.Shared/MockEngine.cs
+++ b/src/UnitTests.Shared/MockEngine.cs
@@ -12,7 +12,7 @@
using Microsoft.Build.Logging;
using Shouldly;
-using Xunit.Abstractions;
+using Xunit;
#nullable disable
diff --git a/src/UnitTests.Shared/MockLogger.cs b/src/UnitTests.Shared/MockLogger.cs
index ba8c937e598..bb3c4e72ab6 100644
--- a/src/UnitTests.Shared/MockLogger.cs
+++ b/src/UnitTests.Shared/MockLogger.cs
@@ -12,7 +12,6 @@
using Microsoft.Build.Framework;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
using ProjectCollection = Microsoft.Build.Evaluation.ProjectCollection;
#nullable disable
diff --git a/src/UnitTests.Shared/ObjectModelHelpers.cs b/src/UnitTests.Shared/ObjectModelHelpers.cs
index f7867edce49..4d6aeb152d6 100644
--- a/src/UnitTests.Shared/ObjectModelHelpers.cs
+++ b/src/UnitTests.Shared/ObjectModelHelpers.cs
@@ -25,7 +25,6 @@
using Microsoft.Build.Shared.FileSystem;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/UnitTests.Shared/RunnerUtilities.cs b/src/UnitTests.Shared/RunnerUtilities.cs
index 0874b996907..6bd047693dd 100644
--- a/src/UnitTests.Shared/RunnerUtilities.cs
+++ b/src/UnitTests.Shared/RunnerUtilities.cs
@@ -9,7 +9,7 @@
using Microsoft.Build.Framework;
using Microsoft.Build.Internal;
using Microsoft.Build.Shared;
-using Xunit.Abstractions;
+using Xunit;
using Constants = Microsoft.Build.Framework.Constants;
#nullable disable
diff --git a/src/UnitTests.Shared/TestEnvironment.cs b/src/UnitTests.Shared/TestEnvironment.cs
index f031a0bd834..f659c70b6c9 100644
--- a/src/UnitTests.Shared/TestEnvironment.cs
+++ b/src/UnitTests.Shared/TestEnvironment.cs
@@ -8,6 +8,7 @@
using System.IO;
using System.IO.Compression;
using System.Linq;
+using System.Text;
using System.Text.RegularExpressions;
using Microsoft.Build.Framework;
using Microsoft.Build.Internal;
@@ -17,7 +18,6 @@
using Microsoft.Build.UnitTests.Shared;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
using CommonWriterType = System.Action>;
using TempPaths = System.Collections.Generic.Dictionary;
@@ -396,6 +396,15 @@ public TransientDebugEngine WithTransientDebugEngineForNewProcesses(bool state)
private sealed class DefaultOutput : ITestOutputHelper
{
+ // Probably unreachable. Don't bother implementing it unless we hit this exception.
+ public string Output => throw new InvalidOperationException();
+
+ public void Write(string message)
+ => Console.Write(message);
+
+ public void Write(string format, params object[] args)
+ => Console.Write(format, args);
+
public void WriteLine(string message)
{
Console.WriteLine(message);
diff --git a/src/Utilities.UnitTests/ProcessExtensions_Tests.cs b/src/Utilities.UnitTests/ProcessExtensions_Tests.cs
index 7f4bbc61950..22a9e916a30 100644
--- a/src/Utilities.UnitTests/ProcessExtensions_Tests.cs
+++ b/src/Utilities.UnitTests/ProcessExtensions_Tests.cs
@@ -6,7 +6,6 @@
using Microsoft.Build.Shared;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Utilities.UnitTests/ToolLocationHelper_Tests.cs b/src/Utilities.UnitTests/ToolLocationHelper_Tests.cs
index d18d9a48ff6..c22a4d6e9d7 100644
--- a/src/Utilities.UnitTests/ToolLocationHelper_Tests.cs
+++ b/src/Utilities.UnitTests/ToolLocationHelper_Tests.cs
@@ -22,7 +22,6 @@
using UtilitiesDotNetFrameworkArchitecture = Microsoft.Build.Utilities.DotNetFrameworkArchitecture;
using SharedDotNetFrameworkArchitecture = Microsoft.Build.Shared.DotNetFrameworkArchitecture;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Utilities.UnitTests/ToolTask_Tests.cs b/src/Utilities.UnitTests/ToolTask_Tests.cs
index 77af6815973..cb02b22cba5 100644
--- a/src/Utilities.UnitTests/ToolTask_Tests.cs
+++ b/src/Utilities.UnitTests/ToolTask_Tests.cs
@@ -13,7 +13,6 @@
using Microsoft.Build.Utilities;
using Shouldly;
using Xunit;
-using Xunit.Abstractions;
#nullable disable
diff --git a/src/Xunit.NetCore.Extensions/AssemblyFixtureSupport/AssemblyFixtureAttribute.cs b/src/Xunit.NetCore.Extensions/AssemblyFixtureSupport/AssemblyFixtureAttribute.cs
deleted file mode 100644
index 42d05e95efa..00000000000
--- a/src/Xunit.NetCore.Extensions/AssemblyFixtureSupport/AssemblyFixtureAttribute.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-using System;
-
-#nullable disable
-
-namespace Xunit
-{
- [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
- public class AssemblyFixtureAttribute : Attribute
- {
- public AssemblyFixtureAttribute(Type fixtureType)
- {
- FixtureType = fixtureType;
- }
-
- public Type FixtureType { get; private set; }
-
- public Scope LifetimeScope { get; set; }
-
- public enum Scope
- {
- Assembly,
- Class,
- Method
- }
- }
-}
diff --git a/src/Xunit.NetCore.Extensions/AssemblyFixtureSupport/README.md b/src/Xunit.NetCore.Extensions/AssemblyFixtureSupport/README.md
deleted file mode 100644
index a7cb5671dd5..00000000000
--- a/src/Xunit.NetCore.Extensions/AssemblyFixtureSupport/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# Assembly Fixture support
-
-Originally copied from xunit samples, found here: https://github.com/xunit/samples.xunit/tree/master/AssemblyFixtureExample
\ No newline at end of file
diff --git a/src/Xunit.NetCore.Extensions/AssemblyFixtureSupport/XunitTestAssemblyRunnerWithAssemblyFixture.cs b/src/Xunit.NetCore.Extensions/AssemblyFixtureSupport/XunitTestAssemblyRunnerWithAssemblyFixture.cs
deleted file mode 100644
index a74228cb0ec..00000000000
--- a/src/Xunit.NetCore.Extensions/AssemblyFixtureSupport/XunitTestAssemblyRunnerWithAssemblyFixture.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Xunit.Abstractions;
-using Xunit.Sdk;
-
-#nullable disable
-
-namespace Xunit.NetCore.Extensions
-{
- public class XunitTestAssemblyRunnerWithAssemblyFixture : XunitTestAssemblyRunner
- {
- private readonly Dictionary assemblyFixtureMappings = new Dictionary();
- private List assemblyFixtureAttributes;
-
- public XunitTestAssemblyRunnerWithAssemblyFixture(ITestAssembly testAssembly,
- IEnumerable testCases,
- IMessageSink diagnosticMessageSink,
- IMessageSink executionMessageSink,
- ITestFrameworkExecutionOptions executionOptions)
- : base(testAssembly, testCases, diagnosticMessageSink, executionMessageSink, executionOptions)
- { }
-
- protected override async Task AfterTestAssemblyStartingAsync()
- {
- // Let everything initialize
- await base.AfterTestAssemblyStartingAsync();
-
- // Go find all the AssemblyFixtureAttributes adorned on the test assembly
- Aggregator.Run(() =>
- {
- var fixturesAttrs = ((IReflectionAssemblyInfo)TestAssembly.Assembly).Assembly
- .GetCustomAttributes(typeof(AssemblyFixtureAttribute), false)
- .Cast()
- .ToList();
-
- this.assemblyFixtureAttributes = fixturesAttrs;
-
- // Instantiate all the fixtures
- foreach (var fixtureAttr in fixturesAttrs.Where(a => a.LifetimeScope == AssemblyFixtureAttribute.Scope.Assembly))
- {
- assemblyFixtureMappings[fixtureAttr.FixtureType] = Activator.CreateInstance(fixtureAttr.FixtureType);
- }
- });
- }
-
- protected override Task BeforeTestAssemblyFinishedAsync()
- {
- // Make sure we clean up everybody who is disposable, and use Aggregator.Run to isolate Dispose failures
- foreach (var disposable in assemblyFixtureMappings.Values.OfType())
- {
- Aggregator.Run(disposable.Dispose);
- }
-
- return base.BeforeTestAssemblyFinishedAsync();
- }
-
- protected override Task RunTestCollectionAsync(IMessageBus messageBus,
- ITestCollection testCollection,
- IEnumerable testCases,
- CancellationTokenSource cancellationTokenSource)
- => new XunitTestCollectionRunnerWithAssemblyFixture(assemblyFixtureMappings, assemblyFixtureAttributes,
- testCollection, testCases, DiagnosticMessageSink, messageBus, TestCaseOrderer, new ExceptionAggregator(Aggregator), cancellationTokenSource).RunAsync();
- }
-}
diff --git a/src/Xunit.NetCore.Extensions/AssemblyFixtureSupport/XunitTestClassRunnerWithAssemblyFixture.cs b/src/Xunit.NetCore.Extensions/AssemblyFixtureSupport/XunitTestClassRunnerWithAssemblyFixture.cs
deleted file mode 100644
index 44afc240a24..00000000000
--- a/src/Xunit.NetCore.Extensions/AssemblyFixtureSupport/XunitTestClassRunnerWithAssemblyFixture.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Xunit.Abstractions;
-using Xunit.Sdk;
-
-#nullable disable
-
-namespace Xunit.NetCore.Extensions
-{
- public class XunitTestClassRunnerWithAssemblyFixture : XunitTestClassRunner
- {
- private readonly Dictionary assemblyFixtureMappings = new Dictionary();
- private readonly List assemblyFixtureAttributes;
-
- public XunitTestClassRunnerWithAssemblyFixture(
- List assemblyFixtureAttributes,
- ITestClass testClass, IReflectionTypeInfo @class, IEnumerable testCases,
- IMessageSink diagnosticMessageSink, IMessageBus messageBus, ITestCaseOrderer testCaseOrderer, ExceptionAggregator aggregator,
- CancellationTokenSource cancellationTokenSource, IDictionary collectionFixtureMappings)
- : base(testClass, @class, testCases, diagnosticMessageSink, messageBus, testCaseOrderer, aggregator, cancellationTokenSource, collectionFixtureMappings)
- {
- this.assemblyFixtureAttributes = assemblyFixtureAttributes;
- }
-
- protected override async Task AfterTestClassStartingAsync()
- {
- await base.AfterTestClassStartingAsync();
-
- Aggregator.Run(() =>
- {
- // Instantiate all the fixtures
- foreach (var fixtureAttr in assemblyFixtureAttributes.Where(a => a.LifetimeScope == AssemblyFixtureAttribute.Scope.Class))
- {
- assemblyFixtureMappings[fixtureAttr.FixtureType] = Activator.CreateInstance(fixtureAttr.FixtureType);
- }
- });
- }
- protected override Task BeforeTestClassFinishedAsync()
- {
- // Make sure we clean up everybody who is disposable, and use Aggregator.Run to isolate Dispose failures
- foreach (var disposable in assemblyFixtureMappings.Values.OfType())
- {
- Aggregator.Run(disposable.Dispose);
- }
-
- return base.BeforeTestClassFinishedAsync();
- }
-
- protected override Task RunTestMethodAsync(ITestMethod testMethod, IReflectionMethodInfo method, IEnumerable testCases, object[] constructorArguments)
- {
- return new XunitTestMethodRunnerWithAssemblyFixture(assemblyFixtureAttributes,
- testMethod, Class, method, testCases, DiagnosticMessageSink, MessageBus,
- new ExceptionAggregator(Aggregator), CancellationTokenSource, constructorArguments).RunAsync();
- }
- }
-}
diff --git a/src/Xunit.NetCore.Extensions/AssemblyFixtureSupport/XunitTestCollectionRunnerWithAssemblyFixture.cs b/src/Xunit.NetCore.Extensions/AssemblyFixtureSupport/XunitTestCollectionRunnerWithAssemblyFixture.cs
deleted file mode 100644
index 6171ff3f902..00000000000
--- a/src/Xunit.NetCore.Extensions/AssemblyFixtureSupport/XunitTestCollectionRunnerWithAssemblyFixture.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-using System;
-using System.Collections.Generic;
-using System.Threading;
-using System.Threading.Tasks;
-using Xunit.Abstractions;
-using Xunit.Sdk;
-
-#nullable disable
-
-namespace Xunit.NetCore.Extensions
-{
- public class XunitTestCollectionRunnerWithAssemblyFixture : XunitTestCollectionRunner
- {
- private readonly Dictionary assemblyFixtureMappings;
- private readonly IMessageSink diagnosticMessageSink;
- private readonly List assemblyFixtureAttributes;
-
- public XunitTestCollectionRunnerWithAssemblyFixture(Dictionary assemblyFixtureMappings,
- List assemblyFixtureAttributes,
- ITestCollection testCollection,
- IEnumerable testCases,
- IMessageSink diagnosticMessageSink,
- IMessageBus messageBus,
- ITestCaseOrderer testCaseOrderer,
- ExceptionAggregator aggregator,
- CancellationTokenSource cancellationTokenSource)
- : base(testCollection, testCases, diagnosticMessageSink, messageBus, testCaseOrderer, aggregator, cancellationTokenSource)
- {
- this.assemblyFixtureMappings = assemblyFixtureMappings;
- this.assemblyFixtureAttributes = assemblyFixtureAttributes ?? throw new ArgumentNullException(nameof(assemblyFixtureAttributes));
- this.diagnosticMessageSink = diagnosticMessageSink;
- }
-
- protected override Task RunTestClassAsync(ITestClass testClass, IReflectionTypeInfo @class, IEnumerable testCases)
- {
- // Don't want to use .Concat + .ToDictionary because of the possibility of overriding types,
- // so instead we'll just let collection fixtures override assembly fixtures.
- var combinedFixtures = new Dictionary(assemblyFixtureMappings);
- foreach (var kvp in CollectionFixtureMappings)
- {
- combinedFixtures[kvp.Key] = kvp.Value;
- }
-
- return new XunitTestClassRunnerWithAssemblyFixture(assemblyFixtureAttributes, testClass, @class, testCases, diagnosticMessageSink, MessageBus, TestCaseOrderer, new ExceptionAggregator(Aggregator), CancellationTokenSource, combinedFixtures).RunAsync();
- }
- }
-}
diff --git a/src/Xunit.NetCore.Extensions/AssemblyFixtureSupport/XunitTestFrameworkExecutorWithAssemblyFixture.cs b/src/Xunit.NetCore.Extensions/AssemblyFixtureSupport/XunitTestFrameworkExecutorWithAssemblyFixture.cs
deleted file mode 100644
index 605fa16786e..00000000000
--- a/src/Xunit.NetCore.Extensions/AssemblyFixtureSupport/XunitTestFrameworkExecutorWithAssemblyFixture.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-using System.Collections.Generic;
-using System.Reflection;
-using Xunit.Abstractions;
-using Xunit.Sdk;
-
-#nullable disable
-
-namespace Xunit.NetCore.Extensions
-{
- public class XunitTestFrameworkExecutorWithAssemblyFixture : XunitTestFrameworkExecutor
- {
- public XunitTestFrameworkExecutorWithAssemblyFixture(AssemblyName assemblyName, ISourceInformationProvider sourceInformationProvider, IMessageSink diagnosticMessageSink)
- : base(assemblyName, sourceInformationProvider, diagnosticMessageSink)
- { }
-
- protected override async void RunTestCases(IEnumerable testCases, IMessageSink executionMessageSink, ITestFrameworkExecutionOptions executionOptions)
- {
- using (var assemblyRunner = new XunitTestAssemblyRunnerWithAssemblyFixture(TestAssembly, testCases, DiagnosticMessageSink, executionMessageSink, executionOptions))
- {
- await assemblyRunner.RunAsync();
- }
- }
- }
-}
diff --git a/src/Xunit.NetCore.Extensions/AssemblyFixtureSupport/XunitTestFrameworkWithAssemblyFixture.cs b/src/Xunit.NetCore.Extensions/AssemblyFixtureSupport/XunitTestFrameworkWithAssemblyFixture.cs
deleted file mode 100644
index de14792e09d..00000000000
--- a/src/Xunit.NetCore.Extensions/AssemblyFixtureSupport/XunitTestFrameworkWithAssemblyFixture.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-using System.Reflection;
-using Xunit.Abstractions;
-using Xunit.Sdk;
-
-#nullable disable
-
-namespace Xunit.NetCore.Extensions
-{
- public class XunitTestFrameworkWithAssemblyFixture : XunitTestFramework
- {
- public XunitTestFrameworkWithAssemblyFixture(IMessageSink messageSink)
- : base(messageSink)
- { }
-
- protected override ITestFrameworkExecutor CreateExecutor(AssemblyName assemblyName)
- => new XunitTestFrameworkExecutorWithAssemblyFixture(assemblyName, SourceInformationProvider, DiagnosticMessageSink);
- }
-}
diff --git a/src/Xunit.NetCore.Extensions/AssemblyFixtureSupport/XunitTestMethodRunnerWithAssemblyFixture.cs b/src/Xunit.NetCore.Extensions/AssemblyFixtureSupport/XunitTestMethodRunnerWithAssemblyFixture.cs
deleted file mode 100644
index 84307112d1d..00000000000
--- a/src/Xunit.NetCore.Extensions/AssemblyFixtureSupport/XunitTestMethodRunnerWithAssemblyFixture.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using Xunit.Abstractions;
-using Xunit.Sdk;
-
-#nullable disable
-
-namespace Xunit.NetCore.Extensions
-{
- public class XunitTestMethodRunnerWithAssemblyFixture : XunitTestMethodRunner
- {
- private readonly Dictionary assemblyFixtureMappings = new Dictionary();
- private readonly List assemblyFixtureAttributes;
-
- public XunitTestMethodRunnerWithAssemblyFixture(List assemblyFixtureAttributes,
- ITestMethod testMethod,
- IReflectionTypeInfo @class,
- IReflectionMethodInfo method,
- IEnumerable testCases,
- IMessageSink diagnosticMessageSink,
- IMessageBus messageBus,
- ExceptionAggregator aggregator,
- CancellationTokenSource cancellationTokenSource,
- object[] constructorArguments)
- : base(testMethod, @class, method, testCases, diagnosticMessageSink, messageBus, aggregator, cancellationTokenSource, constructorArguments)
- {
- this.assemblyFixtureAttributes = assemblyFixtureAttributes;
- }
-
- protected override void AfterTestMethodStarting()
- {
- base.AfterTestMethodStarting();
-
- Aggregator.Run(() =>
- {
- // Instantiate all the fixtures
- foreach (var fixtureAttr in assemblyFixtureAttributes.Where(a => a.LifetimeScope == AssemblyFixtureAttribute.Scope.Method))
- {
- assemblyFixtureMappings[fixtureAttr.FixtureType] = Activator.CreateInstance(fixtureAttr.FixtureType);
- }
- });
- }
-
- protected override void BeforeTestMethodFinished()
- {
- // Make sure we clean up everybody who is disposable, and use Aggregator.Run to isolate Dispose failures
- foreach (var disposable in assemblyFixtureMappings.Values.OfType())
- {
- Aggregator.Run(disposable.Dispose);
- }
-
- base.BeforeTestMethodFinished();
- }
- }
-}
diff --git a/src/Xunit.NetCore.Extensions/UseInvariantCultureAttribute.cs b/src/Xunit.NetCore.Extensions/UseInvariantCultureAttribute.cs
index adb3b05ca3a..dabaebde0da 100644
--- a/src/Xunit.NetCore.Extensions/UseInvariantCultureAttribute.cs
+++ b/src/Xunit.NetCore.Extensions/UseInvariantCultureAttribute.cs
@@ -6,6 +6,7 @@
using System.Reflection;
using System.Threading;
using Xunit.Sdk;
+using Xunit.v3;
namespace Xunit.NetCore.Extensions
{
@@ -15,7 +16,7 @@ public class UseInvariantCultureAttribute : BeforeAfterTestAttribute
private CultureInfo? originalCulture;
private CultureInfo? originalUICulture;
- public override void Before(MethodInfo methodUnderTest)
+ public override void Before(MethodInfo methodUnderTest, IXunitTest test)
{
originalCulture = CultureInfo.CurrentCulture;
originalUICulture = CultureInfo.CurrentUICulture;
@@ -24,7 +25,7 @@ public override void Before(MethodInfo methodUnderTest)
CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture;
}
- public override void After(MethodInfo methodUnderTest)
+ public override void After(MethodInfo methodUnderTest, IXunitTest test)
{
if (originalCulture != null)
{
diff --git a/src/Xunit.NetCore.Extensions/Xunit.NetCore.Extensions.csproj b/src/Xunit.NetCore.Extensions/Xunit.NetCore.Extensions.csproj
index 01d47500a32..5380e6acb8b 100644
--- a/src/Xunit.NetCore.Extensions/Xunit.NetCore.Extensions.csproj
+++ b/src/Xunit.NetCore.Extensions/Xunit.NetCore.Extensions.csproj
@@ -1,14 +1,12 @@
- $(LibraryTargetFrameworks)
+ $(RuntimeOutputTargetFrameworks)
false
true
false
- false
+ false
-
-
+