Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic selection of the current path (AST-67695) #206

Merged
merged 1 commit into from
Oct 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
OrShamirCM marked this conversation as resolved.
Show resolved Hide resolved

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
Loading