-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[wasm][debugger] Run getter using Runtime.GetProperties #62857
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…s it's done by chrome.
|
Tagging subscribers to this area: @thaystg |
| { | ||
| public string Scheme { get; } | ||
| public string Value { get; } | ||
| public string SubScheme { get; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be useful to add a deconstructor which returns int values?
https://docs.microsoft.com/en-us/dotnet/csharp/fundamentals/functional/deconstruct#user-defined-types
public void Deconstruct(out string scheme, out int value, out string? subscheme, out int? subvalue)
{..}
.. and use it as (example):
var (_, value, subscheme, _) = dotnetObjectId;int value - so the callers don't have to worry about int.Parse failing. And IIUC, the string value should always parse as an int.
And int? subValue as a null` value would indicate a missing value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, we should maybe use an enum for this, even if it has only one value MethodId to start with. That would avoid callers having to check for == "methodId", and having any typos.
| SubValue = subvalue; | ||
| } | ||
|
|
||
| public override string ToString() => $"dotnet:{Scheme}:{Value}"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be updated too
| } | ||
|
|
||
| public DotnetObjectId(string scheme, string value) | ||
| public DotnetObjectId(string scheme, string value, string subscheme = "", string subvalue = "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't null be better default values for these?
| public async Task<JObject> InvokeMethodInObject(int objectId, int methodId, string varName, CancellationToken token) | ||
| { | ||
| using var commandParamsObjWriter = new MonoBinaryWriter(); | ||
| commandParamsObjWriter.Write(ElementType.Class, objectId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this work for structs too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No.
| GetJ = TGetter("GetJ"), | ||
| GetI = TGetter("GetI"), | ||
| GetK = TGetter("GetK") | ||
| GetJ = TGetter("GetJ", TNumber(20)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should other tests with TGetter also be updated, like the datetime ones?
| string[] parts = id.Split(":", 3); | ||
| string[] parts = id.Split(":", 5); | ||
|
|
||
| if (parts.Length < 3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, change to:
if (parts.Length < 3 || parts.Length == 4)
because when running DebuggerTests.ArrayTests.InvalidArrayId we are passing 4 part ID:
dotnet:array:{ "arrayId": 234980 }.
After split we are left with 4 elements so the condition is false and we are reaching for non-existing element: parts[4] in the following lines. Without this change the test is failing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest doing something like https://github.com/dotnet/runtime/blob/release/5.0/src/mono/wasm/runtime/library_mono.js#L508-L512 . 3 parts, dotnet, scheme, and the rest. How to parse the rest part would depend on the scheme.


Implementing support on running getters using Runtime.GetProperties as it's done by CDP.
Behavior on VS (not related to this PR)

Bahavior on Chrome (using this PR)

Fixes #62774