From dc623228bff7c3907217ed5dc69f5cff26230a71 Mon Sep 17 00:00:00 2001 From: Felix Date: Wed, 27 Sep 2023 17:58:55 +0200 Subject: [PATCH] ProjectConfigService.GetItemsFromProjectConfig now returns a list --- .../Services/ProjectConfigService.cs | 10 +++++++--- .../Services/ViewModelUpdateService.cs | 9 +-------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/SmartCmdArgs/SmartCmdArgs.Shared/Services/ProjectConfigService.cs b/SmartCmdArgs/SmartCmdArgs.Shared/Services/ProjectConfigService.cs index ce184132..6c3b1cc9 100644 --- a/SmartCmdArgs/SmartCmdArgs.Shared/Services/ProjectConfigService.cs +++ b/SmartCmdArgs/SmartCmdArgs.Shared/Services/ProjectConfigService.cs @@ -12,7 +12,7 @@ public interface IProjectConfigService { bool IsSupportedProject(IVsHierarchyWrapper project); - void GetItemsFromProjectConfig(IVsHierarchyWrapper project, List allArgs); + List GetItemsFromProjectConfig(IVsHierarchyWrapper project); void UpdateProjectConfig(IVsHierarchyWrapper project); } @@ -698,17 +698,21 @@ private static bool TryGetProjectConfigHandlers(IVsHierarchyWrapper project, out return supportedProjects.TryGetValue(projectKind, out handler); } - public void GetItemsFromProjectConfig(IVsHierarchyWrapper project, List allArgs) + public List GetItemsFromProjectConfig(IVsHierarchyWrapper project) { + var result = new List(); + if (TryGetProjectConfigHandlers(project, out ProjectConfigHandlers handler)) { handler.GetItemsFromConfig( project.GetProject(), - allArgs, + result, includeArgs: optionsSettings.ManageCommandLineArgs, includeEnvVars: optionsSettings.ManageEnvironmentVars, includeWorkDir: optionsSettings.ManageWorkingDirectories); } + + return result; } public void UpdateProjectConfig(IVsHierarchyWrapper project) diff --git a/SmartCmdArgs/SmartCmdArgs.Shared/Services/ViewModelUpdateService.cs b/SmartCmdArgs/SmartCmdArgs.Shared/Services/ViewModelUpdateService.cs index 1f912227..66312a52 100644 --- a/SmartCmdArgs/SmartCmdArgs.Shared/Services/ViewModelUpdateService.cs +++ b/SmartCmdArgs/SmartCmdArgs.Shared/Services/ViewModelUpdateService.cs @@ -188,7 +188,7 @@ public void UpdateCommandsForProject(IVsHierarchyWrapper project) projectData = new ProjectDataJson(); Logger.Info($"Gathering commands from configurations for project '{project.GetName()}'."); - projectData.Items.AddRange(ReadCommandlineArgumentsFromProject(project)); + projectData.Items.AddRange(projectConfig.GetItemsFromProjectConfig(project)); } // push projectData to the ViewModel @@ -197,13 +197,6 @@ public void UpdateCommandsForProject(IVsHierarchyWrapper project) Logger.Info($"Updated Commands for project '{project.GetName()}'."); } - private List ReadCommandlineArgumentsFromProject(IVsHierarchyWrapper project) - { - var prjCmdArgs = new List(); - projectConfig.GetItemsFromProjectConfig(project, prjCmdArgs); - return prjCmdArgs; - } - private ISet GetAllActiveItemsForProject(IVsHierarchyWrapper project) { if (!optionsSettings.ManageCommandLineArgs