Skip to content

Commit

Permalink
[wasm][debugger] Default null columnNumber to 0 (dotnet#81336)
Browse files Browse the repository at this point in the history
* Default null columnNumber to 0

* Fix compilation

* adding test case

---------

Co-authored-by: Thays Grazia <[email protected]>
  • Loading branch information
lewing and thaystg authored Jan 30, 2023
1 parent bf5afd4 commit b5e79f5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,15 @@ public bool TryResolve(SourceFile sourceFile)
return false;

int? line = request?["lineNumber"]?.Value<int>();
int? column = request?["columnNumber"]?.Value<int>();
int column = request?["columnNumber"]?.Value<int>() ?? 0;

if (line == null || column == null)
if (line == null)
return false;

Assembly = sourceFile.AssemblyName;
File = sourceFile.FilePath;
Line = line.Value;
Column = column.Value;
Column = column;
return true;
}

Expand Down
12 changes: 12 additions & 0 deletions src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,18 @@ await EvaluateAndCheck(
);
}

[ConditionalFact(nameof(RunningOnChrome))]
public async Task CreateGoodBreakpointWithoutColumnAndHit()
{
var bp = await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", 10, -1);

await EvaluateAndCheck(
"window.setTimeout(function() { invoke_add(); }, 1);",
"dotnet://debugger-test.dll/debugger-test.cs", 10, 8,
"Math.IntAdd"
);
}

public static TheoryData<string, string, string, bool> FalseConditions = new TheoryData<string, string, string, bool>
{
{ "invoke_add()", "IntAdd", "0.0", false },
Expand Down
12 changes: 11 additions & 1 deletion src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1155,9 +1155,19 @@ internal async Task<Result> RemoveBreakpoint(string id, bool expect_ok = true)

internal virtual async Task<Result> SetBreakpoint(string url_key, int line, int column, bool expect_ok = true, bool use_regex = false, string condition = "")
{
var bp1_req = !use_regex ?
JObject bp1_req;
if (column != -1)
{
bp1_req = !use_regex ?
JObject.FromObject(new { lineNumber = line, columnNumber = column, url = dicFileToUrl[url_key], condition }) :
JObject.FromObject(new { lineNumber = line, columnNumber = column, urlRegex = url_key, condition });
}
else
{
bp1_req = !use_regex ?
JObject.FromObject(new { lineNumber = line, url = dicFileToUrl[url_key], condition }) :
JObject.FromObject(new { lineNumber = line, urlRegex = url_key, condition });
}

var bp1_res = await cli.SendCommand("Debugger.setBreakpointByUrl", bp1_req, token);
Assert.True(expect_ok ? bp1_res.IsOk : !bp1_res.IsOk);
Expand Down

0 comments on commit b5e79f5

Please sign in to comment.