Skip to content

Conversation

@thaystg
Copy link
Member

@thaystg thaystg commented Dec 15, 2021

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

@thaystg thaystg requested a review from marek-safar as a code owner December 15, 2021 19:51
@ghost ghost added the area-Debugger-mono label Dec 15, 2021
@ghost ghost assigned thaystg Dec 15, 2021
@ghost
Copy link

ghost commented Dec 15, 2021

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; }
Copy link
Member

@radical radical Dec 16, 2021

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
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
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
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
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
Member Author

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
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?

@ghost ghost 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
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
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.

@ghost ghost 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:main Dec 21, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Jan 20, 2022
Sign up for free to 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