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

未關閉
#9,634 13 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
5/5
預估耗時
一週以上
新手友好度
25/100
Issue 類型
功能
描述清晰度
需要釐清
活躍度
停滯
技術堆疊
dart
領域
devtools

研究方向

從 EvalOnDartLibrary API 以及 issue 中描述的兩種評估模式開始。重現遞迴檢查情境,並比較 Sentinel 過期、私有成員存取和 late 欄位行為。完成的條件是有 maintainer 確認的解決方案或範圍明確的新能力,並在調查後確定測試或文件。

由索引模型根據 Issue 內容生成。

描述

devtools extensions P2

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 <expired> Sentinel or not loosing the ability to inspect private members.

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

final id = eval('globalMap.register(<expression to evaluate>)')

try {
  final content = eval('globalMap.get("$id").<field I want to read>');
} finally {
  eval('globalMap.unregister("$id")');
}

This prevents the <expired>. 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:

final value= eval('<expression to evaluate>')
final content = eval('that.<field I want to read>', 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?

主要語言
Dart
星號
1.7k
分支
420
平均合併
3 天 11 小時
30 天內合併 PR
29

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

flutter/devtools 的其他 Issue

查看 flutter/devtools 的全部 Issue

相似的 Issue

更多 Dart Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。