From 6bdf3b7ed643f628675b893aa03ad24279f7bad0 Mon Sep 17 00:00:00 2001 From: Alexander Aprelev Date: Tue, 7 Aug 2018 22:58:36 +0000 Subject: [PATCH] [observatory] Fix _guardLength serialization to output a string, rather than an int. Change-Id: I12e3505649ebe9bb72f479dc7e2fc2dd19226ed7 Reviewed-on: https://dart-review.googlesource.com/68802 Reviewed-by: Ryan Macnak --- .../tests/service/get_object_rpc_test.dart | 22 +++++++++++++++++++ runtime/vm/object_service.cc | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/runtime/observatory/tests/service/get_object_rpc_test.dart b/runtime/observatory/tests/service/get_object_rpc_test.dart index 6e1cb4366af0b..7734057d16e93 100644 --- a/runtime/observatory/tests/service/get_object_rpc_test.dart +++ b/runtime/observatory/tests/service/get_object_rpc_test.dart @@ -14,6 +14,7 @@ import 'test_helper.dart'; class _DummyClass { static var dummyVar = 11; + final List dummyList = new List(20); void dummyFunction() {} } @@ -884,6 +885,27 @@ var tests = [ expect(result['_guardLength'], isNotNull); }, + // field + (Isolate isolate) async { + // Call eval to get a class id. + var evalResult = await eval(isolate, 'new _DummyClass()'); + var id = "${evalResult['class']['id']}/fields/dummyList"; + var params = { + 'objectId': id, + }; + var result = await isolate.invokeRpcNoUpgrade('getObject', params); + expect(result['type'], equals('Field')); + expect(result['id'], equals(id)); + expect(result['name'], equals('dummyList')); + expect(result['const'], equals(false)); + expect(result['static'], equals(false)); + expect(result['final'], equals(true)); + expect(result['location']['type'], equals('SourceLocation')); + expect(result['_guardNullable'], isNotNull); + expect(result['_guardClass'], isNotNull); + expect(result['_guardLength'], equals('20')); + }, + // invalid field. (Isolate isolate) async { // Call eval to get a class id. diff --git a/runtime/vm/object_service.cc b/runtime/vm/object_service.cc index 6dd1d5b236cca..7812ac543ecad 100644 --- a/runtime/vm/object_service.cc +++ b/runtime/vm/object_service.cc @@ -394,7 +394,7 @@ void Field::PrintJSONImpl(JSONStream* stream, bool ref) const { } else if (guarded_list_length() == kNoFixedLength) { jsobj.AddProperty("_guardLength", "variable"); } else { - jsobj.AddProperty("_guardLength", guarded_list_length()); + jsobj.AddPropertyF("_guardLength", "%" Pd, guarded_list_length()); } const class Script& script = Script::Handle(Script()); if (!script.IsNull()) {