From dfdddd6db86a15652e2b94d884bcb1c5f616d7f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=91=A8=F0=9F=8F=BC=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier-Muller?= Date: Mon, 1 Jul 2019 11:47:23 +0200 Subject: [PATCH] fix(.net): occasional incorrect param type cast When structures (as literal JSON blocks) get passed through a "map" argument, a `JObject` would be passed to the method despite the declared type on the .NET code is `IDictionary`, resulting in a crash. This code forcefully converts `JObject` to `IDictionary` in such code paths. Fixes awslabs/aws-cdk#3093 --- packages/jsii-calc/lib/compliance.ts | 15 ++++ packages/jsii-calc/test/assembly.jsii | 75 ++++++++++++++++++- .../ComplianceTests.cs | 16 ++++ .../Amazon.JSII.Runtime.sln | 17 +++++ .../Amazon.JSII.Runtime/CallbackExtensions.cs | 14 +++- .../.jsii | 75 ++++++++++++++++++- .../Tests/CalculatorNamespace/DataRenderer.cs | 39 ++++++++++ .../amazon/jsii/tests/calculator/$Module.java | 1 + .../jsii/tests/calculator/DataRenderer.java | 47 ++++++++++++ .../python/src/jsii_calc/__init__.py | 46 +++++++++++- .../expected.jsii-calc/sphinx/jsii-calc.rst | 46 ++++++++++++ .../jsii-reflect/test/classes.expected.txt | 1 + .../test/jsii-tree.test.all.expected.txt | 13 ++++ .../jsii-tree.test.inheritance.expected.txt | 1 + .../test/jsii-tree.test.members.expected.txt | 5 ++ .../test/jsii-tree.test.types.expected.txt | 1 + 16 files changed, 408 insertions(+), 4 deletions(-) create mode 100644 packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Amazon.JSII.Runtime.sln create mode 100644 packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/DataRenderer.cs create mode 100644 packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/DataRenderer.java diff --git a/packages/jsii-calc/lib/compliance.ts b/packages/jsii-calc/lib/compliance.ts index cff955bd89..b67894ffc6 100644 --- a/packages/jsii-calc/lib/compliance.ts +++ b/packages/jsii-calc/lib/compliance.ts @@ -1726,3 +1726,18 @@ export enum SingletonIntEnum { /** Elite! */ SINGLETON_INT = 1337 } + +/** + * Verifies proper type handling through dynamic overrides. + */ +export class DataRenderer { + constructor() { } + + public render(data: MyFirstStruct = { anumber: 42, astring: 'bazinga!' }): string { + return this.renderMap(data); + } + + public renderMap(map: { [key: string]: any }): string { + return JSON.stringify(map, null, 2); + } +} diff --git a/packages/jsii-calc/test/assembly.jsii b/packages/jsii-calc/test/assembly.jsii index aa98ac65aa..1445291e8d 100644 --- a/packages/jsii-calc/test/assembly.jsii +++ b/packages/jsii-calc/test/assembly.jsii @@ -2082,6 +2082,79 @@ ], "name": "ConsumersOfThisCrazyTypeSystem" }, + "jsii-calc.DataRenderer": { + "assembly": "jsii-calc", + "docs": { + "stability": "experimental", + "summary": "Verifies proper type handling through dynamic overrides." + }, + "fqn": "jsii-calc.DataRenderer", + "initializer": { + "docs": { + "stability": "experimental" + } + }, + "kind": "class", + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 1733 + }, + "methods": [ + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 1736 + }, + "name": "render", + "parameters": [ + { + "name": "data", + "optional": true, + "type": { + "fqn": "@scope/jsii-calc-lib.MyFirstStruct" + } + } + ], + "returns": { + "type": { + "primitive": "string" + } + } + }, + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 1740 + }, + "name": "renderMap", + "parameters": [ + { + "name": "map", + "type": { + "collection": { + "elementtype": { + "primitive": "any" + }, + "kind": "map" + } + } + } + ], + "returns": { + "type": { + "primitive": "string" + } + } + } + ], + "name": "DataRenderer" + }, "jsii-calc.DefaultedConstructorArgument": { "assembly": "jsii-calc", "docs": { @@ -8778,5 +8851,5 @@ } }, "version": "0.13.2", - "fingerprint": "IzBpmwowWT7JOt7LEK9v3wIGmNWcpmqf9O1C927cs8o=" + "fingerprint": "iCTmGcYc3DTgEt3Y8PBPaiJNOI7O9tRRGI49RI6rAwk=" } 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 2e4b1e3b5b..6ba171f560 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 @@ -915,6 +915,22 @@ public void CorrectlyReturnsFromVoidCallback() Assert.True(voidCallback.MethodWasCalled); } + [Fact(DisplayName = Prefix + nameof(CallbacksCorrectlyDeserializeArguments))] + public void CallbacksCorrectlyDeserializeArguments() + { + var obj = new DataRendererSubclass(); + Assert.Equal("{\n \"anumber\": 42,\n \"astring\": \"bazinga!\"\n}", obj.Render(null)); + } + + class DataRendererSubclass : DataRenderer + { + [JsiiMethod("renderMap", returnsJson: "{\"type\":{\"primitive\":\"string\"}}", parametersJson: "[{\"name\":\"map\",\"type\":{\"collection\":{\"kind\":\"map\",\"elementtype\":{\"primitive\":\"any\"}}}}]", isOverride: true)] + public override string RenderMap(IDictionary map) + { + return base.RenderMap(map); + } + } + class VoidCallbackImpl : VoidCallback { protected override void OverrideMe() diff --git a/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Amazon.JSII.Runtime.sln b/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Amazon.JSII.Runtime.sln new file mode 100644 index 0000000000..a9b693836d --- /dev/null +++ b/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Amazon.JSII.Runtime.sln @@ -0,0 +1,17 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Amazon.JSII.Runtime", "Amazon.JSII.Runtime.csproj", "{A31525BC-0422-446E-B7DE-92769D96302B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A31525BC-0422-446E-B7DE-92769D96302B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A31525BC-0422-446E-B7DE-92769D96302B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A31525BC-0422-446E-B7DE-92769D96302B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A31525BC-0422-446E-B7DE-92769D96302B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/CallbackExtensions.cs b/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/CallbackExtensions.cs index 5ad922d2e1..c162c8d6b8 100644 --- a/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/CallbackExtensions.cs +++ b/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/CallbackExtensions.cs @@ -6,6 +6,7 @@ using Amazon.JSII.Runtime.Services.Converters; using Newtonsoft.Json.Linq; using System; +using System.Collections.Generic; using System.Linq; using System.Reflection; @@ -136,6 +137,17 @@ private static object FromKernel(object obj, IReferenceMap referenceMap) { return referenceMap.GetOrCreateNativeReference(new ByRefValue(prop.Value.Value())); } + + var dict = ((JObject)obj).ToObject>(); + foreach (var key in dict.Keys) + { + var value = dict[key]; + if (value != null && value.GetType() == typeof(JObject)) + { + dict[key] = FromKernel(value, referenceMap); + } + } + return dict; } return obj; } @@ -145,7 +157,7 @@ internal class CallbackResult : OptionalValue { public CallbackResult(IOptionalValue optionalValue, object value) : this(optionalValue?.Type, optionalValue?.IsOptional ?? false, value) {} - + private CallbackResult(TypeReference type, bool isOptional, object value): base(type, isOptional) { Value = value; 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 aa98ac65aa..1445291e8d 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 @@ -2082,6 +2082,79 @@ ], "name": "ConsumersOfThisCrazyTypeSystem" }, + "jsii-calc.DataRenderer": { + "assembly": "jsii-calc", + "docs": { + "stability": "experimental", + "summary": "Verifies proper type handling through dynamic overrides." + }, + "fqn": "jsii-calc.DataRenderer", + "initializer": { + "docs": { + "stability": "experimental" + } + }, + "kind": "class", + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 1733 + }, + "methods": [ + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 1736 + }, + "name": "render", + "parameters": [ + { + "name": "data", + "optional": true, + "type": { + "fqn": "@scope/jsii-calc-lib.MyFirstStruct" + } + } + ], + "returns": { + "type": { + "primitive": "string" + } + } + }, + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 1740 + }, + "name": "renderMap", + "parameters": [ + { + "name": "map", + "type": { + "collection": { + "elementtype": { + "primitive": "any" + }, + "kind": "map" + } + } + } + ], + "returns": { + "type": { + "primitive": "string" + } + } + } + ], + "name": "DataRenderer" + }, "jsii-calc.DefaultedConstructorArgument": { "assembly": "jsii-calc", "docs": { @@ -8778,5 +8851,5 @@ } }, "version": "0.13.2", - "fingerprint": "IzBpmwowWT7JOt7LEK9v3wIGmNWcpmqf9O1C927cs8o=" + "fingerprint": "iCTmGcYc3DTgEt3Y8PBPaiJNOI7O9tRRGI49RI6rAwk=" } diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/DataRenderer.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/DataRenderer.cs new file mode 100644 index 0000000000..e13d31d9e9 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/DataRenderer.cs @@ -0,0 +1,39 @@ +using Amazon.JSII.Runtime.Deputy; +using Amazon.JSII.Tests.CalculatorNamespace.LibNamespace; +using System.Collections.Generic; + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + /// Verifies proper type handling through dynamic overrides. + /// stability: Experimental + [JsiiClass(nativeType: typeof(DataRenderer), fullyQualifiedName: "jsii-calc.DataRenderer")] + public class DataRenderer : DeputyBase + { + /// stability: Experimental + public DataRenderer(): base(new DeputyProps(new object[]{})) + { + } + + protected DataRenderer(ByRefValue reference): base(reference) + { + } + + protected DataRenderer(DeputyProps props): base(props) + { + } + + /// stability: Experimental + [JsiiMethod(name: "render", returnsJson: "{\"type\":{\"primitive\":\"string\"}}", parametersJson: "[{\"name\":\"data\",\"type\":{\"fqn\":\"@scope/jsii-calc-lib.MyFirstStruct\"},\"optional\":true}]")] + public virtual string Render(IMyFirstStruct data) + { + return InvokeInstanceMethod(new object[]{data}); + } + + /// stability: Experimental + [JsiiMethod(name: "renderMap", returnsJson: "{\"type\":{\"primitive\":\"string\"}}", parametersJson: "[{\"name\":\"map\",\"type\":{\"collection\":{\"kind\":\"map\",\"elementtype\":{\"primitive\":\"any\"}}}}]")] + public virtual string RenderMap(IDictionary map) + { + return InvokeInstanceMethod(new object[]{map}); + } + } +} \ No newline at end of file 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 db3803cc14..66e2ff3e73 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 @@ -38,6 +38,7 @@ protected Class resolveClass(final String fqn) throws ClassNotFoundException case "jsii-calc.ConstructorPassesThisOut": return software.amazon.jsii.tests.calculator.ConstructorPassesThisOut.class; case "jsii-calc.Constructors": return software.amazon.jsii.tests.calculator.Constructors.class; case "jsii-calc.ConsumersOfThisCrazyTypeSystem": return software.amazon.jsii.tests.calculator.ConsumersOfThisCrazyTypeSystem.class; + case "jsii-calc.DataRenderer": return software.amazon.jsii.tests.calculator.DataRenderer.class; case "jsii-calc.DefaultedConstructorArgument": return software.amazon.jsii.tests.calculator.DefaultedConstructorArgument.class; case "jsii-calc.DeprecatedClass": return software.amazon.jsii.tests.calculator.DeprecatedClass.class; case "jsii-calc.DeprecatedEnum": return software.amazon.jsii.tests.calculator.DeprecatedEnum.class; diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/DataRenderer.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/DataRenderer.java new file mode 100644 index 0000000000..fa32f1b056 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/DataRenderer.java @@ -0,0 +1,47 @@ +package software.amazon.jsii.tests.calculator; + +/** + * Verifies proper type handling through dynamic overrides. + * + * EXPERIMENTAL + */ +@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.DataRenderer") +public class DataRenderer extends software.amazon.jsii.JsiiObject { + protected DataRenderer(final software.amazon.jsii.JsiiObject.InitializationMode mode) { + super(mode); + } + /** + * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public DataRenderer() { + super(software.amazon.jsii.JsiiObject.InitializationMode.Jsii); + software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this); + } + + /** + * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public java.lang.String render(@javax.annotation.Nullable final software.amazon.jsii.tests.calculator.lib.MyFirstStruct data) { + return this.jsiiCall("render", java.lang.String.class, new Object[] { data }); + } + + /** + * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public java.lang.String render() { + return this.jsiiCall("render", java.lang.String.class); + } + + /** + * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public java.lang.String renderMap(final java.util.Map map) { + return this.jsiiCall("renderMap", java.lang.String.class, new Object[] { java.util.Objects.requireNonNull(map, "map is required") }); + } +} 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 4ed7560f7d..875de6342b 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 @@ -813,6 +813,50 @@ def consume_non_internal_interface(self, obj: "INonInternalInterface") -> typing return jsii.invoke(self, "consumeNonInternalInterface", [obj]) +class DataRenderer(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.DataRenderer"): + """Verifies proper type handling through dynamic overrides. + + Stability: + experimental + """ + def __init__(self) -> None: + """ + Stability: + experimental + """ + jsii.create(DataRenderer, self, []) + + @jsii.member(jsii_name="render") + def render(self, *, anumber: jsii.Number, astring: str, first_optional: typing.Optional[typing.List[str]]=None) -> str: + """ + Arguments: + data: - + anumber: An awesome number value. + astring: A string value. + first_optional: + + Stability: + experimental + """ + data: scope.jsii_calc_lib.MyFirstStruct = {"anumber": anumber, "astring": astring} + + if first_optional is not None: + data["firstOptional"] = first_optional + + return jsii.invoke(self, "render", [data]) + + @jsii.member(jsii_name="renderMap") + def render_map(self, map: typing.Mapping[str,typing.Any]) -> str: + """ + Arguments: + map: - + + Stability: + experimental + """ + return jsii.invoke(self, "renderMap", [map]) + + class DefaultedConstructorArgument(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.DefaultedConstructorArgument"): """ Stability: @@ -5981,6 +6025,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", "AsyncVirtualMethods", "AugmentableClass", "BinaryOperation", "Calculator", "CalculatorProps", "ClassThatImplementsTheInternalInterface", "ClassThatImplementsThePrivateInterface", "ClassWithDocs", "ClassWithMutableObjectLiteralProperty", "ClassWithPrivateConstructorAndAutomaticProperties", "ConstructorPassesThisOut", "Constructors", "ConsumersOfThisCrazyTypeSystem", "DefaultedConstructorArgument", "DeprecatedClass", "DeprecatedEnum", "DeprecatedStruct", "DerivedClassHasNoProperties", "DerivedStruct", "DoNotOverridePrivates", "DoNotRecognizeAnyAsOptional", "DocumentedClass", "DontComplainAboutVariadicAfterOptional", "DoubleTrouble", "EraseUndefinedHashValues", "EraseUndefinedHashValuesOptions", "ExperimentalClass", "ExperimentalEnum", "ExperimentalStruct", "ExportedBaseClass", "ExtendsInternalInterface", "GiveMeStructs", "Greetee", "GreetingAugmenter", "IAnotherPublicInterface", "IDeprecatedInterface", "IExperimentalInterface", "IExtendsPrivateInterface", "IFriendlier", "IFriendlyRandomGenerator", "IInterfaceImplementedByAbstractClass", "IInterfaceThatShouldNotBeADataType", "IInterfaceWithInternal", "IInterfaceWithMethods", "IInterfaceWithOptionalMethodArguments", "IInterfaceWithProperties", "IInterfaceWithPropertiesExtension", "IJSII417Derived", "IJSII417PublicBaseOfBase", "IJsii487External", "IJsii487External2", "IJsii496", "IMutableObjectLiteral", "INonInternalInterface", "IPrivatelyImplemented", "IPublicInterface", "IPublicInterface2", "IRandomNumberGenerator", "IReturnsNumber", "IStableInterface", "ImplementInternalInterface", "ImplementsInterfaceWithInternal", "ImplementsInterfaceWithInternalSubclass", "ImplementsPrivateInterface", "ImplictBaseOfBase", "InbetweenClass", "InterfaceInNamespaceIncludesClasses", "InterfaceInNamespaceOnlyInterface", "JSII417Derived", "JSII417PublicBaseOfBase", "JSObjectLiteralForInterface", "JSObjectLiteralToNative", "JSObjectLiteralToNativeClass", "JavaReservedWords", "Jsii487Derived", "Jsii496Derived", "JsiiAgent", "LoadBalancedFargateServiceProps", "Multiply", "Negate", "NodeStandardLibrary", "NullShouldBeTreatedAsUndefined", "NullShouldBeTreatedAsUndefinedData", "NumberGenerator", "ObjectRefsInCollections", "Old", "OptionalConstructorArgument", "OptionalStruct", "OptionalStructConsumer", "OverrideReturnsObject", "PartiallyInitializedThisConsumer", "Polymorphism", "Power", "PublicClass", "PythonReservedWords", "ReferenceEnumFromScopedPackage", "ReturnsPrivateImplementationOfInterface", "RuntimeTypeChecking", "SingleInstanceTwoTypes", "SingletonInt", "SingletonIntEnum", "SingletonString", "SingletonStringEnum", "StableClass", "StableEnum", "StableStruct", "StaticContext", "Statics", "StringEnum", "StripInternal", "Sum", "SyncVirtualMethods", "Thrower", "UnaryOperation", "UnionProperties", "UseBundledDependency", "UseCalcBase", "UsesInterfaceWithProperties", "VariadicMethod", "VirtualMethodPlayground", "VoidCallback", "WithPrivatePropertyInConstructor", "__jsii_assembly__", "composition"] +__all__ = ["AbstractClass", "AbstractClassBase", "AbstractClassReturner", "Add", "AllTypes", "AllTypesEnum", "AllowedMethodNames", "AsyncVirtualMethods", "AugmentableClass", "BinaryOperation", "Calculator", "CalculatorProps", "ClassThatImplementsTheInternalInterface", "ClassThatImplementsThePrivateInterface", "ClassWithDocs", "ClassWithMutableObjectLiteralProperty", "ClassWithPrivateConstructorAndAutomaticProperties", "ConstructorPassesThisOut", "Constructors", "ConsumersOfThisCrazyTypeSystem", "DataRenderer", "DefaultedConstructorArgument", "DeprecatedClass", "DeprecatedEnum", "DeprecatedStruct", "DerivedClassHasNoProperties", "DerivedStruct", "DoNotOverridePrivates", "DoNotRecognizeAnyAsOptional", "DocumentedClass", "DontComplainAboutVariadicAfterOptional", "DoubleTrouble", "EraseUndefinedHashValues", "EraseUndefinedHashValuesOptions", "ExperimentalClass", "ExperimentalEnum", "ExperimentalStruct", "ExportedBaseClass", "ExtendsInternalInterface", "GiveMeStructs", "Greetee", "GreetingAugmenter", "IAnotherPublicInterface", "IDeprecatedInterface", "IExperimentalInterface", "IExtendsPrivateInterface", "IFriendlier", "IFriendlyRandomGenerator", "IInterfaceImplementedByAbstractClass", "IInterfaceThatShouldNotBeADataType", "IInterfaceWithInternal", "IInterfaceWithMethods", "IInterfaceWithOptionalMethodArguments", "IInterfaceWithProperties", "IInterfaceWithPropertiesExtension", "IJSII417Derived", "IJSII417PublicBaseOfBase", "IJsii487External", "IJsii487External2", "IJsii496", "IMutableObjectLiteral", "INonInternalInterface", "IPrivatelyImplemented", "IPublicInterface", "IPublicInterface2", "IRandomNumberGenerator", "IReturnsNumber", "IStableInterface", "ImplementInternalInterface", "ImplementsInterfaceWithInternal", "ImplementsInterfaceWithInternalSubclass", "ImplementsPrivateInterface", "ImplictBaseOfBase", "InbetweenClass", "InterfaceInNamespaceIncludesClasses", "InterfaceInNamespaceOnlyInterface", "JSII417Derived", "JSII417PublicBaseOfBase", "JSObjectLiteralForInterface", "JSObjectLiteralToNative", "JSObjectLiteralToNativeClass", "JavaReservedWords", "Jsii487Derived", "Jsii496Derived", "JsiiAgent", "LoadBalancedFargateServiceProps", "Multiply", "Negate", "NodeStandardLibrary", "NullShouldBeTreatedAsUndefined", "NullShouldBeTreatedAsUndefinedData", "NumberGenerator", "ObjectRefsInCollections", "Old", "OptionalConstructorArgument", "OptionalStruct", "OptionalStructConsumer", "OverrideReturnsObject", "PartiallyInitializedThisConsumer", "Polymorphism", "Power", "PublicClass", "PythonReservedWords", "ReferenceEnumFromScopedPackage", "ReturnsPrivateImplementationOfInterface", "RuntimeTypeChecking", "SingleInstanceTwoTypes", "SingletonInt", "SingletonIntEnum", "SingletonString", "SingletonStringEnum", "StableClass", "StableEnum", "StableStruct", "StaticContext", "Statics", "StringEnum", "StripInternal", "Sum", "SyncVirtualMethods", "Thrower", "UnaryOperation", "UnionProperties", "UseBundledDependency", "UseCalcBase", "UsesInterfaceWithProperties", "VariadicMethod", "VirtualMethodPlayground", "VoidCallback", "WithPrivatePropertyInConstructor", "__jsii_assembly__", "composition"] publication.publish() diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/sphinx/jsii-calc.rst b/packages/jsii-pacmak/test/expected.jsii-calc/sphinx/jsii-calc.rst index 3ee428418f..a69b98ddcd 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/sphinx/jsii-calc.rst +++ b/packages/jsii-pacmak/test/expected.jsii-calc/sphinx/jsii-calc.rst @@ -1440,6 +1440,52 @@ ConsumersOfThisCrazyTypeSystem :rtype: any +DataRenderer +^^^^^^^^^^^^ + +.. py:class:: DataRenderer() + + **Language-specific names:** + + .. tabs:: + + .. code-tab:: c# + + using Amazon.JSII.Tests.CalculatorNamespace; + + .. code-tab:: java + + import software.amazon.jsii.tests.calculator.DataRenderer; + + .. code-tab:: javascript + + const { DataRenderer } = require('jsii-calc'); + + .. code-tab:: typescript + + import { DataRenderer } from 'jsii-calc'; + + + + Verifies proper type handling through dynamic overrides. + + + + + .. py:method:: render([data]) -> string + + :param data: + :type data: :py:class:`@scope/jsii-calc-lib.MyFirstStruct`\ + :rtype: string + + + .. py:method:: renderMap(map) -> string + + :param map: + :type map: string => any + :rtype: string + + DefaultedConstructorArgument ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/packages/jsii-reflect/test/classes.expected.txt b/packages/jsii-reflect/test/classes.expected.txt index 824626299b..2dce67b20a 100644 --- a/packages/jsii-reflect/test/classes.expected.txt +++ b/packages/jsii-reflect/test/classes.expected.txt @@ -19,6 +19,7 @@ CompositeOperation ConstructorPassesThisOut Constructors ConsumersOfThisCrazyTypeSystem +DataRenderer DefaultedConstructorArgument DeprecatedClass Derived diff --git a/packages/jsii-reflect/test/jsii-tree.test.all.expected.txt b/packages/jsii-reflect/test/jsii-tree.test.all.expected.txt index 5cd76b3f67..0ff8d94ccc 100644 --- a/packages/jsii-reflect/test/jsii-tree.test.all.expected.txt +++ b/packages/jsii-reflect/test/jsii-tree.test.all.expected.txt @@ -312,6 +312,19 @@ assemblies │ │ │ └─┬ obj │ │ │ └── type: jsii-calc.INonInternalInterface │ │ └── returns: any + │ ├─┬ class DataRenderer + │ │ └─┬ members + │ │ ├── () initializer + │ │ ├─┬ render(data) method + │ │ │ ├─┬ parameters + │ │ │ │ └─┬ data + │ │ │ │ └── type: Optional<@scope/jsii-calc-lib.MyFirstStruct> + │ │ │ └── returns: string + │ │ └─┬ renderMap(map) method + │ │ ├─┬ parameters + │ │ │ └─┬ map + │ │ │ └── type: Map any> + │ │ └── returns: string │ ├─┬ class DefaultedConstructorArgument │ │ └─┬ members │ │ ├─┬ (arg1,arg2,arg3) initializer diff --git a/packages/jsii-reflect/test/jsii-tree.test.inheritance.expected.txt b/packages/jsii-reflect/test/jsii-tree.test.inheritance.expected.txt index 65419eb49b..5d1a34fa03 100644 --- a/packages/jsii-reflect/test/jsii-tree.test.inheritance.expected.txt +++ b/packages/jsii-reflect/test/jsii-tree.test.inheritance.expected.txt @@ -28,6 +28,7 @@ assemblies │ ├── class ConstructorPassesThisOut │ ├── class Constructors │ ├── class ConsumersOfThisCrazyTypeSystem + │ ├── class DataRenderer │ ├── class DefaultedConstructorArgument │ ├── class DeprecatedClass │ ├── class Base diff --git a/packages/jsii-reflect/test/jsii-tree.test.members.expected.txt b/packages/jsii-reflect/test/jsii-tree.test.members.expected.txt index befa545763..651a1beba9 100644 --- a/packages/jsii-reflect/test/jsii-tree.test.members.expected.txt +++ b/packages/jsii-reflect/test/jsii-tree.test.members.expected.txt @@ -132,6 +132,11 @@ assemblies │ │ ├── () initializer │ │ ├── consumeAnotherPublicInterface(obj) method │ │ └── consumeNonInternalInterface(obj) method + │ ├─┬ class DataRenderer + │ │ └─┬ members + │ │ ├── () initializer + │ │ ├── render(data) method + │ │ └── renderMap(map) method │ ├─┬ class DefaultedConstructorArgument │ │ └─┬ members │ │ ├── (arg1,arg2,arg3) initializer diff --git a/packages/jsii-reflect/test/jsii-tree.test.types.expected.txt b/packages/jsii-reflect/test/jsii-tree.test.types.expected.txt index 405d82278c..0c11d1dce0 100644 --- a/packages/jsii-reflect/test/jsii-tree.test.types.expected.txt +++ b/packages/jsii-reflect/test/jsii-tree.test.types.expected.txt @@ -19,6 +19,7 @@ assemblies │ ├── class ConstructorPassesThisOut │ ├── class Constructors │ ├── class ConsumersOfThisCrazyTypeSystem + │ ├── class DataRenderer │ ├── class DefaultedConstructorArgument │ ├── class DeprecatedClass │ ├── class Base