From d4a2bd3a7e9f02bd3f0160a3d35f30167150e470 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: Tue, 16 Apr 2019 10:42:58 +0200 Subject: [PATCH 1/2] fix(kernel): Set `this` in static contexts Javascript allows static members to refer to other static members through `this`, but the `jsii-kernel` passed `null` for the `this` context in `sinvoke`, making it impossible to invoke static methods that made use of this feature through the `jsii` runtimes. Fixes awslabs/aws-cdk#2304 --- packages/jsii-calc/lib/compliance.ts | 29 +++++++++++- packages/jsii-calc/test/assembly.jsii | 44 +++++++++++++++++- packages/jsii-kernel/lib/kernel.ts | 4 +- packages/jsii-kernel/test/test.kernel.ts | 25 ++++++++++ .../.jsii | 45 +++++++++++++++++- .../CalculatorNamespace/StaticContext.cs | 35 ++++++++++++++ .../amazon/jsii/tests/calculator/$Module.java | 1 + .../jsii/tests/calculator/StaticContext.java | 30 ++++++++++++ .../python/src/jsii_calc/__init__.py | 21 ++++++++- .../expected.jsii-calc/sphinx/jsii-calc.rst | 46 +++++++++++++++++++ .../jsii-reflect/test/classes.expected.txt | 1 + .../test/jsii-tree.test.all.expected.txt | 8 ++++ .../jsii-tree.test.inheritance.expected.txt | 1 + .../test/jsii-tree.test.members.expected.txt | 4 ++ .../test/jsii-tree.test.types.expected.txt | 1 + 15 files changed, 289 insertions(+), 6 deletions(-) create mode 100644 packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/StaticContext.cs create mode 100644 packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/StaticContext.java diff --git a/packages/jsii-calc/lib/compliance.ts b/packages/jsii-calc/lib/compliance.ts index a01d9808a1..07b94a07da 100644 --- a/packages/jsii-calc/lib/compliance.ts +++ b/packages/jsii-calc/lib/compliance.ts @@ -1635,4 +1635,31 @@ export interface OptionalStruct { * @stable */ export class ClassWithDocs { -} \ No newline at end of file +} + +/** + * This is used to validate the ability to use `this` from within a static context. + * + * https://github.com/awslabs/aws-cdk/issues/2304 + */ +export class StaticContext { + private static _staticVariable = true; + + public static canAccessStaticContext(): boolean { + return this.staticContextAvailable(); + } + + private static staticContextAvailable() { + return true; + } + + public static get staticVariable() { + return this._staticVariable; + } + + public static set staticVariable(value: boolean) { + this._staticVariable = value; + } + + private constructor() { } +} diff --git a/packages/jsii-calc/test/assembly.jsii b/packages/jsii-calc/test/assembly.jsii index 658c2d8cf7..63b7d1bbe7 100644 --- a/packages/jsii-calc/test/assembly.jsii +++ b/packages/jsii-calc/test/assembly.jsii @@ -5597,6 +5597,48 @@ ], "name": "SingleInstanceTwoTypes" }, + "jsii-calc.StaticContext": { + "assembly": "jsii-calc", + "docs": { + "remarks": "https://github.com/awslabs/aws-cdk/issues/2304", + "summary": "This is used to validate the ability to use `this` from within a static context." + }, + "fqn": "jsii-calc.StaticContext", + "kind": "class", + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 1645 + }, + "methods": [ + { + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 1648 + }, + "name": "canAccessStaticContext", + "returns": { + "type": { + "primitive": "boolean" + } + }, + "static": true + } + ], + "name": "StaticContext", + "properties": [ + { + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 1656 + }, + "name": "staticVariable", + "static": true, + "type": { + "primitive": "boolean" + } + } + ] + }, "jsii-calc.Statics": { "assembly": "jsii-calc", "fqn": "jsii-calc.Statics", @@ -6655,5 +6697,5 @@ } }, "version": "0.9.0", - "fingerprint": "rheLw7bhMAmuMfbnzQ4tXZyQTSYIydCp59wiBfA8Gpo=" + "fingerprint": "7Kv5qQOHJ4CtCTKoLfaavS4jHjk/HJvT6aWOIZAHTvw=" } diff --git a/packages/jsii-kernel/lib/kernel.ts b/packages/jsii-kernel/lib/kernel.ts index 5a1d54589b..3c50fd4a48 100644 --- a/packages/jsii-kernel/lib/kernel.ts +++ b/packages/jsii-kernel/lib/kernel.ts @@ -269,10 +269,10 @@ export class Kernel { } const prototype = this._findSymbol(fqn); - const fn = prototype[method]; + const fn = prototype[method] as (...params: any[]) => any; const ret = this._ensureSync(`method '${fqn}.${method}'`, () => { - return this._wrapSandboxCode(() => fn.apply(null, this._toSandboxValues(args, ti.parameters))); + return this._wrapSandboxCode(() => fn.apply(prototype, this._toSandboxValues(args, ti.parameters))); }); this._debug('method returned:', ret); diff --git a/packages/jsii-kernel/test/test.kernel.ts b/packages/jsii-kernel/test/test.kernel.ts index 37d67c9927..cac631a623 100644 --- a/packages/jsii-kernel/test/test.kernel.ts +++ b/packages/jsii-kernel/test/test.kernel.ts @@ -996,6 +996,31 @@ defineTest('ObjRefs are labeled with the "most correct" type', async (test, sand } }); +/** + * This is used to validate the ability to use `this` from within a static context. + * + * https://github.com/awslabs/aws-cdk/issues/2304 + */ +defineTest('sinvoke allows access to the static context', async (test, sandbox) => { + test.doesNotThrow(() => { + const response = sandbox.sinvoke({ fqn: 'jsii-calc.StaticContext', method: 'canAccessStaticContext' }); + test.ok(response.result, 'The result should be true'); + }); +}); +defineTest('sget allows access to the static context', async (test, sandbox) => { + test.doesNotThrow(() => { + const response = sandbox.sget({ fqn: 'jsii-calc.StaticContext', property: 'staticVariable' }); + test.ok(response.value, 'The result should be true'); + }); +}); +defineTest('sset allows access to the static context', async (test, sandbox) => { + test.doesNotThrow(() => { + sandbox.sset({ fqn: 'jsii-calc.StaticContext', property: 'staticVariable', value: false }); + const response = sandbox.sget({ fqn: 'jsii-calc.StaticContext', property: 'staticVariable' }); + test.ok(!response.value, 'The result should be true'); + }); +}); + /* Test currently disabled because we don't have the infrastructure to make it pass. 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 658c2d8cf7..717c4cf405 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 @@ -5597,6 +5597,49 @@ ], "name": "SingleInstanceTwoTypes" }, + "jsii-calc.StaticContext": { + "assembly": "jsii-calc", + "docs": { + "remarks": "https://github.com/awslabs/aws-cdk/issues/2304", + "summary": "This is used to validate the ability to use `this` from within a static context." + }, + "fqn": "jsii-calc.StaticContext", + "initializer": {}, + "kind": "class", + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 1645 + }, + "methods": [ + { + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 1648 + }, + "name": "canAccessStaticContext", + "returns": { + "type": { + "primitive": "boolean" + } + }, + "static": true + } + ], + "name": "StaticContext", + "properties": [ + { + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 1656 + }, + "name": "staticVariable", + "static": true, + "type": { + "primitive": "boolean" + } + } + ] + }, "jsii-calc.Statics": { "assembly": "jsii-calc", "fqn": "jsii-calc.Statics", @@ -6655,5 +6698,5 @@ } }, "version": "0.9.0", - "fingerprint": "rheLw7bhMAmuMfbnzQ4tXZyQTSYIydCp59wiBfA8Gpo=" + "fingerprint": "C0y3p66CUOJDewBR5RE3y7wgqyhxOFdQoqHg0HgSM1w=" } diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/StaticContext.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/StaticContext.cs new file mode 100644 index 0000000000..4280e4313d --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/StaticContext.cs @@ -0,0 +1,35 @@ +using Amazon.JSII.Runtime.Deputy; + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + /// This is used to validate the ability to use `this` from within a static context. + /// https://github.com/awslabs/aws-cdk/issues/2304 + [JsiiClass(nativeType: typeof(StaticContext), fullyQualifiedName: "jsii-calc.StaticContext")] + public class StaticContext : DeputyBase + { + public StaticContext(): base(new DeputyProps(new object[]{})) + { + } + + protected StaticContext(ByRefValue reference): base(reference) + { + } + + protected StaticContext(DeputyProps props): base(props) + { + } + + [JsiiProperty(name: "staticVariable", typeJson: "{\"primitive\":\"boolean\"}")] + public static bool StaticVariable + { + get => GetStaticProperty(typeof(StaticContext)); + set => SetStaticProperty(typeof(StaticContext), value); + } + + [JsiiMethod(name: "canAccessStaticContext", returnsJson: "{\"type\":{\"primitive\":\"boolean\"}}")] + public static bool CanAccessStaticContext() + { + return InvokeStaticMethod(typeof(StaticContext), new object[]{}); + } + } +} \ 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 f9ebbbc92d..689c74027f 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 @@ -112,6 +112,7 @@ protected Class resolveClass(final String fqn) throws ClassNotFoundException case "jsii-calc.ReturnsPrivateImplementationOfInterface": return software.amazon.jsii.tests.calculator.ReturnsPrivateImplementationOfInterface.class; case "jsii-calc.RuntimeTypeChecking": return software.amazon.jsii.tests.calculator.RuntimeTypeChecking.class; case "jsii-calc.SingleInstanceTwoTypes": return software.amazon.jsii.tests.calculator.SingleInstanceTwoTypes.class; + case "jsii-calc.StaticContext": return software.amazon.jsii.tests.calculator.StaticContext.class; case "jsii-calc.Statics": return software.amazon.jsii.tests.calculator.Statics.class; case "jsii-calc.StringEnum": return software.amazon.jsii.tests.calculator.StringEnum.class; case "jsii-calc.StripInternal": return software.amazon.jsii.tests.calculator.StripInternal.class; diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/StaticContext.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/StaticContext.java new file mode 100644 index 0000000000..38b98e29e6 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/StaticContext.java @@ -0,0 +1,30 @@ +package software.amazon.jsii.tests.calculator; + +/** + * This is used to validate the ability to use `this` from within a static context. + * + * https://github.com/awslabs/aws-cdk/issues/2304 + */ +@javax.annotation.Generated(value = "jsii-pacmak") +@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.StaticContext") +public class StaticContext extends software.amazon.jsii.JsiiObject { + protected StaticContext(final software.amazon.jsii.JsiiObject.InitializationMode mode) { + super(mode); + } + public StaticContext() { + super(software.amazon.jsii.JsiiObject.InitializationMode.Jsii); + software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this); + } + + public static java.lang.Boolean canAccessStaticContext() { + return software.amazon.jsii.JsiiObject.jsiiStaticCall(software.amazon.jsii.tests.calculator.StaticContext.class, "canAccessStaticContext", java.lang.Boolean.class); + } + + public static java.lang.Boolean getStaticVariable() { + return software.amazon.jsii.JsiiObject.jsiiStaticGet(software.amazon.jsii.tests.calculator.StaticContext.class, "staticVariable", java.lang.Boolean.class); + } + + public static void setStaticVariable(final java.lang.Boolean value) { + software.amazon.jsii.JsiiObject.jsiiStaticSet(software.amazon.jsii.tests.calculator.StaticContext.class, "staticVariable", java.util.Objects.requireNonNull(value, "staticVariable 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 516aecddb7..8216d5a8ac 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 @@ -2128,6 +2128,25 @@ def interface2(self) -> "IPublicInterface": return jsii.invoke(self, "interface2", []) +class StaticContext(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.StaticContext"): + def __init__(self) -> None: + jsii.create(StaticContext, self, []) + + @jsii.member(jsii_name="canAccessStaticContext") + @classmethod + def can_access_static_context(cls) -> bool: + return jsii.sinvoke(cls, "canAccessStaticContext", []) + + @classproperty + @jsii.member(jsii_name="staticVariable") + def static_variable(cls) -> bool: + return jsii.sget(cls, "staticVariable") + + @static_variable.setter + def static_variable(cls, value: bool): + return jsii.sset(cls, "staticVariable", value) + + class Statics(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Statics"): def __init__(self, value: str) -> None: jsii.create(Statics, self, [value]) @@ -2613,6 +2632,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", "DerivedClassHasNoProperties", "DerivedStruct", "DoNotOverridePrivates", "DoNotRecognizeAnyAsOptional", "DocumentedClass", "DontComplainAboutVariadicAfterOptional", "DoubleTrouble", "EraseUndefinedHashValues", "EraseUndefinedHashValuesOptions", "ExportedBaseClass", "ExtendsInternalInterface", "GiveMeStructs", "Greetee", "GreetingAugmenter", "IAnotherPublicInterface", "IExtendsPrivateInterface", "IFriendlier", "IFriendlyRandomGenerator", "IInterfaceImplementedByAbstractClass", "IInterfaceThatShouldNotBeADataType", "IInterfaceWithInternal", "IInterfaceWithMethods", "IInterfaceWithOptionalMethodArguments", "IInterfaceWithProperties", "IInterfaceWithPropertiesExtension", "IJSII417Derived", "IJSII417PublicBaseOfBase", "IMutableObjectLiteral", "INonInternalInterface", "IPrivatelyImplemented", "IPublicInterface", "IPublicInterface2", "IRandomNumberGenerator", "IReturnsNumber", "ImplementInternalInterface", "ImplementsInterfaceWithInternal", "ImplementsInterfaceWithInternalSubclass", "ImplementsPrivateInterface", "ImplictBaseOfBase", "InbetweenClass", "InterfaceInNamespaceIncludesClasses", "InterfaceInNamespaceOnlyInterface", "JSII417Derived", "JSII417PublicBaseOfBase", "JSObjectLiteralForInterface", "JSObjectLiteralToNative", "JSObjectLiteralToNativeClass", "JavaReservedWords", "JsiiAgent", "LoadBalancedFargateServiceProps", "Multiply", "Negate", "NodeStandardLibrary", "NullShouldBeTreatedAsUndefined", "NullShouldBeTreatedAsUndefinedData", "NumberGenerator", "ObjectRefsInCollections", "Old", "OptionalConstructorArgument", "OptionalStruct", "OptionalStructConsumer", "OverrideReturnsObject", "PartiallyInitializedThisConsumer", "Polymorphism", "Power", "PublicClass", "PythonReservedWords", "ReferenceEnumFromScopedPackage", "ReturnsPrivateImplementationOfInterface", "RuntimeTypeChecking", "SingleInstanceTwoTypes", "Statics", "StringEnum", "StripInternal", "Sum", "SyncVirtualMethods", "Thrower", "UnaryOperation", "UnionProperties", "UseBundledDependency", "UseCalcBase", "UsesInterfaceWithProperties", "VariadicMethod", "VirtualMethodPlayground", "__jsii_assembly__", "composition"] +__all__ = ["AbstractClass", "AbstractClassBase", "AbstractClassReturner", "Add", "AllTypes", "AllTypesEnum", "AllowedMethodNames", "AsyncVirtualMethods", "AugmentableClass", "BinaryOperation", "Calculator", "CalculatorProps", "ClassThatImplementsTheInternalInterface", "ClassThatImplementsThePrivateInterface", "ClassWithDocs", "ClassWithMutableObjectLiteralProperty", "ClassWithPrivateConstructorAndAutomaticProperties", "ConstructorPassesThisOut", "Constructors", "ConsumersOfThisCrazyTypeSystem", "DefaultedConstructorArgument", "DerivedClassHasNoProperties", "DerivedStruct", "DoNotOverridePrivates", "DoNotRecognizeAnyAsOptional", "DocumentedClass", "DontComplainAboutVariadicAfterOptional", "DoubleTrouble", "EraseUndefinedHashValues", "EraseUndefinedHashValuesOptions", "ExportedBaseClass", "ExtendsInternalInterface", "GiveMeStructs", "Greetee", "GreetingAugmenter", "IAnotherPublicInterface", "IExtendsPrivateInterface", "IFriendlier", "IFriendlyRandomGenerator", "IInterfaceImplementedByAbstractClass", "IInterfaceThatShouldNotBeADataType", "IInterfaceWithInternal", "IInterfaceWithMethods", "IInterfaceWithOptionalMethodArguments", "IInterfaceWithProperties", "IInterfaceWithPropertiesExtension", "IJSII417Derived", "IJSII417PublicBaseOfBase", "IMutableObjectLiteral", "INonInternalInterface", "IPrivatelyImplemented", "IPublicInterface", "IPublicInterface2", "IRandomNumberGenerator", "IReturnsNumber", "ImplementInternalInterface", "ImplementsInterfaceWithInternal", "ImplementsInterfaceWithInternalSubclass", "ImplementsPrivateInterface", "ImplictBaseOfBase", "InbetweenClass", "InterfaceInNamespaceIncludesClasses", "InterfaceInNamespaceOnlyInterface", "JSII417Derived", "JSII417PublicBaseOfBase", "JSObjectLiteralForInterface", "JSObjectLiteralToNative", "JSObjectLiteralToNativeClass", "JavaReservedWords", "JsiiAgent", "LoadBalancedFargateServiceProps", "Multiply", "Negate", "NodeStandardLibrary", "NullShouldBeTreatedAsUndefined", "NullShouldBeTreatedAsUndefinedData", "NumberGenerator", "ObjectRefsInCollections", "Old", "OptionalConstructorArgument", "OptionalStruct", "OptionalStructConsumer", "OverrideReturnsObject", "PartiallyInitializedThisConsumer", "Polymorphism", "Power", "PublicClass", "PythonReservedWords", "ReferenceEnumFromScopedPackage", "ReturnsPrivateImplementationOfInterface", "RuntimeTypeChecking", "SingleInstanceTwoTypes", "StaticContext", "Statics", "StringEnum", "StripInternal", "Sum", "SyncVirtualMethods", "Thrower", "UnaryOperation", "UnionProperties", "UseBundledDependency", "UseCalcBase", "UsesInterfaceWithProperties", "VariadicMethod", "VirtualMethodPlayground", "__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 f169148b62..8166b9f1e8 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 @@ -5344,6 +5344,52 @@ SingleInstanceTwoTypes :rtype: :py:class:`~jsii-calc.IPublicInterface`\ +StaticContext +^^^^^^^^^^^^^ + +.. py:class:: StaticContext() + + **Language-specific names:** + + .. tabs:: + + .. code-tab:: c# + + using Amazon.JSII.Tests.CalculatorNamespace; + + .. code-tab:: java + + import software.amazon.jsii.tests.calculator.StaticContext; + + .. code-tab:: javascript + + const { StaticContext } = require('jsii-calc'); + + .. code-tab:: typescript + + import { StaticContext } from 'jsii-calc'; + + + + This is used to validate the ability to use `this` from within a static context. + + + + https://github.com/awslabs/aws-cdk/issues/2304 + + + + + .. py:staticmethod:: canAccessStaticContext() -> boolean + + :rtype: boolean + + + .. py:attribute:: staticVariable + + :type: boolean *(static)* + + Statics ^^^^^^^ diff --git a/packages/jsii-reflect/test/classes.expected.txt b/packages/jsii-reflect/test/classes.expected.txt index 30732595bf..d039b6e8a5 100644 --- a/packages/jsii-reflect/test/classes.expected.txt +++ b/packages/jsii-reflect/test/classes.expected.txt @@ -64,6 +64,7 @@ ReferenceEnumFromScopedPackage ReturnsPrivateImplementationOfInterface RuntimeTypeChecking SingleInstanceTwoTypes +StaticContext Statics StripInternal Sum 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 9bfbe206ef..d8587b00ee 100644 --- a/packages/jsii-reflect/test/jsii-tree.test.all.expected.txt +++ b/packages/jsii-reflect/test/jsii-tree.test.all.expected.txt @@ -950,6 +950,14 @@ assemblies │ │ │ └── returns: jsii-calc.InbetweenClass │ │ └─┬ interface2() method │ │ └── returns: jsii-calc.IPublicInterface + │ ├─┬ class StaticContext + │ │ └─┬ members + │ │ ├─┬ canAccessStaticContext() method + │ │ │ ├── static + │ │ │ └── returns: boolean + │ │ └─┬ staticVariable property + │ │ ├── static + │ │ └── type: boolean │ ├─┬ class Statics │ │ └─┬ members │ │ ├─┬ (value) 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 b7da2ff226..092c21aec5 100644 --- a/packages/jsii-reflect/test/jsii-tree.test.inheritance.expected.txt +++ b/packages/jsii-reflect/test/jsii-tree.test.inheritance.expected.txt @@ -84,6 +84,7 @@ assemblies │ ├── class ReturnsPrivateImplementationOfInterface │ ├── class RuntimeTypeChecking │ ├── class SingleInstanceTwoTypes + │ ├── class StaticContext │ ├── class Statics │ ├── class StripInternal │ ├─┬ class Sum 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 dfc2fcdca2..116a745a73 100644 --- a/packages/jsii-reflect/test/jsii-tree.test.members.expected.txt +++ b/packages/jsii-reflect/test/jsii-tree.test.members.expected.txt @@ -433,6 +433,10 @@ assemblies │ │ ├── () initializer │ │ ├── interface1() method │ │ └── interface2() method + │ ├─┬ class StaticContext + │ │ └─┬ members + │ │ ├── canAccessStaticContext() method + │ │ └── staticVariable property │ ├─┬ class Statics │ │ └─┬ members │ │ ├── (value) 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 36e05ae539..d12ec07943 100644 --- a/packages/jsii-reflect/test/jsii-tree.test.types.expected.txt +++ b/packages/jsii-reflect/test/jsii-tree.test.types.expected.txt @@ -63,6 +63,7 @@ assemblies │ ├── class ReturnsPrivateImplementationOfInterface │ ├── class RuntimeTypeChecking │ ├── class SingleInstanceTwoTypes + │ ├── class StaticContext │ ├── class Statics │ ├── class StripInternal │ ├── class Sum From e5736607cd56213e765274abe2a8894f6fb9702c 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: Tue, 16 Apr 2019 10:48:31 +0200 Subject: [PATCH 2/2] Add missing test expectation fixes. --- .../dotnet/Amazon.JSII.Tests.CalculatorPackageId/.jsii | 3 +-- .../Amazon/JSII/Tests/CalculatorNamespace/StaticContext.cs | 4 ---- .../software/amazon/jsii/tests/calculator/StaticContext.java | 4 ---- .../test/expected.jsii-calc/python/src/jsii_calc/__init__.py | 3 --- .../jsii-pacmak/test/expected.jsii-calc/sphinx/jsii-calc.rst | 2 +- 5 files changed, 2 insertions(+), 14 deletions(-) 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 717c4cf405..63b7d1bbe7 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 @@ -5604,7 +5604,6 @@ "summary": "This is used to validate the ability to use `this` from within a static context." }, "fqn": "jsii-calc.StaticContext", - "initializer": {}, "kind": "class", "locationInModule": { "filename": "lib/compliance.ts", @@ -6698,5 +6697,5 @@ } }, "version": "0.9.0", - "fingerprint": "C0y3p66CUOJDewBR5RE3y7wgqyhxOFdQoqHg0HgSM1w=" + "fingerprint": "7Kv5qQOHJ4CtCTKoLfaavS4jHjk/HJvT6aWOIZAHTvw=" } diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/StaticContext.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/StaticContext.cs index 4280e4313d..1e578afb91 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/StaticContext.cs +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/StaticContext.cs @@ -7,10 +7,6 @@ namespace Amazon.JSII.Tests.CalculatorNamespace [JsiiClass(nativeType: typeof(StaticContext), fullyQualifiedName: "jsii-calc.StaticContext")] public class StaticContext : DeputyBase { - public StaticContext(): base(new DeputyProps(new object[]{})) - { - } - protected StaticContext(ByRefValue reference): base(reference) { } diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/StaticContext.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/StaticContext.java index 38b98e29e6..d5047c2e3a 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/StaticContext.java +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/StaticContext.java @@ -11,10 +11,6 @@ public class StaticContext extends software.amazon.jsii.JsiiObject { protected StaticContext(final software.amazon.jsii.JsiiObject.InitializationMode mode) { super(mode); } - public StaticContext() { - super(software.amazon.jsii.JsiiObject.InitializationMode.Jsii); - software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this); - } public static java.lang.Boolean canAccessStaticContext() { return software.amazon.jsii.JsiiObject.jsiiStaticCall(software.amazon.jsii.tests.calculator.StaticContext.class, "canAccessStaticContext", java.lang.Boolean.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 8216d5a8ac..31bc290849 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 @@ -2129,9 +2129,6 @@ def interface2(self) -> "IPublicInterface": class StaticContext(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.StaticContext"): - def __init__(self) -> None: - jsii.create(StaticContext, self, []) - @jsii.member(jsii_name="canAccessStaticContext") @classmethod def can_access_static_context(cls) -> bool: 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 8166b9f1e8..4ca83625bb 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 @@ -5347,7 +5347,7 @@ SingleInstanceTwoTypes StaticContext ^^^^^^^^^^^^^ -.. py:class:: StaticContext() +.. py:class:: StaticContext **Language-specific names:**