angular: DevTools: Setters and Getters do not appear in the property viewer

Description

Currently DevTools is unable to display setters or getters in the property view. See the example images below.

Screen Shot 2022-05-18 at 4 12 52 PM Screen Shot 2022-05-18 at 4 14 11 PM

Proposed solution

Let’s use Object.getOwnPropertyDescriptors on the directive __proto__ to parse out setters and getters and display them in the directive explorer as functions.

Relevant files https://github.com/angular/angular/blob/db841d02c9758e51f9c2250c549a2acc52ba446e/devtools/projects/ng-devtools-backend/src/lib/state-serializer/serialized-descriptor-factory.ts https://github.com/angular/angular/blob/2a1ff17b427a2686c673a82151991c8ff56df62c/devtools/projects/ng-devtools-backend/src/lib/state-serializer/object-utils.ts

What do you think @mgechev?

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 17 (15 by maintainers)

Most upvoted comments

I think this one might be obsolete by #49695, @AleksanderBodurri .

@hereiskeith those functions were not originally designed to handle getters/setters.

Since get and set functions can execute arbitrary code, an application may only be expecting them to be read at specific times. There’s a risk that we may cause developers who are relying on this timing some trouble if we attempt to read those getters with Angular DevTools.

Because of this, I think it would be ideal to simply display the function representations of get/set properties instead of trying to support reading and editing them through Angular DevTools. Even that is an improvement over the current implementation which doesn’t display getters and setters at all

@AleksanderBodurri Thanks for the clarifications. Have been pretty busy recently and did not get to catch up on the work here, my apologies for that. I will work on the ticket these two days and hopefully I would make some progress.

@hereiskeith can you rebase onto the latest main and try it now? Should be fixed

Thanks @AleksanderBodurri , it seems to be fixed perfectly!

@hereiskeith absolutely, thank you for taking this 🙏