Skip to content

[wasm][debugger] Run getter using Runtime.GetProperties - #62857

Merged
thaystg merged 4 commits into
dotnet:mainfrom
thaystg:thays_fix_62774
Dec 21, 2021
Merged

[wasm][debugger] Run getter using Runtime.GetProperties#62857
thaystg merged 4 commits into
dotnet:mainfrom
thaystg:thays_fix_62774

Conversation

@thaystg

@thaystgthaystg commented Dec 15, 2021

Copy link
Copy Markdown
Member

Implementing support on running getters using Runtime.GetProperties as it's done by CDP.

Behavior on VS (not related to this PR)
image

Bahavior on Chrome (using this PR)
image

Fixes#62774

@ghost

Copy link
Copy Markdown

Tagging subscribers to this area: @thaystg
See info in area-owners.md if you want to be subscribed.

Issue Details

Implementing support on running getters using Runtime.GetProperties as it's done by CDP.

Behavior on VS (not related to this PR)
image

Bahavior on Chrome (using this PR)
image

Author:thaystg
Assignees:-
Labels:

area-Debugger-mono

Milestone:-

{
public string Scheme { get; }
public string Value { get; }
public string SubScheme { get; }

@radicalradicalDec 16, 2021

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Member

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}";

Copy link
Copy Markdown
Member

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 = "")

Copy link
Copy Markdown
Member

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);

Copy link
Copy Markdown
Member

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?

Copy link
Copy Markdown
MemberAuthor

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)),

Copy link
Copy Markdown
Member

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?

@ghostghost added the needs-author-action An issue or pull request that requires more info or actions from the author. label Dec 16, 2021
string[] parts = id.Split(":", 3);
string[] parts = id.Split(":", 5);

if (parts.Length < 3)

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Member

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.

@ghostghost removed the needs-author-action An issue or pull request that requires more info or actions from the author. label Dec 20, 2021
@thaystg
thaystg merged commit 1c09d36 into dotnet:mainDec 21, 2021
@ghostghost locked as resolved and limited conversation to collaborators Jan 20, 2022
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[wasm][debugger] Display custom accessors the same way as in Console Application

3 participants

@thaystg@radical@ilonatommy