Include raw value in Diagnostics json for basic types (#34417)
This commit is contained in:
parent
1c6cda9a0d
commit
72828d66cf
@ -2551,6 +2551,8 @@ class DiagnosticsProperty<T> extends DiagnosticsNode {
|
|||||||
json['defaultLevel'] = describeEnum(_defaultLevel);
|
json['defaultLevel'] = describeEnum(_defaultLevel);
|
||||||
if (value is Diagnosticable || value is DiagnosticsNode)
|
if (value is Diagnosticable || value is DiagnosticsNode)
|
||||||
json['isDiagnosticableValue'] = true;
|
json['isDiagnosticableValue'] = true;
|
||||||
|
if (value is num || value is String || value is bool || value == null)
|
||||||
|
json['value'] = value;
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2098,4 +2098,41 @@ void main() {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('DiagnosticsProperty for basic types has value in json', () {
|
||||||
|
DiagnosticsProperty<int> intProperty = DiagnosticsProperty<int>('int1', 10);
|
||||||
|
Map<String, Object> json = simulateJsonSerialization(intProperty);
|
||||||
|
expect(json['name'], 'int1');
|
||||||
|
expect(json['value'], 10);
|
||||||
|
|
||||||
|
intProperty = IntProperty('int2', 20);
|
||||||
|
json = simulateJsonSerialization(intProperty);
|
||||||
|
expect(json['name'], 'int2');
|
||||||
|
expect(json['value'], 20);
|
||||||
|
|
||||||
|
DiagnosticsProperty<double> doubleProperty = DiagnosticsProperty<double>('double', 33.3);
|
||||||
|
json = simulateJsonSerialization(doubleProperty);
|
||||||
|
expect(json['name'], 'double');
|
||||||
|
expect(json['value'], 33.3);
|
||||||
|
|
||||||
|
doubleProperty = DoubleProperty('double2', 33.3);
|
||||||
|
json = simulateJsonSerialization(doubleProperty);
|
||||||
|
expect(json['name'], 'double2');
|
||||||
|
expect(json['value'], 33.3);
|
||||||
|
|
||||||
|
final DiagnosticsProperty<bool> boolProperty = DiagnosticsProperty<bool>('bool', true);
|
||||||
|
json = simulateJsonSerialization(boolProperty);
|
||||||
|
expect(json['name'], 'bool');
|
||||||
|
expect(json['value'], true);
|
||||||
|
|
||||||
|
DiagnosticsProperty<String> stringProperty = DiagnosticsProperty<String>('string1', 'hello');
|
||||||
|
json = simulateJsonSerialization(stringProperty);
|
||||||
|
expect(json['name'], 'string1');
|
||||||
|
expect(json['value'], 'hello');
|
||||||
|
|
||||||
|
stringProperty = StringProperty('string2', 'world');
|
||||||
|
json = simulateJsonSerialization(stringProperty);
|
||||||
|
expect(json['name'], 'string2');
|
||||||
|
expect(json['value'], 'world');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user