diff --git a/src/Microsoft.TestPlatform.AdapterUtilities/ManagedNameUtilities/ManagedNameHelper.Reflection.cs b/src/Microsoft.TestPlatform.AdapterUtilities/ManagedNameUtilities/ManagedNameHelper.Reflection.cs index 0f5848d568..e08ee95647 100644 --- a/src/Microsoft.TestPlatform.AdapterUtilities/ManagedNameUtilities/ManagedNameHelper.Reflection.cs +++ b/src/Microsoft.TestPlatform.AdapterUtilities/ManagedNameUtilities/ManagedNameHelper.Reflection.cs @@ -232,10 +232,8 @@ private static void GetManagedNameAndHierarchy(MethodBase method, bool useClosed /// public static MethodBase GetMethod(Assembly assembly, string managedTypeName, string managedMethodName) { - Type? type; - var parsedManagedTypeName = ReflectionHelpers.ParseEscapedString(managedTypeName); - type = assembly.GetType(parsedManagedTypeName, throwOnError: false, ignoreCase: false); + var type = assembly.GetType(parsedManagedTypeName, throwOnError: false, ignoreCase: false); if (type == null) { @@ -291,10 +289,8 @@ bool Filter(MemberInfo mbr, object? param) return true; } - MemberInfo[] methods; - var bindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static; - methods = type.FindMembers(MemberTypes.Method, bindingFlags, Filter, null); + var methods = type.FindMembers(MemberTypes.Method, bindingFlags, Filter, null); return (MethodInfo?)(methods.Length switch { diff --git a/src/Microsoft.TestPlatform.Common/ExtensionFramework/VSExtensionManager.cs b/src/Microsoft.TestPlatform.Common/ExtensionFramework/VSExtensionManager.cs index 9b516ea109..cec8312fe0 100644 --- a/src/Microsoft.TestPlatform.Common/ExtensionFramework/VSExtensionManager.cs +++ b/src/Microsoft.TestPlatform.Common/ExtensionFramework/VSExtensionManager.cs @@ -85,10 +85,7 @@ private IEnumerable GetTestExtensionsInternal(string extensionType) var resolutionPaths = installContext.GetVisualStudioCommonLocations(vsInstallPath); using (var assemblyResolver = new AssemblyResolver(resolutionPaths)) { - object? extensionManager; - object? settingsManager; - - settingsManager = SettingsManagerType.GetMethod("CreateForApplication", new Type[] { typeof(string) })?.Invoke(null, new object[] { installContext.GetVisualStudioPath(vsInstallPath) }); + var settingsManager = SettingsManagerType.GetMethod("CreateForApplication", new Type[] { typeof(string) })?.Invoke(null, new object[] { installContext.GetVisualStudioPath(vsInstallPath) }); if (settingsManager == null) { EqtTrace.Warning("VSExtensionManager : Unable to create settings manager"); @@ -98,7 +95,7 @@ private IEnumerable GetTestExtensionsInternal(string extensionType) try { // create extension manager - extensionManager = Activator.CreateInstance(ExtensionManagerServiceType, settingsManager); + var extensionManager = Activator.CreateInstance(ExtensionManagerServiceType, settingsManager); if (extensionManager != null) { diff --git a/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs b/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs index 6592a8fd09..6087dbb2e4 100644 --- a/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs +++ b/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs @@ -665,10 +665,9 @@ public static IEnumerable FilterCompatibleSources(Architecture chosenPla bool isSettingIncompatible = IsSettingIncompatible(actualPlatform, chosenPlatform, actualFramework, chosenFramework); if (isSettingIncompatible) { - string incompatiblityMessage; var onlyFileName = Path.GetFileName(source); // Add message for incompatible sources. - incompatiblityMessage = string.Format(CultureInfo.CurrentCulture, OMResources.SourceIncompatible, onlyFileName, actualFramework.Name, actualPlatform); + var incompatiblityMessage = string.Format(CultureInfo.CurrentCulture, OMResources.SourceIncompatible, onlyFileName, actualFramework.Name, actualPlatform); warnings.AppendLine(incompatiblityMessage); incompatiblityFound = true; diff --git a/src/vstest.console/Processors/TestAdapterPathArgumentProcessor.cs b/src/vstest.console/Processors/TestAdapterPathArgumentProcessor.cs index f18af53704..2c1ab3f7b0 100644 --- a/src/vstest.console/Processors/TestAdapterPathArgumentProcessor.cs +++ b/src/vstest.console/Processors/TestAdapterPathArgumentProcessor.cs @@ -127,8 +127,6 @@ public void Initialize(string? argument) string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestAdapterPathValueRequired)); } - string[] customAdaptersPath; - var testAdapterPaths = new List(); // VSTS task add double quotes around TestAdapterpath. For example if user has given TestAdapter path C:\temp, @@ -145,7 +143,7 @@ public void Initialize(string? argument) } testAdapterPaths.AddRange(SplitPaths(argument)); - customAdaptersPath = testAdapterPaths.Distinct().ToArray(); + var customAdaptersPath = testAdapterPaths.Distinct().ToArray(); _runSettingsManager.UpdateRunSettingsNode(RunSettingsPath, string.Join(";", customAdaptersPath)); _commandLineOptions.TestAdapterPath = customAdaptersPath; diff --git a/test/Microsoft.TestPlatform.TestUtilities/IntegrationTestBase.cs b/test/Microsoft.TestPlatform.TestUtilities/IntegrationTestBase.cs index c35573aadb..dc2865861c 100644 --- a/test/Microsoft.TestPlatform.TestUtilities/IntegrationTestBase.cs +++ b/test/Microsoft.TestPlatform.TestUtilities/IntegrationTestBase.cs @@ -692,8 +692,6 @@ public IVsTestConsoleWrapper GetVsTestConsoleWrapper(Dictionary Console.WriteLine($"Console runner path: {consoleRunnerPath}"); - VsTestConsoleWrapper vstestConsoleWrapper; - // Providing any environment variable to vstest.console will clear all existing environment variables, // this works around it by copying all existing variables, and adding debug. But we only want to do that // when we are setting any debug variables. @@ -717,7 +715,7 @@ public IVsTestConsoleWrapper GetVsTestConsoleWrapper(Dictionary consoleParameters.EnvironmentVariables = environmentVariables; } - vstestConsoleWrapper = new VsTestConsoleWrapper(consoleRunnerPath, dotnetPath, consoleParameters); + var vstestConsoleWrapper = new VsTestConsoleWrapper(consoleRunnerPath, dotnetPath, consoleParameters); vstestConsoleWrapper.StartSession(); return vstestConsoleWrapper;