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 个 reaction 已指派 0 人 在 GitHub 查看
devtools extensions P2
主要语言
Dart
星标
1.7k
派生
404
平均合并
6 天 17 小时
30 天内合并 PR
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?

贡献指南

打开贡献指南

调研方向

从 EvalOnDartLibrary API 以及 issue 中描述的两种评估模式开始。复现递归检查场景,并比较 Sentinel 过期、私有成员访问和 late 字段行为。完成的条件是有 maintainer 确认的解决方案或范围明确的新能力,并在调查后确定测试或文档。

由索引模型根据 Issue 内容生成。

评估

技术栈
dart
领域
devtools
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
需要澄清
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。