Skip to content

Commit 61d55bf

Browse files
committed
cleanup
1 parent ce66883 commit 61d55bf

File tree

2 files changed

+30
-35
lines changed

2 files changed

+30
-35
lines changed

src/MIDebugEngine/AD7.Impl/AD7StackFrame.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace Microsoft.MIDebugEngine
1414
{
1515
// Represents a logical stack frame on the thread stack.
1616
// Also implements the IDebugExpressionContext interface, which allows expression evaluation and watch windows.
17-
internal class AD7StackFrame : IDebugStackFrame2, IDebugExpressionContext2
17+
internal sealed class AD7StackFrame : IDebugStackFrame2, IDebugExpressionContext2
1818
{
1919
public AD7Engine Engine { get; private set; }
2020
public AD7Thread Thread { get; private set; }
@@ -53,11 +53,7 @@ public AD7StackFrame(AD7Engine engine, AD7Thread thread, ThreadContext threadCon
5353
if (_textPosition != null)
5454
{
5555
_documentCxt = new AD7DocumentContext(_textPosition, _codeCxt, this.Engine.DebuggedProcess);
56-
57-
if (_codeCxt != null)
58-
{
59-
_codeCxt.SetDocumentContext(_documentCxt);
60-
}
56+
_codeCxt?.SetDocumentContext(_documentCxt);
6157
}
6258
}
6359

src/MIDebugEngine/Engine.Impl/DebuggedProcess.cs

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2264,38 +2264,37 @@ private Task<string> ResetConsole()
22642264

22652265
public bool MapCurrentSrcToCompileTimeSrc(string currentSrc, out string compilerSrc)
22662266
{
2267-
if (_launchOptions.SourceMap != null)
2267+
if (_launchOptions.SourceMap == null)
22682268
{
2269-
StringComparison comp = PlatformUtilities.IsWindows() ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal;
2270-
foreach (var e in _launchOptions.SourceMap)
2269+
compilerSrc = currentSrc;
2270+
return false;
2271+
}
2272+
2273+
StringComparison comp = PlatformUtilities.IsWindows() ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal;
2274+
foreach (var e in _launchOptions.SourceMap)
2275+
{
2276+
if (!e.UseForBreakpoints || !currentSrc.StartsWith(e.EditorPath, comp))
2277+
continue;
2278+
2279+
var file = currentSrc.Substring(e.EditorPath.Length);
2280+
if (string.IsNullOrEmpty(file)) // matched the whole string
22712281
{
2272-
if (e.UseForBreakpoints && currentSrc.StartsWith(e.EditorPath, comp))
2273-
{
2274-
var file = currentSrc.Substring(e.EditorPath.Length);
2275-
if (string.IsNullOrEmpty(file)) // matched the whole string
2276-
{
2277-
compilerSrc = e.CompileTimePath; // return the matches compile time path
2278-
return true;
2279-
}
2280-
// must do the path break at a directory boundry, i.e. at a '\' or '/' char
2281-
char firstFilechar = file[0];
2282-
char lastDirectoryChar = e.EditorPath[e.EditorPath.Length - 1];
2283-
if (firstFilechar == Path.DirectorySeparatorChar || firstFilechar == Path.AltDirectorySeparatorChar)
2284-
{
2285-
file = file.Trim(new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }); // Trim the directory separator(s)
2286-
}
2287-
else if (lastDirectoryChar != Path.DirectorySeparatorChar && lastDirectoryChar != Path.AltDirectorySeparatorChar)
2288-
{
2289-
continue; // match didn't end at a directory separator, not actually a match
2290-
}
2291-
compilerSrc = Path.Combine(e.CompileTimePath, file); // map to the compiled location
2292-
if (compilerSrc.IndexOf('\\') > 0)
2293-
{
2294-
compilerSrc = compilerSrc.Replace('\\', '/'); // use Unix notation for the compiled path
2295-
}
2296-
return true;
2297-
}
2282+
compilerSrc = e.CompileTimePath; // return the matches compile time path
2283+
return true;
22982284
}
2285+
// must do the path break at a directory boundry, i.e. at a '\' or '/' char
2286+
char firstFilechar = file[0];
2287+
char lastDirectoryChar = e.EditorPath[e.EditorPath.Length - 1];
2288+
if (firstFilechar == Path.DirectorySeparatorChar || firstFilechar == Path.AltDirectorySeparatorChar)
2289+
file = file.Trim(new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }); // Trim the directory separator(s)
2290+
else if (lastDirectoryChar != Path.DirectorySeparatorChar && lastDirectoryChar != Path.AltDirectorySeparatorChar)
2291+
continue; // match didn't end at a directory separator, not actually a match
2292+
2293+
compilerSrc = Path.Combine(e.CompileTimePath, file); // map to the compiled location
2294+
if (compilerSrc.IndexOf('\\') > 0)
2295+
compilerSrc = compilerSrc.Replace('\\', '/'); // use Unix notation for the compiled path
2296+
2297+
return true;
22992298
}
23002299
compilerSrc = currentSrc;
23012300
return false;

0 commit comments

Comments
 (0)