From 684a3687194bd8bc17a765418c50fabea6fcc2b4 Mon Sep 17 00:00:00 2001 From: Elad Ben-Israel Date: Mon, 18 Nov 2019 13:09:42 +0200 Subject: [PATCH 1/5] fix(kernel): cannot pass decorated structs as "any" When a struct is serialized with a $jsii.struct decoration from a jsii host language and passed into a value typed `any`, the kernel ignored the decoration. This resulted in a malformed object passed to the javascript code. This fix undecorates the object and continues to deserialize it as `any`. Fixes aws/aws-cdk#5066 --- packages/jsii-calc/lib/compliance.ts | 13 ++++++ packages/jsii-calc/test/assembly.jsii | 43 ++++++++++++++++++- .../ComplianceTests.cs | 13 ++++++ .../Deputy/JsiiByValueAttribute.cs | 4 +- .../Converters/FrameworkToJsiiConverter.cs | 8 +++- .../amazon/jsii/testing/ComplianceTest.java | 14 ++++++ packages/jsii-kernel/lib/serialization.ts | 11 ++++- packages/jsii-kernel/test/kernel.test.ts | 7 +++ .../.jsii | 43 ++++++++++++++++++- .../CalculatorNamespace/JsonFormatter.cs | 31 +++++++++++++ .../amazon/jsii/tests/calculator/$Module.java | 1 + .../jsii/tests/calculator/JsonFormatter.java | 32 ++++++++++++++ .../python/src/jsii_calc/__init__.py | 22 +++++++++- .../tests/test_compliance.py | 7 +++ .../test/__snapshots__/jsii-tree.test.js.snap | 13 ++++++ .../__snapshots__/type-system.test.js.snap | 1 + 16 files changed, 256 insertions(+), 7 deletions(-) create mode 100644 packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/JsonFormatter.cs create mode 100644 packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/JsonFormatter.java diff --git a/packages/jsii-calc/lib/compliance.ts b/packages/jsii-calc/lib/compliance.ts index 07570c64c9..66e1342e29 100644 --- a/packages/jsii-calc/lib/compliance.ts +++ b/packages/jsii-calc/lib/compliance.ts @@ -2331,3 +2331,16 @@ export class ObjectWithPropertyProvider { private constructor() { } } + +/** + * Make sure structs are un-decorated on the way in. + * + * @see https://github.com/aws/aws-cdk/issues/5066 + */ +export class JsonFormatter { + public static stringify(value: any): string { + return JSON.stringify(value, null, 2); + } + + private constructor() { } +} diff --git a/packages/jsii-calc/test/assembly.jsii b/packages/jsii-calc/test/assembly.jsii index 7634c11c48..50fa95a0f7 100644 --- a/packages/jsii-calc/test/assembly.jsii +++ b/packages/jsii-calc/test/assembly.jsii @@ -6826,6 +6826,47 @@ } ] }, + "jsii-calc.JsonFormatter": { + "assembly": "jsii-calc", + "docs": { + "see": "https://github.com/aws/aws-cdk/issues/5066", + "stability": "experimental", + "summary": "Make sure structs are un-decorated on the way in." + }, + "fqn": "jsii-calc.JsonFormatter", + "kind": "class", + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2340 + }, + "methods": [ + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2341 + }, + "name": "stringify", + "parameters": [ + { + "name": "value", + "type": { + "primitive": "any" + } + } + ], + "returns": { + "type": { + "primitive": "string" + } + }, + "static": true + } + ], + "name": "JsonFormatter" + }, "jsii-calc.LoadBalancedFargateServiceProps": { "assembly": "jsii-calc", "datatype": true, @@ -11413,5 +11454,5 @@ } }, "version": "0.20.6", - "fingerprint": "veHd1Q/376CoMR3O/DjjAiH9aVD/jcwnPEg88barg9I=" + "fingerprint": "xXC7/htdFP0Ns+aNf856G/K6PBPRJjPlsg5KtO3bEXY=" } diff --git a/packages/jsii-dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/ComplianceTests.cs b/packages/jsii-dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/ComplianceTests.cs index 87804c0cae..16ba9abbfd 100644 --- a/packages/jsii-dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/ComplianceTests.cs +++ b/packages/jsii-dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/ComplianceTests.cs @@ -1297,5 +1297,18 @@ public void CanUseInterfaceSetters() obj.Property = "New Value"; Assert.True(obj.WasSet()); } + + [Fact(DisplayName = Prefix + nameof(StructsAreUndecoratedOntheWayToKernel))] + public void StructsAreUndecoratedOntheWayToKernel() + { + var json = JsonFormatter.Stringify(new StructB {RequiredString = "Bazinga!", OptionalBoolean = false}); + var actual = JObject.Parse(json); + + var expected = new JObject(); + expected.Add("RequiredString", "Bazinga!"); + expected.Add("OptionalBoolean", false); + + Assert.Equal(expected, actual); + } } } diff --git a/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Deputy/JsiiByValueAttribute.cs b/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Deputy/JsiiByValueAttribute.cs index a9e578588b..832bcf4d97 100644 --- a/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Deputy/JsiiByValueAttribute.cs +++ b/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Deputy/JsiiByValueAttribute.cs @@ -7,9 +7,9 @@ public sealed class JsiiByValueAttribute : Attribute { public JsiiByValueAttribute(string fqn) { - Fqn = fqn ?? throw new ArgumentNullException(nameof(fqn)); + FullyQualifiedName = fqn ?? throw new ArgumentNullException(nameof(fqn)); } - public string Fqn { get; } + public string FullyQualifiedName { get; } } } \ No newline at end of file diff --git a/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Services/Converters/FrameworkToJsiiConverter.cs b/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Services/Converters/FrameworkToJsiiConverter.cs index be9edb0b7e..e0a53e60f6 100644 --- a/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Services/Converters/FrameworkToJsiiConverter.cs +++ b/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Services/Converters/FrameworkToJsiiConverter.cs @@ -72,7 +72,7 @@ protected override bool TryConvertClass(Type type, IReferenceMap referenceMap, o } var structInfo = new JObject(); - structInfo.Add(new JProperty("fqn", byValueAttribute.Fqn)); + structInfo.Add(new JProperty("fqn", byValueAttribute.FullyQualifiedName)); structInfo.Add(new JProperty("data", data)); var resultObject = new JObject(); @@ -353,6 +353,12 @@ TypeReference InferType(IReferenceMap referenceMap, Type type) return new TypeReference(enumAttribute.FullyQualifiedName); } + JsiiByValueAttribute structAttribute = type.GetCustomAttribute(); + if (structAttribute != null) + { + return new TypeReference(structAttribute.FullyQualifiedName); + } + if (typeof(string).IsAssignableFrom(type)) { return new TypeReference(primitive: PrimitiveType.String); diff --git a/packages/jsii-java-runtime-test/project/src/test/java/software/amazon/jsii/testing/ComplianceTest.java b/packages/jsii-java-runtime-test/project/src/test/java/software/amazon/jsii/testing/ComplianceTest.java index ae27f1608d..f8e9c9b9da 100644 --- a/packages/jsii-java-runtime-test/project/src/test/java/software/amazon/jsii/testing/ComplianceTest.java +++ b/packages/jsii-java-runtime-test/project/src/test/java/software/amazon/jsii/testing/ComplianceTest.java @@ -1,5 +1,6 @@ package software.amazon.jsii.testing; +import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; import org.junit.Test; @@ -1580,4 +1581,17 @@ public void canUseInterfaceSetters() { obj.setProperty("New Value"); assertTrue(obj.wasSet()); } + + @Test + public void structsAreUndecoratedOntheWayToKernel() throws IOException { + final ObjectMapper om = new ObjectMapper(); + final String json = JsonFormatter.stringify(StructB.builder().requiredString("Bazinga!").optionalBoolean(false).build()); + final JsonNode actual = om.readTree(json); + + final ObjectNode expected = om.createObjectNode(); + expected.put("requiredString", "Bazinga!"); + expected.put("optionalBoolean", Boolean.FALSE); + + assertEquals(expected, actual); + } } diff --git a/packages/jsii-kernel/lib/serialization.ts b/packages/jsii-kernel/lib/serialization.ts index 4961b1cb8d..ecddda6c5e 100644 --- a/packages/jsii-kernel/lib/serialization.ts +++ b/packages/jsii-kernel/lib/serialization.ts @@ -27,7 +27,7 @@ */ import * as spec from 'jsii-spec'; -import { isObjRef, isWireDate, isWireEnum, isWireMap, ObjRef, TOKEN_DATE, TOKEN_ENUM, TOKEN_MAP, WireDate, WireEnum } from './api'; +import { isObjRef, isWireDate, isWireEnum, isWireMap, ObjRef, TOKEN_DATE, TOKEN_ENUM, TOKEN_MAP, WireDate, WireEnum, isWireStruct, TOKEN_STRUCT } from './api'; import { jsiiTypeFqn, objectReference, ObjectTable } from './objects'; import { api } from '.'; @@ -520,6 +520,15 @@ export const SERIALIZERS: {[k: string]: Serializer} = { host.debug('ANY is a Ref'); return host.objects.findObject(value).instance; } + + // if the value has a struct token, it was serialized by a typed jsii + // struct, but since the deserialization target is ANY, all we can do is + // strip the data from $jsii.struct and continue to deserialize as ANY. + if (isWireStruct(value)) { + const { fqn, data } = value[TOKEN_STRUCT]; + host.debug(`ANY is a struct of type ${fqn}`); + return SERIALIZERS[SerializationClass.Any].deserialize(data, _type, host); + } // At this point again, deserialize by-value. host.debug('ANY is a Map'); diff --git a/packages/jsii-kernel/test/kernel.test.ts b/packages/jsii-kernel/test/kernel.test.ts index 475f8962ee..1743935724 100644 --- a/packages/jsii-kernel/test/kernel.test.ts +++ b/packages/jsii-kernel/test/kernel.test.ts @@ -1218,6 +1218,13 @@ defineTest('correctly deserializes struct unions', (sandbox) => { } }); +defineTest('structs are undecorated on the way to kernel', sandbox => { + const input = { '$jsii.struct': { 'fqn': 'jsii-calc.StructB', 'data': { 'requiredString': 'Bazinga!', 'optionalBoolean': false } } }; + const ret = sandbox.sinvoke({ fqn: 'jsii-calc.JsonFormatter', method: 'stringify', args: [input] }); + const json = JSON.parse(ret.result); + expect(json).toStrictEqual({ 'requiredString': 'Bazinga!', 'optionalBoolean': false }); +}); + // ================================================================================================= const testNames: { [name: string]: boolean } = { }; diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/.jsii b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/.jsii index 7634c11c48..50fa95a0f7 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/.jsii +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/.jsii @@ -6826,6 +6826,47 @@ } ] }, + "jsii-calc.JsonFormatter": { + "assembly": "jsii-calc", + "docs": { + "see": "https://github.com/aws/aws-cdk/issues/5066", + "stability": "experimental", + "summary": "Make sure structs are un-decorated on the way in." + }, + "fqn": "jsii-calc.JsonFormatter", + "kind": "class", + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2340 + }, + "methods": [ + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2341 + }, + "name": "stringify", + "parameters": [ + { + "name": "value", + "type": { + "primitive": "any" + } + } + ], + "returns": { + "type": { + "primitive": "string" + } + }, + "static": true + } + ], + "name": "JsonFormatter" + }, "jsii-calc.LoadBalancedFargateServiceProps": { "assembly": "jsii-calc", "datatype": true, @@ -11413,5 +11454,5 @@ } }, "version": "0.20.6", - "fingerprint": "veHd1Q/376CoMR3O/DjjAiH9aVD/jcwnPEg88barg9I=" + "fingerprint": "xXC7/htdFP0Ns+aNf856G/K6PBPRJjPlsg5KtO3bEXY=" } diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/JsonFormatter.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/JsonFormatter.cs new file mode 100644 index 0000000000..7846fed16e --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/JsonFormatter.cs @@ -0,0 +1,31 @@ +using Amazon.JSII.Runtime.Deputy; + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + /// Make sure structs are un-decorated on the way in. + /// + /// stability: Experimental + /// see: + /// https://github.com/aws/aws-cdk/issues/5066 + /// + [JsiiClass(nativeType: typeof(Amazon.JSII.Tests.CalculatorNamespace.JsonFormatter), fullyQualifiedName: "jsii-calc.JsonFormatter")] + public class JsonFormatter : DeputyBase + { + protected JsonFormatter(ByRefValue reference): base(reference) + { + } + + protected JsonFormatter(DeputyProps props): base(props) + { + } + + /// + /// stability: Experimental + /// + [JsiiMethod(name: "stringify", returnsJson: "{\"type\":{\"primitive\":\"string\"}}", parametersJson: "[{\"name\":\"value\",\"type\":{\"primitive\":\"any\"}}]")] + public static string Stringify(object @value) + { + return InvokeStaticMethod(typeof(Amazon.JSII.Tests.CalculatorNamespace.JsonFormatter), new System.Type[]{typeof(object)}, new object[]{@value}); + } + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/$Module.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/$Module.java index 3b14e94eaf..8df477385f 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/$Module.java +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/$Module.java @@ -130,6 +130,7 @@ protected Class resolveClass(final String fqn) throws ClassNotFoundException case "jsii-calc.Jsii487Derived": return software.amazon.jsii.tests.calculator.Jsii487Derived.class; case "jsii-calc.Jsii496Derived": return software.amazon.jsii.tests.calculator.Jsii496Derived.class; case "jsii-calc.JsiiAgent": return software.amazon.jsii.tests.calculator.JsiiAgent.class; + case "jsii-calc.JsonFormatter": return software.amazon.jsii.tests.calculator.JsonFormatter.class; case "jsii-calc.LoadBalancedFargateServiceProps": return software.amazon.jsii.tests.calculator.LoadBalancedFargateServiceProps.class; case "jsii-calc.Multiply": return software.amazon.jsii.tests.calculator.Multiply.class; case "jsii-calc.Negate": return software.amazon.jsii.tests.calculator.Negate.class; diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/JsonFormatter.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/JsonFormatter.java new file mode 100644 index 0000000000..e802833537 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/JsonFormatter.java @@ -0,0 +1,32 @@ +package software.amazon.jsii.tests.calculator; + +/** + * Make sure structs are un-decorated on the way in. + * + * EXPERIMENTAL + * + * @see https://github.com/aws/aws-cdk/issues/5066 + */ +@javax.annotation.Generated(value = "jsii-pacmak") +@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) +@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.JsonFormatter") +public class JsonFormatter extends software.amazon.jsii.JsiiObject { + + protected JsonFormatter(final software.amazon.jsii.JsiiObjectRef objRef) { + super(objRef); + } + + protected JsonFormatter(final software.amazon.jsii.JsiiObject.InitializationMode initializationMode) { + super(initializationMode); + } + + /** + * EXPERIMENTAL + * + * @param value This parameter is required. + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public static java.lang.String stringify(final java.lang.Object value) { + return software.amazon.jsii.JsiiObject.jsiiStaticCall(software.amazon.jsii.tests.calculator.JsonFormatter.class, "stringify", java.lang.String.class, new Object[] { value }); + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/__init__.py b/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/__init__.py index 3359599cce..39b7fcf2d0 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/__init__.py +++ b/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/__init__.py @@ -4950,6 +4950,26 @@ def jsii_agent(cls) -> typing.Optional[str]: return jsii.sget(cls, "jsiiAgent") +class JsonFormatter(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.JsonFormatter"): + """Make sure structs are un-decorated on the way in. + + see + :see: https://github.com/aws/aws-cdk/issues/5066 + stability + :stability: experimental + """ + @jsii.member(jsii_name="stringify") + @classmethod + def stringify(cls, value: typing.Any) -> str: + """ + :param value: - + + stability + :stability: experimental + """ + return jsii.sinvoke(cls, "stringify", [value]) + + @jsii.data_type(jsii_type="jsii-calc.LoadBalancedFargateServiceProps", jsii_struct_bases=[], name_mapping={'container_port': 'containerPort', 'cpu': 'cpu', 'memory_mib': 'memoryMiB', 'public_load_balancer': 'publicLoadBalancer', 'public_tasks': 'publicTasks'}) class LoadBalancedFargateServiceProps(): def __init__(self, *, container_port: typing.Optional[jsii.Number]=None, cpu: typing.Optional[str]=None, memory_mib: typing.Optional[str]=None, public_load_balancer: typing.Optional[bool]=None, public_tasks: typing.Optional[bool]=None): @@ -8025,6 +8045,6 @@ def parts(self, value: typing.List[scope.jsii_calc_lib.Value]): return jsii.set(self, "parts", value) -__all__ = ["AbstractClass", "AbstractClassBase", "AbstractClassReturner", "Add", "AllTypes", "AllTypesEnum", "AllowedMethodNames", "AnonymousImplementationProvider", "AsyncVirtualMethods", "AugmentableClass", "BaseJsii976", "Bell", "BinaryOperation", "Calculator", "CalculatorProps", "ChildStruct982", "ClassThatImplementsTheInternalInterface", "ClassThatImplementsThePrivateInterface", "ClassWithCollections", "ClassWithDocs", "ClassWithJavaReservedWords", "ClassWithMutableObjectLiteralProperty", "ClassWithPrivateConstructorAndAutomaticProperties", "ConfusingToJackson", "ConfusingToJacksonStruct", "ConstructorPassesThisOut", "Constructors", "ConsumerCanRingBell", "ConsumersOfThisCrazyTypeSystem", "DataRenderer", "DefaultedConstructorArgument", "Demonstrate982", "DeprecatedClass", "DeprecatedEnum", "DeprecatedStruct", "DerivedClassHasNoProperties", "DerivedStruct", "DiamondInheritanceBaseLevelStruct", "DiamondInheritanceFirstMidLevelStruct", "DiamondInheritanceSecondMidLevelStruct", "DiamondInheritanceTopLevelStruct", "DisappointingCollectionSource", "DoNotOverridePrivates", "DoNotRecognizeAnyAsOptional", "DocumentedClass", "DontComplainAboutVariadicAfterOptional", "DoubleTrouble", "EnumDispenser", "EraseUndefinedHashValues", "EraseUndefinedHashValuesOptions", "ExperimentalClass", "ExperimentalEnum", "ExperimentalStruct", "ExportedBaseClass", "ExtendsInternalInterface", "GiveMeStructs", "Greetee", "GreetingAugmenter", "IAnonymousImplementationProvider", "IAnonymouslyImplementMe", "IAnotherPublicInterface", "IBell", "IBellRinger", "IConcreteBellRinger", "IDeprecatedInterface", "IExperimentalInterface", "IExtendsPrivateInterface", "IFriendlier", "IFriendlyRandomGenerator", "IInterfaceImplementedByAbstractClass", "IInterfaceThatShouldNotBeADataType", "IInterfaceWithInternal", "IInterfaceWithMethods", "IInterfaceWithOptionalMethodArguments", "IInterfaceWithProperties", "IInterfaceWithPropertiesExtension", "IJSII417Derived", "IJSII417PublicBaseOfBase", "IJsii487External", "IJsii487External2", "IJsii496", "IMutableObjectLiteral", "INonInternalInterface", "IObjectWithProperty", "IPrivatelyImplemented", "IPublicInterface", "IPublicInterface2", "IRandomNumberGenerator", "IReturnJsii976", "IReturnsNumber", "IStableInterface", "ImplementInternalInterface", "Implementation", "ImplementsInterfaceWithInternal", "ImplementsInterfaceWithInternalSubclass", "ImplementsPrivateInterface", "ImplictBaseOfBase", "InbetweenClass", "InterfaceInNamespaceIncludesClasses", "InterfaceInNamespaceOnlyInterface", "InterfacesMaker", "JSII417Derived", "JSII417PublicBaseOfBase", "JSObjectLiteralForInterface", "JSObjectLiteralToNative", "JSObjectLiteralToNativeClass", "JavaReservedWords", "Jsii487Derived", "Jsii496Derived", "JsiiAgent", "LoadBalancedFargateServiceProps", "Multiply", "Negate", "NestedStruct", "NodeStandardLibrary", "NullShouldBeTreatedAsUndefined", "NullShouldBeTreatedAsUndefinedData", "NumberGenerator", "ObjectRefsInCollections", "ObjectWithPropertyProvider", "Old", "OptionalArgumentInvoker", "OptionalConstructorArgument", "OptionalStruct", "OptionalStructConsumer", "OverridableProtectedMember", "OverrideReturnsObject", "ParentStruct982", "PartiallyInitializedThisConsumer", "Polymorphism", "Power", "PublicClass", "PythonReservedWords", "ReferenceEnumFromScopedPackage", "ReturnsPrivateImplementationOfInterface", "RootStruct", "RootStructValidator", "RuntimeTypeChecking", "SecondLevelStruct", "SingleInstanceTwoTypes", "SingletonInt", "SingletonIntEnum", "SingletonString", "SingletonStringEnum", "SomeTypeJsii976", "StableClass", "StableEnum", "StableStruct", "StaticContext", "Statics", "StringEnum", "StripInternal", "StructA", "StructB", "StructPassing", "StructUnionConsumer", "StructWithJavaReservedWords", "Sum", "SupportsNiceJavaBuilder", "SupportsNiceJavaBuilderProps", "SupportsNiceJavaBuilderWithRequiredProps", "SyncVirtualMethods", "Thrower", "TopLevelStruct", "UnaryOperation", "UnionProperties", "UseBundledDependency", "UseCalcBase", "UsesInterfaceWithProperties", "VariadicInvoker", "VariadicMethod", "VirtualMethodPlayground", "VoidCallback", "WithPrivatePropertyInConstructor", "__jsii_assembly__", "composition"] +__all__ = ["AbstractClass", "AbstractClassBase", "AbstractClassReturner", "Add", "AllTypes", "AllTypesEnum", "AllowedMethodNames", "AnonymousImplementationProvider", "AsyncVirtualMethods", "AugmentableClass", "BaseJsii976", "Bell", "BinaryOperation", "Calculator", "CalculatorProps", "ChildStruct982", "ClassThatImplementsTheInternalInterface", "ClassThatImplementsThePrivateInterface", "ClassWithCollections", "ClassWithDocs", "ClassWithJavaReservedWords", "ClassWithMutableObjectLiteralProperty", "ClassWithPrivateConstructorAndAutomaticProperties", "ConfusingToJackson", "ConfusingToJacksonStruct", "ConstructorPassesThisOut", "Constructors", "ConsumerCanRingBell", "ConsumersOfThisCrazyTypeSystem", "DataRenderer", "DefaultedConstructorArgument", "Demonstrate982", "DeprecatedClass", "DeprecatedEnum", "DeprecatedStruct", "DerivedClassHasNoProperties", "DerivedStruct", "DiamondInheritanceBaseLevelStruct", "DiamondInheritanceFirstMidLevelStruct", "DiamondInheritanceSecondMidLevelStruct", "DiamondInheritanceTopLevelStruct", "DisappointingCollectionSource", "DoNotOverridePrivates", "DoNotRecognizeAnyAsOptional", "DocumentedClass", "DontComplainAboutVariadicAfterOptional", "DoubleTrouble", "EnumDispenser", "EraseUndefinedHashValues", "EraseUndefinedHashValuesOptions", "ExperimentalClass", "ExperimentalEnum", "ExperimentalStruct", "ExportedBaseClass", "ExtendsInternalInterface", "GiveMeStructs", "Greetee", "GreetingAugmenter", "IAnonymousImplementationProvider", "IAnonymouslyImplementMe", "IAnotherPublicInterface", "IBell", "IBellRinger", "IConcreteBellRinger", "IDeprecatedInterface", "IExperimentalInterface", "IExtendsPrivateInterface", "IFriendlier", "IFriendlyRandomGenerator", "IInterfaceImplementedByAbstractClass", "IInterfaceThatShouldNotBeADataType", "IInterfaceWithInternal", "IInterfaceWithMethods", "IInterfaceWithOptionalMethodArguments", "IInterfaceWithProperties", "IInterfaceWithPropertiesExtension", "IJSII417Derived", "IJSII417PublicBaseOfBase", "IJsii487External", "IJsii487External2", "IJsii496", "IMutableObjectLiteral", "INonInternalInterface", "IObjectWithProperty", "IPrivatelyImplemented", "IPublicInterface", "IPublicInterface2", "IRandomNumberGenerator", "IReturnJsii976", "IReturnsNumber", "IStableInterface", "ImplementInternalInterface", "Implementation", "ImplementsInterfaceWithInternal", "ImplementsInterfaceWithInternalSubclass", "ImplementsPrivateInterface", "ImplictBaseOfBase", "InbetweenClass", "InterfaceInNamespaceIncludesClasses", "InterfaceInNamespaceOnlyInterface", "InterfacesMaker", "JSII417Derived", "JSII417PublicBaseOfBase", "JSObjectLiteralForInterface", "JSObjectLiteralToNative", "JSObjectLiteralToNativeClass", "JavaReservedWords", "Jsii487Derived", "Jsii496Derived", "JsiiAgent", "JsonFormatter", "LoadBalancedFargateServiceProps", "Multiply", "Negate", "NestedStruct", "NodeStandardLibrary", "NullShouldBeTreatedAsUndefined", "NullShouldBeTreatedAsUndefinedData", "NumberGenerator", "ObjectRefsInCollections", "ObjectWithPropertyProvider", "Old", "OptionalArgumentInvoker", "OptionalConstructorArgument", "OptionalStruct", "OptionalStructConsumer", "OverridableProtectedMember", "OverrideReturnsObject", "ParentStruct982", "PartiallyInitializedThisConsumer", "Polymorphism", "Power", "PublicClass", "PythonReservedWords", "ReferenceEnumFromScopedPackage", "ReturnsPrivateImplementationOfInterface", "RootStruct", "RootStructValidator", "RuntimeTypeChecking", "SecondLevelStruct", "SingleInstanceTwoTypes", "SingletonInt", "SingletonIntEnum", "SingletonString", "SingletonStringEnum", "SomeTypeJsii976", "StableClass", "StableEnum", "StableStruct", "StaticContext", "Statics", "StringEnum", "StripInternal", "StructA", "StructB", "StructPassing", "StructUnionConsumer", "StructWithJavaReservedWords", "Sum", "SupportsNiceJavaBuilder", "SupportsNiceJavaBuilderProps", "SupportsNiceJavaBuilderWithRequiredProps", "SyncVirtualMethods", "Thrower", "TopLevelStruct", "UnaryOperation", "UnionProperties", "UseBundledDependency", "UseCalcBase", "UsesInterfaceWithProperties", "VariadicInvoker", "VariadicMethod", "VirtualMethodPlayground", "VoidCallback", "WithPrivatePropertyInConstructor", "__jsii_assembly__", "composition"] publication.publish() diff --git a/packages/jsii-python-runtime/tests/test_compliance.py b/packages/jsii-python-runtime/tests/test_compliance.py index 5bd455839f..ceacb3f777 100644 --- a/packages/jsii-python-runtime/tests/test_compliance.py +++ b/packages/jsii-python-runtime/tests/test_compliance.py @@ -6,6 +6,8 @@ import jsii +from json import loads + from jsii_calc import ( AbstractClassReturner, Add, @@ -32,6 +34,7 @@ JsiiAgent, JSObjectLiteralForInterface, JSObjectLiteralToNative, + JsonFormatter, Multiply, Negate, NodeStandardLibrary, @@ -1073,3 +1076,7 @@ def test_can_use_interface_setters(): obj = ObjectWithPropertyProvider.provide() obj.property = 'New Value' assert obj.was_set() + +def test_structs_are_undecorated_on_the_way_to_kernel(): + json = JsonFormatter.stringify(StructB(required_string='Bazinga!', optional_boolean=False)) + assert loads(json) == {'requiredString': 'Bazinga!', 'optionalBoolean': False} diff --git a/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.js.snap b/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.js.snap index 2979b10ac0..9051fa15d9 100644 --- a/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.js.snap +++ b/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.js.snap @@ -858,6 +858,14 @@ exports[`jsii-tree --all 1`] = ` │ │ ├── immutable │ │ ├── static │ │ └── type: Optional + │ ├─┬ class JsonFormatter (experimental) + │ │ └─┬ members + │ │ └─┬ static stringify(value) method (experimental) + │ │ ├── static + │ │ ├─┬ parameters + │ │ │ └─┬ value + │ │ │ └── type: any + │ │ └── returns: string │ ├─┬ class Multiply (experimental) │ │ ├── base: BinaryOperation │ │ ├── interfaces: IFriendlier,IRandomNumberGenerator @@ -2341,6 +2349,7 @@ exports[`jsii-tree --inheritance 1`] = ` │ ├─┬ class Jsii496Derived │ │ └── interfaces: IJsii496 │ ├── class JsiiAgent + │ ├── class JsonFormatter │ ├─┬ class Multiply │ │ ├── base: BinaryOperation │ │ └── interfaces: IFriendlier,IRandomNumberGenerator @@ -2917,6 +2926,9 @@ exports[`jsii-tree --members 1`] = ` │ │ └─┬ members │ │ ├── () initializer │ │ └── static jsiiAgent property + │ ├─┬ class JsonFormatter + │ │ └─┬ members + │ │ └── static stringify(value) method │ ├─┬ class Multiply │ │ └─┬ members │ │ ├── (lhs,rhs) initializer @@ -3597,6 +3609,7 @@ exports[`jsii-tree --types 1`] = ` │ ├── class Jsii487Derived │ ├── class Jsii496Derived │ ├── class JsiiAgent + │ ├── class JsonFormatter │ ├── class Multiply │ ├── class Negate │ ├── class NodeStandardLibrary diff --git a/packages/jsii-reflect/test/__snapshots__/type-system.test.js.snap b/packages/jsii-reflect/test/__snapshots__/type-system.test.js.snap index c2142fc3ea..4bd5eb80e2 100644 --- a/packages/jsii-reflect/test/__snapshots__/type-system.test.js.snap +++ b/packages/jsii-reflect/test/__snapshots__/type-system.test.js.snap @@ -73,6 +73,7 @@ Array [ "Jsii487Derived", "Jsii496Derived", "JsiiAgent", + "JsonFormatter", "Multiply", "Negate", "NodeStandardLibrary", From ee79e7baefb34f9551872a425495edc418b0b660 Mon Sep 17 00:00:00 2001 From: Elad Ben-Israel Date: Mon, 18 Nov 2019 15:50:10 +0200 Subject: [PATCH 2/5] use fqn from struct decoration and delegate to struct deserializer --- packages/jsii-kernel/lib/serialization.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/jsii-kernel/lib/serialization.ts b/packages/jsii-kernel/lib/serialization.ts index ecddda6c5e..522fc1fd2f 100644 --- a/packages/jsii-kernel/lib/serialization.ts +++ b/packages/jsii-kernel/lib/serialization.ts @@ -527,7 +527,7 @@ export const SERIALIZERS: {[k: string]: Serializer} = { if (isWireStruct(value)) { const { fqn, data } = value[TOKEN_STRUCT]; host.debug(`ANY is a struct of type ${fqn}`); - return SERIALIZERS[SerializationClass.Any].deserialize(data, _type, host); + return SERIALIZERS[SerializationClass.Struct].deserialize(data, { type: { fqn } }, host); } // At this point again, deserialize by-value. From e8ae5f9b30744c0bca491a2dfad654f319d1c77b Mon Sep 17 00:00:00 2001 From: Elad Ben-Israel Date: Mon, 18 Nov 2019 15:50:26 +0200 Subject: [PATCH 3/5] increase coverage for any ser/deser --- packages/jsii-calc/lib/compliance.ts | 54 +++++++++- packages/jsii-kernel/test/kernel.test.ts | 130 +++++++++++++++++++++-- 2 files changed, 176 insertions(+), 8 deletions(-) diff --git a/packages/jsii-calc/lib/compliance.ts b/packages/jsii-calc/lib/compliance.ts index 66e1342e29..9c025ac763 100644 --- a/packages/jsii-calc/lib/compliance.ts +++ b/packages/jsii-calc/lib/compliance.ts @@ -2338,9 +2338,61 @@ export class ObjectWithPropertyProvider { * @see https://github.com/aws/aws-cdk/issues/5066 */ export class JsonFormatter { - public static stringify(value: any): string { + public static stringify(value?: any): string | undefined { return JSON.stringify(value, null, 2); } + public static anyNull(): any { + return null; + } + + public static anyUndefined(): any { + return undefined; + } + + public static anyFunction(): any { + return () => 'boom'; + } + + public static anyDate(): any { + return new Date('2019-11-18T13:01:20.515Z'); + } + + public static anyNumber(): any { + return 123; + } + + public static anyZero(): any { + return 0; + } + + public static anyString(): any { + return 'foo'; + } + + public static anyEmptyString(): any { + return ''; + } + + public static anyBooleanTrue(): any { + return true; + } + + public static anyBooleanFalse(): any { + return false; + } + + public static anyArray(): any { + return [ 1, 2, 3, new Number(123), { foo: 'bar' } ]; + } + + public static anyHash(): any { + return { hello: 1234, world: new Number(122) }; + } + + public static anyRef(): any { + return new Number(444); + } + private constructor() { } } diff --git a/packages/jsii-kernel/test/kernel.test.ts b/packages/jsii-kernel/test/kernel.test.ts index 1743935724..7cc6266573 100644 --- a/packages/jsii-kernel/test/kernel.test.ts +++ b/packages/jsii-kernel/test/kernel.test.ts @@ -1031,9 +1031,6 @@ defineTest('calculator can set and retrieve union properties', (sandbox) => { expect(27).toBe(value); const expression = sandbox.get({ objref: calculator, property: 'unionProperty' }).value; - - console.log(expression); - expect(deepEqualWithRegex(expression, { [TOKEN_REF]: /^jsii-calc.Multiply@/ })).toBeTruthy(); }); @@ -1218,13 +1215,117 @@ defineTest('correctly deserializes struct unions', (sandbox) => { } }); -defineTest('structs are undecorated on the way to kernel', sandbox => { +defineTest('ANY deserializer: decorated structs', sandbox => { const input = { '$jsii.struct': { 'fqn': 'jsii-calc.StructB', 'data': { 'requiredString': 'Bazinga!', 'optionalBoolean': false } } }; - const ret = sandbox.sinvoke({ fqn: 'jsii-calc.JsonFormatter', method: 'stringify', args: [input] }); - const json = JSON.parse(ret.result); - expect(json).toStrictEqual({ 'requiredString': 'Bazinga!', 'optionalBoolean': false }); + expect(deserializeAny(sandbox, input)).toStrictEqual({ 'requiredString': 'Bazinga!', 'optionalBoolean': false }); +}); + +defineTest('ANY deserializer: primitives', sandbox => { + expect(deserializeAny(sandbox, -100)).toStrictEqual(-100); + expect(deserializeAny(sandbox, 0)).toStrictEqual(0); + expect(deserializeAny(sandbox, 1234)).toStrictEqual(1234); + expect(deserializeAny(sandbox, 'hello')).toStrictEqual('hello'); + expect(deserializeAny(sandbox, '')).toStrictEqual(''); + expect(deserializeAny(sandbox, true)).toStrictEqual(true); + expect(deserializeAny(sandbox, false)).toStrictEqual(false); +}); + +defineTest('ANY deserializer: array', sandbox => { + expect(deserializeAny(sandbox, [ 1, 2, 3, 'four' ])).toStrictEqual([ 1, 2, 3, 'four' ]); +}); + +defineTest('ANY deserializer: undefined/null', sandbox => { + expect(deserializeAny(sandbox, null)).toStrictEqual(undefined); + expect(deserializeAny(sandbox, undefined)).toStrictEqual(undefined); +}); + +defineTest('ANY deserializer: wire date', sandbox => { + expect(deserializeAny(sandbox, { '$jsii.date': '2019-11-18T13:01:20.515Z' })).toStrictEqual('2019-11-18T13:01:20.515Z'); +}); + +defineTest('ANY deserializer: enum', sandbox => { + expect(deserializeAny(sandbox, { '$jsii.enum': 'jsii-calc.AllTypesEnum/YOUR_ENUM_VALUE' })).toStrictEqual(100); +}); + +defineTest('ANY deserializer: wire map', sandbox => { + const input = { '$jsii.map': { foo: 123, bar: { '$jsii.enum': 'jsii-calc.AllTypesEnum/YOUR_ENUM_VALUE' } } }; + expect(deserializeAny(sandbox, input)).toStrictEqual({ + foo: 123, + bar: 100 + }); +}); + +defineTest('ANY deserializer: by value', sandbox => { + const ref = sandbox.create({ fqn: '@scope/jsii-calc-lib.Number', args: [444] }); + + const input = { + foo: 123, + bar: { '$jsii.enum': 'jsii-calc.AllTypesEnum/YOUR_ENUM_VALUE' }, + struct: { '$jsii.struct': { 'fqn': 'jsii-calc.StructB', 'data': { 'requiredString': 'Bazinga!', 'optionalBoolean': false } } }, + ref + }; + + expect(deserializeAny(sandbox, input)).toStrictEqual({ + foo: 123, + bar: 100, + struct: { + requiredString: 'Bazinga!', + optionalBoolean: false + }, + ref: { value: 444 }, + }); }); +defineTest('ANY serializer: null/undefined', sandbox => { + expect(serializeAny(sandbox, 'anyNull')).toStrictEqual(undefined); + expect(serializeAny(sandbox, 'anyUndefined')).toStrictEqual(undefined); +}); + +defineTest('ANY serializer: function (fails)', sandbox => { + expect(() => serializeAny(sandbox, 'anyFunction')).toThrow(/JSII Kernel is unable to serialize `function`. An instance with methods might have been returned by an `any` method\?/); +}); + +defineTest('ANY serializer: date', sandbox => { + expect(serializeAny(sandbox, 'anyDate')).toStrictEqual({ '$jsii.date': '2019-11-18T13:01:20.515Z' }); +}); + +defineTest('ANY serializer: primitives', sandbox => { + expect(serializeAny(sandbox, 'anyNumber')).toStrictEqual(123); + expect(serializeAny(sandbox, 'anyZero')).toStrictEqual(0); + expect(serializeAny(sandbox, 'anyString')).toStrictEqual('foo'); + expect(serializeAny(sandbox, 'anyEmptyString')).toStrictEqual(''); + expect(serializeAny(sandbox, 'anyBooleanTrue')).toStrictEqual(true); + expect(serializeAny(sandbox, 'anyBooleanFalse')).toStrictEqual(false); +}); + +defineTest('ANY serializer: array', sandbox => { + expect(serializeAny(sandbox, 'anyArray')).toEqual([ + 1, 2, 3, + { + '$jsii.byref': '@scope/jsii-calc-lib.Number@10000', + '$jsii.interfaces': undefined + }, + { foo: 'bar' } + ]); +}); + +defineTest('ANY serializer: hash', sandbox => { + expect(serializeAny(sandbox, 'anyHash')).toStrictEqual({ + hello: 1234, + world: { + '$jsii.byref': '@scope/jsii-calc-lib.Number@10000', + '$jsii.interfaces': undefined + } + }); +}); + +defineTest('ANY serializer: ref', sandbox => { + expect(serializeAny(sandbox, 'anyRef')).toStrictEqual({ + '$jsii.byref': '@scope/jsii-calc-lib.Number@10000', + '$jsii.interfaces': undefined + }); +}) + // ================================================================================================= const testNames: { [name: string]: boolean } = { }; @@ -1359,3 +1460,18 @@ function get(kernel: Kernel, objref: ObjRef) { return kernel.get({ objref, property }).value; }; } + +/** + * Passes `input` to the kernel through an "any" type and returns the JSON + * stringified version that the JavaScript code saw. + */ +function deserializeAny(sandbox: Kernel, input: any) { + const ret = sandbox.sinvoke({ fqn: 'jsii-calc.JsonFormatter', method: 'stringify', args: [ input ] }); + if (ret.result === undefined) { return undefined; } + const json = JSON.parse(ret.result); + return json; +} + +function serializeAny(sandbox: Kernel, method: string): any { + return sandbox.sinvoke({ fqn: 'jsii-calc.JsonFormatter', method }).result; +} \ No newline at end of file From bf3d568825806a46ae3650a0c133570149209124 Mon Sep 17 00:00:00 2001 From: Elad Ben-Israel Date: Mon, 18 Nov 2019 16:01:19 +0200 Subject: [PATCH 4/5] update expectations --- packages/jsii-calc/test/assembly.jsii | 212 +++++++++++++++++- .../.jsii | 212 +++++++++++++++++- .../CalculatorNamespace/JsonFormatter.cs | 121 +++++++++- .../jsii/tests/calculator/JsonFormatter.java | 114 +++++++++- .../python/src/jsii_calc/__init__.py | 119 +++++++++- .../test/__snapshots__/jsii-tree.test.js.snap | 54 ++++- 6 files changed, 825 insertions(+), 7 deletions(-) diff --git a/packages/jsii-calc/test/assembly.jsii b/packages/jsii-calc/test/assembly.jsii index 50fa95a0f7..02073546c5 100644 --- a/packages/jsii-calc/test/assembly.jsii +++ b/packages/jsii-calc/test/assembly.jsii @@ -6840,6 +6840,214 @@ "line": 2340 }, "methods": [ + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2385 + }, + "name": "anyArray", + "returns": { + "type": { + "primitive": "any" + } + }, + "static": true + }, + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2381 + }, + "name": "anyBooleanFalse", + "returns": { + "type": { + "primitive": "any" + } + }, + "static": true + }, + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2377 + }, + "name": "anyBooleanTrue", + "returns": { + "type": { + "primitive": "any" + } + }, + "static": true + }, + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2357 + }, + "name": "anyDate", + "returns": { + "type": { + "primitive": "any" + } + }, + "static": true + }, + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2373 + }, + "name": "anyEmptyString", + "returns": { + "type": { + "primitive": "any" + } + }, + "static": true + }, + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2353 + }, + "name": "anyFunction", + "returns": { + "type": { + "primitive": "any" + } + }, + "static": true + }, + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2389 + }, + "name": "anyHash", + "returns": { + "type": { + "primitive": "any" + } + }, + "static": true + }, + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2345 + }, + "name": "anyNull", + "returns": { + "type": { + "primitive": "any" + } + }, + "static": true + }, + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2361 + }, + "name": "anyNumber", + "returns": { + "type": { + "primitive": "any" + } + }, + "static": true + }, + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2393 + }, + "name": "anyRef", + "returns": { + "type": { + "primitive": "any" + } + }, + "static": true + }, + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2369 + }, + "name": "anyString", + "returns": { + "type": { + "primitive": "any" + } + }, + "static": true + }, + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2349 + }, + "name": "anyUndefined", + "returns": { + "type": { + "primitive": "any" + } + }, + "static": true + }, + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2365 + }, + "name": "anyZero", + "returns": { + "type": { + "primitive": "any" + } + }, + "static": true + }, { "docs": { "stability": "experimental" @@ -6852,12 +7060,14 @@ "parameters": [ { "name": "value", + "optional": true, "type": { "primitive": "any" } } ], "returns": { + "optional": true, "type": { "primitive": "string" } @@ -11454,5 +11664,5 @@ } }, "version": "0.20.6", - "fingerprint": "xXC7/htdFP0Ns+aNf856G/K6PBPRJjPlsg5KtO3bEXY=" + "fingerprint": "xRnF3HrD87xlfIYG262JFu5WEdrC0eQelRBEzyQyARo=" } diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/.jsii b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/.jsii index 50fa95a0f7..02073546c5 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/.jsii +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/.jsii @@ -6840,6 +6840,214 @@ "line": 2340 }, "methods": [ + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2385 + }, + "name": "anyArray", + "returns": { + "type": { + "primitive": "any" + } + }, + "static": true + }, + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2381 + }, + "name": "anyBooleanFalse", + "returns": { + "type": { + "primitive": "any" + } + }, + "static": true + }, + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2377 + }, + "name": "anyBooleanTrue", + "returns": { + "type": { + "primitive": "any" + } + }, + "static": true + }, + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2357 + }, + "name": "anyDate", + "returns": { + "type": { + "primitive": "any" + } + }, + "static": true + }, + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2373 + }, + "name": "anyEmptyString", + "returns": { + "type": { + "primitive": "any" + } + }, + "static": true + }, + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2353 + }, + "name": "anyFunction", + "returns": { + "type": { + "primitive": "any" + } + }, + "static": true + }, + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2389 + }, + "name": "anyHash", + "returns": { + "type": { + "primitive": "any" + } + }, + "static": true + }, + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2345 + }, + "name": "anyNull", + "returns": { + "type": { + "primitive": "any" + } + }, + "static": true + }, + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2361 + }, + "name": "anyNumber", + "returns": { + "type": { + "primitive": "any" + } + }, + "static": true + }, + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2393 + }, + "name": "anyRef", + "returns": { + "type": { + "primitive": "any" + } + }, + "static": true + }, + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2369 + }, + "name": "anyString", + "returns": { + "type": { + "primitive": "any" + } + }, + "static": true + }, + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2349 + }, + "name": "anyUndefined", + "returns": { + "type": { + "primitive": "any" + } + }, + "static": true + }, + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2365 + }, + "name": "anyZero", + "returns": { + "type": { + "primitive": "any" + } + }, + "static": true + }, { "docs": { "stability": "experimental" @@ -6852,12 +7060,14 @@ "parameters": [ { "name": "value", + "optional": true, "type": { "primitive": "any" } } ], "returns": { + "optional": true, "type": { "primitive": "string" } @@ -11454,5 +11664,5 @@ } }, "version": "0.20.6", - "fingerprint": "xXC7/htdFP0Ns+aNf856G/K6PBPRJjPlsg5KtO3bEXY=" + "fingerprint": "xRnF3HrD87xlfIYG262JFu5WEdrC0eQelRBEzyQyARo=" } diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/JsonFormatter.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/JsonFormatter.cs index 7846fed16e..cfab0a528f 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/JsonFormatter.cs +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/JsonFormatter.cs @@ -22,8 +22,125 @@ protected JsonFormatter(DeputyProps props): base(props) /// /// stability: Experimental /// - [JsiiMethod(name: "stringify", returnsJson: "{\"type\":{\"primitive\":\"string\"}}", parametersJson: "[{\"name\":\"value\",\"type\":{\"primitive\":\"any\"}}]")] - public static string Stringify(object @value) + [JsiiMethod(name: "anyArray", returnsJson: "{\"type\":{\"primitive\":\"any\"}}")] + public static object AnyArray() + { + return InvokeStaticMethod(typeof(Amazon.JSII.Tests.CalculatorNamespace.JsonFormatter), new System.Type[]{}, new object[]{}); + } + + /// + /// stability: Experimental + /// + [JsiiMethod(name: "anyBooleanFalse", returnsJson: "{\"type\":{\"primitive\":\"any\"}}")] + public static object AnyBooleanFalse() + { + return InvokeStaticMethod(typeof(Amazon.JSII.Tests.CalculatorNamespace.JsonFormatter), new System.Type[]{}, new object[]{}); + } + + /// + /// stability: Experimental + /// + [JsiiMethod(name: "anyBooleanTrue", returnsJson: "{\"type\":{\"primitive\":\"any\"}}")] + public static object AnyBooleanTrue() + { + return InvokeStaticMethod(typeof(Amazon.JSII.Tests.CalculatorNamespace.JsonFormatter), new System.Type[]{}, new object[]{}); + } + + /// + /// stability: Experimental + /// + [JsiiMethod(name: "anyDate", returnsJson: "{\"type\":{\"primitive\":\"any\"}}")] + public static object AnyDate() + { + return InvokeStaticMethod(typeof(Amazon.JSII.Tests.CalculatorNamespace.JsonFormatter), new System.Type[]{}, new object[]{}); + } + + /// + /// stability: Experimental + /// + [JsiiMethod(name: "anyEmptyString", returnsJson: "{\"type\":{\"primitive\":\"any\"}}")] + public static object AnyEmptyString() + { + return InvokeStaticMethod(typeof(Amazon.JSII.Tests.CalculatorNamespace.JsonFormatter), new System.Type[]{}, new object[]{}); + } + + /// + /// stability: Experimental + /// + [JsiiMethod(name: "anyFunction", returnsJson: "{\"type\":{\"primitive\":\"any\"}}")] + public static object AnyFunction() + { + return InvokeStaticMethod(typeof(Amazon.JSII.Tests.CalculatorNamespace.JsonFormatter), new System.Type[]{}, new object[]{}); + } + + /// + /// stability: Experimental + /// + [JsiiMethod(name: "anyHash", returnsJson: "{\"type\":{\"primitive\":\"any\"}}")] + public static object AnyHash() + { + return InvokeStaticMethod(typeof(Amazon.JSII.Tests.CalculatorNamespace.JsonFormatter), new System.Type[]{}, new object[]{}); + } + + /// + /// stability: Experimental + /// + [JsiiMethod(name: "anyNull", returnsJson: "{\"type\":{\"primitive\":\"any\"}}")] + public static object AnyNull() + { + return InvokeStaticMethod(typeof(Amazon.JSII.Tests.CalculatorNamespace.JsonFormatter), new System.Type[]{}, new object[]{}); + } + + /// + /// stability: Experimental + /// + [JsiiMethod(name: "anyNumber", returnsJson: "{\"type\":{\"primitive\":\"any\"}}")] + public static object AnyNumber() + { + return InvokeStaticMethod(typeof(Amazon.JSII.Tests.CalculatorNamespace.JsonFormatter), new System.Type[]{}, new object[]{}); + } + + /// + /// stability: Experimental + /// + [JsiiMethod(name: "anyRef", returnsJson: "{\"type\":{\"primitive\":\"any\"}}")] + public static object AnyRef() + { + return InvokeStaticMethod(typeof(Amazon.JSII.Tests.CalculatorNamespace.JsonFormatter), new System.Type[]{}, new object[]{}); + } + + /// + /// stability: Experimental + /// + [JsiiMethod(name: "anyString", returnsJson: "{\"type\":{\"primitive\":\"any\"}}")] + public static object AnyString() + { + return InvokeStaticMethod(typeof(Amazon.JSII.Tests.CalculatorNamespace.JsonFormatter), new System.Type[]{}, new object[]{}); + } + + /// + /// stability: Experimental + /// + [JsiiMethod(name: "anyUndefined", returnsJson: "{\"type\":{\"primitive\":\"any\"}}")] + public static object AnyUndefined() + { + return InvokeStaticMethod(typeof(Amazon.JSII.Tests.CalculatorNamespace.JsonFormatter), new System.Type[]{}, new object[]{}); + } + + /// + /// stability: Experimental + /// + [JsiiMethod(name: "anyZero", returnsJson: "{\"type\":{\"primitive\":\"any\"}}")] + public static object AnyZero() + { + return InvokeStaticMethod(typeof(Amazon.JSII.Tests.CalculatorNamespace.JsonFormatter), new System.Type[]{}, new object[]{}); + } + + /// + /// stability: Experimental + /// + [JsiiMethod(name: "stringify", returnsJson: "{\"optional\":true,\"type\":{\"primitive\":\"string\"}}", parametersJson: "[{\"name\":\"value\",\"optional\":true,\"type\":{\"primitive\":\"any\"}}]")] + public static string Stringify(object @value = null) { return InvokeStaticMethod(typeof(Amazon.JSII.Tests.CalculatorNamespace.JsonFormatter), new System.Type[]{typeof(object)}, new object[]{@value}); } diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/JsonFormatter.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/JsonFormatter.java index e802833537..3c890881b3 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/JsonFormatter.java +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/JsonFormatter.java @@ -20,13 +20,125 @@ protected JsonFormatter(final software.amazon.jsii.JsiiObject.InitializationMode super(initializationMode); } + /** + * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public static java.lang.Object anyArray() { + return software.amazon.jsii.JsiiObject.jsiiStaticCall(software.amazon.jsii.tests.calculator.JsonFormatter.class, "anyArray", java.lang.Object.class); + } + + /** + * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public static java.lang.Object anyBooleanFalse() { + return software.amazon.jsii.JsiiObject.jsiiStaticCall(software.amazon.jsii.tests.calculator.JsonFormatter.class, "anyBooleanFalse", java.lang.Object.class); + } + + /** + * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public static java.lang.Object anyBooleanTrue() { + return software.amazon.jsii.JsiiObject.jsiiStaticCall(software.amazon.jsii.tests.calculator.JsonFormatter.class, "anyBooleanTrue", java.lang.Object.class); + } + + /** + * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public static java.lang.Object anyDate() { + return software.amazon.jsii.JsiiObject.jsiiStaticCall(software.amazon.jsii.tests.calculator.JsonFormatter.class, "anyDate", java.lang.Object.class); + } + + /** + * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public static java.lang.Object anyEmptyString() { + return software.amazon.jsii.JsiiObject.jsiiStaticCall(software.amazon.jsii.tests.calculator.JsonFormatter.class, "anyEmptyString", java.lang.Object.class); + } + + /** + * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public static java.lang.Object anyFunction() { + return software.amazon.jsii.JsiiObject.jsiiStaticCall(software.amazon.jsii.tests.calculator.JsonFormatter.class, "anyFunction", java.lang.Object.class); + } + + /** + * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public static java.lang.Object anyHash() { + return software.amazon.jsii.JsiiObject.jsiiStaticCall(software.amazon.jsii.tests.calculator.JsonFormatter.class, "anyHash", java.lang.Object.class); + } + + /** + * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public static java.lang.Object anyNull() { + return software.amazon.jsii.JsiiObject.jsiiStaticCall(software.amazon.jsii.tests.calculator.JsonFormatter.class, "anyNull", java.lang.Object.class); + } + + /** + * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public static java.lang.Object anyNumber() { + return software.amazon.jsii.JsiiObject.jsiiStaticCall(software.amazon.jsii.tests.calculator.JsonFormatter.class, "anyNumber", java.lang.Object.class); + } + + /** + * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public static java.lang.Object anyRef() { + return software.amazon.jsii.JsiiObject.jsiiStaticCall(software.amazon.jsii.tests.calculator.JsonFormatter.class, "anyRef", java.lang.Object.class); + } + + /** + * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public static java.lang.Object anyString() { + return software.amazon.jsii.JsiiObject.jsiiStaticCall(software.amazon.jsii.tests.calculator.JsonFormatter.class, "anyString", java.lang.Object.class); + } + + /** + * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public static java.lang.Object anyUndefined() { + return software.amazon.jsii.JsiiObject.jsiiStaticCall(software.amazon.jsii.tests.calculator.JsonFormatter.class, "anyUndefined", java.lang.Object.class); + } + + /** + * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public static java.lang.Object anyZero() { + return software.amazon.jsii.JsiiObject.jsiiStaticCall(software.amazon.jsii.tests.calculator.JsonFormatter.class, "anyZero", java.lang.Object.class); + } + /** * EXPERIMENTAL * - * @param value This parameter is required. + * @param value */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public static java.lang.String stringify(final java.lang.Object value) { return software.amazon.jsii.JsiiObject.jsiiStaticCall(software.amazon.jsii.tests.calculator.JsonFormatter.class, "stringify", java.lang.String.class, new Object[] { value }); } + + /** + * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public static java.lang.String stringify() { + return software.amazon.jsii.JsiiObject.jsiiStaticCall(software.amazon.jsii.tests.calculator.JsonFormatter.class, "stringify", java.lang.String.class); + } } diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/__init__.py b/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/__init__.py index 39b7fcf2d0..fdb0f0b17f 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/__init__.py +++ b/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/__init__.py @@ -4958,9 +4958,126 @@ class JsonFormatter(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.JsonFormatter" stability :stability: experimental """ + @jsii.member(jsii_name="anyArray") + @classmethod + def any_array(cls) -> typing.Any: + """ + stability + :stability: experimental + """ + return jsii.sinvoke(cls, "anyArray", []) + + @jsii.member(jsii_name="anyBooleanFalse") + @classmethod + def any_boolean_false(cls) -> typing.Any: + """ + stability + :stability: experimental + """ + return jsii.sinvoke(cls, "anyBooleanFalse", []) + + @jsii.member(jsii_name="anyBooleanTrue") + @classmethod + def any_boolean_true(cls) -> typing.Any: + """ + stability + :stability: experimental + """ + return jsii.sinvoke(cls, "anyBooleanTrue", []) + + @jsii.member(jsii_name="anyDate") + @classmethod + def any_date(cls) -> typing.Any: + """ + stability + :stability: experimental + """ + return jsii.sinvoke(cls, "anyDate", []) + + @jsii.member(jsii_name="anyEmptyString") + @classmethod + def any_empty_string(cls) -> typing.Any: + """ + stability + :stability: experimental + """ + return jsii.sinvoke(cls, "anyEmptyString", []) + + @jsii.member(jsii_name="anyFunction") + @classmethod + def any_function(cls) -> typing.Any: + """ + stability + :stability: experimental + """ + return jsii.sinvoke(cls, "anyFunction", []) + + @jsii.member(jsii_name="anyHash") + @classmethod + def any_hash(cls) -> typing.Any: + """ + stability + :stability: experimental + """ + return jsii.sinvoke(cls, "anyHash", []) + + @jsii.member(jsii_name="anyNull") + @classmethod + def any_null(cls) -> typing.Any: + """ + stability + :stability: experimental + """ + return jsii.sinvoke(cls, "anyNull", []) + + @jsii.member(jsii_name="anyNumber") + @classmethod + def any_number(cls) -> typing.Any: + """ + stability + :stability: experimental + """ + return jsii.sinvoke(cls, "anyNumber", []) + + @jsii.member(jsii_name="anyRef") + @classmethod + def any_ref(cls) -> typing.Any: + """ + stability + :stability: experimental + """ + return jsii.sinvoke(cls, "anyRef", []) + + @jsii.member(jsii_name="anyString") + @classmethod + def any_string(cls) -> typing.Any: + """ + stability + :stability: experimental + """ + return jsii.sinvoke(cls, "anyString", []) + + @jsii.member(jsii_name="anyUndefined") + @classmethod + def any_undefined(cls) -> typing.Any: + """ + stability + :stability: experimental + """ + return jsii.sinvoke(cls, "anyUndefined", []) + + @jsii.member(jsii_name="anyZero") + @classmethod + def any_zero(cls) -> typing.Any: + """ + stability + :stability: experimental + """ + return jsii.sinvoke(cls, "anyZero", []) + @jsii.member(jsii_name="stringify") @classmethod - def stringify(cls, value: typing.Any) -> str: + def stringify(cls, value: typing.Any=None) -> typing.Optional[str]: """ :param value: - diff --git a/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.js.snap b/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.js.snap index 9051fa15d9..e61f71443e 100644 --- a/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.js.snap +++ b/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.js.snap @@ -860,12 +860,51 @@ exports[`jsii-tree --all 1`] = ` │ │ └── type: Optional │ ├─┬ class JsonFormatter (experimental) │ │ └─┬ members + │ │ ├─┬ static anyArray() method (experimental) + │ │ │ ├── static + │ │ │ └── returns: any + │ │ ├─┬ static anyBooleanFalse() method (experimental) + │ │ │ ├── static + │ │ │ └── returns: any + │ │ ├─┬ static anyBooleanTrue() method (experimental) + │ │ │ ├── static + │ │ │ └── returns: any + │ │ ├─┬ static anyDate() method (experimental) + │ │ │ ├── static + │ │ │ └── returns: any + │ │ ├─┬ static anyEmptyString() method (experimental) + │ │ │ ├── static + │ │ │ └── returns: any + │ │ ├─┬ static anyFunction() method (experimental) + │ │ │ ├── static + │ │ │ └── returns: any + │ │ ├─┬ static anyHash() method (experimental) + │ │ │ ├── static + │ │ │ └── returns: any + │ │ ├─┬ static anyNull() method (experimental) + │ │ │ ├── static + │ │ │ └── returns: any + │ │ ├─┬ static anyNumber() method (experimental) + │ │ │ ├── static + │ │ │ └── returns: any + │ │ ├─┬ static anyRef() method (experimental) + │ │ │ ├── static + │ │ │ └── returns: any + │ │ ├─┬ static anyString() method (experimental) + │ │ │ ├── static + │ │ │ └── returns: any + │ │ ├─┬ static anyUndefined() method (experimental) + │ │ │ ├── static + │ │ │ └── returns: any + │ │ ├─┬ static anyZero() method (experimental) + │ │ │ ├── static + │ │ │ └── returns: any │ │ └─┬ static stringify(value) method (experimental) │ │ ├── static │ │ ├─┬ parameters │ │ │ └─┬ value │ │ │ └── type: any - │ │ └── returns: string + │ │ └── returns: Optional │ ├─┬ class Multiply (experimental) │ │ ├── base: BinaryOperation │ │ ├── interfaces: IFriendlier,IRandomNumberGenerator @@ -2928,6 +2967,19 @@ exports[`jsii-tree --members 1`] = ` │ │ └── static jsiiAgent property │ ├─┬ class JsonFormatter │ │ └─┬ members + │ │ ├── static anyArray() method + │ │ ├── static anyBooleanFalse() method + │ │ ├── static anyBooleanTrue() method + │ │ ├── static anyDate() method + │ │ ├── static anyEmptyString() method + │ │ ├── static anyFunction() method + │ │ ├── static anyHash() method + │ │ ├── static anyNull() method + │ │ ├── static anyNumber() method + │ │ ├── static anyRef() method + │ │ ├── static anyString() method + │ │ ├── static anyUndefined() method + │ │ ├── static anyZero() method │ │ └── static stringify(value) method │ ├─┬ class Multiply │ │ └─┬ members From 4bccda0581cbda54309c7e8dd259050a6f8f216f Mon Sep 17 00:00:00 2001 From: Elad Ben-Israel Date: Mon, 18 Nov 2019 16:23:31 +0200 Subject: [PATCH 5/5] fix eslint issues --- packages/jsii-kernel/test/kernel.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/jsii-kernel/test/kernel.test.ts b/packages/jsii-kernel/test/kernel.test.ts index 7cc6266573..dc85f2f8ba 100644 --- a/packages/jsii-kernel/test/kernel.test.ts +++ b/packages/jsii-kernel/test/kernel.test.ts @@ -1231,7 +1231,7 @@ defineTest('ANY deserializer: primitives', sandbox => { }); defineTest('ANY deserializer: array', sandbox => { - expect(deserializeAny(sandbox, [ 1, 2, 3, 'four' ])).toStrictEqual([ 1, 2, 3, 'four' ]); + expect(deserializeAny(sandbox, [1, 2, 3, 'four'])).toStrictEqual([1, 2, 3, 'four']); }); defineTest('ANY deserializer: undefined/null', sandbox => { @@ -1324,7 +1324,7 @@ defineTest('ANY serializer: ref', sandbox => { '$jsii.byref': '@scope/jsii-calc-lib.Number@10000', '$jsii.interfaces': undefined }); -}) +}); // ================================================================================================= @@ -1466,7 +1466,7 @@ function get(kernel: Kernel, objref: ObjRef) { * stringified version that the JavaScript code saw. */ function deserializeAny(sandbox: Kernel, input: any) { - const ret = sandbox.sinvoke({ fqn: 'jsii-calc.JsonFormatter', method: 'stringify', args: [ input ] }); + const ret = sandbox.sinvoke({ fqn: 'jsii-calc.JsonFormatter', method: 'stringify', args: [input] }); if (ret.result === undefined) { return undefined; } const json = JSON.parse(ret.result); return json;