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 摘要。