Skip to content

Commit

Permalink
Merge pull request #3 from ilonatommy/add-nested-static-attribute-sup…
Browse files Browse the repository at this point in the history
…port

Add nested static attribute support
  • Loading branch information
ilonatommy authored Nov 24, 2021
2 parents a223689 + e7e4e5b commit acd9613
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ public async Task<JObject> GetValueFromObject(JToken objRet, CancellationToken t
return (memberObject, remaining);
}

if (!string.IsNullOrEmpty(methodInfo.TypeInfo.Namespace))
if (!string.IsNullOrEmpty(methodInfo?.TypeInfo?.Namespace))
{
typeId = await FindStaticTypeId(methodInfo.TypeInfo.Namespace + "." + classNameToFind);
typeId = await FindStaticTypeId(methodInfo?.TypeInfo?.Namespace + "." + classNameToFind);
if (typeId != -1)
continue;
}
Expand Down Expand Up @@ -207,6 +207,7 @@ public async Task<JObject> Resolve(string varName, CancellationToken token)

async Task<JObject> ResolveAsLocalOrThisMember(string name)
{
var nameTrimmed = name.Trim();
if (scopeCache.Locals.Count == 0 && !localsFetched)
{
Result scope_res = await proxy.GetScopeProperties(sessionId, scopeId, token);
Expand All @@ -215,7 +216,7 @@ async Task<JObject> ResolveAsLocalOrThisMember(string name)
localsFetched = true;
}

if (scopeCache.Locals.TryGetValue(name, out JObject obj))
if (scopeCache.Locals.TryGetValue(nameTrimmed, out JObject obj))
return obj["value"]?.Value<JObject>();

if (!scopeCache.Locals.TryGetValue("this", out JObject objThis))
Expand All @@ -225,7 +226,7 @@ async Task<JObject> ResolveAsLocalOrThisMember(string name)
return null;

var rootResObj = await proxy.RuntimeGetPropertiesInternal(sessionId, objectId, null, token);
var objRet = rootResObj.FirstOrDefault(objPropAttr => objPropAttr["name"].Value<string>() == name);
var objRet = rootResObj.FirstOrDefault(objPropAttr => objPropAttr["name"].Value<string>() == nameTrimmed);
if (objRet != null)
return await GetValueFromObject(objRet, token);

Expand Down
4 changes: 2 additions & 2 deletions src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -500,8 +500,8 @@ protected override async Task<bool> AcceptCommand(MessageId id, string method, J
{
// Maybe this is an async method, in which case the debug info is attached
// to the async method implementation, in class named:
// `{type_name}/<method_name>::MoveNext`
methodInfo = assembly.TypesByName.Values.SingleOrDefault(t => t.FullName.StartsWith($"{typeName}/<{methodName}>"))?
// `{type_name}.<method_name>::MoveNext`
methodInfo = assembly.TypesByName.Values.SingleOrDefault(t => t.FullName.StartsWith($"{typeName}.<{methodName}>"))?
.Methods.FirstOrDefault(mi => mi.Name == "MoveNext");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ await EvaluateOnCallFrameAndCheck(id,

[Fact]
public async Task EvaluateSimpleExpressions() => await CheckInspectLocalsAtBreakpointSite(
"DebuggerTests.EvaluateTestsClass/TestEvaluate", "run", 9, "run",
"DebuggerTests.EvaluateTestsClass.TestEvaluate", "run", 9, "run",
"window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateTestsClass:EvaluateLocals'); })",
wait_for_event_fn: async (pause_location) =>
{
Expand Down Expand Up @@ -432,7 +432,7 @@ await EvaluateOnCallFrameFail(id,

[Fact]
public async Task NegativeTestsInInstanceMethod() => await CheckInspectLocalsAtBreakpointSite(
"DebuggerTests.EvaluateTestsClass/TestEvaluate", "run", 9, "run",
"DebuggerTests.EvaluateTestsClass.TestEvaluate", "run", 9, "run",
"window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateTestsClass:EvaluateLocals'); })",
wait_for_event_fn: async (pause_location) =>
{
Expand Down Expand Up @@ -495,7 +495,7 @@ async Task EvaluateOnCallFrameFail(string call_frame_id, params (string expressi

[Fact]
public async Task EvaluateSimpleMethodCallsError() => await CheckInspectLocalsAtBreakpointSite(
"DebuggerTests.EvaluateMethodTestsClass/TestEvaluate", "run", 9, "run",
"DebuggerTests.EvaluateMethodTestsClass.TestEvaluate", "run", 9, "run",
"window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateMethodTestsClass:EvaluateMethods'); })",
wait_for_event_fn: async (pause_location) =>
{
Expand All @@ -519,7 +519,7 @@ public async Task EvaluateSimpleMethodCallsError() => await CheckInspectLocalsAt

[Fact]
public async Task EvaluateSimpleMethodCallsWithoutParms() => await CheckInspectLocalsAtBreakpointSite(
"DebuggerTests.EvaluateMethodTestsClass/TestEvaluate", "run", 9, "run",
"DebuggerTests.EvaluateMethodTestsClass.TestEvaluate", "run", 9, "run",
"window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateMethodTestsClass:EvaluateMethods'); })",
wait_for_event_fn: async (pause_location) =>
{
Expand All @@ -536,7 +536,7 @@ await EvaluateOnCallFrameAndCheck(id,

[Fact]
public async Task EvaluateSimpleMethodCallsWithConstParms() => await CheckInspectLocalsAtBreakpointSite(
"DebuggerTests.EvaluateMethodTestsClass/TestEvaluate", "run", 9, "run",
"DebuggerTests.EvaluateMethodTestsClass.TestEvaluate", "run", 9, "run",
"window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateMethodTestsClass:EvaluateMethods'); })",
wait_for_event_fn: async (pause_location) =>
{
Expand All @@ -560,7 +560,7 @@ await EvaluateOnCallFrameAndCheck(id,

[Fact]
public async Task EvaluateSimpleMethodCallsWithVariableParms() => await CheckInspectLocalsAtBreakpointSite(
"DebuggerTests.EvaluateMethodTestsClass/TestEvaluate", "run", 9, "run",
"DebuggerTests.EvaluateMethodTestsClass.TestEvaluate", "run", 9, "run",
"window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateMethodTestsClass:EvaluateMethods'); })",
wait_for_event_fn: async (pause_location) =>
{
Expand Down Expand Up @@ -670,7 +670,7 @@ await EvaluateOnCallFrameAndCheck(id,

[Fact]
public async Task EvaluateSimpleMethodCallsCheckChangedValue() => await CheckInspectLocalsAtBreakpointSite(
"DebuggerTests.EvaluateMethodTestsClass/TestEvaluate", "run", 9, "run",
"DebuggerTests.EvaluateMethodTestsClass.TestEvaluate", "run", 9, "run",
"window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateMethodTestsClass:EvaluateMethods'); })",
wait_for_event_fn: async (pause_location) =>
{
Expand All @@ -690,7 +690,7 @@ await EvaluateOnCallFrameAndCheck(id,

[Fact]
public async Task EvaluateStaticClass() => await CheckInspectLocalsAtBreakpointSite(
"DebuggerTests.EvaluateMethodTestsClass/TestEvaluate", "run", 9, "run",
"DebuggerTests.EvaluateMethodTestsClass.TestEvaluate", "run", 9, "run",
"window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateMethodTestsClass:EvaluateMethods'); })",
wait_for_event_fn: async (pause_location) =>
{
Expand Down Expand Up @@ -806,7 +806,7 @@ await EvaluateOnCallFrameAndCheck(id_second,

[Fact]
public async Task EvaluateStaticClassInvalidField() => await CheckInspectLocalsAtBreakpointSite(
"DebuggerTests.EvaluateMethodTestsClass/TestEvaluate", "run", 9, "run",
"DebuggerTests.EvaluateMethodTestsClass.TestEvaluate", "run", 9, "run",
"window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateMethodTestsClass:EvaluateMethods'); })",
wait_for_event_fn: async (pause_location) =>
{
Expand Down

0 comments on commit acd9613

Please sign in to comment.