From acb02ea4b55e90895f1b49d7b74941b070188b6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Lev=C3=A9?= Date: Thu, 23 Jun 2022 10:38:45 +0200 Subject: [PATCH] More culture and cleaning --- .../Serialization/TestCaseConverter.cs | 2 +- .../Serialization/TestResultConverter.cs | 6 +++--- .../Helpers/CommandLineArgumentsHelper.cs | 1 - .../Execution/BaseRunTests.cs | 2 +- src/Microsoft.TestPlatform.CrossPlatEngine/TestEngine.cs | 7 +++++-- .../ObjectModel/TestResult.cs | 1 - .../Utility/EqtAssert.cs | 1 - .../Navigation/FullSymbolReader.cs | 1 - .../CommandLineUtilities.cs | 1 - .../Processors/ListFullyQualifiedTestsArgumentProcessor.cs | 1 - .../Processors/ListTestsTargetPathArgumentProcessor.cs | 1 - .../Processors/ResultsDirectoryArgumentProcessor.cs | 1 - src/vstest.console/Processors/RunTestsArgumentProcessor.cs | 2 -- .../Client/ProxyOperationManagerTests.cs | 2 +- .../Discovery/DiscovererEnumeratorTests.cs | 1 - 15 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestCaseConverter.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestCaseConverter.cs index e68d359212..49906b0008 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestCaseConverter.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestCaseConverter.cs @@ -85,7 +85,7 @@ public override bool CanConvert(Type objectType) case "TestCase.CodeFilePath": testCase.CodeFilePath = propertyData; break; case "TestCase.LineNumber": - testCase.LineNumber = int.Parse(propertyData!); break; + testCase.LineNumber = int.Parse(propertyData!, CultureInfo.CurrentCulture); break; default: // No need to register member properties as they get registered as part of TestCaseProperties class. testProperty = TestProperty.Register(testProperty.Id, testProperty.Label, testProperty.GetValueType(), testProperty.Attributes, typeof(TestObject)); diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestResultConverter.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestResultConverter.cs index 0f6b48177c..1ea61521aa 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestResultConverter.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestResultConverter.cs @@ -95,11 +95,11 @@ public override object ReadJson(JsonReader reader, Type objectType, object? exis case "TestResult.Outcome": testResult.Outcome = (TestOutcome)Enum.Parse(typeof(TestOutcome), propertyData!); break; case "TestResult.Duration": - testResult.Duration = TimeSpan.Parse(propertyData!); break; + testResult.Duration = TimeSpan.Parse(propertyData!, CultureInfo.CurrentCulture); break; case "TestResult.StartTime": - testResult.StartTime = DateTimeOffset.Parse(propertyData!); break; + testResult.StartTime = DateTimeOffset.Parse(propertyData!, CultureInfo.CurrentCulture); break; case "TestResult.EndTime": - testResult.EndTime = DateTimeOffset.Parse(propertyData!); break; + testResult.EndTime = DateTimeOffset.Parse(propertyData!, CultureInfo.CurrentCulture); break; case "TestResult.ErrorMessage": testResult.ErrorMessage = propertyData; break; case "TestResult.ErrorStackTrace": diff --git a/src/Microsoft.TestPlatform.CoreUtilities/Helpers/CommandLineArgumentsHelper.cs b/src/Microsoft.TestPlatform.CoreUtilities/Helpers/CommandLineArgumentsHelper.cs index 89347391ed..6d59b3b1e9 100644 --- a/src/Microsoft.TestPlatform.CoreUtilities/Helpers/CommandLineArgumentsHelper.cs +++ b/src/Microsoft.TestPlatform.CoreUtilities/Helpers/CommandLineArgumentsHelper.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Globalization; namespace Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers; diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/BaseRunTests.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/BaseRunTests.cs index 7d232cb9f4..5d21e64282 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/BaseRunTests.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/BaseRunTests.cs @@ -678,7 +678,7 @@ private bool TryToRunInStaThread(Action action, bool waitForCompletion) EqtTrace.Warning("BaseRunTests.TryToRunInSTAThread: Failed to run in STA thread: {0}", ex); TestRunEventsHandler.HandleLogMessage( TestMessageLevel.Warning, - string.Format(CultureInfo.CurrentCulture, CrossPlatEngineResources.ExecutionThreadApartmentStateNotSupportedForFramework, _runConfiguration.TargetFramework.ToString())); + string.Format(CultureInfo.CurrentCulture, CrossPlatEngineResources.ExecutionThreadApartmentStateNotSupportedForFramework, _runConfiguration.TargetFramework!.ToString())); } return success; diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/TestEngine.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/TestEngine.cs index c2f1311b07..709d50e431 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/TestEngine.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/TestEngine.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Globalization; using System.Linq; using System.Text; @@ -674,7 +673,11 @@ private static void WarnAboutNotFoundRuntimeProvidersOrThrowWhenNoneAreFound(Lis { stringBuilder.Append(Resources.Resources.SkippingSource).Append(' '); } - stringBuilder.AppendLine($"{detail.Source} ({detail.Framework}, {detail.Architecture})"); + stringBuilder.AppendLine( +#if NET6_0_OR_GREATER + System.Globalization.CultureInfo.InvariantCulture, +#endif + $"{detail.Source} ({detail.Framework}, {detail.Architecture})"); }); } diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestResult.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestResult.cs index d23e39c5ce..9a22b3c87b 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestResult.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestResult.cs @@ -6,7 +6,6 @@ using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; -using System.Globalization; using Microsoft.TestPlatform.Extensions.TrxLogger.Utility; using Microsoft.TestPlatform.Extensions.TrxLogger.XML; diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/EqtAssert.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/EqtAssert.cs index b0c3303b39..d12662bf64 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/EqtAssert.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/EqtAssert.cs @@ -4,7 +4,6 @@ using System; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; -using System.Globalization; using Microsoft.VisualStudio.TestPlatform.Extensions.TrxLogger; diff --git a/src/Microsoft.TestPlatform.ObjectModel/Navigation/FullSymbolReader.cs b/src/Microsoft.TestPlatform.ObjectModel/Navigation/FullSymbolReader.cs index 77e077a056..165d408413 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Navigation/FullSymbolReader.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Navigation/FullSymbolReader.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Globalization; using System.IO; using System.Runtime.InteropServices; diff --git a/src/Microsoft.TestPlatform.Utilities/CommandLineUtilities.cs b/src/Microsoft.TestPlatform.Utilities/CommandLineUtilities.cs index 8dbde5f22d..b7c7fc0b66 100644 --- a/src/Microsoft.TestPlatform.Utilities/CommandLineUtilities.cs +++ b/src/Microsoft.TestPlatform.Utilities/CommandLineUtilities.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Globalization; using System.Text; using Microsoft.VisualStudio.TestPlatform.ObjectModel; diff --git a/src/vstest.console/Processors/ListFullyQualifiedTestsArgumentProcessor.cs b/src/vstest.console/Processors/ListFullyQualifiedTestsArgumentProcessor.cs index fb93d2ea9f..9b925023a2 100644 --- a/src/vstest.console/Processors/ListFullyQualifiedTestsArgumentProcessor.cs +++ b/src/vstest.console/Processors/ListFullyQualifiedTestsArgumentProcessor.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Globalization; using System.IO; using System.Linq; diff --git a/src/vstest.console/Processors/ListTestsTargetPathArgumentProcessor.cs b/src/vstest.console/Processors/ListTestsTargetPathArgumentProcessor.cs index 7639b2e6d7..8c2fd26991 100644 --- a/src/vstest.console/Processors/ListTestsTargetPathArgumentProcessor.cs +++ b/src/vstest.console/Processors/ListTestsTargetPathArgumentProcessor.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; -using System.Globalization; using Microsoft.VisualStudio.TestPlatform.ObjectModel; diff --git a/src/vstest.console/Processors/ResultsDirectoryArgumentProcessor.cs b/src/vstest.console/Processors/ResultsDirectoryArgumentProcessor.cs index ae2359765d..3855941ce0 100644 --- a/src/vstest.console/Processors/ResultsDirectoryArgumentProcessor.cs +++ b/src/vstest.console/Processors/ResultsDirectoryArgumentProcessor.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; -using System.Diagnostics.Contracts; using System.Globalization; using System.IO; using System.Security; diff --git a/src/vstest.console/Processors/RunTestsArgumentProcessor.cs b/src/vstest.console/Processors/RunTestsArgumentProcessor.cs index 0006656d25..b09ee265bb 100644 --- a/src/vstest.console/Processors/RunTestsArgumentProcessor.cs +++ b/src/vstest.console/Processors/RunTestsArgumentProcessor.cs @@ -2,8 +2,6 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; -using System.Diagnostics.Contracts; -using System.Globalization; using System.Linq; using Microsoft.VisualStudio.TestPlatform.Client.RequestHelper; diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyOperationManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyOperationManagerTests.cs index adb030cb32..7f8127035d 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyOperationManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyOperationManagerTests.cs @@ -93,7 +93,7 @@ public void SetupChannelShouldCreateTimestampedLogFileForHost() It.IsAny>(), It.IsAny>(), It.Is( - t => t.LogFile.Contains("log.host." + DateTime.Now.ToString("yy-MM-dd", CultureInfo.CurrentCulture)) + t => t.LogFile!.Contains("log.host." + DateTime.Now.ToString("yy-MM-dd", CultureInfo.CurrentCulture)) && t.LogFile.Contains("_" + Environment.CurrentManagedThreadId + ".txt")))); #if NETFRAMEWORK EqtTrace.TraceLevel = TraceLevel.Off; diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscovererEnumeratorTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscovererEnumeratorTests.cs index d92e5c52ed..9978da8ae2 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscovererEnumeratorTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscovererEnumeratorTests.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.ComponentModel; -using System.Globalization; using System.Linq; using System.Reflection; using System.Threading;