Skip to content

Display parents' members on GetProperties. - #68907

Merged
ilonatommy merged 20 commits into
dotnet:mainfrom
ilonatommy:get-props-parents-68542
May 27, 2022
Merged

ilonatommy merged 20 commits into
dotnet:mainfrom
ilonatommy:get-props-parents-68542

Conversation

@ilonatommy

@ilonatommy ilonatommy commented May 5, 2022 •

Copy link
Copy Markdown
Member

Fixes #68542.

In Console Application class DerivedClass from test InspectTypeInheritedMembers displays more members on getProperties than the same class in a Blazor project. The missing members belong to parents of DerivedClass and have the same names as the ones in DerivedClass. The desired behavior is on the screenshot below:
image

Changes:

  • Adding a suffix to some members' names: If the child's field does not shadow inherited field then to keep names in getProperties response unique, we append parent class's name in brackets to the original name. If the parent's member is shadowed and no duplicated names are present, we do not change the name.
  • Reorganizing the test cases to be easier to read, leaving previously tested functionalities.
    BaseBaseClass + BaseClass test hiding 3 types of members: fields, properties and auto-properties.
    BaseClass + DerivedClass test overriding of properties and auto-properties.
    BaseClass has 2 virtual properties that have the same attributes as new-hidden members and have to be displayed while virtual members have to be skipped.
  • Fixing DebuggerTests.MiscTests.InspectTaskAtLocals, now not-own DebuggerDisplayMethodDescription (Task) is also returned on GetProperties. Before it was skipped in the test even though it's visible in ConsoleApp:
    image

@ilonatommy ilonatommy added arch-wasm WebAssembly architecture area-Debugger-mono labels May 5, 2022
@ilonatommy ilonatommy added this to the 7.0.0 milestone May 5, 2022
@ilonatommy
ilonatommy requested a review from thaystg May 5, 2022 13:40
@ilonatommy ilonatommy self-assigned this May 5, 2022
@ilonatommy
ilonatommy requested a review from marek-safar as a code owner May 5, 2022 13:40
@ghost

ghost commented May 5, 2022

Copy link
Copy Markdown

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

Issue Details

Fixes #68542.

Author: ilonatommy
Assignees: ilonatommy
Labels:

arch-wasm, area-Debugger-mono

Milestone: 7.0.0

@ilonatommy

Copy link
Copy Markdown
Member Author

All tests that failed in staging failed due to timeout and locally when run separately, are passing.

Comment thread src/libraries/sendtohelix-wasm.targets Resolved
@radical

radical commented May 6, 2022

Copy link
Copy Markdown
Member

Could you please add the description of the what is being solved here in the PR description itself?

@radical

radical commented May 6, 2022

Copy link
Copy Markdown
Member

I would also suggest changing:

    public class BaseBaseClass
    {
        private string _memberForOverrideBackingField = "BaseBaseClass#BaseBase_MemberForOverride";
        public string BaseBase_MemberForOverride
        {
            get { return _memberForOverrideBackingField; }
            set { _memberForOverrideBackingField = value; }
        }
    }

.. so we can check calling getters on such base members.

@radical

radical commented May 10, 2022

Copy link
Copy Markdown
Member

There is a failing test right now. I'll continue the review once that is fixed.

This might be useful to add btw:

diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestBase.cs b/src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestBase.cs
index 4647fa8f998..78e8030d2a9 100644
--- a/src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestBase.cs
+++ b/src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestBase.cs
@@ -732,7 +732,20 @@ internal async Task CheckProps(JToken actual, object exp_o, string label, int nu
             if (!skip_num_fields_check)
             {
                 num_fields = num_fields < 0 ? exp.Values<JToken>().Count() : num_fields;
-                Assert.True(num_fields == actual.Count(), $"[{label}] Number of fields don't match, Expected: {num_fields}, Actual: {actual.Count()}");
+                var expected_str = string.Join(", ",
+                                            exp.Children()
+                                            .Select(e => e is JProperty jprop ? jprop.Name : e["name"]?.Value<string>())
+                                            .Where(e => !string.IsNullOrEmpty(e))
+                                            .OrderBy(e => e));
+
+                var actual_str = string.Join(", ",
+                                            actual.Children()
+                                            .Select(e => e["name"]?.Value<string>())
+                                            .Where(e => !string.IsNullOrEmpty(e))
+                                            .OrderBy(e => e));
+                Assert.True(num_fields == actual.Count(), $"[{label}] Number of fields don't match, Expected: {num_fields}, Actual: {actual.Count()}.{Environment.NewLine}"
+                                                            + $"  Expected: {expected_str}{Environment.NewLine}"
+                                                            + $"  Actual:   {actual_str}");
             }

             foreach (var kvp in exp)

@ilonatommy
ilonatommy marked this pull request as draft May 10, 2022 08:01
@ilonatommy
ilonatommy force-pushed the get-props-parents-68542 branch from 068f19c to d7226a3 Compare May 12, 2022 06:44
@ilonatommy
ilonatommy marked this pull request as ready for review May 13, 2022 07:06
@ilonatommy
ilonatommy requested a review from radical May 16, 2022 14:16
@ilonatommy
ilonatommy requested a review from radical May 18, 2022 07:03
@ilonatommy

ilonatommy commented May 23, 2022 •

Copy link
Copy Markdown
Member Author

/azp run runtime-staging

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

1 similar comment
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@radical

radical commented May 25, 2022

Copy link
Copy Markdown
Member

I had a hard time trying to figure out why the various changes were needed, and I ended up reworking that code a bit to make it easier to read (IMHO!). https://gist.github.com/radical/294a89671bc1412468a071e7624cd685

@radical radical left a comment

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.

Make sure the tests are passing after the last two changes. Other than that, looks great 👍

@ilonatommy
ilonatommy merged commit 84513a2 into dotnet:main May 27, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Jun 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasm WebAssembly architecture area-Debugger-mono

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[wasm][debugger] Display parent's members on getProperties

3 participants