Skip to content

Commit

Permalink
fixes bug with the logic to insert a folder from the option windows
Browse files Browse the repository at this point in the history
  • Loading branch information
codingadventures committed Apr 25, 2018
1 parent e060a8e commit 669e292
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Src/DynamicCore/DynamicDebuggerVisualizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public Form ShowLINQPad(Stream inData, string vsVersion)
{
WindowStyle = ProcessWindowStyle.Normal,
FileName = Resources.LINQPadExe,
WorkingDirectory = linqPadInstallationPath,
WorkingDirectory = Path.GetFullPath(linqPadInstallationPath),
Arguments = linqQueryfileName + " " + Resources.LINQPadCommands
};

Expand Down
32 changes: 21 additions & 11 deletions Src/VsExtension.Helper/Settings/PackageSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ namespace BridgeVs.Helper.Settings
[CLSCompliant(false), ComVisible(true)]
public sealed class PackageSettings : DialogPage
{

private const string ErrorMessage = "Please insert a valid path to LINQPad";
[Category("LINQPad")]
[DisplayName("Installation Path")]
[Description("Sets the path to the LINQPad exe")]
Expand All @@ -34,25 +36,33 @@ public string LINQPadInstallationPath
var dte = (DTE)GetService(typeof(SDTE));
if (dte != null)
{
if (string.IsNullOrEmpty(value))
{
MessageBox.Show("Please insert a valid path to LINQPad");
return;
}
bool possiblePath = value.IndexOfAny(Path.GetInvalidPathChars()) == -1;
bool isPathInValid = string.IsNullOrEmpty(value)
|| value.IndexOfAny(Path.GetInvalidPathChars()) != -1;

if (!possiblePath)
if (isPathInValid)
{
MessageBox.Show("Please insert a valid path to LINQPad");
MessageBox.Show(ErrorMessage);
return;
}

if (!Directory.GetFiles(value, "*.exe", SearchOption.TopDirectoryOnly).Any( p=> p.Contains("LINQPad.exe")))
//check the inserted path is a valid directory that contains linqpad.exe
//if the inserted value is a file then check for its directory otherwise a directory
//has been inserted
var insertedDirectory = File.Exists(value) ? Path.GetDirectoryName(value) : value;

var isInvalidDirectory =
!Directory.Exists(insertedDirectory)
|| !Directory.GetFiles(insertedDirectory, "*.exe", SearchOption.TopDirectoryOnly)
.Any(p => p.Contains("LINQPad.exe"));

if (isInvalidDirectory)
{
MessageBox.Show("Please insert a valid path to LINQPad");
MessageBox.Show(ErrorMessage);
return;
}
CommonRegistryConfigurations.SetLINQPadInstallationPath(dte.Version, value);

string filterInsertedDirectory = Path.GetFullPath(insertedDirectory);
CommonRegistryConfigurations.SetLINQPadInstallationPath(dte.Version, filterInsertedDirectory);
}
}
}
Expand Down

0 comments on commit 669e292

Please sign in to comment.