Skip to content

Commit d9dd531

Browse files
Enhance the command preprocessor
1 parent 839d89e commit d9dd531

File tree

3 files changed

+0
-103
lines changed

3 files changed

+0
-103
lines changed

mcp_nexus/Utilities/PathHandler.cs

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,6 @@ public static string ConvertToWindowsPath(string path)
5858
return cached.Converted;
5959
}
6060

61-
// Fast-path: /mnt/<drive>/... mapping without external calls
62-
if (TryConvertLocalMntMapping(path, out var localConverted))
63-
{
64-
m_ConversionCache[path] = (localConverted, DateTime.UtcNow + ConversionTtl);
65-
return localConverted;
66-
}
67-
6861
// Use fstab mapping (cached) before invoking wslpath
6962
if (TryConvertWithFstabMapping(path, out var fstabConverted))
7063
{
@@ -90,38 +83,6 @@ public static string ConvertToWindowsPath(string path)
9083
}
9184
}
9285

93-
/// <summary>
94-
/// Local, zero-cost conversion for /mnt/<letter> patterns without spawning processes.
95-
/// </summary>
96-
private static bool TryConvertLocalMntMapping(string path, out string windowsPath)
97-
{
98-
windowsPath = path;
99-
if (!path.StartsWith("/mnt/", StringComparison.OrdinalIgnoreCase) || path.Length < 6)
100-
{
101-
return false;
102-
}
103-
104-
char letter = path[5];
105-
// Expecting /mnt/<letter> or /mnt/<letter>/...
106-
if (!char.IsLetter(letter))
107-
{
108-
return false;
109-
}
110-
111-
string rest = path.Length > 6 ? path.Substring(6) : string.Empty; // skip "/mnt/<l>"
112-
// Normalize: if rest starts with '/', drop it for root scenarios
113-
if (rest.StartsWith('/')) rest = rest.Substring(1);
114-
115-
if (string.IsNullOrEmpty(rest))
116-
{
117-
windowsPath = char.ToUpperInvariant(letter) + ":\\";
118-
return true;
119-
}
120-
121-
windowsPath = char.ToUpperInvariant(letter) + ":\\" + rest.Replace('/', '\\');
122-
return true;
123-
}
124-
12586
/// <summary>
12687
/// Attempts to convert a Linux path to a Windows path using 'wsl.exe wslpath -w'.
12788
/// Uses a very short timeout and fails silently to avoid blocking.

mcp_nexus_tests/Utilities/CommandPreprocessorTests.cs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ namespace mcp_nexus_tests.Utilities
1010
public class CommandPreprocessorTests
1111
{
1212
[Theory]
13-
[InlineData(".srcpath /mnt/c/inetpub/wwwroot/workingdir/work_20251006_185410_082/source",
14-
".srcpath C:\\inetpub\\wwwroot\\workingdir\\work_20251006_185410_082\\source")]
15-
[InlineData(".srcpath srv*/mnt/c/inetpub/wwwroot/workingdir/Sources",
16-
".srcpath srv*C:\\inetpub\\wwwroot\\workingdir\\Sources")]
17-
[InlineData(".srcpath \"srv*;/mnt/c/inetpub/wwwroot/workingdir/Sources\"",
18-
".srcpath \"srv*;C:\\inetpub\\wwwroot\\workingdir\\Sources\"")]
1913
[InlineData(".srcpath \"C:\\already\\windows\\path\"",
2014
".srcpath \"C:\\already\\windows\\path\"")]
2115
[InlineData(".srcpath srv*Q:\\Workbench\\Analyses\\test-dmp_src",
@@ -132,24 +126,6 @@ public void PreprocessCommand_Symfix_CreatesLocalStore_ForWindowsPath()
132126
}
133127
}
134128

135-
[Fact]
136-
public void PreprocessCommand_Symfix_ConvertsAndCreates_ForWslPath()
137-
{
138-
var temp = Path.Combine(Path.GetTempPath(), "symfix_" + Guid.NewGuid().ToString("N").Substring(0, 8));
139-
var wsl = PathHandler.ConvertToWslPath(temp);
140-
try
141-
{
142-
var input = $".symfix {wsl}";
143-
var result = CommandPreprocessor.PreprocessCommand(input);
144-
Assert.Equal($".symfix {temp}", result);
145-
Assert.True(Directory.Exists(temp));
146-
}
147-
finally
148-
{
149-
try { if (Directory.Exists(temp)) Directory.Delete(temp, true); } catch { }
150-
}
151-
}
152-
153129
[Fact]
154130
public void PreprocessCommand_WithNonExistentDirectory_CreatesDirectory()
155131
{

mcp_nexus_tests/Utilities/PathHandlerTests.cs

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,6 @@ public void ConvertToWindowsPath_WslMountRootPath_ConvertsProperly()
4747
Assert.Equal(expectedWindowsPath, result);
4848
}
4949

50-
[Fact]
51-
public void ConvertToWindowsPath_WslMountRootPathNoTrailingSlash_ConvertsProperly()
52-
{
53-
// Arrange
54-
var wslPath = "/mnt/c";
55-
var expectedWindowsPath = "C:\\";
56-
57-
// Act
58-
var result = PathHandler.ConvertToWindowsPath(wslPath);
59-
60-
// Assert
61-
Assert.Equal(expectedWindowsPath, result);
62-
}
63-
6450
[Fact]
6551
public void ConvertToWindowsPath_AlreadyWindowsPath_ReturnsUnchanged()
6652
{
@@ -196,32 +182,6 @@ public void ConvertToWslPath_UnixPathWithBackslashes_NormalizesSlashes()
196182
Assert.Equal(expectedPath, result);
197183
}
198184

199-
[Fact]
200-
public void IsWslMountPath_ValidWslMountPath_ReturnsTrue()
201-
{
202-
// Using conversion behavior as proxy: /mnt/c/... must convert to C:\...
203-
var wslPath = "/mnt/c/inetpub/wwwroot/uploads/dump.dmp";
204-
var converted = PathHandler.ConvertToWindowsPath(wslPath);
205-
Assert.StartsWith("C:\\", converted);
206-
}
207-
208-
[Fact]
209-
public void IsWslMountPath_ValidWslMountPathUppercase_ReturnsTrue()
210-
{
211-
var wslPath = "/mnt/D/symbols";
212-
var converted = PathHandler.ConvertToWindowsPath(wslPath);
213-
Assert.StartsWith("D:\\", converted);
214-
}
215-
216-
[Fact]
217-
public void IsWslMountPath_WindowsPath_ReturnsFalse()
218-
{
219-
var windowsPath = "C:\\inetpub\\wwwroot\\uploads\\dump.dmp";
220-
var converted = PathHandler.ConvertToWindowsPath(windowsPath);
221-
// Ensure we didn't corrupt backslashes (ASCII backslash expected)
222-
Assert.StartsWith("C:\\", converted);
223-
}
224-
225185
[Fact]
226186
public void IsWslMountPath_UnixPath_ReturnsFalse()
227187
{

0 commit comments

Comments
 (0)