Skip to content

Commit

Permalink
join some declarations (#4529)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Jun 7, 2023
1 parent cd06405 commit 8381658
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,8 @@ private static void GetManagedNameAndHierarchy(MethodBase method, bool useClosed
/// </remarks>
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)
{
Expand Down Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,7 @@ private IEnumerable<string> 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");
Expand All @@ -98,7 +95,7 @@ private IEnumerable<string> GetTestExtensionsInternal(string extensionType)
try
{
// create extension manager
extensionManager = Activator.CreateInstance(ExtensionManagerServiceType, settingsManager);
var extensionManager = Activator.CreateInstance(ExtensionManagerServiceType, settingsManager);

if (extensionManager != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -665,10 +665,9 @@ public static IEnumerable<string> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@ public void Initialize(string? argument)
string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestAdapterPathValueRequired));
}

string[] customAdaptersPath;

var testAdapterPaths = new List<string>();

// VSTS task add double quotes around TestAdapterpath. For example if user has given TestAdapter path C:\temp,
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -692,8 +692,6 @@ public IVsTestConsoleWrapper GetVsTestConsoleWrapper(Dictionary<string, string?>

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.
Expand All @@ -717,7 +715,7 @@ public IVsTestConsoleWrapper GetVsTestConsoleWrapper(Dictionary<string, string?>
consoleParameters.EnvironmentVariables = environmentVariables;
}

vstestConsoleWrapper = new VsTestConsoleWrapper(consoleRunnerPath, dotnetPath, consoleParameters);
var vstestConsoleWrapper = new VsTestConsoleWrapper(consoleRunnerPath, dotnetPath, consoleParameters);
vstestConsoleWrapper.StartSession();

return vstestConsoleWrapper;
Expand Down

0 comments on commit 8381658

Please sign in to comment.