diff --git a/Directory.Build.props b/Directory.Build.props
index 81e8489fd4..ce63537502 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -40,12 +40,11 @@
- alpha
-
1.0.0
+ alpha
@@ -70,6 +69,12 @@
true
+
+
+
+ TestingPlatformRunner
+
+
diff --git a/Directory.Packages.props b/Directory.Packages.props
index 2447431037..2b8b2566a2 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -37,6 +37,7 @@
+
diff --git a/TestFx.sln b/TestFx.sln
index ef5738fbb2..622210e8ed 100644
--- a/TestFx.sln
+++ b/TestFx.sln
@@ -72,6 +72,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "IntegrationTests", "Integra
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TestAssets", "TestAssets", "{C9F82701-0E0F-4E61-B05B-AE387E7631F6}"
ProjectSection(SolutionItems) = preProject
+ test\IntegrationTests\TestAssets\Directory.Build.props = test\IntegrationTests\TestAssets\Directory.Build.props
test\IntegrationTests\TestAssets\Directory.Build.targets = test\IntegrationTests\TestAssets\Directory.Build.targets
EndProjectSection
EndProject
diff --git a/samples/Playground/Playground.csproj b/samples/Playground/Playground.csproj
index b8570b8348..136fbdad91 100644
--- a/samples/Playground/Playground.csproj
+++ b/samples/Playground/Playground.csproj
@@ -20,7 +20,6 @@
-
diff --git a/src/Adapter/MSTest.TestAdapter/Helpers/FixtureMethodRunner.cs b/src/Adapter/MSTest.TestAdapter/Helpers/FixtureMethodRunner.cs
index 6653057879..8b5888c642 100644
--- a/src/Adapter/MSTest.TestAdapter/Helpers/FixtureMethodRunner.cs
+++ b/src/Adapter/MSTest.TestAdapter/Helpers/FixtureMethodRunner.cs
@@ -12,6 +12,24 @@ namespace Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Helpers;
internal static class FixtureMethodRunner
{
+ internal static void RunOnContext(ExecutionContext? executionContext, Action action)
+ {
+ if (executionContext is null)
+ {
+ action();
+ }
+ else
+ {
+ // CreateCopy doesn't do anything on .NET Core as ExecutionContexts are immutable.
+ // But it's important on .NET Framework.
+ // On .NET Framework, ExecutionContext.Run cannot be called twice with the same ExecutionContext.
+ // Otherwise, it will throw InvalidOperationException with message:
+ // Cannot apply a context that has been marshaled across AppDomains, that was not acquired through a Capture operation or that has already been the argument to a Set call.
+ executionContext = executionContext.CreateCopy();
+ ExecutionContext.Run(executionContext, static action => ((Action)action!).Invoke(), action);
+ }
+ }
+
internal static TestFailedException? RunWithTimeoutAndCancellation(
Action action, CancellationTokenSource cancellationTokenSource, TimeoutInfo? timeoutInfo, MethodInfo methodInfo,
ExecutionContext? executionContext, string methodCanceledMessageFormat, string methodTimedOutMessageFormat,
diff --git a/src/Adapter/MSTest.TestAdapter/MSTest.TestAdapter.csproj b/src/Adapter/MSTest.TestAdapter/MSTest.TestAdapter.csproj
index 9574cbfe6e..6170c0f259 100644
--- a/src/Adapter/MSTest.TestAdapter/MSTest.TestAdapter.csproj
+++ b/src/Adapter/MSTest.TestAdapter/MSTest.TestAdapter.csproj
@@ -54,7 +54,8 @@
-
+
Analyzer
false
diff --git a/src/Analyzers/MSTest.Analyzers.Package/MSTest.Analyzers.Package.csproj b/src/Analyzers/MSTest.Analyzers.Package/MSTest.Analyzers.Package.csproj
index dbeb1dfb27..c4d90bd485 100644
--- a/src/Analyzers/MSTest.Analyzers.Package/MSTest.Analyzers.Package.csproj
+++ b/src/Analyzers/MSTest.Analyzers.Package/MSTest.Analyzers.Package.csproj
@@ -22,8 +22,8 @@
-
-
+
+
diff --git a/src/Analyzers/MSTest.Analyzers/xlf/Resources.cs.xlf b/src/Analyzers/MSTest.Analyzers/xlf/Resources.cs.xlf
index d40df19f9c..7d2f8fdf1e 100644
--- a/src/Analyzers/MSTest.Analyzers/xlf/Resources.cs.xlf
+++ b/src/Analyzers/MSTest.Analyzers/xlf/Resources.cs.xlf
@@ -19,7 +19,7 @@ The type declaring these methods should also respect the following rules:
-The class shouldn't be 'static'
-The class should be marked with '[TestClass]' (or a derived attribute)
-the class should not be generic.
- Aby byly metody s označením [AssemblyCleanup] platné, musí se řídit následujícím rozložením:
+ Aby byly metody s označením [AssemblyCleanup] platné, musí se řídit následujícím rozložením:
– Nesmí být deklarované pro obecnou třídu.
– Musí být public.
– Musí být static.
@@ -29,7 +29,7 @@ The type declaring these methods should also respect the following rules:
– Nesmí přijímat žádný parametr, nebo musí přijímat jediný parametr typu TestContext.
– Návratový typ musí být void, Task nebo ValueTask.
-Typ deklarující tyto metody by měl také respektovat následující pravidla:
+Typ deklarující tyto metody by měl také respektovat následující pravidla:
– Typ by měl být třída.
– Třída by měla být public nebo internal (pokud testovací projekt používá atribut [DiscoverInternals]).
– Třída by neměla být static.
@@ -64,7 +64,7 @@ The type declaring these methods should also respect the following rules:
-The class shouldn't be 'static'
-The class should be marked with '[TestClass]' (or a derived attribute)
-the class should not be generic.
- Aby byly metody s označením [AssemblyInitialize] platné, musí se řídit následujícím rozložením:
+ Aby byly metody s označením [AssemblyInitialize] platné, musí se řídit následujícím rozložením:
– Nesmí být deklarované pro obecnou třídu.
– Musí být public.
– Musí být static.
@@ -74,7 +74,7 @@ The type declaring these methods should also respect the following rules:
– Musí mít jeden parametr typu TestContext.
– Návratový typ musí být void, Task nebo ValueTask.
-Typ deklarující tyto metody by měl také respektovat následující pravidla:
+Typ deklarující tyto metody by měl také respektovat následující pravidla:
– Typ by měl být třída.
– Třída by měla být public nebo internal (pokud testovací projekt používá atribut [DiscoverInternals]).
– Třída by neměla být static.
@@ -181,7 +181,7 @@ The type declaring these methods should also respect the following rules:
-The class shouldn't be 'static'
-If the class is 'sealed', it should be marked with '[TestClass]' (or a derived attribute)
-the class should not be generic.
- Aby byly metody s označením [ClassCleanup] platné, musí se řídit následujícím rozložením:
+ Aby byly metody s označením [ClassCleanup] platné, musí se řídit následujícím rozložením:
– Nesmí být deklarované pro obecnou třídu bez nastavení režimu InheritanceBehavior.
– Musí být public.
– Musí být static.
@@ -193,7 +193,7 @@ The type declaring these methods should also respect the following rules:
– V případě třídy abstract by měl být zadán parametr atributu InheritanceBehavior.BeforeEachDerivedClass.
– V případě třídy sealed by neměl být zadán parametr atributu InheritanceBehavior.BeforeEachDerivedClass.
-Typ deklarující tyto metody by měl také respektovat následující pravidla:
+Typ deklarující tyto metody by měl také respektovat následující pravidla:
– Typ by měl být třída.
– Třída by měla být public nebo internal (pokud testovací projekt používá atribut [DiscoverInternals]).
– Třída by neměla být static.
@@ -230,7 +230,7 @@ The type declaring these methods should also respect the following rules:
-The class shouldn't be 'static'
-If the class is 'sealed', it should be marked with '[TestClass]' (or a derived attribute)
-the class should not be generic.
- Aby byly metody s označením [ClassInitialize] platné, musí se řídit následujícím rozložením:
+ Aby byly metody s označením [ClassInitialize] platné, musí se řídit následujícím rozložením:
– Nesmí být deklarované pro obecnou třídu bez nastavení režimu InheritanceBehavior.
– Musí být public.
– Musí být static.
@@ -242,7 +242,7 @@ The type declaring these methods should also respect the following rules:
– V případě třídy abstract by měl být zadán parametr atributu InheritanceBehavior.BeforeEachDerivedClass.
– V případě třídy sealed by neměl být zadán parametr atributu InheritanceBehavior.BeforeEachDerivedClass.
-Typ deklarující tyto metody by měl také respektovat následující pravidla:
+Typ deklarující tyto metody by měl také respektovat následující pravidla:
– Typ by měl být třída.
– Třída by měla být public nebo internal (pokud testovací projekt používá atribut [DiscoverInternals]).
– Třída by neměla být static.
@@ -594,7 +594,7 @@ The type declaring these methods should also respect the following rules:
-The class should be 'public' or 'internal' (if the test project is using the '[DiscoverInternals]' attribute)
-The class shouldn't be 'static'
-If the class is 'sealed', it should be marked with '[TestClass]' (or a derived attribute).
- Aby byly metody s označením [TestCleanup] platné, musí se řídit následujícím rozložením:
+ Aby byly metody s označením [TestCleanup] platné, musí se řídit následujícím rozložením:
– Musí být public.
– Nesmí být abstract.
– Nesmí být async void.
@@ -604,7 +604,7 @@ The type declaring these methods should also respect the following rules:
– Nesmí přijímat žádný parametr.
– Návratový typ musí být void, Task nebo ValueTask.
-Typ deklarující tyto metody by měl také respektovat následující pravidla:
+Typ deklarující tyto metody by měl také respektovat následující pravidla:
– Typ by měl být třída.
– Třída by měla být public nebo internal (pokud testovací projekt používá atribut [DiscoverInternals]).
– Třída by neměla být static.
@@ -653,7 +653,7 @@ The type declaring these methods should also respect the following rules:
-The class should be 'public' or 'internal' (if the test project is using the '[DiscoverInternals]' attribute)
-The class shouldn't be 'static'
-If the class is 'sealed', it should be marked with '[TestClass]' (or a derived attribute).
- Aby byly metody s označením [TestInitialize] platné, musí se řídit následujícím rozložením:
+ Aby byly metody s označením [TestInitialize] platné, musí se řídit následujícím rozložením:
– Musí být public.
– Nesmí být abstract.
– Nesmí být async void.
@@ -663,7 +663,7 @@ The type declaring these methods should also respect the following rules:
– Nesmí přijímat žádný parametr.
– Návratový typ musí být void, Task nebo ValueTask.
-Typ deklarující tyto metody by měl také respektovat následující pravidla:
+Typ deklarující tyto metody by měl také respektovat následující pravidla:
– Typ by měl být třída.
– Třída by měla být public nebo internal (pokud testovací projekt používá atribut [DiscoverInternals]).
– Třída by neměla být static.
@@ -821,4 +821,4 @@ Typ deklarující tyto metody by měl také respektovat následující pravidla: