From 3bbc39b95cd49b919ce0064de7c80e97700cc5a9 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Mon, 23 Dec 2024 23:02:52 +1100 Subject: [PATCH 1/3] remove some redundant qualifiers not possible for it to be null --- .../Execution/ExceptionHelper.cs | 2 +- .../Helpers/DataSerializationHelper.cs | 2 +- .../MSTest.TestAdapter/Helpers/FixtureKind.cs | 2 +- .../VSTestAdapter/MSTestDiscoverer.cs | 2 +- .../AssemblyResolver.cs | 8 +- .../Deployment/AssemblyLoadWorker.cs | 4 +- .../Services/ThreadOperations.cs | 2 +- .../Utilities/DeploymentUtility.cs | 2 +- .../Utilities/VSInstallationUtilities.cs | 2 +- ...JsonConfigurationFileParser.netstandard.cs | 6 +- .../OutputDevice/Terminal/NativeMethods.cs | 2 +- .../Execution/TestMethodRunnerTests.cs | 74 +++++++++---------- .../MSTestSettingsTests.cs | 10 +-- 13 files changed, 59 insertions(+), 59 deletions(-) diff --git a/src/Adapter/MSTest.TestAdapter/Execution/ExceptionHelper.cs b/src/Adapter/MSTest.TestAdapter/Execution/ExceptionHelper.cs index 5f2c2be59c..b25306e891 100644 --- a/src/Adapter/MSTest.TestAdapter/Execution/ExceptionHelper.cs +++ b/src/Adapter/MSTest.TestAdapter/Execution/ExceptionHelper.cs @@ -140,7 +140,7 @@ internal static string TrimStackTrace(string stackTrace) /// /// The aggregated exception message that considers inner exceptions. /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Requirement is to handle all kinds of user exceptions and message appropriately.")] + [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Requirement is to handle all kinds of user exceptions and message appropriately.")] internal static string GetFormattedExceptionMessage(this Exception ex) { DebugEx.Assert(ex != null, "exception should not be null."); diff --git a/src/Adapter/MSTest.TestAdapter/Helpers/DataSerializationHelper.cs b/src/Adapter/MSTest.TestAdapter/Helpers/DataSerializationHelper.cs index 0b9e1bc782..dc4a1cb069 100644 --- a/src/Adapter/MSTest.TestAdapter/Helpers/DataSerializationHelper.cs +++ b/src/Adapter/MSTest.TestAdapter/Helpers/DataSerializationHelper.cs @@ -14,7 +14,7 @@ internal static class DataSerializationHelper { UseSimpleDictionaryFormat = true, EmitTypeInformation = System.Runtime.Serialization.EmitTypeInformation.Always, - DateTimeFormat = new System.Runtime.Serialization.DateTimeFormat("O", System.Globalization.CultureInfo.InvariantCulture), + DateTimeFormat = new System.Runtime.Serialization.DateTimeFormat("O", CultureInfo.InvariantCulture), }; /// diff --git a/src/Adapter/MSTest.TestAdapter/Helpers/FixtureKind.cs b/src/Adapter/MSTest.TestAdapter/Helpers/FixtureKind.cs index c472b72d4b..7258055724 100644 --- a/src/Adapter/MSTest.TestAdapter/Helpers/FixtureKind.cs +++ b/src/Adapter/MSTest.TestAdapter/Helpers/FixtureKind.cs @@ -3,7 +3,7 @@ namespace Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Helpers; -[System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1602:Enumeration items should be documented", Justification = "Internal and self-explanatory")] +[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1602:Enumeration items should be documented", Justification = "Internal and self-explanatory")] internal enum FixtureKind { AssemblyInitialize, diff --git a/src/Adapter/MSTest.TestAdapter/VSTestAdapter/MSTestDiscoverer.cs b/src/Adapter/MSTest.TestAdapter/VSTestAdapter/MSTestDiscoverer.cs index c61b73aaa3..e64d03b055 100644 --- a/src/Adapter/MSTest.TestAdapter/VSTestAdapter/MSTestDiscoverer.cs +++ b/src/Adapter/MSTest.TestAdapter/VSTestAdapter/MSTestDiscoverer.cs @@ -33,7 +33,7 @@ public class MSTestDiscoverer : ITestDiscoverer /// Logger used to log messages. /// Used to send testcases and discovery related events back to Discoverer manager. [System.Security.SecurityCritical] - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Justification = "Discovery context can be null.")] + [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Justification = "Discovery context can be null.")] public void DiscoverTests(IEnumerable sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) => MSTestDiscoverer.DiscoverTests(sources, discoveryContext, logger, discoverySink, null); internal static void DiscoverTests(IEnumerable sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink, IConfiguration? configuration) diff --git a/src/Adapter/MSTestAdapter.PlatformServices/AssemblyResolver.cs b/src/Adapter/MSTestAdapter.PlatformServices/AssemblyResolver.cs index 6e09cd6020..4c5a64cc6f 100644 --- a/src/Adapter/MSTestAdapter.PlatformServices/AssemblyResolver.cs +++ b/src/Adapter/MSTestAdapter.PlatformServices/AssemblyResolver.cs @@ -485,8 +485,8 @@ private void WindowsRuntimeMetadataReflectionOnlyNamespaceResolve(object sender, /// The args. /// Indicates whether this is called under a Reflection Only Load context. /// The . - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Requirement is to handle all kinds of user exceptions and message appropriately.")] - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "senderAppDomain", Justification = "This is an event handler.")] + [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Requirement is to handle all kinds of user exceptions and message appropriately.")] + [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "senderAppDomain", Justification = "This is an event handler.")] #pragma warning disable IDE0060 // Remove unused parameter private Assembly? OnResolveInternal(object? senderAppDomain, ResolveEventArgs args, bool isReflectionOnly) #pragma warning restore IDE0060 // Remove unused parameter @@ -688,8 +688,8 @@ private static void SafeLog(string? assemblyName, Action loggerAction) /// The requested Name. /// Indicates whether this is called under a Reflection Only Load context. /// The . - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2001:AvoidCallingProblematicMethods", MessageId = "System.Reflection.Assembly.LoadFrom", Justification = "The assembly location is figured out from the configuration that the user passes in.")] - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Requirement is to handle all kinds of user exceptions and message appropriately.")] + [SuppressMessage("Microsoft.Reliability", "CA2001:AvoidCallingProblematicMethods", MessageId = "System.Reflection.Assembly.LoadFrom", Justification = "The assembly location is figured out from the configuration that the user passes in.")] + [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Requirement is to handle all kinds of user exceptions and message appropriately.")] private Assembly? SearchAndLoadAssembly(string assemblyPath, string assemblyName, AssemblyName requestedName, bool isReflectionOnly) { try diff --git a/src/Adapter/MSTestAdapter.PlatformServices/Deployment/AssemblyLoadWorker.cs b/src/Adapter/MSTestAdapter.PlatformServices/Deployment/AssemblyLoadWorker.cs index 7caef27a5a..d961636e4f 100644 --- a/src/Adapter/MSTestAdapter.PlatformServices/Deployment/AssemblyLoadWorker.cs +++ b/src/Adapter/MSTestAdapter.PlatformServices/Deployment/AssemblyLoadWorker.cs @@ -39,7 +39,7 @@ public AssemblyLoadWorker() /// Path to the assembly file to load from. /// The warnings. /// Full path to dependent assemblies. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Requirement is to handle all kinds of user exceptions and message appropriately.")] + [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Requirement is to handle all kinds of user exceptions and message appropriately.")] public IReadOnlyCollection GetFullPathToDependentAssemblies(string assemblyPath, out IList warnings) { DebugEx.Assert(!StringEx.IsNullOrEmpty(assemblyPath), "assemblyPath"); @@ -220,7 +220,7 @@ private void ProcessChildren(Assembly assembly, IList result, ISet The result. /// The visited Assemblies. /// The warnings. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Requirement is to handle all kinds of user exceptions and message appropriately.")] + [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Requirement is to handle all kinds of user exceptions and message appropriately.")] private void GetDependentAssembliesInternal(string assemblyString, IList result, ISet visitedAssemblies, IList warnings) { DebugEx.Assert(!StringEx.IsNullOrEmpty(assemblyString), "assemblyString"); diff --git a/src/Adapter/MSTestAdapter.PlatformServices/Services/ThreadOperations.cs b/src/Adapter/MSTestAdapter.PlatformServices/Services/ThreadOperations.cs index 156a2e7efb..1740059e36 100644 --- a/src/Adapter/MSTestAdapter.PlatformServices/Services/ThreadOperations.cs +++ b/src/Adapter/MSTestAdapter.PlatformServices/Services/ThreadOperations.cs @@ -59,7 +59,7 @@ private static bool ExecuteWithThreadPool(Action action, int timeout, Cancellati } #endif - [System.Runtime.Versioning.SupportedOSPlatform("windows")] + [SupportedOSPlatform("windows")] private static bool ExecuteWithCustomThread(Action action, int timeout, CancellationToken cancellationToken) { if (cancellationToken.IsCancellationRequested) diff --git a/src/Adapter/MSTestAdapter.PlatformServices/Utilities/DeploymentUtility.cs b/src/Adapter/MSTestAdapter.PlatformServices/Utilities/DeploymentUtility.cs index 51c73227b0..149727dd56 100644 --- a/src/Adapter/MSTestAdapter.PlatformServices/Utilities/DeploymentUtility.cs +++ b/src/Adapter/MSTestAdapter.PlatformServices/Utilities/DeploymentUtility.cs @@ -103,7 +103,7 @@ protected override void AddDependenciesOfDeploymentItem(string deploymentItemFil } #if NETFRAMEWORK - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Requirement is to handle all kinds of user exceptions and message appropriately.")] + [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Requirement is to handle all kinds of user exceptions and message appropriately.")] public void ProcessNewStorage(string testSource, IList deploymentItems, IList warnings) { // Add deployment items and process .config files only for storages we have not processed before. diff --git a/src/Adapter/MSTestAdapter.PlatformServices/Utilities/VSInstallationUtilities.cs b/src/Adapter/MSTestAdapter.PlatformServices/Utilities/VSInstallationUtilities.cs index 0a16f5e3f4..73e08164ab 100644 --- a/src/Adapter/MSTestAdapter.PlatformServices/Utilities/VSInstallationUtilities.cs +++ b/src/Adapter/MSTestAdapter.PlatformServices/Utilities/VSInstallationUtilities.cs @@ -40,7 +40,7 @@ public static class VSInstallationUtilities /// Gets the visual studio installation path on the local machine. /// /// VS install path. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Need to ignore failures to read the registry settings")] + [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Need to ignore failures to read the registry settings")] public static string? VSInstallPath { get diff --git a/src/Platform/Microsoft.Testing.Platform/Configurations/JsonConfigurationFileParser.netstandard.cs b/src/Platform/Microsoft.Testing.Platform/Configurations/JsonConfigurationFileParser.netstandard.cs index 74b89b15e0..0c594cfc6d 100644 --- a/src/Platform/Microsoft.Testing.Platform/Configurations/JsonConfigurationFileParser.netstandard.cs +++ b/src/Platform/Microsoft.Testing.Platform/Configurations/JsonConfigurationFileParser.netstandard.cs @@ -33,7 +33,7 @@ public static (Dictionary SingleValueData, Dictionary SingleValueData, Dictionary PropertyToAllChildren) ParseStream(Stream input) { using StreamReader reader = new(input); - var doc = (JsonObject)Jsonite.Json.Deserialize(reader.ReadToEnd(), _settings); + var doc = (JsonObject)Json.Deserialize(reader.ReadToEnd(), _settings); if (doc is not null) { VisitObjectElement(doc); @@ -66,7 +66,7 @@ private void SavePropertyToAllChildren(object? property) throw new FormatException(string.Format(CultureInfo.InvariantCulture, PlatformResources.JsonConfigurationFileParserDuplicateKeyErrorMessage, key)); } - _propertyToAllChildren[key] = Jsonite.Json.Serialize(property, _settings); + _propertyToAllChildren[key] = Json.Serialize(property, _settings); } private void VisitArrayElement(JsonArray array) @@ -116,7 +116,7 @@ private void VisitValue(object? value) // Adapt to the System.Text.Json serialization outcome _singleValueData[key] = value is bool boolean ? CultureInfo.InvariantCulture.TextInfo.ToTitleCase(boolean.ToString()) - : value is string stringValue ? stringValue.Trim('\"') : Jsonite.Json.Serialize(value, _settings); + : value is string stringValue ? stringValue.Trim('\"') : Json.Serialize(value, _settings); break; } diff --git a/src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/NativeMethods.cs b/src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/NativeMethods.cs index cd4ae2de81..daf9306011 100644 --- a/src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/NativeMethods.cs +++ b/src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/NativeMethods.cs @@ -30,7 +30,7 @@ internal static bool IsWindows internal static (bool AcceptAnsiColorCodes, bool OutputIsScreen, uint? OriginalConsoleMode) QueryIsScreenAndTryEnableAnsiColorCodes(StreamHandleType handleType = StreamHandleType.StdOut) { - if (System.Console.IsOutputRedirected) + if (Console.IsOutputRedirected) { // There's no ANSI terminal support if console output is redirected. return (AcceptAnsiColorCodes: false, OutputIsScreen: false, OriginalConsoleMode: null); diff --git a/test/UnitTests/MSTestAdapter.UnitTests/Execution/TestMethodRunnerTests.cs b/test/UnitTests/MSTestAdapter.UnitTests/Execution/TestMethodRunnerTests.cs index 7041365e7d..e973080b81 100644 --- a/test/UnitTests/MSTestAdapter.UnitTests/Execution/TestMethodRunnerTests.cs +++ b/test/UnitTests/MSTestAdapter.UnitTests/Execution/TestMethodRunnerTests.cs @@ -28,7 +28,7 @@ public class TestMethodRunnerTests : TestContainer { private readonly MethodInfo _methodInfo; - private readonly UTF.TestMethodAttribute _testMethodAttribute; + private readonly TestMethodAttribute _testMethodAttribute; private readonly TestContextImplementation _testContextImplementation; @@ -43,7 +43,7 @@ public class TestMethodRunnerTests : TestContainer public TestMethodRunnerTests() { _methodInfo = typeof(DummyTestClass).GetMethods().Single(m => m.Name.Equals("DummyTestMethod", StringComparison.Ordinal)); - _testMethodAttribute = new UTF.TestMethodAttribute(); + _testMethodAttribute = new TestMethodAttribute(); _testMethod = new TestMethod("dummyTestName", "dummyClassName", "dummyAssemblyName", false); _testContextImplementation = new TestContextImplementation(_testMethod, new ThreadSafeStringWriter(null, "test"), new Dictionary()); @@ -70,7 +70,7 @@ private static TestClassInfo GetTestClassInfo() { ConstructorInfo constructorInfo = typeof(T).GetConstructor([])!; PropertyInfo testContextProperty = typeof(T).GetProperty("TestContext"); - var classAttribute = new UTF.TestClassAttribute(); + var classAttribute = new TestClassAttribute(); var testAssemblyInfo = new TestAssemblyInfo(typeof(T).Assembly); return new TestClassInfo(typeof(T), constructorInfo, isParameterlessConstructor: true, testContextProperty, classAttribute, testAssemblyInfo); } @@ -96,7 +96,7 @@ public void ExecuteForTestThrowingExceptionShouldReturnUnitTestResultWithFailedO public void ExecuteForPassingTestShouldReturnUnitTestResultWithPassedOutcome() { - var testMethodInfo = new TestableTestMethodInfo(_methodInfo, _testClassInfo, _testMethodOptions, () => new UTF.TestResult() { Outcome = UTF.UnitTestOutcome.Passed }); + var testMethodInfo = new TestableTestMethodInfo(_methodInfo, _testClassInfo, _testMethodOptions, () => new TestResult() { Outcome = UTF.UnitTestOutcome.Passed }); var testMethodRunner = new TestMethodRunner(testMethodInfo, _testMethod, _testContextImplementation); UnitTestResult[] results = testMethodRunner.Execute(string.Empty, string.Empty, string.Empty, string.Empty); @@ -105,7 +105,7 @@ public void ExecuteForPassingTestShouldReturnUnitTestResultWithPassedOutcome() public void ExecuteShouldNotFillInDebugAndTraceLogsIfDebugTraceDisabled() { - var testMethodInfo = new TestableTestMethodInfo(_methodInfo, _testClassInfo, _testMethodOptions, () => new UTF.TestResult() { Outcome = UTF.UnitTestOutcome.Passed }); + var testMethodInfo = new TestableTestMethodInfo(_methodInfo, _testClassInfo, _testMethodOptions, () => new TestResult() { Outcome = UTF.UnitTestOutcome.Passed }); var testMethodRunner = new TestMethodRunner(testMethodInfo, _testMethod, _testContextImplementation); StringWriter writer = new(new StringBuilder("DummyTrace")); @@ -125,7 +125,7 @@ public void ExecuteShouldNotFillInDebugAndTraceLogsFromRunningTestMethod() () => { writer.Write("InTestMethod"); - return new UTF.TestResult() + return new TestResult() { Outcome = UTF.UnitTestOutcome.Passed, }; @@ -150,11 +150,11 @@ public void RunTestMethodForTestThrowingExceptionShouldReturnUnitTestResultWithF public void RunTestMethodForMultipleResultsReturnMultipleResults() { - var testMethodAttributeMock = new Mock(); - testMethodAttributeMock.Setup(_ => _.Execute(It.IsAny())).Returns( + var testMethodAttributeMock = new Mock(); + testMethodAttributeMock.Setup(_ => _.Execute(It.IsAny())).Returns( [ - new UTF.TestResult { Outcome = UTF.UnitTestOutcome.Passed }, - new UTF.TestResult { Outcome = UTF.UnitTestOutcome.Failed }, + new TestResult { Outcome = UTF.UnitTestOutcome.Passed }, + new TestResult { Outcome = UTF.UnitTestOutcome.Failed }, ]); var localTestMethodOptions = new TestMethodOptions(TimeoutInfo.FromTimeout(200), null, _testContextImplementation, false, testMethodAttributeMock.Object); @@ -171,7 +171,7 @@ public void RunTestMethodForMultipleResultsReturnMultipleResults() public void RunTestMethodForPassingTestThrowingExceptionShouldReturnUnitTestResultWithPassedOutcome() { - var testMethodInfo = new TestableTestMethodInfo(_methodInfo, _testClassInfo, _testMethodOptions, () => new UTF.TestResult() { Outcome = UTF.UnitTestOutcome.Passed }); + var testMethodInfo = new TestableTestMethodInfo(_methodInfo, _testClassInfo, _testMethodOptions, () => new TestResult() { Outcome = UTF.UnitTestOutcome.Passed }); var testMethodRunner = new TestMethodRunner(testMethodInfo, _testMethod, _testContextImplementation); UnitTestResult[] results = testMethodRunner.Execute(string.Empty, string.Empty, string.Empty, string.Empty); @@ -180,7 +180,7 @@ public void RunTestMethodForPassingTestThrowingExceptionShouldReturnUnitTestResu public void RunTestMethodForFailingTestThrowingExceptionShouldReturnUnitTestResultWithFailedOutcome() { - var testMethodInfo = new TestableTestMethodInfo(_methodInfo, _testClassInfo, _testMethodOptions, () => new UTF.TestResult() { Outcome = UTF.UnitTestOutcome.Failed }); + var testMethodInfo = new TestableTestMethodInfo(_methodInfo, _testClassInfo, _testMethodOptions, () => new TestResult() { Outcome = UTF.UnitTestOutcome.Failed }); var testMethodRunner = new TestMethodRunner(testMethodInfo, _testMethod, _testContextImplementation); UnitTestResult[] results = testMethodRunner.Execute(string.Empty, string.Empty, string.Empty, string.Empty); @@ -189,7 +189,7 @@ public void RunTestMethodForFailingTestThrowingExceptionShouldReturnUnitTestResu public void RunTestMethodShouldGiveTestResultAsPassedWhenTestMethodPasses() { - var testMethodInfo = new TestableTestMethodInfo(_methodInfo, _testClassInfo, _testMethodOptions, () => new UTF.TestResult() { Outcome = UTF.UnitTestOutcome.Passed }); + var testMethodInfo = new TestableTestMethodInfo(_methodInfo, _testClassInfo, _testMethodOptions, () => new TestResult() { Outcome = UTF.UnitTestOutcome.Passed }); var testMethodRunner = new TestMethodRunner(testMethodInfo, _testMethod, _testContextImplementation); UnitTestResult[] results = testMethodRunner.RunTestMethod(); @@ -200,7 +200,7 @@ public void RunTestMethodShouldGiveTestResultAsPassedWhenTestMethodPasses() public void RunTestMethodShouldGiveTestResultAsFailedWhenTestMethodFails() { - var testMethodInfo = new TestableTestMethodInfo(_methodInfo, _testClassInfo, _testMethodOptions, () => new UTF.TestResult() { Outcome = UTF.UnitTestOutcome.Failed }); + var testMethodInfo = new TestableTestMethodInfo(_methodInfo, _testClassInfo, _testMethodOptions, () => new TestResult() { Outcome = UTF.UnitTestOutcome.Failed }); var testMethodRunner = new TestMethodRunner(testMethodInfo, _testMethod, _testContextImplementation); UnitTestResult[] results = testMethodRunner.RunTestMethod(); @@ -211,10 +211,10 @@ public void RunTestMethodShouldGiveTestResultAsFailedWhenTestMethodFails() public void RunTestMethodShouldRunDataDrivenTestsWhenDataIsProvidedUsingDataSourceAttribute() { - var testMethodInfo = new TestableTestMethodInfo(_methodInfo, _testClassInfo, _testMethodOptions, () => new UTF.TestResult() { Outcome = UTF.UnitTestOutcome.Passed }); + var testMethodInfo = new TestableTestMethodInfo(_methodInfo, _testClassInfo, _testMethodOptions, () => new TestResult() { Outcome = UTF.UnitTestOutcome.Passed }); var testMethodRunner = new TestMethodRunner(testMethodInfo, _testMethod, _testContextImplementation); - UTF.DataSourceAttribute dataSourceAttribute = new("DummyConnectionString", "DummyTableName"); + DataSourceAttribute dataSourceAttribute = new("DummyConnectionString", "DummyTableName"); var attributes = new Attribute[] { dataSourceAttribute }; @@ -234,7 +234,7 @@ public void RunTestMethodShouldRunDataDrivenTestsWhenDataIsProvidedUsingDataSour public void RunTestMethodShouldRunDataDrivenTestsWhenDataIsProvidedUsingDataRowAttribute() { - UTF.TestResult testResult = new() + TestResult testResult = new() { Outcome = UTF.UnitTestOutcome.Inconclusive, }; @@ -244,7 +244,7 @@ public void RunTestMethodShouldRunDataDrivenTestsWhenDataIsProvidedUsingDataRowA int dummyIntData = 2; string dummyStringData = "DummyString"; - UTF.DataRowAttribute dataRowAttribute = new( + DataRowAttribute dataRowAttribute = new( dummyIntData, dummyStringData); @@ -262,7 +262,7 @@ public void RunTestMethodShouldSetDataRowIndexForDataDrivenTestsWhenDataIsProvid var testMethodInfo = new TestableTestMethodInfo(_methodInfo, _testClassInfo, _testMethodOptions, () => new UTF.TestResult()); var testMethodRunner = new TestMethodRunner(testMethodInfo, _testMethod, _testContextImplementation); - UTF.DataSourceAttribute dataSourceAttribute = new("DummyConnectionString", "DummyTableName"); + DataSourceAttribute dataSourceAttribute = new("DummyConnectionString", "DummyTableName"); var attributes = new Attribute[] { dataSourceAttribute }; @@ -283,10 +283,10 @@ public void RunTestMethodShouldRunOnlyDataSourceTestsWhenBothDataSourceAndDataRo var testMethodInfo = new TestableTestMethodInfo(_methodInfo, _testClassInfo, _testMethodOptions, () => new UTF.TestResult()); var testMethodRunner = new TestMethodRunner(testMethodInfo, _testMethod, _testContextImplementation); - UTF.DataSourceAttribute dataSourceAttribute = new("DummyConnectionString", "DummyTableName"); + DataSourceAttribute dataSourceAttribute = new("DummyConnectionString", "DummyTableName"); int dummyIntData = 2; string dummyStringData = "DummyString"; - UTF.DataRowAttribute dataRowAttribute = new( + DataRowAttribute dataRowAttribute = new( dummyIntData, dummyStringData); @@ -306,13 +306,13 @@ public void RunTestMethodShouldRunOnlyDataSourceTestsWhenBothDataSourceAndDataRo public void RunTestMethodShouldFillInDisplayNameWithDataRowDisplayNameIfProvidedForDataDrivenTests() { - UTF.TestResult testResult = new(); + TestResult testResult = new(); var testMethodInfo = new TestableTestMethodInfo(_methodInfo, _testClassInfo, _testMethodOptions, () => testResult); var testMethodRunner = new TestMethodRunner(testMethodInfo, _testMethod, _testContextImplementation); int dummyIntData = 2; string dummyStringData = "DummyString"; - UTF.DataRowAttribute dataRowAttribute = new(dummyIntData, dummyStringData) + DataRowAttribute dataRowAttribute = new(dummyIntData, dummyStringData) { DisplayName = "DataRowTestDisplayName", }; @@ -330,13 +330,13 @@ public void RunTestMethodShouldFillInDisplayNameWithDataRowDisplayNameIfProvided public void RunTestMethodShouldFillInDisplayNameWithDataRowArgumentsIfNoDisplayNameIsProvidedForDataDrivenTests() { - UTF.TestResult testResult = new(); + TestResult testResult = new(); var testMethodInfo = new TestableTestMethodInfo(_methodInfo, _testClassInfo, _testMethodOptions, () => testResult); var testMethodRunner = new TestMethodRunner(testMethodInfo, _testMethod, _testContextImplementation); int dummyIntData = 2; string dummyStringData = "DummyString"; - UTF.DataRowAttribute dataRowAttribute = new( + DataRowAttribute dataRowAttribute = new( dummyIntData, dummyStringData); @@ -353,7 +353,7 @@ public void RunTestMethodShouldFillInDisplayNameWithDataRowArgumentsIfNoDisplayN public void RunTestMethodShouldSetResultFilesIfPresentForDataDrivenTests() { - UTF.TestResult testResult = new() + TestResult testResult = new() { ResultFiles = new List() { "C:\\temp.txt" }, }; @@ -363,8 +363,8 @@ public void RunTestMethodShouldSetResultFilesIfPresentForDataDrivenTests() int dummyIntData1 = 1; int dummyIntData2 = 2; - UTF.DataRowAttribute dataRowAttribute1 = new(dummyIntData1); - UTF.DataRowAttribute dataRowAttribute2 = new(dummyIntData2); + DataRowAttribute dataRowAttribute1 = new(dummyIntData1); + DataRowAttribute dataRowAttribute2 = new(dummyIntData2); var attributes = new Attribute[] { dataRowAttribute1, dataRowAttribute2 }; @@ -429,7 +429,7 @@ private void RunTestMethodWithEmptyDataSourceShouldFailIfConsiderEmptyDataSource #region Test data [SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Use through reflection")] - private static void InitMethodThrowingException(UTFExtension.TestContext tc) + private static void InitMethodThrowingException(TestContext tc) // TODO: Fix exception type #pragma warning disable CA2208 // Instantiate argument exceptions correctly => throw new ArgumentException(); @@ -437,12 +437,12 @@ private static void InitMethodThrowingException(UTFExtension.TestContext tc) public class TestableTestMethodInfo : TestMethodInfo { - private readonly Func _invokeTest; + private readonly Func _invokeTest; internal TestableTestMethodInfo(MethodInfo testMethod, TestClassInfo parent, TestMethodOptions testMethodOptions, Func invoke) : base(testMethod, parent, testMethodOptions) => _invokeTest = invoke; - public override UTF.TestResult Invoke(object[] arguments) => + public override TestResult Invoke(object[] arguments) => // Ignore args for now _invokeTest(); } @@ -470,20 +470,20 @@ public class DummyTestClass : DummyTestClassBase public static Func DummyAsyncTestMethodBody { get; set; } - public static Action AssemblyInitializeMethodBody { get; set; } + public static Action AssemblyInitializeMethodBody { get; set; } - public static Action ClassInitializeMethodBody { get; set; } + public static Action ClassInitializeMethodBody { get; set; } - public UTFExtension.TestContext TestContext + public TestContext TestContext { get => throw new NotImplementedException(); set => TestContextSetterBody(value); } - public static void DummyAssemblyInit(UTFExtension.TestContext tc) => AssemblyInitializeMethodBody(tc); + public static void DummyAssemblyInit(TestContext tc) => AssemblyInitializeMethodBody(tc); - public static void DummyClassInit(UTFExtension.TestContext tc) => ClassInitializeMethodBody(tc); + public static void DummyClassInit(TestContext tc) => ClassInitializeMethodBody(tc); public void DummyTestInitializeMethod() => TestInitializeMethodBody(this); @@ -505,7 +505,7 @@ public DummyTestClassWithParameterizedCtor(int x) public class DummyTestClassWithTestContextWithoutSetter { - public UTFExtension.TestContext TestContext { get; } + public TestContext TestContext { get; } } public class DummyTestClassEmptyDataSource diff --git a/test/UnitTests/MSTestAdapter.UnitTests/MSTestSettingsTests.cs b/test/UnitTests/MSTestAdapter.UnitTests/MSTestSettingsTests.cs index 7e0eab35dc..42f859b59e 100644 --- a/test/UnitTests/MSTestAdapter.UnitTests/MSTestSettingsTests.cs +++ b/test/UnitTests/MSTestAdapter.UnitTests/MSTestSettingsTests.cs @@ -478,7 +478,7 @@ public void ParallelizationSettingsShouldBeSetToDefaultsWhenNotSet() var adapterSettings = MSTestSettings.GetSettings(runSettingxml, MSTestSettings.SettingsNameAlias, _mockMessageLogger.Object); Verify(Environment.ProcessorCount == adapterSettings.ParallelizationWorkers); - Verify(adapterSettings.ParallelizationScope == UTF.ExecutionScope.ClassLevel); + Verify(adapterSettings.ParallelizationScope == ExecutionScope.ClassLevel); } public void ParallelizationSettingsShouldBeSetToDefaultsOnAnEmptyParalleizeSetting() @@ -495,7 +495,7 @@ public void ParallelizationSettingsShouldBeSetToDefaultsOnAnEmptyParalleizeSetti var adapterSettings = MSTestSettings.GetSettings(runSettingxml, MSTestSettings.SettingsNameAlias, _mockMessageLogger.Object); Verify(Environment.ProcessorCount == adapterSettings.ParallelizationWorkers); - Verify(adapterSettings.ParallelizationScope == UTF.ExecutionScope.ClassLevel); + Verify(adapterSettings.ParallelizationScope == .ExecutionScope.ClassLevel); } public void ParallelizationSettingsShouldBeConsumedFromRunSettingsWhenSpecified() @@ -515,7 +515,7 @@ public void ParallelizationSettingsShouldBeConsumedFromRunSettingsWhenSpecified( var adapterSettings = MSTestSettings.GetSettings(runSettingxml, MSTestSettings.SettingsNameAlias, _mockMessageLogger.Object); Verify(adapterSettings.ParallelizationWorkers == 127); - Verify(adapterSettings.ParallelizationScope == UTF.ExecutionScope.MethodLevel); + Verify(adapterSettings.ParallelizationScope == ExecutionScope.MethodLevel); } public void GetSettingsShouldThrowIfParallelizationScopeIsNotValid() @@ -550,7 +550,7 @@ public void ParallelizationScopeShouldBeConsumedFromRunSettingsWhenSpecified() var adapterSettings = MSTestSettings.GetSettings(runSettingxml, MSTestSettings.SettingsNameAlias, _mockMessageLogger.Object); - Verify(adapterSettings.ParallelizationScope == UTF.ExecutionScope.MethodLevel); + Verify(adapterSettings.ParallelizationScope == ExecutionScope.MethodLevel); } public void GetSettingsShouldThrowWhenParallelizeHasInvalidElements() @@ -607,7 +607,7 @@ public void GetSettingsShouldBeAbleToReadAfterParallelizationSettingsWithData() Verify(adapterSettings.TestSettingsFile is not null); Verify(adapterSettings.ParallelizationWorkers == 127); - Verify(adapterSettings.ParallelizationScope == UTF.ExecutionScope.MethodLevel); + Verify(adapterSettings.ParallelizationScope == ExecutionScope.MethodLevel); } public void GetSettingsShouldBeAbleToReadAfterParallelizationSettingsOnEmptyParallelizationNode() From 1e54abb60cca9cb0873ef7d2cd3d67c2c00f1744 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Lev=C3=A9?= Date: Thu, 26 Dec 2024 10:14:58 +0100 Subject: [PATCH 2/3] Fix --- test/UnitTests/MSTestAdapter.UnitTests/MSTestSettingsTests.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/UnitTests/MSTestAdapter.UnitTests/MSTestSettingsTests.cs b/test/UnitTests/MSTestAdapter.UnitTests/MSTestSettingsTests.cs index d47d6277cb..97ff0c0704 100644 --- a/test/UnitTests/MSTestAdapter.UnitTests/MSTestSettingsTests.cs +++ b/test/UnitTests/MSTestAdapter.UnitTests/MSTestSettingsTests.cs @@ -13,8 +13,6 @@ using TestFramework.ForTestingMSTest; -using UTF = Microsoft.VisualStudio.TestTools.UnitTesting; - namespace Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests; public class MSTestSettingsTests : TestContainer @@ -493,7 +491,7 @@ public void ParallelizationSettingsShouldBeSetToDefaultsOnAnEmptyParalleizeSetti var adapterSettings = MSTestSettings.GetSettings(runSettingxml, MSTestSettings.SettingsNameAlias, _mockMessageLogger.Object); Verify(Environment.ProcessorCount == adapterSettings.ParallelizationWorkers); - Verify(adapterSettings.ParallelizationScope == .ExecutionScope.ClassLevel); + Verify(adapterSettings.ParallelizationScope == ExecutionScope.ClassLevel); } public void ParallelizationSettingsShouldBeConsumedFromRunSettingsWhenSpecified() From d8b5212408973f892b5551902701e609f42c5b6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Lev=C3=A9?= Date: Thu, 26 Dec 2024 10:37:15 +0100 Subject: [PATCH 3/3] More simplifications --- .../PlatformServiceProvider.cs | 4 ++-- .../MSTestBannerCapability.cs | 2 +- .../VSTestAdapter/MSTestDiscoverer.cs | 2 +- .../Services/ReflectionOperations2.cs | 2 +- .../CrashDumpEnvironmentVariableProvider.cs | 2 +- .../Hosts/TestHostBuilder.cs | 22 +++++++++---------- .../MSBuildTests.Test.cs | 2 +- .../Utilities/AppDomainUtilitiesTests.cs | 2 +- .../TestAssemblySettingsProviderTests.cs | 6 ++--- .../Execution/TestMethodRunnerTests.cs | 1 - .../TestablePlatformServiceProvider.cs | 2 +- .../Assertions/AssertTests.cs | 2 +- .../Automation.CLI/CLITestBase.common.cs | 4 ++-- 13 files changed, 26 insertions(+), 27 deletions(-) diff --git a/src/Adapter/MSTest.TestAdapter/PlatformServiceProvider.cs b/src/Adapter/MSTest.TestAdapter/PlatformServiceProvider.cs index 6bb7a3348f..90c8134b8c 100644 --- a/src/Adapter/MSTest.TestAdapter/PlatformServiceProvider.cs +++ b/src/Adapter/MSTest.TestAdapter/PlatformServiceProvider.cs @@ -27,11 +27,11 @@ private PlatformServiceProvider() => #if !WINDOWS_UWP // Set the provider that is used by DynamicDataAttribute when generating data, to allow substituting functionality // in TestFramework without having to put all the stuff in that library. - TestTools.UnitTesting.DynamicDataProvider.Instance = SourceGeneratorToggle.UseSourceGenerator + UTF.DynamicDataProvider.Instance = SourceGeneratorToggle.UseSourceGenerator ? new SourceGeneratedDynamicDataOperations() : new DynamicDataOperations(); #else - TestTools.UnitTesting.DynamicDataProvider.Instance = new DynamicDataOperations(); + UTF.DynamicDataProvider.Instance = new DynamicDataOperations(); #endif /// diff --git a/src/Adapter/MSTest.TestAdapter/TestingPlatformAdapter/MSTestBannerCapability.cs b/src/Adapter/MSTest.TestAdapter/TestingPlatformAdapter/MSTestBannerCapability.cs index 22f3d64a18..46693dd8c3 100644 --- a/src/Adapter/MSTest.TestAdapter/TestingPlatformAdapter/MSTestBannerCapability.cs +++ b/src/Adapter/MSTest.TestAdapter/TestingPlatformAdapter/MSTestBannerCapability.cs @@ -28,7 +28,7 @@ internal sealed class MSTestBannerCapability : IBannerMessageOwnerCapability } #if NETCOREAPP - if (System.Runtime.CompilerServices.RuntimeFeature.IsDynamicCodeCompiled) + if (RuntimeFeature.IsDynamicCodeCompiled) #endif { bannerMessage.Append(" ["); diff --git a/src/Adapter/MSTest.TestAdapter/VSTestAdapter/MSTestDiscoverer.cs b/src/Adapter/MSTest.TestAdapter/VSTestAdapter/MSTestDiscoverer.cs index e64d03b055..1ba0d68d3f 100644 --- a/src/Adapter/MSTest.TestAdapter/VSTestAdapter/MSTestDiscoverer.cs +++ b/src/Adapter/MSTest.TestAdapter/VSTestAdapter/MSTestDiscoverer.cs @@ -34,7 +34,7 @@ public class MSTestDiscoverer : ITestDiscoverer /// Used to send testcases and discovery related events back to Discoverer manager. [System.Security.SecurityCritical] [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Justification = "Discovery context can be null.")] - public void DiscoverTests(IEnumerable sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) => MSTestDiscoverer.DiscoverTests(sources, discoveryContext, logger, discoverySink, null); + public void DiscoverTests(IEnumerable sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) => DiscoverTests(sources, discoveryContext, logger, discoverySink, null); internal static void DiscoverTests(IEnumerable sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink, IConfiguration? configuration) { diff --git a/src/Adapter/MSTestAdapter.PlatformServices/Services/ReflectionOperations2.cs b/src/Adapter/MSTestAdapter.PlatformServices/Services/ReflectionOperations2.cs index cf7597438f..acce42de99 100644 --- a/src/Adapter/MSTestAdapter.PlatformServices/Services/ReflectionOperations2.cs +++ b/src/Adapter/MSTestAdapter.PlatformServices/Services/ReflectionOperations2.cs @@ -13,7 +13,7 @@ internal sealed class ReflectionOperations2 : ReflectionOperations, IReflectionO public ReflectionOperations2() { #if NET8_0_OR_GREATER - if (!System.Runtime.CompilerServices.RuntimeFeature.IsDynamicCodeSupported) + if (!RuntimeFeature.IsDynamicCodeSupported) { throw new NotSupportedException("ReflectionOperations2 are not allowed when dynamic code is not supported, use NativeReflectionOperations instead"); } diff --git a/src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpEnvironmentVariableProvider.cs b/src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpEnvironmentVariableProvider.cs index 47dbe3465e..95c11353cc 100644 --- a/src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpEnvironmentVariableProvider.cs +++ b/src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpEnvironmentVariableProvider.cs @@ -201,7 +201,7 @@ public Task ValidateTestHostEnvironmentVariablesAsync(IReadOnl static void AddError(StringBuilder errors, string variableName, string? expectedValue, string? actualValue) { string actualValueString = actualValue ?? ""; - errors.AppendLine(string.Format(System.Globalization.CultureInfo.InvariantCulture, CrashDumpResources.CrashDumpInvalidEnvironmentVariableValueErrorMessage, variableName, expectedValue, actualValueString)); + errors.AppendLine(string.Format(CultureInfo.InvariantCulture, CrashDumpResources.CrashDumpInvalidEnvironmentVariableValueErrorMessage, variableName, expectedValue, actualValueString)); } #endif } diff --git a/src/Platform/Microsoft.Testing.Platform/Hosts/TestHostBuilder.cs b/src/Platform/Microsoft.Testing.Platform/Hosts/TestHostBuilder.cs index 06c93611dc..ca36e2af56 100644 --- a/src/Platform/Microsoft.Testing.Platform/Hosts/TestHostBuilder.cs +++ b/src/Platform/Microsoft.Testing.Platform/Hosts/TestHostBuilder.cs @@ -503,7 +503,7 @@ await LogTestHostCreatedAsync( } // Build the test host - ConsoleTestHost consoleHost = TestHostBuilder.CreateConsoleTestHost( + ConsoleTestHost consoleHost = CreateConsoleTestHost( serviceProvider, BuildTestFrameworkAsync, (TestFrameworkManager)TestFramework, @@ -648,10 +648,10 @@ private async Task BuildTestFrameworkAsync(TestFrameworkBuilderD // creations and we could lose interesting diagnostic information. List dataConsumersBuilder = []; - await TestHostBuilder.RegisterAsServiceOrConsumerOrBothAsync(testFrameworkBuilderData.PlatformOutputDisplayService, serviceProvider, dataConsumersBuilder); - await TestHostBuilder.RegisterAsServiceOrConsumerOrBothAsync(testFrameworkBuilderData.TestExecutionRequestFactory, serviceProvider, dataConsumersBuilder); - await TestHostBuilder.RegisterAsServiceOrConsumerOrBothAsync(testFrameworkBuilderData.TestExecutionRequestInvoker, serviceProvider, dataConsumersBuilder); - await TestHostBuilder.RegisterAsServiceOrConsumerOrBothAsync(testFrameworkBuilderData.TestExecutionFilterFactory, serviceProvider, dataConsumersBuilder); + await RegisterAsServiceOrConsumerOrBothAsync(testFrameworkBuilderData.PlatformOutputDisplayService, serviceProvider, dataConsumersBuilder); + await RegisterAsServiceOrConsumerOrBothAsync(testFrameworkBuilderData.TestExecutionRequestFactory, serviceProvider, dataConsumersBuilder); + await RegisterAsServiceOrConsumerOrBothAsync(testFrameworkBuilderData.TestExecutionRequestInvoker, serviceProvider, dataConsumersBuilder); + await RegisterAsServiceOrConsumerOrBothAsync(testFrameworkBuilderData.TestExecutionFilterFactory, serviceProvider, dataConsumersBuilder); // Create the test framework adapter ITestFrameworkCapabilities testFrameworkCapabilities = serviceProvider.GetTestFrameworkCapabilities(); @@ -661,7 +661,7 @@ private async Task BuildTestFrameworkAsync(TestFrameworkBuilderD serviceProvider.AllowTestAdapterFrameworkRegistration = true; try { - await TestHostBuilder.RegisterAsServiceOrConsumerOrBothAsync(new TestFrameworkProxy(testFramework), serviceProvider, dataConsumersBuilder); + await RegisterAsServiceOrConsumerOrBothAsync(new TestFrameworkProxy(testFramework), serviceProvider, dataConsumersBuilder); } finally { @@ -687,11 +687,11 @@ private async Task BuildTestFrameworkAsync(TestFrameworkBuilderD { if (testhostExtension.Extension is IDataConsumer) { - await TestHostBuilder.RegisterAsServiceOrConsumerOrBothAsync(testhostExtension.Extension, serviceProvider, dataConsumersBuilder); + await RegisterAsServiceOrConsumerOrBothAsync(testhostExtension.Extension, serviceProvider, dataConsumersBuilder); } else { - await TestHostBuilder.AddServiceIfNotSkippedAsync(testhostExtension.Extension, serviceProvider); + await AddServiceIfNotSkippedAsync(testhostExtension.Extension, serviceProvider); } } } @@ -705,7 +705,7 @@ private async Task BuildTestFrameworkAsync(TestFrameworkBuilderD testSessionLifetimeHandlers.Add(handler); } - await TestHostBuilder.RegisterAsServiceOrConsumerOrBothAsync(consumerService, serviceProvider, dataConsumersBuilder); + await RegisterAsServiceOrConsumerOrBothAsync(consumerService, serviceProvider, dataConsumersBuilder); } // Register the test session lifetime handlers container @@ -721,7 +721,7 @@ private async Task BuildTestFrameworkAsync(TestFrameworkBuilderD // Allow the ITestApplicationProcessExitCode to subscribe as IDataConsumer ITestApplicationProcessExitCode testApplicationResult = serviceProvider.GetRequiredService(); - await TestHostBuilder.RegisterAsServiceOrConsumerOrBothAsync(testApplicationResult, serviceProvider, dataConsumersBuilder); + await RegisterAsServiceOrConsumerOrBothAsync(testApplicationResult, serviceProvider, dataConsumersBuilder); // We register the data consumer handler if we're connected to the dotnet test pipe if (pushOnlyProtocolDataConsumer is not null) @@ -817,7 +817,7 @@ private static async Task RegisterAsServiceOrConsumerOrBothAsync(object service, return; } - await TestHostBuilder.AddServiceIfNotSkippedAsync(service, serviceProvider); + await AddServiceIfNotSkippedAsync(service, serviceProvider); } private async Task DisplayBannerIfEnabledAsync(ApplicationLoggingState loggingState, ProxyOutputDevice outputDevice, diff --git a/test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/MSBuildTests.Test.cs b/test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/MSBuildTests.Test.cs index e403fdfbe4..fe1344af45 100644 --- a/test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/MSBuildTests.Test.cs +++ b/test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/MSBuildTests.Test.cs @@ -9,7 +9,7 @@ public class MSBuildTests_Test : AcceptanceTestBase private const string AssetName = "MSBuildTests"; public static string? FormatBuildMatrixEntry(MethodInfo method, object?[]? data) - => $"{data![0]},{(string.Equals(TargetFrameworks.All.ToMSBuildTargetFrameworks(), data[1]) ? "multitfm" : data[1])},{data[2]},{((bool)data[3]! ? "Succeeded" : "Failed")}"; + => $"{data![0]},{(Equals(TargetFrameworks.All.ToMSBuildTargetFrameworks(), data[1]) ? "multitfm" : data[1])},{data[2]},{((bool)data[3]! ? "Succeeded" : "Failed")}"; internal static IEnumerable<(string BuildCommand, string TargetFramework, BuildConfiguration BuildConfiguration, bool TestSucceeded)> GetBuildMatrix() { diff --git a/test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Utilities/AppDomainUtilitiesTests.cs b/test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Utilities/AppDomainUtilitiesTests.cs index 1f91b2374a..20414f8607 100644 --- a/test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Utilities/AppDomainUtilitiesTests.cs +++ b/test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Utilities/AppDomainUtilitiesTests.cs @@ -51,7 +51,7 @@ public void SetConfigurationFileShouldSetOMRedirectionIfConfigFileIsPresent() """; byte[] observedConfigBytes = setup.GetConfigurationBytes(); - string observedXml = System.Text.Encoding.UTF8.GetString(observedConfigBytes); + string observedXml = Encoding.UTF8.GetString(observedConfigBytes); Verify(SanitizeString(observedXml).Contains(SanitizeString(expectedRedir)), "Config must have OM redirection"); diff --git a/test/UnitTests/MSTestAdapter.UnitTests/Execution/TestAssemblySettingsProviderTests.cs b/test/UnitTests/MSTestAdapter.UnitTests/Execution/TestAssemblySettingsProviderTests.cs index 854ebb489c..95afcb4469 100644 --- a/test/UnitTests/MSTestAdapter.UnitTests/Execution/TestAssemblySettingsProviderTests.cs +++ b/test/UnitTests/MSTestAdapter.UnitTests/Execution/TestAssemblySettingsProviderTests.cs @@ -99,7 +99,7 @@ public void GetSettingsShouldSetParallelScopeToClassLevelByDefault() MSTest.TestAdapter.ObjectModel.TestAssemblySettings settings = TestAssemblySettingsProvider.GetSettings("Foo"); // Assert. - Verify(settings.Scope == UTF.ExecutionScope.ClassLevel); + Verify(settings.Scope == ExecutionScope.ClassLevel); } public void GetSettingsShouldSetParallelScope() @@ -112,13 +112,13 @@ public void GetSettingsShouldSetParallelScope() _testablePlatformServiceProvider .MockReflectionOperations .Setup(ro => ro.GetCustomAttributes(It.IsAny(), typeof(UTF.ParallelizeAttribute))) - .Returns([new UTF.ParallelizeAttribute { Scope = UTF.ExecutionScope.MethodLevel }]); + .Returns([new UTF.ParallelizeAttribute { Scope = ExecutionScope.MethodLevel }]); // Act. MSTest.TestAdapter.ObjectModel.TestAssemblySettings settings = TestAssemblySettingsProvider.GetSettings("Foo"); // Assert. - Verify(settings.Scope == UTF.ExecutionScope.MethodLevel); + Verify(settings.Scope == ExecutionScope.MethodLevel); } public void GetSettingsShouldSetCanParallelizeAssemblyToTrueByDefault() diff --git a/test/UnitTests/MSTestAdapter.UnitTests/Execution/TestMethodRunnerTests.cs b/test/UnitTests/MSTestAdapter.UnitTests/Execution/TestMethodRunnerTests.cs index ffc8b97de8..d5c4fe1939 100644 --- a/test/UnitTests/MSTestAdapter.UnitTests/Execution/TestMethodRunnerTests.cs +++ b/test/UnitTests/MSTestAdapter.UnitTests/Execution/TestMethodRunnerTests.cs @@ -15,7 +15,6 @@ using AdapterTestOutcome = Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.ObjectModel.UnitTestOutcome; using UTF = Microsoft.VisualStudio.TestTools.UnitTesting; -using UTFExtension = Microsoft.VisualStudio.TestTools.UnitTesting; namespace Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution; diff --git a/test/UnitTests/MSTestAdapter.UnitTests/TestableImplementations/TestablePlatformServiceProvider.cs b/test/UnitTests/MSTestAdapter.UnitTests/TestableImplementations/TestablePlatformServiceProvider.cs index 80dae5ce83..f00c1b7411 100644 --- a/test/UnitTests/MSTestAdapter.UnitTests/TestableImplementations/TestablePlatformServiceProvider.cs +++ b/test/UnitTests/MSTestAdapter.UnitTests/TestableImplementations/TestablePlatformServiceProvider.cs @@ -27,7 +27,7 @@ public TestablePlatformServiceProvider() MockTraceListener = new Mock(); MockTraceListenerManager = new Mock(); MockThreadOperations = new Mock(); - TestTools.UnitTesting.DynamicDataProvider.Instance = SourceGeneratorToggle.UseSourceGenerator + UTF.DynamicDataProvider.Instance = SourceGeneratorToggle.UseSourceGenerator ? new SourceGeneratedDynamicDataOperations() : new DynamicDataOperations(); } diff --git a/test/UnitTests/TestFramework.UnitTests/Assertions/AssertTests.cs b/test/UnitTests/TestFramework.UnitTests/Assertions/AssertTests.cs index 4d1f5a12c3..8b3584fc46 100644 --- a/test/UnitTests/TestFramework.UnitTests/Assertions/AssertTests.cs +++ b/test/UnitTests/TestFramework.UnitTests/Assertions/AssertTests.cs @@ -10,7 +10,7 @@ public partial class AssertTests #region That tests public void ThatShouldReturnAnInstanceOfAssert() => Verify(Assert.That is not null); - public void ThatShouldCacheAssertInstance() => Verify(object.ReferenceEquals(Assert.That, Assert.That)); + public void ThatShouldCacheAssertInstance() => Verify(ReferenceEquals(Assert.That, Assert.That)); #endregion #region ReplaceNullChars tests diff --git a/test/Utilities/Automation.CLI/CLITestBase.common.cs b/test/Utilities/Automation.CLI/CLITestBase.common.cs index 6f307a30c4..bc098fad92 100644 --- a/test/Utilities/Automation.CLI/CLITestBase.common.cs +++ b/test/Utilities/Automation.CLI/CLITestBase.common.cs @@ -44,7 +44,7 @@ protected static string GetTestPlatformVersion() protected static string GetArtifactsBinFolderPath() { - string assemblyLocation = System.Reflection.Assembly.GetExecutingAssembly().Location; + string assemblyLocation = Assembly.GetExecutingAssembly().Location; string artifactsBinFolder = Path.GetFullPath(Path.Combine(assemblyLocation, @"..\..\..\..")); Directory.Exists(artifactsBinFolder).Should().BeTrue(); @@ -54,7 +54,7 @@ protected static string GetArtifactsBinFolderPath() protected static string GetArtifactsTestResultsFolderPath() { - string assemblyLocation = System.Reflection.Assembly.GetExecutingAssembly().Location; + string assemblyLocation = Assembly.GetExecutingAssembly().Location; string artifactsFolder = Path.GetFullPath(Path.Combine(assemblyLocation, @"..\..\..\..\..")); Directory.Exists(artifactsFolder).Should().BeTrue();