From 9f9b015adb8953847644796e8ed7b07a607c1184 Mon Sep 17 00:00:00 2001 From: Elad Ben-Israel Date: Wed, 7 Nov 2018 13:42:23 +0200 Subject: [PATCH 1/3] fix(jsii): do not mark "any" or "unknown" as optional (unless "?") We accidentally marked every "any" and "unknown" types as optional, regardless if the declaration had a question mark or not. Fixes #284 --- packages/jsii-calc-base/test/assembly.jsii | 3 +- packages/jsii-calc/lib/compliance.ts | 9 ++ packages/jsii-calc/test/assembly.jsii | 62 ++++++++++---- .../jsii-java-runtime-test/project/.gitignore | 2 + packages/jsii-java-runtime/project/.gitignore | 2 + packages/jsii-pacmak/test/.gitignore | 2 + .../.jsii | 3 +- .../CalculatorNamespace/BaseNamespace/Base.cs | 2 +- .../jsii/tests/calculator/base/Base.java | 1 - .../sphinx/_scope_jsii-calc-base.rst | 2 +- .../sphinx/_scope_jsii-calc-lib.rst | 6 +- .../.jsii | 62 ++++++++++---- .../Tests/CalculatorNamespace/AllTypes.cs | 26 +++--- .../DoNotRecognizeAnyAsOptional.cs | 27 ++++++ .../UseBundledDependency.cs | 2 +- .../amazon/jsii/tests/calculator/$Module.java | 1 + .../jsii/tests/calculator/AllTypes.java | 26 +++--- .../DoNotRecognizeAnyAsOptional.java | 28 +++++++ .../calculator/UseBundledDependency.java | 1 - .../expected.jsii-calc/sphinx/jsii-calc.rst | 83 ++++++++++++++----- packages/jsii/lib/assembler.ts | 4 +- 21 files changed, 262 insertions(+), 92 deletions(-) create mode 100644 packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/DoNotRecognizeAnyAsOptional.cs create mode 100644 packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/DoNotRecognizeAnyAsOptional.java diff --git a/packages/jsii-calc-base/test/assembly.jsii b/packages/jsii-calc-base/test/assembly.jsii index d9b4a575a4..c8e66971d3 100644 --- a/packages/jsii-calc-base/test/assembly.jsii +++ b/packages/jsii-calc-base/test/assembly.jsii @@ -73,7 +73,6 @@ }, "name": "typeName", "returns": { - "optional": true, "primitive": "any" } } @@ -103,5 +102,5 @@ } }, "version": "0.7.8", - "fingerprint": "K1rAUs6WiQ5lF08T46B8v/5UL8T8Ot59e0Nc8rh2jiQ=" + "fingerprint": "FbKHAP60R40tOOnvhCeDrZDrNlgzIypOfAdWPed+Jog=" } diff --git a/packages/jsii-calc/lib/compliance.ts b/packages/jsii-calc/lib/compliance.ts index 783a5a94cf..a0989493cc 100644 --- a/packages/jsii-calc/lib/compliance.ts +++ b/packages/jsii-calc/lib/compliance.ts @@ -939,3 +939,12 @@ export interface IInterfaceWithMethods { export interface IInterfaceThatShouldNotBeADataType extends IInterfaceWithMethods { readonly otherValue: string; } + +/** + * jsii#284: do not recognize "any" as an optional argument + */ +export class DoNotRecognizeAnyAsOptional { + public method(_requiredAny: any, _optionalAny?: any, _optionalString?: string) { + + } +} diff --git a/packages/jsii-calc/test/assembly.jsii b/packages/jsii-calc/test/assembly.jsii index 97e7a8e8a5..d245fa15e5 100644 --- a/packages/jsii-calc/test/assembly.jsii +++ b/packages/jsii-calc/test/assembly.jsii @@ -382,7 +382,6 @@ "type": { "collection": { "elementtype": { - "optional": true, "primitive": "any" }, "kind": "array" @@ -394,13 +393,18 @@ "type": { "collection": { "elementtype": { - "optional": true, "primitive": "any" }, "kind": "map" } } }, + { + "name": "anyProperty", + "type": { + "primitive": "any" + } + }, { "name": "arrayProperty", "type": { @@ -528,7 +532,6 @@ "type": { "collection": { "elementtype": { - "optional": true, "primitive": "any" }, "kind": "array" @@ -540,7 +543,6 @@ "type": { "collection": { "elementtype": { - "optional": true, "primitive": "any" }, "kind": "map" @@ -548,9 +550,8 @@ } }, { - "name": "anyProperty", + "name": "unknownProperty", "type": { - "optional": true, "primitive": "any" } }, @@ -560,13 +561,6 @@ "fqn": "jsii-calc.StringEnum", "optional": true } - }, - { - "name": "unknownProperty", - "type": { - "optional": true, - "primitive": "any" - } } ] }, @@ -1301,6 +1295,45 @@ ], "name": "DoNotOverridePrivates" }, + "jsii-calc.DoNotRecognizeAnyAsOptional": { + "assembly": "jsii-calc", + "docs": { + "comment": "jsii#284: do not recognize \"any\" as an optional argument" + }, + "fqn": "jsii-calc.DoNotRecognizeAnyAsOptional", + "initializer": { + "initializer": true + }, + "kind": "class", + "methods": [ + { + "name": "method", + "parameters": [ + { + "name": "_requiredAny", + "type": { + "primitive": "any" + } + }, + { + "name": "_optionalAny", + "type": { + "optional": true, + "primitive": "any" + } + }, + { + "name": "_optionalString", + "type": { + "optional": true, + "primitive": "string" + } + } + ] + } + ], + "name": "DoNotRecognizeAnyAsOptional" + }, "jsii-calc.DoubleTrouble": { "assembly": "jsii-calc", "fqn": "jsii-calc.DoubleTrouble", @@ -3062,7 +3095,6 @@ { "name": "value", "returns": { - "optional": true, "primitive": "any" } } @@ -3412,5 +3444,5 @@ } }, "version": "0.7.8", - "fingerprint": "Xn7Rk17rqR3AaMx3+ssxT0GR1sCWwz0OGC+C8QuLI3A=" + "fingerprint": "2BaszImarh4WChl9DFUcygfTpEfXU17fHQT2wgEptfM=" } diff --git a/packages/jsii-java-runtime-test/project/.gitignore b/packages/jsii-java-runtime-test/project/.gitignore index 58d35b13a4..46aa9ff1a5 100644 --- a/packages/jsii-java-runtime-test/project/.gitignore +++ b/packages/jsii-java-runtime-test/project/.gitignore @@ -1,3 +1,5 @@ +bin/ + !index.js .idea pom.xml diff --git a/packages/jsii-java-runtime/project/.gitignore b/packages/jsii-java-runtime/project/.gitignore index d0b519a66f..a6e9c72336 100644 --- a/packages/jsii-java-runtime/project/.gitignore +++ b/packages/jsii-java-runtime/project/.gitignore @@ -1,3 +1,5 @@ +bin/ + !index.js .idea pom.xml diff --git a/packages/jsii-pacmak/test/.gitignore b/packages/jsii-pacmak/test/.gitignore index 013c75f014..ad8d4b09f2 100644 --- a/packages/jsii-pacmak/test/.gitignore +++ b/packages/jsii-pacmak/test/.gitignore @@ -1,2 +1,4 @@ +**/java/bin/ + !*.tgz diff --git a/packages/jsii-pacmak/test/expected.jsii-calc-base/dotnet/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId/.jsii b/packages/jsii-pacmak/test/expected.jsii-calc-base/dotnet/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId/.jsii index d9b4a575a4..c8e66971d3 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc-base/dotnet/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId/.jsii +++ b/packages/jsii-pacmak/test/expected.jsii-calc-base/dotnet/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId/.jsii @@ -73,7 +73,6 @@ }, "name": "typeName", "returns": { - "optional": true, "primitive": "any" } } @@ -103,5 +102,5 @@ } }, "version": "0.7.8", - "fingerprint": "K1rAUs6WiQ5lF08T46B8v/5UL8T8Ot59e0Nc8rh2jiQ=" + "fingerprint": "FbKHAP60R40tOOnvhCeDrZDrNlgzIypOfAdWPed+Jog=" } diff --git a/packages/jsii-pacmak/test/expected.jsii-calc-base/dotnet/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId/Amazon/JSII/Tests/CalculatorNamespace/BaseNamespace/Base.cs b/packages/jsii-pacmak/test/expected.jsii-calc-base/dotnet/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId/Amazon/JSII/Tests/CalculatorNamespace/BaseNamespace/Base.cs index 83224daeac..c38472e6b3 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc-base/dotnet/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId/Amazon/JSII/Tests/CalculatorNamespace/BaseNamespace/Base.cs +++ b/packages/jsii-pacmak/test/expected.jsii-calc-base/dotnet/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId/Amazon/JSII/Tests/CalculatorNamespace/BaseNamespace/Base.cs @@ -19,7 +19,7 @@ protected Base(DeputyProps props): base(props) } /// the name of the class (to verify native type names are created for derived classes). - [JsiiMethod("typeName", "{\"primitive\":\"any\",\"optional\":true}", "[]")] + [JsiiMethod("typeName", "{\"primitive\":\"any\"}", "[]")] public virtual object TypeName() { return InvokeInstanceMethod(new object[]{}); diff --git a/packages/jsii-pacmak/test/expected.jsii-calc-base/java/src/main/java/software/amazon/jsii/tests/calculator/base/Base.java b/packages/jsii-pacmak/test/expected.jsii-calc-base/java/src/main/java/software/amazon/jsii/tests/calculator/base/Base.java index 2b1a3402f8..7a64b8e3d7 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc-base/java/src/main/java/software/amazon/jsii/tests/calculator/base/Base.java +++ b/packages/jsii-pacmak/test/expected.jsii-calc-base/java/src/main/java/software/amazon/jsii/tests/calculator/base/Base.java @@ -13,7 +13,6 @@ protected Base(final software.amazon.jsii.JsiiObject.InitializationMode mode) { /** * @return the name of the class (to verify native type names are created for derived classes). */ - @javax.annotation.Nullable public java.lang.Object typeName() { return this.jsiiCall("typeName", java.lang.Object.class); } diff --git a/packages/jsii-pacmak/test/expected.jsii-calc-base/sphinx/_scope_jsii-calc-base.rst b/packages/jsii-pacmak/test/expected.jsii-calc-base/sphinx/_scope_jsii-calc-base.rst index 006c87fdd1..f7c0678760 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc-base/sphinx/_scope_jsii-calc-base.rst +++ b/packages/jsii-pacmak/test/expected.jsii-calc-base/sphinx/_scope_jsii-calc-base.rst @@ -158,7 +158,7 @@ Base .. py:method:: typeName() -> any :return: the name of the class (to verify native type names are created for derived classes). - :rtype: any or ``undefined`` + :rtype: any BaseProps (interface) diff --git a/packages/jsii-pacmak/test/expected.jsii-calc-lib/sphinx/_scope_jsii-calc-lib.rst b/packages/jsii-pacmak/test/expected.jsii-calc-lib/sphinx/_scope_jsii-calc-lib.rst index 0121d0e144..2e9437ce51 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc-lib/sphinx/_scope_jsii-calc-lib.rst +++ b/packages/jsii-pacmak/test/expected.jsii-calc-lib/sphinx/_scope_jsii-calc-lib.rst @@ -349,7 +349,7 @@ Number *Inherited from* :py:meth:`@scope/jsii-calc-base.Base <@scope/jsii-calc-base.Base.typeName>` :return: the name of the class (to verify native type names are created for derived classes). - :rtype: any or ``undefined`` + :rtype: any .. py:method:: toString() -> string @@ -411,7 +411,7 @@ Operation *Inherited from* :py:meth:`@scope/jsii-calc-base.Base <@scope/jsii-calc-base.Base.typeName>` :return: the name of the class (to verify native type names are created for derived classes). - :rtype: any or ``undefined`` + :rtype: any .. py:attribute:: value @@ -528,6 +528,6 @@ Value *Inherited from* :py:meth:`@scope/jsii-calc-base.Base <@scope/jsii-calc-base.Base.typeName>` :return: the name of the class (to verify native type names are created for derived classes). - :rtype: any or ``undefined`` + :rtype: any 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 97e7a8e8a5..d245fa15e5 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 @@ -382,7 +382,6 @@ "type": { "collection": { "elementtype": { - "optional": true, "primitive": "any" }, "kind": "array" @@ -394,13 +393,18 @@ "type": { "collection": { "elementtype": { - "optional": true, "primitive": "any" }, "kind": "map" } } }, + { + "name": "anyProperty", + "type": { + "primitive": "any" + } + }, { "name": "arrayProperty", "type": { @@ -528,7 +532,6 @@ "type": { "collection": { "elementtype": { - "optional": true, "primitive": "any" }, "kind": "array" @@ -540,7 +543,6 @@ "type": { "collection": { "elementtype": { - "optional": true, "primitive": "any" }, "kind": "map" @@ -548,9 +550,8 @@ } }, { - "name": "anyProperty", + "name": "unknownProperty", "type": { - "optional": true, "primitive": "any" } }, @@ -560,13 +561,6 @@ "fqn": "jsii-calc.StringEnum", "optional": true } - }, - { - "name": "unknownProperty", - "type": { - "optional": true, - "primitive": "any" - } } ] }, @@ -1301,6 +1295,45 @@ ], "name": "DoNotOverridePrivates" }, + "jsii-calc.DoNotRecognizeAnyAsOptional": { + "assembly": "jsii-calc", + "docs": { + "comment": "jsii#284: do not recognize \"any\" as an optional argument" + }, + "fqn": "jsii-calc.DoNotRecognizeAnyAsOptional", + "initializer": { + "initializer": true + }, + "kind": "class", + "methods": [ + { + "name": "method", + "parameters": [ + { + "name": "_requiredAny", + "type": { + "primitive": "any" + } + }, + { + "name": "_optionalAny", + "type": { + "optional": true, + "primitive": "any" + } + }, + { + "name": "_optionalString", + "type": { + "optional": true, + "primitive": "string" + } + } + ] + } + ], + "name": "DoNotRecognizeAnyAsOptional" + }, "jsii-calc.DoubleTrouble": { "assembly": "jsii-calc", "fqn": "jsii-calc.DoubleTrouble", @@ -3062,7 +3095,6 @@ { "name": "value", "returns": { - "optional": true, "primitive": "any" } } @@ -3412,5 +3444,5 @@ } }, "version": "0.7.8", - "fingerprint": "Xn7Rk17rqR3AaMx3+ssxT0GR1sCWwz0OGC+C8QuLI3A=" + "fingerprint": "2BaszImarh4WChl9DFUcygfTpEfXU17fHQT2wgEptfM=" } diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/AllTypes.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/AllTypes.cs index 489e96e84c..2e6f227a3f 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/AllTypes.cs +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/AllTypes.cs @@ -32,20 +32,27 @@ public virtual double EnumPropertyValue get => GetInstanceProperty(); } - [JsiiProperty("anyArrayProperty", "{\"collection\":{\"kind\":\"array\",\"elementtype\":{\"primitive\":\"any\",\"optional\":true}}}")] + [JsiiProperty("anyArrayProperty", "{\"collection\":{\"kind\":\"array\",\"elementtype\":{\"primitive\":\"any\"}}}")] public virtual object[] AnyArrayProperty { get => GetInstanceProperty(); set => SetInstanceProperty(value); } - [JsiiProperty("anyMapProperty", "{\"collection\":{\"kind\":\"map\",\"elementtype\":{\"primitive\":\"any\",\"optional\":true}}}")] + [JsiiProperty("anyMapProperty", "{\"collection\":{\"kind\":\"map\",\"elementtype\":{\"primitive\":\"any\"}}}")] public virtual IDictionary AnyMapProperty { get => GetInstanceProperty>(); set => SetInstanceProperty(value); } + [JsiiProperty("anyProperty", "{\"primitive\":\"any\"}")] + public virtual object AnyProperty + { + get => GetInstanceProperty(); + set => SetInstanceProperty(value); + } + [JsiiProperty("arrayProperty", "{\"collection\":{\"kind\":\"array\",\"elementtype\":{\"primitive\":\"string\"}}}")] public virtual string[] ArrayProperty { @@ -123,22 +130,22 @@ public virtual object UnionProperty set => SetInstanceProperty(value); } - [JsiiProperty("unknownArrayProperty", "{\"collection\":{\"kind\":\"array\",\"elementtype\":{\"primitive\":\"any\",\"optional\":true}}}")] + [JsiiProperty("unknownArrayProperty", "{\"collection\":{\"kind\":\"array\",\"elementtype\":{\"primitive\":\"any\"}}}")] public virtual object[] UnknownArrayProperty { get => GetInstanceProperty(); set => SetInstanceProperty(value); } - [JsiiProperty("unknownMapProperty", "{\"collection\":{\"kind\":\"map\",\"elementtype\":{\"primitive\":\"any\",\"optional\":true}}}")] + [JsiiProperty("unknownMapProperty", "{\"collection\":{\"kind\":\"map\",\"elementtype\":{\"primitive\":\"any\"}}}")] public virtual IDictionary UnknownMapProperty { get => GetInstanceProperty>(); set => SetInstanceProperty(value); } - [JsiiProperty("anyProperty", "{\"primitive\":\"any\",\"optional\":true}")] - public virtual object AnyProperty + [JsiiProperty("unknownProperty", "{\"primitive\":\"any\"}")] + public virtual object UnknownProperty { get => GetInstanceProperty(); set => SetInstanceProperty(value); @@ -151,13 +158,6 @@ public virtual StringEnum OptionalEnumValue set => SetInstanceProperty(value); } - [JsiiProperty("unknownProperty", "{\"primitive\":\"any\",\"optional\":true}")] - public virtual object UnknownProperty - { - get => GetInstanceProperty(); - set => SetInstanceProperty(value); - } - [JsiiMethod("enumMethod", "{\"fqn\":\"jsii-calc.StringEnum\"}", "[{\"name\":\"value\",\"type\":{\"fqn\":\"jsii-calc.StringEnum\"}}]")] public virtual StringEnum EnumMethod(StringEnum value) { diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/DoNotRecognizeAnyAsOptional.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/DoNotRecognizeAnyAsOptional.cs new file mode 100644 index 0000000000..50e99be977 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/DoNotRecognizeAnyAsOptional.cs @@ -0,0 +1,27 @@ +using Amazon.JSII.Runtime.Deputy; + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + /// jsii#284: do not recognize "any" as an optional argument + [JsiiClass(typeof(DoNotRecognizeAnyAsOptional), "jsii-calc.DoNotRecognizeAnyAsOptional", "[]")] + public class DoNotRecognizeAnyAsOptional : DeputyBase + { + public DoNotRecognizeAnyAsOptional(): base(new DeputyProps(new object[]{})) + { + } + + protected DoNotRecognizeAnyAsOptional(ByRefValue reference): base(reference) + { + } + + protected DoNotRecognizeAnyAsOptional(DeputyProps props): base(props) + { + } + + [JsiiMethod("method", null, "[{\"name\":\"_requiredAny\",\"type\":{\"primitive\":\"any\"}},{\"name\":\"_optionalAny\",\"type\":{\"primitive\":\"any\",\"optional\":true}},{\"name\":\"_optionalString\",\"type\":{\"primitive\":\"string\",\"optional\":true}}]")] + public virtual void Method(object _requiredAny, object _optionalAny, string _optionalString) + { + InvokeInstanceVoidMethod(new object[]{_requiredAny, _optionalAny, _optionalString}); + } + } +} \ No newline at end of file diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/UseBundledDependency.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/UseBundledDependency.cs index f438961582..7470df65fe 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/UseBundledDependency.cs +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/UseBundledDependency.cs @@ -17,7 +17,7 @@ protected UseBundledDependency(DeputyProps props): base(props) { } - [JsiiMethod("value", "{\"primitive\":\"any\",\"optional\":true}", "[]")] + [JsiiMethod("value", "{\"primitive\":\"any\"}", "[]")] public virtual object Value() { return InvokeInstanceMethod(new object[]{}); 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 614138338f..946461ede3 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 @@ -36,6 +36,7 @@ protected Class resolveClass(final String fqn) throws ClassNotFoundException case "jsii-calc.DerivedClassHasNoProperties.Derived": return software.amazon.jsii.tests.calculator.DerivedClassHasNoProperties.Derived.class; case "jsii-calc.DerivedStruct": return software.amazon.jsii.tests.calculator.DerivedStruct.class; case "jsii-calc.DoNotOverridePrivates": return software.amazon.jsii.tests.calculator.DoNotOverridePrivates.class; + case "jsii-calc.DoNotRecognizeAnyAsOptional": return software.amazon.jsii.tests.calculator.DoNotRecognizeAnyAsOptional.class; case "jsii-calc.DoubleTrouble": return software.amazon.jsii.tests.calculator.DoubleTrouble.class; case "jsii-calc.GiveMeStructs": return software.amazon.jsii.tests.calculator.GiveMeStructs.class; case "jsii-calc.IFriendlier": return software.amazon.jsii.tests.calculator.IFriendlier.class; diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/AllTypes.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/AllTypes.java index c6e710a699..2b1d0fec93 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/AllTypes.java +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/AllTypes.java @@ -39,6 +39,14 @@ public void setAnyMapProperty(final java.util.Map getArrayProperty() { return this.jsiiGet("arrayProperty", java.util.List.class); } @@ -155,13 +163,12 @@ public void setUnknownMapProperty(final java.util.Map` :return: the name of the class (to verify native type names are created for derived classes). - :rtype: any or ``undefined`` + :rtype: any .. py:method:: hello() -> string @@ -399,12 +399,17 @@ AllTypes .. py:attribute:: anyArrayProperty - :type: (any or ``undefined``)[] + :type: any[] .. py:attribute:: anyMapProperty - :type: string => (any or ``undefined``) + :type: string => any + + + .. py:attribute:: anyProperty + + :type: any .. py:attribute:: arrayProperty @@ -464,17 +469,17 @@ AllTypes .. py:attribute:: unknownArrayProperty - :type: (any or ``undefined``)[] + :type: any[] .. py:attribute:: unknownMapProperty - :type: string => (any or ``undefined``) + :type: string => any - .. py:attribute:: anyProperty + .. py:attribute:: unknownProperty - :type: any or ``undefined`` + :type: any .. py:attribute:: optionalEnumValue @@ -482,11 +487,6 @@ AllTypes :type: :py:class:`~jsii-calc.StringEnum`\ or ``undefined`` - .. py:attribute:: unknownProperty - - :type: any or ``undefined`` - - AllTypesEnum (enum) ^^^^^^^^^^^^^^^^^^^ @@ -723,7 +723,7 @@ BinaryOperation *Inherited from* :py:meth:`@scope/jsii-calc-base.Base <@scope/jsii-calc-base.Base.typeName>` :return: the name of the class (to verify native type names are created for derived classes). - :rtype: any or ``undefined`` + :rtype: any .. py:method:: toString() -> string @@ -878,7 +878,7 @@ Calculator *Inherited from* :py:meth:`@scope/jsii-calc-base.Base <@scope/jsii-calc-base.Base.typeName>` :return: the name of the class (to verify native type names are created for derived classes). - :rtype: any or ``undefined`` + :rtype: any .. py:method:: toString() -> string @@ -1327,6 +1327,47 @@ DoNotOverridePrivates :rtype: string +DoNotRecognizeAnyAsOptional +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. py:class:: DoNotRecognizeAnyAsOptional() + + **Language-specific names:** + + .. tabs:: + + .. code-tab:: c# + + using Amazon.JSII.Tests.CalculatorNamespace; + + .. code-tab:: java + + import software.amazon.jsii.tests.calculator.DoNotRecognizeAnyAsOptional; + + .. code-tab:: javascript + + const { DoNotRecognizeAnyAsOptional } = require('jsii-calc'); + + .. code-tab:: typescript + + import { DoNotRecognizeAnyAsOptional } from 'jsii-calc'; + + + + jsii#284: do not recognize "any" as an optional argument + + + + .. py:method:: method(_requiredAny, [_optionalAny, [_optionalString]]) + + :param _requiredAny: + :type _requiredAny: any + :param _optionalAny: + :type _optionalAny: any or ``undefined`` + :param _optionalString: + :type _optionalString: string or ``undefined`` + + DoubleTrouble ^^^^^^^^^^^^^ @@ -2504,7 +2545,7 @@ Multiply *Inherited from* :py:meth:`@scope/jsii-calc-base.Base <@scope/jsii-calc-base.Base.typeName>` :return: the name of the class (to verify native type names are created for derived classes). - :rtype: any or ``undefined`` + :rtype: any .. py:method:: hello() -> string @@ -2661,7 +2702,7 @@ Negate *Inherited from* :py:meth:`@scope/jsii-calc-base.Base <@scope/jsii-calc-base.Base.typeName>` :return: the name of the class (to verify native type names are created for derived classes). - :rtype: any or ``undefined`` + :rtype: any .. py:attribute:: operand @@ -3024,7 +3065,7 @@ Power *Inherited from* :py:meth:`@scope/jsii-calc-base.Base <@scope/jsii-calc-base.Base.typeName>` :return: the name of the class (to verify native type names are created for derived classes). - :rtype: any or ``undefined`` + :rtype: any .. py:method:: toString() -> string @@ -3362,7 +3403,7 @@ Sum *Inherited from* :py:meth:`@scope/jsii-calc-base.Base <@scope/jsii-calc-base.Base.typeName>` :return: the name of the class (to verify native type names are created for derived classes). - :rtype: any or ``undefined`` + :rtype: any .. py:method:: toString() -> string @@ -3605,7 +3646,7 @@ UnaryOperation *Inherited from* :py:meth:`@scope/jsii-calc-base.Base <@scope/jsii-calc-base.Base.typeName>` :return: the name of the class (to verify native type names are created for derived classes). - :rtype: any or ``undefined`` + :rtype: any .. py:method:: toString() -> string @@ -3698,7 +3739,7 @@ UseBundledDependency .. py:method:: value() -> any - :rtype: any or ``undefined`` + :rtype: any UseCalcBase @@ -4026,7 +4067,7 @@ CompositeOperation *Inherited from* :py:meth:`@scope/jsii-calc-base.Base <@scope/jsii-calc-base.Base.typeName>` :return: the name of the class (to verify native type names are created for derived classes). - :rtype: any or ``undefined`` + :rtype: any diff --git a/packages/jsii/lib/assembler.ts b/packages/jsii/lib/assembler.ts index d9847e6792..30d422d079 100644 --- a/packages/jsii/lib/assembler.ts +++ b/packages/jsii/lib/assembler.ts @@ -812,7 +812,7 @@ export class Assembler implements Emitter { this._diagnostic(declaration, ts.DiagnosticCategory.Error, `Only string index maps are supported`); - elementtype = { primitive: spec.PrimitiveType.Any, optional: true }; + elementtype = { primitive: spec.PrimitiveType.Any }; } return { collection: { @@ -830,7 +830,7 @@ export class Assembler implements Emitter { } // tslint:disable-next-line:no-bitwise if (type.flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown)) { - return { primitive: spec.PrimitiveType.Any, optional: true }; + return { primitive: spec.PrimitiveType.Any }; } } else if (type.symbol.valueDeclaration && isUnder(type.symbol.valueDeclaration.getSourceFile().fileName, this.stdlib)) { switch (type.symbol.name) { From d4f873336249fbfca7ec296d595405bddbcf3c3d Mon Sep 17 00:00:00 2001 From: Elad Ben-Israel Date: Wed, 7 Nov 2018 13:46:57 +0200 Subject: [PATCH 2/3] fix(jsii-runtime): treat "null" as "undefined" Since most languages do not have a distinction between "null" and "undefined", jsii will effectively convert any "null" value passed into an argument, a property or inside an object to "undefined". Adds a compliance test to Java and .NET called "NullShouldBeTreatedAsUndefined". Fixes awslabs/aws-cdk#157 Fixes #282 --- packages/jsii-calc/lib/compliance.ts | 46 ++++++++ packages/jsii-calc/test/assembly.jsii | 94 +++++++++++++++ .../ComplianceTests.cs | 21 ++++ .../amazon/jsii/testing/ComplianceTest.java | 14 +++ packages/jsii-kernel/lib/kernel.ts | 5 +- packages/jsii-kernel/test/test.kernel.ts | 23 ++++ .../.jsii | 94 +++++++++++++++ .../INullShouldBeTreatedAsUndefinedData.cs | 22 ++++ .../NullShouldBeTreatedAsUndefined.cs | 46 ++++++++ .../NullShouldBeTreatedAsUndefinedData.cs | 21 ++++ ...NullShouldBeTreatedAsUndefinedDataProxy.cs | 26 +++++ .../amazon/jsii/tests/calculator/$Module.java | 2 + .../NullShouldBeTreatedAsUndefined.java | 45 ++++++++ .../NullShouldBeTreatedAsUndefinedData.java | 108 ++++++++++++++++++ .../expected.jsii-calc/sphinx/jsii-calc.rst | 95 +++++++++++++++ 15 files changed, 660 insertions(+), 2 deletions(-) create mode 100644 packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/INullShouldBeTreatedAsUndefinedData.cs create mode 100644 packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/NullShouldBeTreatedAsUndefined.cs create mode 100644 packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/NullShouldBeTreatedAsUndefinedData.cs create mode 100644 packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/NullShouldBeTreatedAsUndefinedDataProxy.cs create mode 100644 packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/NullShouldBeTreatedAsUndefined.java create mode 100644 packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/NullShouldBeTreatedAsUndefinedData.java diff --git a/packages/jsii-calc/lib/compliance.ts b/packages/jsii-calc/lib/compliance.ts index a0989493cc..24768a0b6b 100644 --- a/packages/jsii-calc/lib/compliance.ts +++ b/packages/jsii-calc/lib/compliance.ts @@ -948,3 +948,49 @@ export class DoNotRecognizeAnyAsOptional { } } + +/** + * jsii#282, aws-cdk#157: null should be treated as "undefined" + */ +export class NullShouldBeTreatedAsUndefined { + public changeMeToUndefined? = "hello"; + + constructor(_param1: string, optional?: any) { + if (optional !== undefined) { + throw new Error('Expecting second constructor argument to be "undefined"'); + } + } + + public giveMeUndefined(value?: any) { + if (value !== undefined) { + throw new Error('I am disappointed. I expected undefined and got: ' + JSON.stringify(value)); + } + } + + public giveMeUndefinedInsideAnObject(input: NullShouldBeTreatedAsUndefinedData) { + if (input.thisShouldBeUndefined !== undefined) { + throw new Error('I am disappointed. I expected undefined in "thisShouldBeUndefined" and got: ' + JSON.stringify(input)); + } + + const array = input.arrayWithThreeElementsAndUndefinedAsSecondArgument; + if (array.length !== 3) { + throw new Error('Expecting "arrayWithThreeElementsAndUndefinedAsSecondArgument" to have three elements: ' + JSON.stringify(input)); + } + + if (array[1] !== undefined) { + throw new Error('Expected arrayWithThreeElementsAndUndefinedAsSecondArgument[1] to be undefined: ' + JSON.stringify(input)) + } + } + + public verifyPropertyIsUndefined() { + if (this.changeMeToUndefined !== undefined) { + throw new Error('Expecting property "changeMeToUndefined" to be undefined, and it is: ' + this.changeMeToUndefined); + } + } +} + +export interface NullShouldBeTreatedAsUndefinedData { + thisShouldBeUndefined?: any; + arrayWithThreeElementsAndUndefinedAsSecondArgument: any[]; +} + diff --git a/packages/jsii-calc/test/assembly.jsii b/packages/jsii-calc/test/assembly.jsii index d245fa15e5..18088e8024 100644 --- a/packages/jsii-calc/test/assembly.jsii +++ b/packages/jsii-calc/test/assembly.jsii @@ -2273,6 +2273,100 @@ } ] }, + "jsii-calc.NullShouldBeTreatedAsUndefined": { + "assembly": "jsii-calc", + "docs": { + "comment": "jsii#282, aws-cdk#157: null should be treated as \"undefined\"" + }, + "fqn": "jsii-calc.NullShouldBeTreatedAsUndefined", + "initializer": { + "initializer": true, + "parameters": [ + { + "name": "_param1", + "type": { + "primitive": "string" + } + }, + { + "name": "optional", + "type": { + "optional": true, + "primitive": "any" + } + } + ] + }, + "kind": "class", + "methods": [ + { + "name": "giveMeUndefined", + "parameters": [ + { + "name": "value", + "type": { + "optional": true, + "primitive": "any" + } + } + ] + }, + { + "name": "giveMeUndefinedInsideAnObject", + "parameters": [ + { + "name": "input", + "type": { + "fqn": "jsii-calc.NullShouldBeTreatedAsUndefinedData" + } + } + ] + }, + { + "name": "verifyPropertyIsUndefined" + } + ], + "name": "NullShouldBeTreatedAsUndefined", + "properties": [ + { + "name": "changeMeToUndefined", + "type": { + "optional": true, + "primitive": "string" + } + } + ] + }, + "jsii-calc.NullShouldBeTreatedAsUndefinedData": { + "assembly": "jsii-calc", + "datatype": true, + "fqn": "jsii-calc.NullShouldBeTreatedAsUndefinedData", + "kind": "interface", + "name": "NullShouldBeTreatedAsUndefinedData", + "properties": [ + { + "abstract": true, + "name": "arrayWithThreeElementsAndUndefinedAsSecondArgument", + "type": { + "collection": { + "elementtype": { + "optional": true, + "primitive": "any" + }, + "kind": "array" + } + } + }, + { + "abstract": true, + "name": "thisShouldBeUndefined", + "type": { + "optional": true, + "primitive": "any" + } + } + ] + }, "jsii-calc.NumberGenerator": { "assembly": "jsii-calc", "docs": { 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 ff6747a7be..7cd6934249 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 @@ -827,6 +827,27 @@ public void TestReturnInterfaceFromOverride() Assert.Equal(4 * n, obj.Test(arg)); } + [Fact(DisplayName = Prefix + nameof(NullShouldBeTreatedAsUndefined))] + public void NullShouldBeTreatedAsUndefined() + { + // ctor + var obj = new NullShouldBeTreatedAsUndefined("param1", null); + + // method argument + obj.GiveMeUndefined(null); + + // inside object + obj.GiveMeUndefinedInsideAnObject(new NullShouldBeTreatedAsUndefinedData + { + ThisShouldBeUndefined = null, + ArrayWithThreeElementsAndUndefinedAsSecondArgument = new[] { "hello", null, "world" } + }); + + // property + obj.ChangeMeToUndefined = null; + obj.VerifyPropertyIsUndefined(); + } + class NumberReturner : DeputyBase, IIReturnsNumber { public NumberReturner(double number) 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 f2c437819b..48dac8a445 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 @@ -25,6 +25,8 @@ import software.amazon.jsii.tests.calculator.Multiply; import software.amazon.jsii.tests.calculator.Negate; import software.amazon.jsii.tests.calculator.NodeStandardLibrary; +import software.amazon.jsii.tests.calculator.NullShouldBeTreatedAsUndefined; +import software.amazon.jsii.tests.calculator.NullShouldBeTreatedAsUndefinedData; import software.amazon.jsii.tests.calculator.NumberGenerator; import software.amazon.jsii.tests.calculator.Polymorphism; import software.amazon.jsii.tests.calculator.Power; @@ -927,6 +929,18 @@ public void classWithPrivateConstructorAndAutomaticProperties() { assertEquals("Hello", obj.getReadOnlyString()); } + @Test + public void nullShouldBeTreatedAsUndefined() { + NullShouldBeTreatedAsUndefined obj = new NullShouldBeTreatedAsUndefined("hello", null); + obj.giveMeUndefined(null); + obj.giveMeUndefinedInsideAnObject(NullShouldBeTreatedAsUndefinedData.builder() + .withThisShouldBeUndefined(null) + .withArrayWithThreeElementsAndUndefinedAsSecondArgument(Arrays.asList("hello", null, "boom")) + .build()); + obj.setChangeMeToUndefined(null); + obj.verifyPropertyIsUndefined(); + } + static class MulTen extends Multiply { public MulTen(final int value) { super(new Number(value), new Number(10)); diff --git a/packages/jsii-kernel/lib/kernel.ts b/packages/jsii-kernel/lib/kernel.ts index a7f5241ba9..c508e34599 100644 --- a/packages/jsii-kernel/lib/kernel.ts +++ b/packages/jsii-kernel/lib/kernel.ts @@ -877,9 +877,10 @@ export class Kernel { return undefined; } - // null + // null is treated as "undefined" because most languages do not have this distinction + // see awslabs/aws-cdk#157 and awslabs/jsii#282 if (v === null) { - return null; + return undefined; } // pointer diff --git a/packages/jsii-kernel/test/test.kernel.ts b/packages/jsii-kernel/test/test.kernel.ts index bd778be7d5..7d54fe430f 100644 --- a/packages/jsii-kernel/test/test.kernel.ts +++ b/packages/jsii-kernel/test/test.kernel.ts @@ -936,6 +936,29 @@ defineTest('overrides: skip overrides of private properties', async (test, sandb test.deepEqual(result.result, 'privateProperty'); }); +defineTest('nulls are converted to undefined - ctor', async (_test, sandbox) => { + sandbox.create({ fqn: 'jsii-calc.NullShouldBeTreatedAsUndefined', args: [ "foo", null ] }); +}); + +defineTest('nulls are converted to undefined - method arguments', async (_test, sandbox) => { + const objref = sandbox.create({ fqn: 'jsii-calc.NullShouldBeTreatedAsUndefined', args: [ "foo" ] }); + sandbox.invoke({ objref, method: 'giveMeUndefined', args: [ null ] }); +}); + +defineTest('nulls are converted to undefined - inside objects', async (_test, sandbox) => { + const objref = sandbox.create({ fqn: 'jsii-calc.NullShouldBeTreatedAsUndefined', args: [ "foo" ] }); + sandbox.invoke({ objref, method: 'giveMeUndefinedInsideAnObject', args: [ { + thisShouldBeUndefined: null, + arrayWithThreeElementsAndUndefinedAsSecondArgument: [ 'one', null, 'two' ] + } ]}); +}); + +defineTest('nulls are converted to undefined - properties', async (_test, sandbox) => { + const objref = sandbox.create({ fqn: 'jsii-calc.NullShouldBeTreatedAsUndefined', args: [ "foo" ] }); + sandbox.set({ objref, property: 'changeMeToUndefined', value: null }); + sandbox.invoke({ objref, method: 'verifyPropertyIsUndefined' }); +}); + // ================================================================================================= 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 d245fa15e5..18088e8024 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 @@ -2273,6 +2273,100 @@ } ] }, + "jsii-calc.NullShouldBeTreatedAsUndefined": { + "assembly": "jsii-calc", + "docs": { + "comment": "jsii#282, aws-cdk#157: null should be treated as \"undefined\"" + }, + "fqn": "jsii-calc.NullShouldBeTreatedAsUndefined", + "initializer": { + "initializer": true, + "parameters": [ + { + "name": "_param1", + "type": { + "primitive": "string" + } + }, + { + "name": "optional", + "type": { + "optional": true, + "primitive": "any" + } + } + ] + }, + "kind": "class", + "methods": [ + { + "name": "giveMeUndefined", + "parameters": [ + { + "name": "value", + "type": { + "optional": true, + "primitive": "any" + } + } + ] + }, + { + "name": "giveMeUndefinedInsideAnObject", + "parameters": [ + { + "name": "input", + "type": { + "fqn": "jsii-calc.NullShouldBeTreatedAsUndefinedData" + } + } + ] + }, + { + "name": "verifyPropertyIsUndefined" + } + ], + "name": "NullShouldBeTreatedAsUndefined", + "properties": [ + { + "name": "changeMeToUndefined", + "type": { + "optional": true, + "primitive": "string" + } + } + ] + }, + "jsii-calc.NullShouldBeTreatedAsUndefinedData": { + "assembly": "jsii-calc", + "datatype": true, + "fqn": "jsii-calc.NullShouldBeTreatedAsUndefinedData", + "kind": "interface", + "name": "NullShouldBeTreatedAsUndefinedData", + "properties": [ + { + "abstract": true, + "name": "arrayWithThreeElementsAndUndefinedAsSecondArgument", + "type": { + "collection": { + "elementtype": { + "optional": true, + "primitive": "any" + }, + "kind": "array" + } + } + }, + { + "abstract": true, + "name": "thisShouldBeUndefined", + "type": { + "optional": true, + "primitive": "any" + } + } + ] + }, "jsii-calc.NumberGenerator": { "assembly": "jsii-calc", "docs": { diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/INullShouldBeTreatedAsUndefinedData.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/INullShouldBeTreatedAsUndefinedData.cs new file mode 100644 index 0000000000..121308d6eb --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/INullShouldBeTreatedAsUndefinedData.cs @@ -0,0 +1,22 @@ +using Amazon.JSII.Runtime.Deputy; + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + [JsiiInterface(typeof(INullShouldBeTreatedAsUndefinedData), "jsii-calc.NullShouldBeTreatedAsUndefinedData")] + public interface INullShouldBeTreatedAsUndefinedData + { + [JsiiProperty("arrayWithThreeElementsAndUndefinedAsSecondArgument", "{\"collection\":{\"kind\":\"array\",\"elementtype\":{\"primitive\":\"any\",\"optional\":true}}}")] + object[] ArrayWithThreeElementsAndUndefinedAsSecondArgument + { + get; + set; + } + + [JsiiProperty("thisShouldBeUndefined", "{\"primitive\":\"any\",\"optional\":true}")] + object ThisShouldBeUndefined + { + get; + set; + } + } +} \ No newline at end of file diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/NullShouldBeTreatedAsUndefined.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/NullShouldBeTreatedAsUndefined.cs new file mode 100644 index 0000000000..59078293ae --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/NullShouldBeTreatedAsUndefined.cs @@ -0,0 +1,46 @@ +using Amazon.JSII.Runtime.Deputy; + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + /// jsii#282, aws-cdk#157: null should be treated as "undefined" + [JsiiClass(typeof(NullShouldBeTreatedAsUndefined), "jsii-calc.NullShouldBeTreatedAsUndefined", "[{\"name\":\"_param1\",\"type\":{\"primitive\":\"string\"}},{\"name\":\"optional\",\"type\":{\"primitive\":\"any\",\"optional\":true}}]")] + public class NullShouldBeTreatedAsUndefined : DeputyBase + { + public NullShouldBeTreatedAsUndefined(string _param1, object optional): base(new DeputyProps(new object[]{_param1, optional})) + { + } + + protected NullShouldBeTreatedAsUndefined(ByRefValue reference): base(reference) + { + } + + protected NullShouldBeTreatedAsUndefined(DeputyProps props): base(props) + { + } + + [JsiiProperty("changeMeToUndefined", "{\"primitive\":\"string\",\"optional\":true}")] + public virtual string ChangeMeToUndefined + { + get => GetInstanceProperty(); + set => SetInstanceProperty(value); + } + + [JsiiMethod("giveMeUndefined", null, "[{\"name\":\"value\",\"type\":{\"primitive\":\"any\",\"optional\":true}}]")] + public virtual void GiveMeUndefined(object value) + { + InvokeInstanceVoidMethod(new object[]{value}); + } + + [JsiiMethod("giveMeUndefinedInsideAnObject", null, "[{\"name\":\"input\",\"type\":{\"fqn\":\"jsii-calc.NullShouldBeTreatedAsUndefinedData\"}}]")] + public virtual void GiveMeUndefinedInsideAnObject(INullShouldBeTreatedAsUndefinedData input) + { + InvokeInstanceVoidMethod(new object[]{input}); + } + + [JsiiMethod("verifyPropertyIsUndefined", null, "[]")] + public virtual void VerifyPropertyIsUndefined() + { + InvokeInstanceVoidMethod(new object[]{}); + } + } +} \ No newline at end of file diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/NullShouldBeTreatedAsUndefinedData.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/NullShouldBeTreatedAsUndefinedData.cs new file mode 100644 index 0000000000..eece17b09e --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/NullShouldBeTreatedAsUndefinedData.cs @@ -0,0 +1,21 @@ +using Amazon.JSII.Runtime.Deputy; + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + public class NullShouldBeTreatedAsUndefinedData : DeputyBase, INullShouldBeTreatedAsUndefinedData + { + [JsiiProperty("arrayWithThreeElementsAndUndefinedAsSecondArgument", "{\"collection\":{\"kind\":\"array\",\"elementtype\":{\"primitive\":\"any\",\"optional\":true}}}", true)] + public object[] ArrayWithThreeElementsAndUndefinedAsSecondArgument + { + get; + set; + } + + [JsiiProperty("thisShouldBeUndefined", "{\"primitive\":\"any\",\"optional\":true}", true)] + public object ThisShouldBeUndefined + { + get; + set; + } + } +} \ No newline at end of file diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/NullShouldBeTreatedAsUndefinedDataProxy.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/NullShouldBeTreatedAsUndefinedDataProxy.cs new file mode 100644 index 0000000000..210a9e6577 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/NullShouldBeTreatedAsUndefinedDataProxy.cs @@ -0,0 +1,26 @@ +using Amazon.JSII.Runtime.Deputy; + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + [JsiiTypeProxy(typeof(INullShouldBeTreatedAsUndefinedData), "jsii-calc.NullShouldBeTreatedAsUndefinedData")] + internal sealed class NullShouldBeTreatedAsUndefinedDataProxy : DeputyBase, INullShouldBeTreatedAsUndefinedData + { + private NullShouldBeTreatedAsUndefinedDataProxy(ByRefValue reference): base(reference) + { + } + + [JsiiProperty("arrayWithThreeElementsAndUndefinedAsSecondArgument", "{\"collection\":{\"kind\":\"array\",\"elementtype\":{\"primitive\":\"any\",\"optional\":true}}}")] + public object[] ArrayWithThreeElementsAndUndefinedAsSecondArgument + { + get => GetInstanceProperty(); + set => SetInstanceProperty(value); + } + + [JsiiProperty("thisShouldBeUndefined", "{\"primitive\":\"any\",\"optional\":true}")] + public object ThisShouldBeUndefined + { + get => GetInstanceProperty(); + set => SetInstanceProperty(value); + } + } +} \ 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 946461ede3..7648aaf8e8 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 @@ -61,6 +61,8 @@ protected Class resolveClass(final String fqn) throws ClassNotFoundException case "jsii-calc.MutableObjectLiteral": return software.amazon.jsii.tests.calculator.MutableObjectLiteral.class; case "jsii-calc.Negate": return software.amazon.jsii.tests.calculator.Negate.class; case "jsii-calc.NodeStandardLibrary": return software.amazon.jsii.tests.calculator.NodeStandardLibrary.class; + case "jsii-calc.NullShouldBeTreatedAsUndefined": return software.amazon.jsii.tests.calculator.NullShouldBeTreatedAsUndefined.class; + case "jsii-calc.NullShouldBeTreatedAsUndefinedData": return software.amazon.jsii.tests.calculator.NullShouldBeTreatedAsUndefinedData.class; case "jsii-calc.NumberGenerator": return software.amazon.jsii.tests.calculator.NumberGenerator.class; case "jsii-calc.ObjectRefsInCollections": return software.amazon.jsii.tests.calculator.ObjectRefsInCollections.class; case "jsii-calc.OptionalConstructorArgument": return software.amazon.jsii.tests.calculator.OptionalConstructorArgument.class; diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/NullShouldBeTreatedAsUndefined.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/NullShouldBeTreatedAsUndefined.java new file mode 100644 index 0000000000..96b9f62e90 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/NullShouldBeTreatedAsUndefined.java @@ -0,0 +1,45 @@ +package software.amazon.jsii.tests.calculator; + +/** + * jsii#282, aws-cdk#157: null should be treated as "undefined" + */ +@javax.annotation.Generated(value = "jsii-pacmak") +@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.NullShouldBeTreatedAsUndefined") +public class NullShouldBeTreatedAsUndefined extends software.amazon.jsii.JsiiObject { + protected NullShouldBeTreatedAsUndefined(final software.amazon.jsii.JsiiObject.InitializationMode mode) { + super(mode); + } + public NullShouldBeTreatedAsUndefined(final java.lang.String _param1, @javax.annotation.Nullable final java.lang.Object optional) { + super(software.amazon.jsii.JsiiObject.InitializationMode.Jsii); + software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this, java.util.stream.Stream.concat(java.util.stream.Stream.of(java.util.Objects.requireNonNull(_param1, "_param1 is required")), java.util.stream.Stream.of(optional)).toArray()); + } + public NullShouldBeTreatedAsUndefined(final java.lang.String _param1) { + super(software.amazon.jsii.JsiiObject.InitializationMode.Jsii); + software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this, java.util.stream.Stream.of(java.util.Objects.requireNonNull(_param1, "_param1 is required")).toArray()); + } + + public void giveMeUndefined(@javax.annotation.Nullable final java.lang.Object value) { + this.jsiiCall("giveMeUndefined", Void.class, java.util.stream.Stream.of(value).toArray()); + } + + public void giveMeUndefined() { + this.jsiiCall("giveMeUndefined", Void.class); + } + + public void giveMeUndefinedInsideAnObject(final software.amazon.jsii.tests.calculator.NullShouldBeTreatedAsUndefinedData input) { + this.jsiiCall("giveMeUndefinedInsideAnObject", Void.class, java.util.stream.Stream.of(java.util.Objects.requireNonNull(input, "input is required")).toArray()); + } + + public void verifyPropertyIsUndefined() { + this.jsiiCall("verifyPropertyIsUndefined", Void.class); + } + + @javax.annotation.Nullable + public java.lang.String getChangeMeToUndefined() { + return this.jsiiGet("changeMeToUndefined", java.lang.String.class); + } + + public void setChangeMeToUndefined(@javax.annotation.Nullable final java.lang.String value) { + this.jsiiSet("changeMeToUndefined", value); + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/NullShouldBeTreatedAsUndefinedData.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/NullShouldBeTreatedAsUndefinedData.java new file mode 100644 index 0000000000..e54655c3bf --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/NullShouldBeTreatedAsUndefinedData.java @@ -0,0 +1,108 @@ +package software.amazon.jsii.tests.calculator; + +@javax.annotation.Generated(value = "jsii-pacmak") +public interface NullShouldBeTreatedAsUndefinedData extends software.amazon.jsii.JsiiSerializable { + java.util.List getArrayWithThreeElementsAndUndefinedAsSecondArgument(); + void setArrayWithThreeElementsAndUndefinedAsSecondArgument(final java.util.List value); + java.lang.Object getThisShouldBeUndefined(); + void setThisShouldBeUndefined(final java.lang.Object value); + + /** + * @return a {@link Builder} of {@link NullShouldBeTreatedAsUndefinedData} + */ + static Builder builder() { + return new Builder(); + } + + /** + * A builder for {@link NullShouldBeTreatedAsUndefinedData} + */ + final class Builder { + private java.util.List _arrayWithThreeElementsAndUndefinedAsSecondArgument; + @javax.annotation.Nullable + private java.lang.Object _thisShouldBeUndefined; + + /** + * Sets the value of ArrayWithThreeElementsAndUndefinedAsSecondArgument + * @param value the value to be set + * @return {@code this} + */ + public Builder withArrayWithThreeElementsAndUndefinedAsSecondArgument(final java.util.List value) { + this._arrayWithThreeElementsAndUndefinedAsSecondArgument = java.util.Objects.requireNonNull(value, "arrayWithThreeElementsAndUndefinedAsSecondArgument is required"); + return this; + } + /** + * Sets the value of ThisShouldBeUndefined + * @param value the value to be set + * @return {@code this} + */ + public Builder withThisShouldBeUndefined(@javax.annotation.Nullable final java.lang.Object value) { + this._thisShouldBeUndefined = value; + return this; + } + + /** + * Builds the configured instance. + * @return a new instance of {@link NullShouldBeTreatedAsUndefinedData} + * @throws NullPointerException if any required attribute was not provided + */ + public NullShouldBeTreatedAsUndefinedData build() { + return new NullShouldBeTreatedAsUndefinedData() { + private java.util.List $arrayWithThreeElementsAndUndefinedAsSecondArgument = java.util.Objects.requireNonNull(_arrayWithThreeElementsAndUndefinedAsSecondArgument, "arrayWithThreeElementsAndUndefinedAsSecondArgument is required"); + @javax.annotation.Nullable + private java.lang.Object $thisShouldBeUndefined = _thisShouldBeUndefined; + + @Override + public java.util.List getArrayWithThreeElementsAndUndefinedAsSecondArgument() { + return this.$arrayWithThreeElementsAndUndefinedAsSecondArgument; + } + + @Override + public void setArrayWithThreeElementsAndUndefinedAsSecondArgument(final java.util.List value) { + this.$arrayWithThreeElementsAndUndefinedAsSecondArgument = java.util.Objects.requireNonNull(value, "arrayWithThreeElementsAndUndefinedAsSecondArgument is required"); + } + + @Override + public java.lang.Object getThisShouldBeUndefined() { + return this.$thisShouldBeUndefined; + } + + @Override + public void setThisShouldBeUndefined(@javax.annotation.Nullable final java.lang.Object value) { + this.$thisShouldBeUndefined = value; + } + + }; + } + } + + /** + * A proxy class which represents a concrete javascript instance of this type. + */ + final static class Jsii$Proxy extends software.amazon.jsii.JsiiObject implements software.amazon.jsii.tests.calculator.NullShouldBeTreatedAsUndefinedData { + protected Jsii$Proxy(final software.amazon.jsii.JsiiObject.InitializationMode mode) { + super(mode); + } + + @Override + public java.util.List getArrayWithThreeElementsAndUndefinedAsSecondArgument() { + return this.jsiiGet("arrayWithThreeElementsAndUndefinedAsSecondArgument", java.util.List.class); + } + + @Override + public void setArrayWithThreeElementsAndUndefinedAsSecondArgument(final java.util.List value) { + this.jsiiSet("arrayWithThreeElementsAndUndefinedAsSecondArgument", java.util.Objects.requireNonNull(value, "arrayWithThreeElementsAndUndefinedAsSecondArgument is required")); + } + + @Override + @javax.annotation.Nullable + public java.lang.Object getThisShouldBeUndefined() { + return this.jsiiGet("thisShouldBeUndefined", java.lang.Object.class); + } + + @Override + public void setThisShouldBeUndefined(@javax.annotation.Nullable final java.lang.Object value) { + this.jsiiSet("thisShouldBeUndefined", value); + } + } +} 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 91db1c06f9..a52c080cfc 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 @@ -2778,6 +2778,101 @@ NodeStandardLibrary :type: string *(readonly)* +NullShouldBeTreatedAsUndefined +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. py:class:: NullShouldBeTreatedAsUndefined(_param1, [optional]) + + **Language-specific names:** + + .. tabs:: + + .. code-tab:: c# + + using Amazon.JSII.Tests.CalculatorNamespace; + + .. code-tab:: java + + import software.amazon.jsii.tests.calculator.NullShouldBeTreatedAsUndefined; + + .. code-tab:: javascript + + const { NullShouldBeTreatedAsUndefined } = require('jsii-calc'); + + .. code-tab:: typescript + + import { NullShouldBeTreatedAsUndefined } from 'jsii-calc'; + + + + jsii#282, aws-cdk#157: null should be treated as "undefined" + + + :param _param1: + :type _param1: string + :param optional: + :type optional: any or ``undefined`` + + .. py:method:: giveMeUndefined([value]) + + :param value: + :type value: any or ``undefined`` + + + .. py:method:: giveMeUndefinedInsideAnObject(input) + + :param input: + :type input: :py:class:`~jsii-calc.NullShouldBeTreatedAsUndefinedData`\ + + + .. py:method:: verifyPropertyIsUndefined() + + + + .. py:attribute:: changeMeToUndefined + + :type: string or ``undefined`` + + +NullShouldBeTreatedAsUndefinedData (interface) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. py:class:: NullShouldBeTreatedAsUndefinedData + + **Language-specific names:** + + .. tabs:: + + .. code-tab:: c# + + using Amazon.JSII.Tests.CalculatorNamespace; + + .. code-tab:: java + + import software.amazon.jsii.tests.calculator.NullShouldBeTreatedAsUndefinedData; + + .. code-tab:: javascript + + // NullShouldBeTreatedAsUndefinedData is an interface + + .. code-tab:: typescript + + import { NullShouldBeTreatedAsUndefinedData } from 'jsii-calc'; + + + + + + .. py:attribute:: arrayWithThreeElementsAndUndefinedAsSecondArgument + + :type: (any or ``undefined``)[] *(abstract)* + + + .. py:attribute:: thisShouldBeUndefined + + :type: any or ``undefined`` *(abstract)* + + NumberGenerator ^^^^^^^^^^^^^^^ From 2af148a13ff66e594a38e7a4a45e5a33e4e759c0 Mon Sep 17 00:00:00 2001 From: Elad Ben-Israel Date: Wed, 7 Nov 2018 14:13:44 +0200 Subject: [PATCH 3/3] Update --- packages/jsii-calc/test/assembly.jsii | 3 +-- .../dotnet/Amazon.JSII.Tests.CalculatorPackageId/.jsii | 3 +-- .../CalculatorNamespace/INullShouldBeTreatedAsUndefinedData.cs | 2 +- .../CalculatorNamespace/NullShouldBeTreatedAsUndefinedData.cs | 2 +- .../NullShouldBeTreatedAsUndefinedDataProxy.cs | 2 +- .../jsii-pacmak/test/expected.jsii-calc/sphinx/jsii-calc.rst | 2 +- 6 files changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/jsii-calc/test/assembly.jsii b/packages/jsii-calc/test/assembly.jsii index 18088e8024..533c28165d 100644 --- a/packages/jsii-calc/test/assembly.jsii +++ b/packages/jsii-calc/test/assembly.jsii @@ -2350,7 +2350,6 @@ "type": { "collection": { "elementtype": { - "optional": true, "primitive": "any" }, "kind": "array" @@ -3538,5 +3537,5 @@ } }, "version": "0.7.8", - "fingerprint": "2BaszImarh4WChl9DFUcygfTpEfXU17fHQT2wgEptfM=" + "fingerprint": "FZk0ePQ2XUte84CmnOjU3PPCl6QUA88ke6wHIJKhyzo=" } 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 18088e8024..533c28165d 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 @@ -2350,7 +2350,6 @@ "type": { "collection": { "elementtype": { - "optional": true, "primitive": "any" }, "kind": "array" @@ -3538,5 +3537,5 @@ } }, "version": "0.7.8", - "fingerprint": "2BaszImarh4WChl9DFUcygfTpEfXU17fHQT2wgEptfM=" + "fingerprint": "FZk0ePQ2XUte84CmnOjU3PPCl6QUA88ke6wHIJKhyzo=" } diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/INullShouldBeTreatedAsUndefinedData.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/INullShouldBeTreatedAsUndefinedData.cs index 121308d6eb..c5eed0cac8 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/INullShouldBeTreatedAsUndefinedData.cs +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/INullShouldBeTreatedAsUndefinedData.cs @@ -5,7 +5,7 @@ namespace Amazon.JSII.Tests.CalculatorNamespace [JsiiInterface(typeof(INullShouldBeTreatedAsUndefinedData), "jsii-calc.NullShouldBeTreatedAsUndefinedData")] public interface INullShouldBeTreatedAsUndefinedData { - [JsiiProperty("arrayWithThreeElementsAndUndefinedAsSecondArgument", "{\"collection\":{\"kind\":\"array\",\"elementtype\":{\"primitive\":\"any\",\"optional\":true}}}")] + [JsiiProperty("arrayWithThreeElementsAndUndefinedAsSecondArgument", "{\"collection\":{\"kind\":\"array\",\"elementtype\":{\"primitive\":\"any\"}}}")] object[] ArrayWithThreeElementsAndUndefinedAsSecondArgument { get; diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/NullShouldBeTreatedAsUndefinedData.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/NullShouldBeTreatedAsUndefinedData.cs index eece17b09e..9be4f5bbd0 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/NullShouldBeTreatedAsUndefinedData.cs +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/NullShouldBeTreatedAsUndefinedData.cs @@ -4,7 +4,7 @@ namespace Amazon.JSII.Tests.CalculatorNamespace { public class NullShouldBeTreatedAsUndefinedData : DeputyBase, INullShouldBeTreatedAsUndefinedData { - [JsiiProperty("arrayWithThreeElementsAndUndefinedAsSecondArgument", "{\"collection\":{\"kind\":\"array\",\"elementtype\":{\"primitive\":\"any\",\"optional\":true}}}", true)] + [JsiiProperty("arrayWithThreeElementsAndUndefinedAsSecondArgument", "{\"collection\":{\"kind\":\"array\",\"elementtype\":{\"primitive\":\"any\"}}}", true)] public object[] ArrayWithThreeElementsAndUndefinedAsSecondArgument { get; diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/NullShouldBeTreatedAsUndefinedDataProxy.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/NullShouldBeTreatedAsUndefinedDataProxy.cs index 210a9e6577..0456317c14 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/NullShouldBeTreatedAsUndefinedDataProxy.cs +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/NullShouldBeTreatedAsUndefinedDataProxy.cs @@ -9,7 +9,7 @@ private NullShouldBeTreatedAsUndefinedDataProxy(ByRefValue reference): base(refe { } - [JsiiProperty("arrayWithThreeElementsAndUndefinedAsSecondArgument", "{\"collection\":{\"kind\":\"array\",\"elementtype\":{\"primitive\":\"any\",\"optional\":true}}}")] + [JsiiProperty("arrayWithThreeElementsAndUndefinedAsSecondArgument", "{\"collection\":{\"kind\":\"array\",\"elementtype\":{\"primitive\":\"any\"}}}")] public object[] ArrayWithThreeElementsAndUndefinedAsSecondArgument { get => GetInstanceProperty(); 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 a52c080cfc..e52e449166 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 @@ -2865,7 +2865,7 @@ NullShouldBeTreatedAsUndefinedData (interface) .. py:attribute:: arrayWithThreeElementsAndUndefinedAsSecondArgument - :type: (any or ``undefined``)[] *(abstract)* + :type: any[] *(abstract)* .. py:attribute:: thisShouldBeUndefined