diff options
author | Matt Ward <matt.ward@microsoft.com> | 2022-02-23 18:16:33 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-23 18:16:33 +0300 |
commit | 656eac83caac2bcce973df1eec8c30414d02f2dd (patch) | |
tree | a95937dd7a9536554887d5f04e8696ebfc0e9d6c | |
parent | 3997eb9e5108bc5f96c989d2ce298d62ea1f018b (diff) | |
parent | fb039a6f4576b65733d6e30b80e2677a54d64d3e (diff) |
Merge pull request #355 from marshall-lerner/main
Make sure that the only real paths get resolved
-rw-r--r-- | Mono.Debugging/Mono.Debugging.Client/BreakpointStore.cs | 9 | ||||
-rw-r--r-- | UnitTests/Mono.Debugging.Tests/Shared/BreakpointsAndSteppingTests.cs | 18 |
2 files changed, 27 insertions, 0 deletions
diff --git a/Mono.Debugging/Mono.Debugging.Client/BreakpointStore.cs b/Mono.Debugging/Mono.Debugging.Client/BreakpointStore.cs index 883e169..f853183 100644 --- a/Mono.Debugging/Mono.Debugging.Client/BreakpointStore.cs +++ b/Mono.Debugging/Mono.Debugging.Client/BreakpointStore.cs @@ -471,8 +471,17 @@ namespace Mono.Debugging.Client [DllImport ("libc")] static extern IntPtr realpath (string path, IntPtr buffer); + /// <summary> + /// Resolves the full path of the given file + /// </summary> + /// <param name="path"></param> + /// <returns>The full path if a file is given, or returns the parameter if it is null or empty</returns> static string ResolveFullPath (string path) { + // If there is no path given, return the same path back + if (string.IsNullOrEmpty (path)) + return path; + if (IsWindows) return Path.GetFullPath (path); diff --git a/UnitTests/Mono.Debugging.Tests/Shared/BreakpointsAndSteppingTests.cs b/UnitTests/Mono.Debugging.Tests/Shared/BreakpointsAndSteppingTests.cs index ced8211..5f61924 100644 --- a/UnitTests/Mono.Debugging.Tests/Shared/BreakpointsAndSteppingTests.cs +++ b/UnitTests/Mono.Debugging.Tests/Shared/BreakpointsAndSteppingTests.cs @@ -1317,5 +1317,23 @@ namespace Mono.Debugging.Tests Assert.AreEqual (1, bps.Count); Assert.AreEqual (Path.Combine(Environment.CurrentDirectory, "fileName2.cs"), bps [0].FileName); } + + [Test] + public void NullFileName () + { + var store = new BreakpointStore (); + store.Add (new Breakpoint (null, 10)); + var bps = store.GetBreakpoints (); + Assert.AreEqual (1, bps.Count); + } + + [Test] + public void EmptyFileName () + { + var store = new BreakpointStore (); + store.Add (new Breakpoint ("", 10)); + var bps = store.GetBreakpoints (); + Assert.AreEqual (1, bps.Count); + } } } |