Skip to content

Commit 3011f36

Browse files
author
Anna Gringauze
authored
Remote obfuscation from late fields, update example to not crash (#1355)
1 parent 8714df3 commit 3011f36

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

dwds/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- Return empty library from `ChromeProxyService.getObject` for
44
libraries present in medatata but not lodaded at runtime.
55
- Log failures to load kernel during expression evaluation.
6+
- Show lowered final fields using their original dart names.
67

78
## 11.1.1
89

dwds/lib/src/debugging/instance.dart

+9-3
Original file line numberDiff line numberDiff line change
@@ -299,11 +299,17 @@ class InstanceHelper extends Domain {
299299
return fields.join(',');
300300
}
301301
const privateFields = sdk_utils.getOwnPropertySymbols(fields);
302-
const nonSymbolNames = privateFields.map(sym => sym.description);
302+
const nonSymbolNames = privateFields
303+
.map(sym => sym.description
304+
.split('#').slice(-1)[0]);
303305
const publicFieldNames = sdk_utils.getOwnPropertyNames(fields);
304306
const symbolNames = Object.getOwnPropertySymbols(this)
305-
.map(sym => sym.description.split('.').slice(-1)[0]);
306-
return nonSymbolNames.concat(publicFieldNames).concat(symbolNames).join(',');
307+
.map(sym => sym.description
308+
.split('#').slice(-1)[0]
309+
.split('.').slice(-1)[0]);
310+
return nonSymbolNames
311+
.concat(publicFieldNames)
312+
.concat(symbolNames).join(',');
307313
}
308314
''';
309315
var allNames = (await inspector

dwds/lib/src/utilities/objects.dart

+5
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ class Property {
4545
var nonSymbol = (rawName.startsWith(prefix))
4646
? rawName.substring(prefix.length, rawName.length - 1)
4747
: rawName;
48+
// Adjust names for late fields:
49+
// '_#MyTestClass#myselfField' -> 'myselfField'
50+
// TODO(annagrin): Use debug symbols to map from dart to JS symbols.
51+
// https://github.com/dart-lang/sdk/issues/40273
52+
nonSymbol = nonSymbol.split('#').last;
4853
return nonSymbol.split('.').last;
4954
}
5055

example/web/scopes_main.dart

+4-4
Original file line numberDiff line numberDiff line change
@@ -137,16 +137,16 @@ Function? someFunction() => null;
137137
// ignore: unused_element
138138
int _libraryPrivateFunction(int a, int b) => a + b;
139139

140-
class NotReallyAList extends ListBase<Object> {
141-
final List<Object> _internal;
140+
class NotReallyAList extends ListBase<Object?> {
141+
final List<Object?> _internal;
142142

143143
NotReallyAList() : _internal = [];
144144

145145
@override
146-
Object operator [](x) => _internal[x];
146+
Object? operator [](x) => _internal[x];
147147

148148
@override
149-
operator []=(int x, Object y) => _internal[x] = y;
149+
operator []=(int x, Object? y) => _internal[x] = y;
150150

151151
@override
152152
int get length => _internal.length;

0 commit comments

Comments
 (0)