Skip to content

Commit 669e292

Browse files
fixes bug with the logic to insert a folder from the option windows
1 parent e060a8e commit 669e292

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

Src/DynamicCore/DynamicDebuggerVisualizer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public Form ShowLINQPad(Stream inData, string vsVersion)
161161
{
162162
WindowStyle = ProcessWindowStyle.Normal,
163163
FileName = Resources.LINQPadExe,
164-
WorkingDirectory = linqPadInstallationPath,
164+
WorkingDirectory = Path.GetFullPath(linqPadInstallationPath),
165165
Arguments = linqQueryfileName + " " + Resources.LINQPadCommands
166166
};
167167

Src/VsExtension.Helper/Settings/PackageSettings.cs

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ namespace BridgeVs.Helper.Settings
1616
[CLSCompliant(false), ComVisible(true)]
1717
public sealed class PackageSettings : DialogPage
1818
{
19+
20+
private const string ErrorMessage = "Please insert a valid path to LINQPad";
1921
[Category("LINQPad")]
2022
[DisplayName("Installation Path")]
2123
[Description("Sets the path to the LINQPad exe")]
@@ -34,25 +36,33 @@ public string LINQPadInstallationPath
3436
var dte = (DTE)GetService(typeof(SDTE));
3537
if (dte != null)
3638
{
37-
if (string.IsNullOrEmpty(value))
38-
{
39-
MessageBox.Show("Please insert a valid path to LINQPad");
40-
return;
41-
}
42-
bool possiblePath = value.IndexOfAny(Path.GetInvalidPathChars()) == -1;
39+
bool isPathInValid = string.IsNullOrEmpty(value)
40+
|| value.IndexOfAny(Path.GetInvalidPathChars()) != -1;
4341

44-
if (!possiblePath)
42+
if (isPathInValid)
4543
{
46-
MessageBox.Show("Please insert a valid path to LINQPad");
44+
MessageBox.Show(ErrorMessage);
4745
return;
4846
}
4947

50-
if (!Directory.GetFiles(value, "*.exe", SearchOption.TopDirectoryOnly).Any( p=> p.Contains("LINQPad.exe")))
48+
//check the inserted path is a valid directory that contains linqpad.exe
49+
//if the inserted value is a file then check for its directory otherwise a directory
50+
//has been inserted
51+
var insertedDirectory = File.Exists(value) ? Path.GetDirectoryName(value) : value;
52+
53+
var isInvalidDirectory =
54+
!Directory.Exists(insertedDirectory)
55+
|| !Directory.GetFiles(insertedDirectory, "*.exe", SearchOption.TopDirectoryOnly)
56+
.Any(p => p.Contains("LINQPad.exe"));
57+
58+
if (isInvalidDirectory)
5159
{
52-
MessageBox.Show("Please insert a valid path to LINQPad");
60+
MessageBox.Show(ErrorMessage);
5361
return;
5462
}
55-
CommonRegistryConfigurations.SetLINQPadInstallationPath(dte.Version, value);
63+
64+
string filterInsertedDirectory = Path.GetFullPath(insertedDirectory);
65+
CommonRegistryConfigurations.SetLINQPadInstallationPath(dte.Version, filterInsertedDirectory);
5666
}
5767
}
5868
}

0 commit comments

Comments
 (0)