Skip to content

Commit 6ed72d3

Browse files
bkonyicommit-bot@chromium.org
authored andcommitted
[ package:vm_service ] Fix issue where TimelineEvent objects never had any content
Change-Id: I5bb1a3e538823cbaaa1a45a1fbbb55e63e1f61ef Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128960 Reviewed-by: Kenzie Schmoll <kenzieschmoll@google.com> Commit-Queue: Ben Konyi <bkonyi@google.com>
1 parent 7ddf353 commit 6ed72d3

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

pkg/vm_service/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Changelog
2+
## 2.1.4
3+
- Fixed issue where `TimelineEvent` always had no content.
4+
25
## 2.1.3
36
- Fixed issue where exception would be thrown when attempting to parse a
47
List entry in a response which is not present. This occurs when connected to

pkg/vm_service/lib/vm_service.dart

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -760,9 +760,9 @@ abstract class VmServiceInterface {
760760
///
761761
/// This method immediately returns success. The VM will then begin delivering
762762
/// binary events on the `HeapSnapshot` event stream. The binary data in these
763-
/// events, when concatenated together, conforms to the SnapshotGraph type.
763+
/// events, when concatenated together, conforms to the [SnapshotGraph] type.
764764
/// The splitting of the SnapshotGraph into events can happen at any byte
765-
/// offset, including the middle of scalar fields.
765+
/// offset.
766766
Future<Success> requestHeapSnapshot(String isolateId);
767767

768768
/// The `resume` RPC is used to resume execution of a paused isolate.
@@ -6069,12 +6069,15 @@ class TimelineEvent {
60696069
static TimelineEvent parse(Map<String, dynamic> json) =>
60706070
json == null ? null : TimelineEvent._fromJson(json);
60716071

6072+
Map<String, dynamic> json;
6073+
60726074
TimelineEvent();
6073-
TimelineEvent._fromJson(Map<String, dynamic> json);
6075+
TimelineEvent._fromJson(this.json);
60746076

60756077
Map<String, dynamic> toJson() {
6076-
var json = <String, dynamic>{};
6077-
return json;
6078+
var result = json == null ? <String, dynamic>{} : Map.of(json);
6079+
result['type'] = 'TimelineEvent';
6080+
return result;
60786081
}
60796082

60806083
String toString() => '[TimelineEvent ]';

pkg/vm_service/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: vm_service
22
description: >-
33
A library to communicate with a service implementing the Dart VM
44
service protocol.
5-
version: 2.1.3
5+
version: 2.1.4
66

77
homepage: https://github.com/dart-lang/sdk/tree/master/pkg/vm_service
88

pkg/vm_service/tool/dart/generate_dart.dart

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,7 +1334,7 @@ class Type extends Member {
13341334
'json == null ? null : ${name}._fromJson(json);');
13351335
gen.writeln();
13361336

1337-
if (name == 'Response') {
1337+
if (name == 'Response' || name == 'TimelineEvent') {
13381338
gen.writeln('Map<String, dynamic> json;');
13391339
}
13401340
if (name == 'Script') {
@@ -1364,7 +1364,7 @@ class Type extends Member {
13641364

13651365
// Build from JSON.
13661366
String superCall = superName == null ? '' : ": super._fromJson(json) ";
1367-
if (name == 'Response') {
1367+
if (name == 'Response' || name == 'TimelineEvent') {
13681368
gen.write('${name}._fromJson(this.json)');
13691369
} else {
13701370
gen.write('${name}._fromJson(Map<String, dynamic> json) ${superCall}');
@@ -1492,6 +1492,16 @@ Map<String, dynamic> toJson() {
14921492
result['type'] = type ?? 'Response';
14931493
return result;
14941494
}''');
1495+
} else if (name == 'TimelineEvent') {
1496+
// TimelineEvent doesn't have any declared properties as the response is
1497+
// fairly dynamic. Return the json directly.
1498+
gen.writeln('''
1499+
Map<String, dynamic> toJson() {
1500+
var result = json == null ? <String, dynamic>{} : Map.of(json);
1501+
result['type'] = 'TimelineEvent';
1502+
return result;
1503+
}
1504+
''');
14951505
} else {
14961506
if (isResponse) {
14971507
gen.writeln('@override');

0 commit comments

Comments
 (0)