Skip to content

Commit

Permalink
Merge branch 'main' into analyzers
Browse files Browse the repository at this point in the history
  • Loading branch information
Evangelink authored Dec 18, 2024
2 parents 4fbf707 + 2dd2f37 commit 6db6473
Show file tree
Hide file tree
Showing 33 changed files with 149 additions and 264 deletions.
16 changes: 15 additions & 1 deletion src/Adapter/MSTest.TestAdapter/Execution/TestExecutionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ namespace Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution;
#endif
public class TestExecutionManager
{
private sealed class RemotingMessageLogger : MarshalByRefObject, IMessageLogger
{
private readonly IMessageLogger _realMessageLogger;

public RemotingMessageLogger(IMessageLogger messageLogger)
=> _realMessageLogger = messageLogger;

public void SendMessage(TestMessageLevel testMessageLevel, string message)
=> _realMessageLogger.SendMessage(testMessageLevel, message);
}

/// <summary>
/// Dictionary for test run parameters.
/// </summary>
Expand Down Expand Up @@ -451,7 +462,10 @@ private void ExecuteTestsWithTestRunner(
// Run single test passing test context properties to it.
IDictionary<TestProperty, object?> tcmProperties = TcmTestPropertiesProvider.GetTcmProperties(currentTest);
Dictionary<string, object?> testContextProperties = GetTestContextProperties(tcmProperties, sourceLevelParameters);
UnitTestResult[] unitTestResult = testRunner.RunSingleTest(unitTestElement.TestMethod, testContextProperties);

// testRunner could be in a different AppDomain. We cannot pass the testExecutionRecorder directly.
// Instead, we pass a proxy (remoting object) that is marshallable by ref.
UnitTestResult[] unitTestResult = testRunner.RunSingleTest(unitTestElement.TestMethod, testContextProperties, new RemotingMessageLogger(testExecutionRecorder));

PlatformServiceProvider.Instance.AdapterTraceLogger.LogInfo("Executed test {0}", unitTestElement.TestMethod.Name);

Expand Down
5 changes: 3 additions & 2 deletions src/Adapter/MSTest.TestAdapter/Execution/UnitTestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.ObjectModel;
using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices;
using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using UnitTestOutcome = Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.ObjectModel.UnitTestOutcome;
Expand Down Expand Up @@ -130,15 +131,15 @@ internal FixtureTestResult GetFixtureTestResult(TestMethod testMethod, string fi
/// <param name="testMethod"> The test Method. </param>
/// <param name="testContextProperties"> The test context properties. </param>
/// <returns> The <see cref="UnitTestResult"/>. </returns>
internal UnitTestResult[] RunSingleTest(TestMethod testMethod, IDictionary<string, object?> testContextProperties)
internal UnitTestResult[] RunSingleTest(TestMethod testMethod, IDictionary<string, object?> testContextProperties, IMessageLogger messageLogger)
{
Guard.NotNull(testMethod);

try
{
using var writer = new ThreadSafeStringWriter(CultureInfo.InvariantCulture, "context");
var properties = new Dictionary<string, object?>(testContextProperties);
ITestContext testContext = PlatformServiceProvider.Instance.GetTestContext(testMethod, writer, properties);
ITestContext testContext = PlatformServiceProvider.Instance.GetTestContext(testMethod, writer, properties, messageLogger);
testContext.SetOutcome(UTF.UnitTestOutcome.InProgress);

// Get the testMethod
Expand Down
3 changes: 2 additions & 1 deletion src/Adapter/MSTest.TestAdapter/IPlatformServiceProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface;
using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface.ObjectModel;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;

namespace Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter;

Expand Down Expand Up @@ -121,5 +122,5 @@ ITestSourceHost CreateTestSourceHost(
/// <remarks>
/// This was required for compatibility reasons since the TestContext object that the V1 adapter had for desktop is not .Net Core compliant.
/// </remarks>
ITestContext GetTestContext(ITestMethod testMethod, StringWriter writer, IDictionary<string, object?> properties);
ITestContext GetTestContext(ITestMethod testMethod, StringWriter writer, IDictionary<string, object?> properties, IMessageLogger messageLogger);
}
5 changes: 3 additions & 2 deletions src/Adapter/MSTest.TestAdapter/PlatformServiceProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices;
using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface;
using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface.ObjectModel;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;

namespace Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter;

Expand Down Expand Up @@ -222,9 +223,9 @@ public ITestSourceHost CreateTestSourceHost(
/// <remarks>
/// This was required for compatibility reasons since the TestContext object that the V1 adapter had for desktop is not .Net Core compliant.
/// </remarks>
public ITestContext GetTestContext(ITestMethod testMethod, StringWriter writer, IDictionary<string, object?> properties)
public ITestContext GetTestContext(ITestMethod testMethod, StringWriter writer, IDictionary<string, object?> properties, IMessageLogger messageLogger)
{
var testContextImplementation = new TestContextImplementation(testMethod, writer, properties);
var testContextImplementation = new TestContextImplementation(testMethod, writer, properties, messageLogger);
TestRunCancellationToken?.Register(CancelDelegate, testContextImplementation);
return testContextImplementation;
}
Expand Down
27 changes: 0 additions & 27 deletions src/Adapter/MSTest.TestAdapter/Resources/Resource.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions src/Adapter/MSTest.TestAdapter/Resources/Resource.resx
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,6 @@ Error: {1}</value>
<value>Exceptions thrown:</value>
<comment>This is usually precedes by TestAssembly_AssemblyDiscoveryFailure message, and preceded by list of exceptions thrown in a test discovery session.</comment>
</data>
<data name="FailedFetchAttributeCache" xml:space="preserve">
<value>Failed to get attribute cache. Ignoring attribute inheritance and falling into 'type defines Attribute model', so that we have some data.</value>
</data>
<data name="FailedToGetCustomAttribute" xml:space="preserve">
<value>Getting custom attributes for type {0} threw exception (will ignore and use the reflection way): {1}</value>
<comment>{0}: Attribute full type name.
Expand All @@ -339,9 +336,6 @@ Error: {1}</value>
<data name="UTA_UserCodeThrewNullValueException" xml:space="preserve">
<value>The called code threw an exception that was caught, but the exception value was null</value>
</data>
<data name="OlderTFMVersionFoundClassCleanup" xml:space="preserve">
<value>An older version of MSTestV2 package is loaded in assembly, test cleanup methods might not run as expected. Please make sure all your test projects references MSTest packages newer then version 2.2.8.</value>
</data>
<data name="CannotExpandIDataSourceAttribute" xml:space="preserve">
<value>Exception occurred while expanding IDataSource rows from attribute on "{0}.{1}": {2}</value>
<comment>{0}: TypeName with namespace,
Expand Down Expand Up @@ -408,9 +402,6 @@ but received {4} argument(s), with types '{5}'.</value>
<data name="InvalidValue" xml:space="preserve">
<value>Invalid value '{0}' for runsettings entry '{1}', setting will be ignored.</value>
</data>
<data name="DynamicDataShouldBeValidMessageFormat_MemberType" xml:space="preserve">
<value>'[DynamicData]' referenced member '{0}.{1}' should return 'IEnumerable&lt;object[]&gt;', 'IEnumerable&lt;Tuple&gt;` or 'IEnumerable&lt;ValueTuple&gt;'</value>
</data>
<data name="DuplicateConfigurationError" xml:space="preserve">
<value>Both '.runsettings' and '.testconfig.json' files have been detected. Please select only one of these test configuration files.</value>
</data>
Expand Down
15 changes: 0 additions & 15 deletions src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ byl však přijat tento počet argumentů: {4} s typy {5}.</target>
<target state="translated">Byly zjištěny soubory .runsettings i .testconfig.json. Vyberte prosím jenom jeden z těchto souborů konfigurace testu.</target>
<note />
</trans-unit>
<trans-unit id="DynamicDataShouldBeValidMessageFormat_MemberType">
<source>'[DynamicData]' referenced member '{0}.{1}' should return 'IEnumerable&lt;object[]&gt;', 'IEnumerable&lt;Tuple&gt;` or 'IEnumerable&lt;ValueTuple&gt;'</source>
<target state="translated">Odkazovaný člen [DynamicData] {0}.{1} by měl vracet IEnumerable&lt;object[]&gt;, IEnumerable&lt;Tuple&gt; nebo IEnumerable&lt;ValueTuple&gt;.</target>
<note />
</trans-unit>
<trans-unit id="DynamicDataSourceShouldExistAndBeValid">
<source>The dynamic data source '{0}' in type '{1}' should exist and be a property or a method.</source>
<target state="new">The dynamic data source '{0}' in type '{1}' should exist and be a property or a method.</target>
Expand Down Expand Up @@ -450,11 +445,6 @@ Chyba: {1}</target>
<target state="translated">Vyvolané výjimky:</target>
<note>This is usually precedes by TestAssembly_AssemblyDiscoveryFailure message, and preceded by list of exceptions thrown in a test discovery session.</note>
</trans-unit>
<trans-unit id="FailedFetchAttributeCache">
<source>Failed to get attribute cache. Ignoring attribute inheritance and falling into 'type defines Attribute model', so that we have some data.</source>
<target state="translated">Nepodařilo se získat mezipaměť atributů. Ignoruje se dědičnost atributů a spadání do „type defines Attribute model“, abychom získali určitá data.</target>
<note></note>
</trans-unit>
<trans-unit id="FailedToGetCustomAttribute">
<source>Getting custom attributes for type {0} threw exception (will ignore and use the reflection way): {1}</source>
<target state="translated">Získání vlastních atributů pro typ {0} vyvolalo výjimku (bude ignorovat a používat způsob reflexe): {1}</target>
Expand All @@ -471,11 +461,6 @@ Chyba: {1}</target>
<target state="translated">Volaný kód vyvolal výjimku, která byla zachycena, ale její hodnota byla null.</target>
<note></note>
</trans-unit>
<trans-unit id="OlderTFMVersionFoundClassCleanup">
<source>An older version of MSTestV2 package is loaded in assembly, test cleanup methods might not run as expected. Please make sure all your test projects references MSTest packages newer then version 2.2.8.</source>
<target state="translated">V sestavení je načtena starší verze balíčku MSTestV2. Metody čištění testů se nemusí spustit očekávaným způsobem. Ujistěte se prosím, že všechny vaše testovací projekty odkazují na balíčky MSTest novější než verze 2.2.8.</target>
<note></note>
</trans-unit>
<trans-unit id="CannotExpandIDataSourceAttribute">
<source>Exception occurred while expanding IDataSource rows from attribute on "{0}.{1}": {2}</source>
<target state="translated">Došlo k výjimce při rozbalování řádků IDataSource z atributu na „{0}.{1}“: {2}</target>
Expand Down
15 changes: 0 additions & 15 deletions src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ aber empfing {4} Argument(e) mit den Typen „{5}“.</target>
<target state="translated">Es wurden sowohl die Dateien „.runsettings“ als auch „.testconfig.json“ erkannt. Wählen Sie nur eine dieser Testkonfigurationsdateien aus.</target>
<note />
</trans-unit>
<trans-unit id="DynamicDataShouldBeValidMessageFormat_MemberType">
<source>'[DynamicData]' referenced member '{0}.{1}' should return 'IEnumerable&lt;object[]&gt;', 'IEnumerable&lt;Tuple&gt;` or 'IEnumerable&lt;ValueTuple&gt;'</source>
<target state="translated">"[DynamicData]"-Element "{0}.{1}" muss "IEnumerable"&lt;"object[]&gt;", "IEnumerable&lt;Tuple&gt;" oder "IEnumerable&lt;ValueTuple&gt;" zurückgeben.</target>
<note />
</trans-unit>
<trans-unit id="DynamicDataSourceShouldExistAndBeValid">
<source>The dynamic data source '{0}' in type '{1}' should exist and be a property or a method.</source>
<target state="new">The dynamic data source '{0}' in type '{1}' should exist and be a property or a method.</target>
Expand Down Expand Up @@ -450,11 +445,6 @@ Fehler: {1}</target>
<target state="translated">Ausgelöste Ausnahmen:</target>
<note>This is usually precedes by TestAssembly_AssemblyDiscoveryFailure message, and preceded by list of exceptions thrown in a test discovery session.</note>
</trans-unit>
<trans-unit id="FailedFetchAttributeCache">
<source>Failed to get attribute cache. Ignoring attribute inheritance and falling into 'type defines Attribute model', so that we have some data.</source>
<target state="translated">Fehler beim Abrufen des Attributcaches. Die Attributvererbung wird ignoriert und fällt in "type defines Attribute model", sodass einige Daten vorhanden sind.</target>
<note></note>
</trans-unit>
<trans-unit id="FailedToGetCustomAttribute">
<source>Getting custom attributes for type {0} threw exception (will ignore and use the reflection way): {1}</source>
<target state="translated">Beim Abrufen von benutzerdefinierten Attributen für den Typ {0} wurde Ausnahme ausgelöst (wird ignoriert und die Reflektionsart verwendet): {1}</target>
Expand All @@ -471,11 +461,6 @@ Fehler: {1}</target>
<target state="translated">Der aufgerufene Code hat eine Ausnahme ausgelöst, die abgefangen wurde, aber der Ausnahmewert war NULL.</target>
<note></note>
</trans-unit>
<trans-unit id="OlderTFMVersionFoundClassCleanup">
<source>An older version of MSTestV2 package is loaded in assembly, test cleanup methods might not run as expected. Please make sure all your test projects references MSTest packages newer then version 2.2.8.</source>
<target state="translated">Eine ältere Version des MSTestV2-Pakets wird in die Assembly geladen. Testbereinigungsmethoden werden möglicherweise nicht wie erwartet ausgeführt. Stellen Sie sicher, dass alle Testprojekte auf MSTest-Pakete verweisen, die neuer als Version 2.2.8 sind.</target>
<note></note>
</trans-unit>
<trans-unit id="CannotExpandIDataSourceAttribute">
<source>Exception occurred while expanding IDataSource rows from attribute on "{0}.{1}": {2}</source>
<target state="translated">Ausnahme beim Erweitern von IDataSource-Zeilen aus dem Attribut auf "{0}.{1}": {2}</target>
Expand Down
15 changes: 0 additions & 15 deletions src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ pero recibió {4} argumento(s), con los tipos "{5}".</target>
<target state="translated">Se han detectado los archivos ".runsettings" y ".testconfig.json". Seleccione solo uno de estos archivos de configuración de prueba.</target>
<note />
</trans-unit>
<trans-unit id="DynamicDataShouldBeValidMessageFormat_MemberType">
<source>'[DynamicData]' referenced member '{0}.{1}' should return 'IEnumerable&lt;object[]&gt;', 'IEnumerable&lt;Tuple&gt;` or 'IEnumerable&lt;ValueTuple&gt;'</source>
<target state="translated">El miembro ''{0}.{1}'' de '[DynamicData]' al que se hace referencia debe devolver ''IEnumerable&lt;object[]&gt;', 'IEnumerable&lt;Tuple&gt;'' o ''IEnumerable&lt;ValueTuple&gt;''</target>
<note />
</trans-unit>
<trans-unit id="DynamicDataSourceShouldExistAndBeValid">
<source>The dynamic data source '{0}' in type '{1}' should exist and be a property or a method.</source>
<target state="new">The dynamic data source '{0}' in type '{1}' should exist and be a property or a method.</target>
Expand Down Expand Up @@ -450,11 +445,6 @@ Error: {1}</target>
<target state="translated">Excepciones devueltas:</target>
<note>This is usually precedes by TestAssembly_AssemblyDiscoveryFailure message, and preceded by list of exceptions thrown in a test discovery session.</note>
</trans-unit>
<trans-unit id="FailedFetchAttributeCache">
<source>Failed to get attribute cache. Ignoring attribute inheritance and falling into 'type defines Attribute model', so that we have some data.</source>
<target state="translated">No se pudo obtener la memoria caché de atributos. Se omitirá la herencia del atributo y se entrará en "type define Attribute model", de modo que tengamos algunos datos.</target>
<note></note>
</trans-unit>
<trans-unit id="FailedToGetCustomAttribute">
<source>Getting custom attributes for type {0} threw exception (will ignore and use the reflection way): {1}</source>
<target state="translated">Al obtener atributos personalizados para el tipo {0} se produjo una excepción (se omitirá y se usará la forma de reflexión): {1}</target>
Expand All @@ -471,11 +461,6 @@ Error: {1}</target>
<target state="translated">El código llamado produjo una excepción que se detectó, pero el valor de la excepción era null</target>
<note></note>
</trans-unit>
<trans-unit id="OlderTFMVersionFoundClassCleanup">
<source>An older version of MSTestV2 package is loaded in assembly, test cleanup methods might not run as expected. Please make sure all your test projects references MSTest packages newer then version 2.2.8.</source>
<target state="translated">Hay una versión anterior del paquete MSTestV2 cargada en el ensamblado. Es posible que los métodos de limpieza de pruebas no se ejecuten según lo esperado. Asegúrese de que todos los proyectos de prueba hacen referencia a paquetes MSTest más recientes que la versión 2.2.8.</target>
<note></note>
</trans-unit>
<trans-unit id="CannotExpandIDataSourceAttribute">
<source>Exception occurred while expanding IDataSource rows from attribute on "{0}.{1}": {2}</source>
<target state="translated">Se produjo una excepción al expandir las filas de IDataSource del atributo en "{0}.{1}": {2}</target>
Expand Down
Loading

0 comments on commit 6db6473

Please sign in to comment.