Skip to content

Commit

Permalink
get current path
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahCx committed Sep 30, 2024
1 parent 495540e commit 0de92f5
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions ast-visual-studio-extension/CxExtension/Toolbar/CxToolbar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
using Microsoft.VisualStudio.Imaging;
using ast_visual_studio_extension.CxWrapper.Exceptions;
using System.Linq;
using EnvDTE;
using EnvDTE80;

namespace ast_visual_studio_extension.CxExtension.Toolbar
{
Expand Down Expand Up @@ -361,9 +363,11 @@ private async Task StartScanAsync()
var scanId = SettingsUtils.GetToolbarValue(Package, SettingsUtils.createdScanIdProperty);
if (cxWrapper == null || !string.IsNullOrWhiteSpace(scanId)) return;

string currentPath = await GetCurrentWorkingDirAsync();

Dictionary<string, string> parameters = new Dictionary<string, string>
{
{ CxCLI.CxConstants.FLAG_SOURCE, "." },
{ CxCLI.CxConstants.FLAG_SOURCE, currentPath },
{ CxCLI.CxConstants.FLAG_PROJECT_NAME, ProjectsCombo.Text },
{ CxCLI.CxConstants.FLAG_BRANCH, BranchesCombo.Text },
{ CxCLI.CxConstants.FLAG_AGENT, CxCLI.CxConstants.EXTENSION_AGENT }
Expand All @@ -384,7 +388,22 @@ private async Task StartScanAsync()
}
}

private async Task PollScanStartedAsync()
private static async Task<string> GetCurrentWorkingDirAsync()
{
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

DTE2 dte = (DTE2)ServiceProvider.GlobalProvider.GetService(typeof(DTE));

var solutionExplorer = dte.ToolWindows.SolutionExplorer;

if ((solutionExplorer.DTE.ActiveSolutionProjects as Array)?.Length > 0)
{
return System.IO.Path.GetDirectoryName(dte.Solution.FullName);
}
return ".";
}

private async Task PollScanStartedAsync()
{
ScanStartButton.IsEnabled = false;
var tsc = Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SVsTaskStatusCenterService)) as IVsTaskStatusCenterService;
Expand Down

0 comments on commit 0de92f5

Please sign in to comment.