flutter / flutter/devtools

Devtool extension authoring: EvalOnDartLibrary, how to recursively inspect an Object without causing `Sentinel <expired>` due to race conditions?

Đang mở
#9,634 13 bình luận 0 reaction 0 người được giao Xem trên GitHub
devtools extensions P2
Ngôn ngữ chính
Dart
Star
1.7k
Fork
404
Merge trung bình
6 ngày 17 giờ
Pull request đã merge (30 ngày)
18

Mô tả

Hello!

I think I'm missing something with regards to `EvalOnDartLibrary`. I fail to see how it is possible to fully map out an object without ever risking an `` Sentinel or not loosing the ability to inspect private members.

I am aware that one trick is to do (pseudo code):

```dart
final id = eval('globalMap.register()')

try {
final content = eval('globalMap.get("$id").');
} finally {
eval('globalMap.unregister("$id")');
}
```

This prevents the ``. But afaik, prevents reading private members on the inspected object, due to `globalMap` and the private members being defined in different libraries.
(also, this will forcibly trigger late fields ; which can be undesired)

If we instead do:

```dart
final value= eval('')
final content = eval('that.', scope: {'that': value.id});
```

Then we risk that `value` will expire before `content` is resolved.

Is there something I'm missing here? Or do we need a new feature to solve this?

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.