flutter / flutter/devtools

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

オープン
#9,634 コメント 13 件 リアクション 0 件 担当者 0 名 GitHub で見る
devtools extensions P2
主要言語
Dart
スター
1.7k
フォーク
404
平均マージ
6日 17時間
マージ済み PR(30日)
18

説明

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?

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。