diff --git a/packages/jsii-calc/lib/compliance.ts b/packages/jsii-calc/lib/compliance.ts index 7b72e151f6..985af9d9d7 100644 --- a/packages/jsii-calc/lib/compliance.ts +++ b/packages/jsii-calc/lib/compliance.ts @@ -2924,6 +2924,8 @@ export namespace LevelOne { * like. */ export class StaticHelloParent { + public static readonly PROPERTY: number = 1337; + public static get property(): number { return 1337; } @@ -2933,6 +2935,8 @@ export class StaticHelloParent { } } export class StaticHelloChild extends StaticHelloParent { + public static readonly PROPERTY: number = 42; + public static get property(): number { return 42; } diff --git a/packages/jsii-calc/test/assembly.jsii b/packages/jsii-calc/test/assembly.jsii index 81da98ab1d..cf3d2e77f7 100644 --- a/packages/jsii-calc/test/assembly.jsii +++ b/packages/jsii-calc/test/assembly.jsii @@ -1547,7 +1547,7 @@ "kind": "class", "locationInModule": { "filename": "lib/compliance.ts", - "line": 3142 + "line": 3146 }, "methods": [ { @@ -1557,7 +1557,7 @@ }, "locationInModule": { "filename": "lib/compliance.ts", - "line": 3151 + "line": 3155 }, "name": "mutateProperties", "parameters": [ @@ -2571,7 +2571,7 @@ }, "locationInModule": { "filename": "lib/compliance.ts", - "line": 3066 + "line": 3070 }, "parameters": [ { @@ -2604,7 +2604,7 @@ "kind": "class", "locationInModule": { "filename": "lib/compliance.ts", - "line": 3065 + "line": 3069 }, "name": "ClassWithCollectionOfUnions", "properties": [ @@ -2614,7 +2614,7 @@ }, "locationInModule": { "filename": "lib/compliance.ts", - "line": 3067 + "line": 3071 }, "name": "unionProperty", "type": { @@ -3093,7 +3093,7 @@ }, "locationInModule": { "filename": "lib/compliance.ts", - "line": 3076 + "line": 3080 }, "parameters": [ { @@ -3149,7 +3149,7 @@ "kind": "class", "locationInModule": { "filename": "lib/compliance.ts", - "line": 3075 + "line": 3079 }, "name": "ClassWithNestedUnion", "properties": [ @@ -3159,7 +3159,7 @@ }, "locationInModule": { "filename": "lib/compliance.ts", - "line": 3077 + "line": 3081 }, "name": "unionProperty", "type": { @@ -4153,7 +4153,7 @@ "kind": "class", "locationInModule": { "filename": "lib/compliance.ts", - "line": 3026 + "line": 3030 }, "methods": [ { @@ -4162,7 +4162,7 @@ }, "locationInModule": { "filename": "lib/compliance.ts", - "line": 3027 + "line": 3031 }, "name": "pleaseCompile" } @@ -8859,13 +8859,13 @@ }, "locationInModule": { "filename": "lib/compliance.ts", - "line": 3010 + "line": 3014 } }, "kind": "class", "locationInModule": { "filename": "lib/compliance.ts", - "line": 3006 + "line": 3010 }, "name": "Issue2638", "symbolId": "lib/compliance:Issue2638" @@ -8882,13 +8882,13 @@ }, "locationInModule": { "filename": "lib/compliance.ts", - "line": 3016 + "line": 3020 } }, "kind": "class", "locationInModule": { "filename": "lib/compliance.ts", - "line": 3015 + "line": 3019 }, "name": "Issue2638B", "symbolId": "lib/compliance:Issue2638B" @@ -11559,7 +11559,7 @@ }, "locationInModule": { "filename": "lib/compliance.ts", - "line": 3114 + "line": 3118 }, "parameters": [ { @@ -11594,7 +11594,7 @@ "kind": "class", "locationInModule": { "filename": "lib/compliance.ts", - "line": 3108 + "line": 3112 }, "name": "ParamShadowsBuiltins", "symbolId": "lib/compliance:ParamShadowsBuiltins" @@ -11609,7 +11609,7 @@ "kind": "interface", "locationInModule": { "filename": "lib/compliance.ts", - "line": 3126 + "line": 3130 }, "name": "ParamShadowsBuiltinsProps", "properties": [ @@ -11621,7 +11621,7 @@ "immutable": true, "locationInModule": { "filename": "lib/compliance.ts", - "line": 3128 + "line": 3132 }, "name": "booleanProperty", "type": { @@ -11636,7 +11636,7 @@ "immutable": true, "locationInModule": { "filename": "lib/compliance.ts", - "line": 3127 + "line": 3131 }, "name": "stringProperty", "type": { @@ -11651,7 +11651,7 @@ "immutable": true, "locationInModule": { "filename": "lib/compliance.ts", - "line": 3129 + "line": 3133 }, "name": "structProperty", "type": { @@ -11677,7 +11677,7 @@ "kind": "class", "locationInModule": { "filename": "lib/compliance.ts", - "line": 3097 + "line": 3101 }, "methods": [ { @@ -11686,7 +11686,7 @@ }, "locationInModule": { "filename": "lib/compliance.ts", - "line": 3099 + "line": 3103 }, "name": "useScope", "parameters": [ @@ -11951,7 +11951,7 @@ "kind": "class", "locationInModule": { "filename": "lib/compliance.ts", - "line": 3132 + "line": 3136 }, "methods": [ { @@ -11961,7 +11961,7 @@ }, "locationInModule": { "filename": "lib/compliance.ts", - "line": 3133 + "line": 3137 }, "name": "promiseIt", "static": true @@ -11973,7 +11973,7 @@ }, "locationInModule": { "filename": "lib/compliance.ts", - "line": 3137 + "line": 3141 }, "name": "instancePromiseIt" } @@ -13432,7 +13432,7 @@ "kind": "class", "locationInModule": { "filename": "lib/compliance.ts", - "line": 2935 + "line": 2937 }, "methods": [ { @@ -13441,7 +13441,7 @@ }, "locationInModule": { "filename": "lib/compliance.ts", - "line": 2940 + "line": 2944 }, "name": "method", "overrides": "jsii-calc.StaticHelloParent", @@ -13457,7 +13457,7 @@ "immutable": true, "locationInModule": { "filename": "lib/compliance.ts", - "line": 2936 + "line": 2940 }, "name": "property", "overrides": "jsii-calc.StaticHelloParent", @@ -13465,6 +13465,23 @@ "type": { "primitive": "number" } + }, + { + "const": true, + "docs": { + "stability": "stable" + }, + "immutable": true, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2938 + }, + "name": "PROPERTY", + "overrides": "jsii-calc.StaticHelloParent", + "static": true, + "type": { + "primitive": "number" + } } ], "symbolId": "lib/compliance:StaticHelloChild" @@ -13494,7 +13511,7 @@ }, "locationInModule": { "filename": "lib/compliance.ts", - "line": 2931 + "line": 2933 }, "name": "method", "static": true @@ -13509,13 +13526,29 @@ "immutable": true, "locationInModule": { "filename": "lib/compliance.ts", - "line": 2927 + "line": 2929 }, "name": "property", "static": true, "type": { "primitive": "number" } + }, + { + "const": true, + "docs": { + "stability": "stable" + }, + "immutable": true, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2927 + }, + "name": "PROPERTY", + "static": true, + "type": { + "primitive": "number" + } } ], "symbolId": "lib/compliance:StaticHelloParent" @@ -14171,7 +14204,7 @@ "kind": "interface", "locationInModule": { "filename": "lib/compliance.ts", - "line": 3071 + "line": 3075 }, "name": "StructWithCollectionOfUnionts", "properties": [ @@ -14183,7 +14216,7 @@ "immutable": true, "locationInModule": { "filename": "lib/compliance.ts", - "line": 3072 + "line": 3076 }, "name": "unionProperty", "type": { @@ -14222,7 +14255,7 @@ "kind": "interface", "locationInModule": { "filename": "lib/compliance.ts", - "line": 2952 + "line": 2956 }, "name": "StructWithEnum", "properties": [ @@ -14235,7 +14268,7 @@ "immutable": true, "locationInModule": { "filename": "lib/compliance.ts", - "line": 2956 + "line": 2960 }, "name": "foo", "type": { @@ -14252,7 +14285,7 @@ "immutable": true, "locationInModule": { "filename": "lib/compliance.ts", - "line": 2962 + "line": 2966 }, "name": "bar", "optional": true, @@ -14934,7 +14967,7 @@ "kind": "class", "locationInModule": { "filename": "lib/compliance.ts", - "line": 2965 + "line": 2969 }, "methods": [ { @@ -14944,7 +14977,7 @@ }, "locationInModule": { "filename": "lib/compliance.ts", - "line": 2969 + "line": 2973 }, "name": "isStringEnumA", "parameters": [ @@ -14968,7 +15001,7 @@ }, "locationInModule": { "filename": "lib/compliance.ts", - "line": 2976 + "line": 2980 }, "name": "isStringEnumB", "parameters": [ @@ -14996,7 +15029,7 @@ "immutable": true, "locationInModule": { "filename": "lib/compliance.ts", - "line": 2995 + "line": 2999 }, "name": "structWithFoo", "type": { @@ -15011,7 +15044,7 @@ "immutable": true, "locationInModule": { "filename": "lib/compliance.ts", - "line": 2985 + "line": 2989 }, "name": "structWithFooBar", "type": { @@ -15143,7 +15176,7 @@ "kind": "class", "locationInModule": { "filename": "lib/compliance.ts", - "line": 3038 + "line": 3042 }, "methods": [ { @@ -15152,7 +15185,7 @@ }, "locationInModule": { "filename": "lib/compliance.ts", - "line": 3039 + "line": 3043 }, "name": "toIsoString", "returns": { @@ -15168,7 +15201,7 @@ }, "locationInModule": { "filename": "lib/compliance.ts", - "line": 3053 + "line": 3057 }, "name": "toIsOString", "returns": { @@ -15184,7 +15217,7 @@ }, "locationInModule": { "filename": "lib/compliance.ts", - "line": 3046 + "line": 3050 }, "name": "toISOString", "returns": { @@ -15203,7 +15236,7 @@ "immutable": true, "locationInModule": { "filename": "lib/compliance.ts", - "line": 3057 + "line": 3061 }, "name": "fooBar", "type": { @@ -15218,7 +15251,7 @@ "immutable": true, "locationInModule": { "filename": "lib/compliance.ts", - "line": 3062 + "line": 3066 }, "name": "fooBAR", "type": { @@ -15798,7 +15831,7 @@ }, "locationInModule": { "filename": "lib/compliance.ts", - "line": 3086 + "line": 3090 }, "parameters": [ { @@ -15823,7 +15856,7 @@ "kind": "class", "locationInModule": { "filename": "lib/compliance.ts", - "line": 3083 + "line": 3087 }, "name": "VariadicTypeUnion", "properties": [ @@ -15833,7 +15866,7 @@ }, "locationInModule": { "filename": "lib/compliance.ts", - "line": 3084 + "line": 3088 }, "name": "union", "type": { @@ -18996,5 +19029,5 @@ } }, "version": "3.20.120", - "fingerprint": "HCIqG5qcERi1okKUxKZq8OFPL4UQrTEFjqQFQ00oCmM=" + "fingerprint": "WnQhIiNXhQ+cJHfcJKHBGnVCeDa8Ds9RLcJFlGrK6jQ=" } \ No newline at end of file diff --git a/packages/jsii-pacmak/lib/targets/dotnet/dotnetgenerator.ts b/packages/jsii-pacmak/lib/targets/dotnet/dotnetgenerator.ts index 84d4a91dc8..d17eaca66f 100644 --- a/packages/jsii-pacmak/lib/targets/dotnet/dotnetgenerator.ts +++ b/packages/jsii-pacmak/lib/targets/dotnet/dotnetgenerator.ts @@ -575,40 +575,12 @@ export class DotNetGenerator extends Generator { ? this.typeresolver.toDotNetType(method.returns.type) : 'void'; const staticKeyWord = method.static ? 'static ' : ''; - let overrideKeyWord = ''; - let virtualKeyWord = ''; - let definedOnAncestor = false; - // In the case of the source being a class, we check if it is already defined on an ancestor - if (spec.isClassType(cls)) { - definedOnAncestor = this.isMemberDefinedOnAncestor(cls, method); - } - // The method is an override if it's defined on the ancestor, or if the parent is a class and we are generating a proxy or datatype class - let overrides = - definedOnAncestor || (spec.isClassType(cls) && emitForProxyOrDatatype); - // We also inspect the jsii model to see if it overrides a class member. - if (method.overrides) { - const overrideType = this.findType(method.overrides); - if (spec.isClassType(overrideType)) { - // Overrides a class, needs overrides keyword - overrides = true; - } - } - if (overrides) { - // Add the override key word if the method is emitted for a proxy or data type or is defined on an ancestor. If - // the member is static, use the "new" keyword instead, to indicate we are intentionally hiding the ancestor - // declaration (as C# does not inherit statics, they can be hidden but not overridden). The "new" keyword is - // optional in this context, but helps clarify intention. - overrideKeyWord = method.static ? 'new ' : 'override '; - } else if ( - !method.static && - (method.abstract || !definedOnAncestor) && - !emitForProxyOrDatatype - ) { - // Add the virtual key word if the method is abstract or not defined on an ancestor and we are NOT generating a proxy or datatype class - // Methods should always be virtual when possible - virtualKeyWord = 'virtual '; - } + const { overrideKeyword, virtualKeyword } = this.memberKeywords( + cls, + method, + emitForProxyOrDatatype, + ); const access = this.renderAccessLevel(method); const methodName = this.nameutils.convertMethodName(method.name); @@ -629,11 +601,11 @@ export class DotNetGenerator extends Generator { ); if (method.abstract) { - this.code.line(`${access} ${overrideKeyWord}abstract ${signature};`); + this.code.line(`${access} ${overrideKeyword}abstract ${signature};`); this.code.line(); } else { this.code.openBlock( - `${access} ${staticKeyWord}${overrideKeyWord}${virtualKeyWord}${signature}`, + `${access} ${staticKeyWord}${overrideKeyword}${virtualKeyword}${signature}`, ); this.emitUnionParameterValdation( ( @@ -652,6 +624,49 @@ export class DotNetGenerator extends Generator { } } + private memberKeywords( + currentClass: spec.Type, + member: spec.Property | spec.Method, + proxyOrDataType: boolean, + ): { overrideKeyword: string; virtualKeyword: string } { + if (!spec.isClassType(currentClass)) { + return { overrideKeyword: '', virtualKeyword: '' }; + } + + const implementedInBase = this.isMemberDefinedOnAncestor( + currentClass, + member, + ); + + if (implementedInBase || proxyOrDataType) { + // Override if the property is in a datatype or proxy class or declared in a parent class. If the member is + // static, use the "new" keyword instead, to indicate we are intentionally hiding the ancestor declaration (as + // C# does not inherit statics, they can be hidden but not overridden).The "new" keyword is optional in this + // context, but helps clarify intention. + return { + overrideKeyword: member.static ? 'new ' : 'override ', + virtualKeyword: '', + }; + } else if (member.abstract) { + // Abstract members get decorated as such + return { + overrideKeyword: '', + virtualKeyword: 'abstract ', + }; + } else if (!member.static && !implementedInBase) { + // Virtual if the prop is not static, and is not implemented in base member, this way we can later override it. + return { + overrideKeyword: '', + virtualKeyword: 'virtual ', + }; + } + + return { + overrideKeyword: '', + virtualKeyword: '', + }; + } + /** * Emits type checks for values passed for type union parameters. * @@ -702,6 +717,16 @@ export class DotNetGenerator extends Generator { } } + // Check the `overrides` directive directly from the jsii assembly + if (member.overrides) { + const overrideType = this.findType(member.overrides); + if (spec.isClassType(overrideType)) { + // Overrides a class, needs overrides keyword + return true; + } + } + + // Look for something that's named the same const base = cls.base; if (base) { const baseType = this.findType(base) as spec.ClassType; @@ -1046,32 +1071,12 @@ export class DotNetGenerator extends Generator { } this.dotnetRuntimeGenerator.emitAttributesForProperty(prop); - let isOverrideKeyWord = ''; - let isVirtualKeyWord = ''; - let isAbstractKeyword = ''; - - // If the prop parent is a class - if (spec.isClassType(cls)) { - const implementedInBase = this.isMemberDefinedOnAncestor( - cls as spec.ClassType, - prop, - ); - if (implementedInBase || datatype || proxy) { - // Override if the property is in a datatype or proxy class or declared in a parent class. If the member is - // static, use the "new" keyword instead, to indicate we are intentionally hiding the ancestor declaration (as - // C# does not inherit statics, they can be hidden but not overridden).The "new" keyword is optional in this - // context, but helps clarify intention. - isOverrideKeyWord = prop.static ? 'new ' : 'override '; - } else if (prop.abstract) { - // Abstract members get decorated as such - isAbstractKeyword = 'abstract '; - } else if (!prop.static && !implementedInBase) { - // Virtual if the prop is not static, and is not implemented in base member, this way we can later override it. - isVirtualKeyWord = 'virtual '; - } - } - - const statement = `${access} ${isAbstractKeyword}${isVirtualKeyWord}${staticKeyWord}${isOverrideKeyWord}${propTypeFQN}${isOptional} ${propName}`; + const { virtualKeyword, overrideKeyword } = this.memberKeywords( + cls, + prop, + datatype || proxy, + ); + const statement = `${access} ${virtualKeyword}${staticKeyWord}${overrideKeyword}${propTypeFQN}${isOptional} ${propName}`; this.code.openBlock(statement); // Emit getters @@ -1146,7 +1151,7 @@ export class DotNetGenerator extends Generator { } /** - * Emits a constant property + * Emits a (static) constant property */ private emitConstProperty(cls: spec.ClassType, prop: spec.Property): void { this.emitNewLineIfNecessary(); @@ -1163,8 +1168,15 @@ export class DotNetGenerator extends Generator { const propName = this.nameutils.convertPropertyName(prop.name); const staticKeyword = prop.static ? 'static ' : ''; + const { overrideKeyword } = this.memberKeywords( + cls, + prop, + // Static properties are never on proxies or datatypes (because those come from TS interfaces) + false, + ); + this.code.openBlock( - `${access} ${staticKeyword}${propType}${isOptional} ${propName}`, + `${access} ${staticKeyword}${overrideKeyword}${propType}${isOptional} ${propName}`, ); this.code.line('get;'); this.code.closeBlock(); diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-dotnet.test.js.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-dotnet.test.js.snap index 3341498b76..66df70f703 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-dotnet.test.js.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-dotnet.test.js.snap @@ -18713,6 +18713,13 @@ namespace Amazon.JSII.Tests.CalculatorNamespace { get => GetStaticProperty(typeof(Amazon.JSII.Tests.CalculatorNamespace.StaticHelloChild))!; } + + [JsiiProperty(name: "PROPERTY", typeJson: "{\\"primitive\\":\\"number\\"}")] + public static new double PROPERTY + { + get; + } + = GetStaticProperty(typeof(Amazon.JSII.Tests.CalculatorNamespace.StaticHelloChild))!; } } @@ -18769,6 +18776,13 @@ namespace Amazon.JSII.Tests.CalculatorNamespace { get => GetStaticProperty(typeof(Amazon.JSII.Tests.CalculatorNamespace.StaticHelloParent))!; } + + [JsiiProperty(name: "PROPERTY", typeJson: "{\\"primitive\\":\\"number\\"}")] + public static double PROPERTY + { + get; + } + = GetStaticProperty(typeof(Amazon.JSII.Tests.CalculatorNamespace.StaticHelloParent))!; } } diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-go.test.js.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-go.test.js.snap index 2cf3a5c550..6918339896 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-go.test.js.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-go.test.js.snap @@ -15802,6 +15802,17 @@ func StaticHelloChild_Property() *float64 { return returns } +func StaticHelloChild_PROPERTY() *float64 { + _init_.Initialize() + var returns *float64 + _jsii_.StaticGet( + "jsii-calc.StaticHelloChild", + "PROPERTY", + &returns, + ) + return returns +} + `; @@ -15871,6 +15882,17 @@ func StaticHelloParent_Property() *float64 { return returns } +func StaticHelloParent_PROPERTY() *float64 { + _init_.Initialize() + var returns *float64 + _jsii_.StaticGet( + "jsii-calc.StaticHelloParent", + "PROPERTY", + &returns, + ) + return returns +} + `; diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-java.test.js.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-java.test.js.snap index ea252615ec..c58374a03a 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-java.test.js.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-java.test.js.snap @@ -20956,6 +20956,10 @@ public class StaticHelloChild extends software.amazon.jsii.tests.calculator.Stat super(initializationMode); } + static { + PROPERTY = software.amazon.jsii.JsiiObject.jsiiStaticGet(software.amazon.jsii.tests.calculator.StaticHelloChild.class, "PROPERTY", software.amazon.jsii.NativeType.forClass(java.lang.Number.class)); + } + /** */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) @@ -20969,6 +20973,11 @@ public class StaticHelloChild extends software.amazon.jsii.tests.calculator.Stat public static @org.jetbrains.annotations.NotNull java.lang.Number getProperty() { return software.amazon.jsii.JsiiObject.jsiiStaticGet(software.amazon.jsii.tests.calculator.StaticHelloChild.class, "property", software.amazon.jsii.NativeType.forClass(java.lang.Number.class)); } + + /** + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + public final static java.lang.Number PROPERTY; } `; @@ -20996,6 +21005,10 @@ public class StaticHelloParent extends software.amazon.jsii.JsiiObject { super(initializationMode); } + static { + PROPERTY = software.amazon.jsii.JsiiObject.jsiiStaticGet(software.amazon.jsii.tests.calculator.StaticHelloParent.class, "PROPERTY", software.amazon.jsii.NativeType.forClass(java.lang.Number.class)); + } + /** */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) @@ -21017,6 +21030,11 @@ public class StaticHelloParent extends software.amazon.jsii.JsiiObject { public static @org.jetbrains.annotations.NotNull java.lang.Number getProperty() { return software.amazon.jsii.JsiiObject.jsiiStaticGet(software.amazon.jsii.tests.calculator.StaticHelloParent.class, "property", software.amazon.jsii.NativeType.forClass(java.lang.Number.class)); } + + /** + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + public final static java.lang.Number PROPERTY; } `; diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.js.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.js.snap index ea2229ae90..5396bfd6b0 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.js.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.js.snap @@ -9870,6 +9870,11 @@ class StaticHelloParent( def property(cls) -> jsii.Number: return typing.cast(jsii.Number, jsii.sget(cls, "property")) + @jsii.python.classproperty + @jsii.member(jsii_name="PROPERTY") + def PROPERTY(cls) -> jsii.Number: + return typing.cast(jsii.Number, jsii.sget(cls, "PROPERTY")) + class Statics(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Statics"): def __init__(self, value: builtins.str) -> None: @@ -11556,6 +11561,11 @@ class StaticHelloChild( def property(cls) -> jsii.Number: return typing.cast(jsii.Number, jsii.sget(cls, "property")) + @jsii.python.classproperty + @jsii.member(jsii_name="PROPERTY") + def PROPERTY(cls) -> jsii.Number: + return typing.cast(jsii.Number, jsii.sget(cls, "PROPERTY")) + class SupportsNiceJavaBuilder( SupportsNiceJavaBuilderWithRequiredProps, @@ -17867,7 +17877,7 @@ exports[`Generated code for "jsii-calc": /python/src/js class StaticHelloParent( metaclass=jsii.JSIIMeta, -@@ -6625,19 +7193,25 @@ +@@ -6630,19 +7198,25 @@ class Statics(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Statics"): def __init__(self, value: builtins.str) -> None: ''' @@ -17893,7 +17903,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @jsii.member(jsii_name="justMethod") def just_method(self) -> builtins.str: return typing.cast(builtins.str, jsii.invoke(self, "justMethod", [])) -@@ -6674,19 +7248,25 @@ +@@ -6679,19 +7253,25 @@ ''' return typing.cast("Statics", jsii.sget(cls, "instance")) @@ -17919,7 +17929,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @builtins.property @jsii.member(jsii_name="value") def value(self) -> builtins.str: -@@ -6709,10 +7289,13 @@ +@@ -6714,10 +7294,13 @@ def you_see_me(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "youSeeMe")) @@ -17933,7 +17943,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @jsii.data_type( jsii_type="jsii-calc.StructA", -@@ -6735,10 +7318,15 @@ +@@ -6740,10 +7323,15 @@ :param required_string: :param optional_number: @@ -17949,7 +17959,7 @@ exports[`Generated code for "jsii-calc": /python/src/js } if optional_number is not None: self._values["optional_number"] = optional_number -@@ -6796,10 +7384,15 @@ +@@ -6801,10 +7389,15 @@ :param optional_boolean: :param optional_struct_a: ''' @@ -17965,7 +17975,7 @@ exports[`Generated code for "jsii-calc": /python/src/js } if optional_boolean is not None: self._values["optional_boolean"] = optional_boolean -@@ -6851,10 +7444,14 @@ +@@ -6856,10 +7449,14 @@ See: https://github.com/aws/aws-cdk/issues/4302 :param scope: @@ -17980,7 +17990,7 @@ exports[`Generated code for "jsii-calc": /python/src/js } if props is not None: self._values["props"] = props -@@ -6897,10 +7494,14 @@ +@@ -6902,10 +7499,14 @@ ) -> jsii.Number: ''' :param _positional: - @@ -17995,7 +18005,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @jsii.member(jsii_name="roundTrip") @builtins.classmethod def round_trip( -@@ -6915,10 +7516,13 @@ +@@ -6920,10 +7521,13 @@ :param _positional: - :param required: This is a required field. :param second_level: A union to really stress test our serialization. @@ -18009,7 +18019,7 @@ exports[`Generated code for "jsii-calc": /python/src/js ) return typing.cast("TopLevelStruct", jsii.sinvoke(cls, "roundTrip", [_positional, input])) -@@ -6935,10 +7539,13 @@ +@@ -6940,10 +7544,13 @@ struct: typing.Union[typing.Union[StructA, typing.Dict[builtins.str, typing.Any]], typing.Union[StructB, typing.Dict[builtins.str, typing.Any]]], ) -> builtins.bool: ''' @@ -18023,7 +18033,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @jsii.member(jsii_name="isStructB") @builtins.classmethod def is_struct_b( -@@ -6946,18 +7553,24 @@ +@@ -6951,18 +7558,24 @@ struct: typing.Union[typing.Union[StructA, typing.Dict[builtins.str, typing.Any]], typing.Union[StructB, typing.Dict[builtins.str, typing.Any]]], ) -> builtins.bool: ''' @@ -18048,7 +18058,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @jsii.data_type( jsii_type="jsii-calc.StructWithCollectionOfUnionts", -@@ -6971,10 +7584,13 @@ +@@ -6976,10 +7589,13 @@ union_property: typing.Sequence[typing.Mapping[builtins.str, typing.Union[typing.Union[StructA, typing.Dict[builtins.str, typing.Any]], typing.Union[StructB, typing.Dict[builtins.str, typing.Any]]]]], ) -> None: ''' @@ -18062,7 +18072,7 @@ exports[`Generated code for "jsii-calc": /python/src/js } @builtins.property -@@ -7011,10 +7627,14 @@ +@@ -7016,10 +7632,14 @@ ) -> None: ''' :param foo: An enum value. @@ -18077,7 +18087,7 @@ exports[`Generated code for "jsii-calc": /python/src/js } if bar is not None: self._values["bar"] = bar -@@ -7070,10 +7690,16 @@ +@@ -7075,10 +7695,16 @@ :param default: :param assert_: :param result: @@ -18094,7 +18104,7 @@ exports[`Generated code for "jsii-calc": /python/src/js } if assert_ is not None: self._values["assert_"] = assert_ -@@ -7143,10 +7769,13 @@ +@@ -7148,10 +7774,13 @@ @parts.setter def parts( self, @@ -18108,7 +18118,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @jsii.data_type( jsii_type="jsii-calc.SupportsNiceJavaBuilderProps", -@@ -7162,10 +7791,14 @@ +@@ -7167,10 +7796,14 @@ ) -> None: ''' :param bar: Some number, like 42. @@ -18123,7 +18133,7 @@ exports[`Generated code for "jsii-calc": /python/src/js } if id is not None: self._values["id"] = id -@@ -7214,10 +7847,13 @@ +@@ -7219,10 +7852,13 @@ ''' :param id_: some identifier of your choice. :param bar: Some number, like 42. @@ -18137,7 +18147,7 @@ exports[`Generated code for "jsii-calc": /python/src/js jsii.create(self.__class__, self, [id_, props]) @builtins.property -@@ -7255,17 +7891,23 @@ +@@ -7260,17 +7896,23 @@ @jsii.member(jsii_name="modifyOtherProperty") def modify_other_property(self, value: builtins.str) -> None: ''' @@ -18161,7 +18171,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @jsii.member(jsii_name="readA") def read_a(self) -> jsii.Number: return typing.cast(jsii.Number, jsii.invoke(self, "readA", [])) -@@ -7285,17 +7927,23 @@ +@@ -7290,17 +7932,23 @@ @jsii.member(jsii_name="virtualMethod") def virtual_method(self, n: jsii.Number) -> jsii.Number: ''' @@ -18185,7 +18195,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @builtins.property @jsii.member(jsii_name="readonlyProperty") def readonly_property(self) -> builtins.str: -@@ -7306,46 +7954,61 @@ +@@ -7311,46 +7959,61 @@ def a(self) -> jsii.Number: return typing.cast(jsii.Number, jsii.get(self, "a")) @@ -18247,7 +18257,7 @@ exports[`Generated code for "jsii-calc": /python/src/js class TestStructWithEnum( metaclass=jsii.JSIIMeta, -@@ -7428,10 +8091,15 @@ +@@ -7433,10 +8096,15 @@ ''' :param required: This is a required field. :param second_level: A union to really stress test our serialization. @@ -18263,7 +18273,7 @@ exports[`Generated code for "jsii-calc": /python/src/js "second_level": second_level, } if optional is not None: -@@ -7522,10 +8190,13 @@ +@@ -7527,10 +8195,13 @@ def __init__(self, operand: _scope_jsii_calc_lib_c61f082f.NumericValue) -> None: ''' @@ -18277,7 +18287,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @builtins.property @jsii.member(jsii_name="operand") def operand(self) -> _scope_jsii_calc_lib_c61f082f.NumericValue: -@@ -7556,10 +8227,14 @@ +@@ -7561,10 +8232,14 @@ ) -> None: ''' :param bar: @@ -18292,7 +18302,7 @@ exports[`Generated code for "jsii-calc": /python/src/js } if foo is not None: self._values["foo"] = foo -@@ -7596,10 +8271,13 @@ +@@ -7601,10 +8276,13 @@ def __init__(self, delegate: typing.Mapping[builtins.str, typing.Any]) -> None: ''' @@ -18306,7 +18316,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @jsii.python.classproperty @jsii.member(jsii_name="reflector") def REFLECTOR(cls) -> _scope_jsii_calc_lib_custom_submodule_name_c61f082f.Reflector: -@@ -7642,10 +8320,13 @@ +@@ -7647,10 +8325,13 @@ ): def __init__(self, obj: IInterfaceWithProperties) -> None: ''' @@ -18320,7 +18330,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @jsii.member(jsii_name="justRead") def just_read(self) -> builtins.str: return typing.cast(builtins.str, jsii.invoke(self, "justRead", [])) -@@ -7656,17 +8337,23 @@ +@@ -7661,17 +8342,23 @@ ext: IInterfaceWithPropertiesExtension, ) -> builtins.str: ''' @@ -18344,7 +18354,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @builtins.property @jsii.member(jsii_name="obj") def obj(self) -> IInterfaceWithProperties: -@@ -7676,25 +8363,34 @@ +@@ -7681,25 +8368,34 @@ class VariadicInvoker(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.VariadicInvoker"): def __init__(self, method: "VariadicMethod") -> None: ''' @@ -18379,7 +18389,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @jsii.member(jsii_name="asArray") def as_array( self, -@@ -7703,10 +8399,14 @@ +@@ -7708,10 +8404,14 @@ ) -> typing.List[jsii.Number]: ''' :param first: the first element of the array to be returned (after the \`\`prefix\`\` provided at construction time). @@ -18394,7 +18404,7 @@ exports[`Generated code for "jsii-calc": /python/src/js class VariadicTypeUnion( metaclass=jsii.JSIIMeta, -@@ -7714,19 +8414,25 @@ +@@ -7719,19 +8419,25 @@ ): def __init__(self, *union: typing.Union[StructA, StructB]) -> None: ''' @@ -18420,7 +18430,7 @@ exports[`Generated code for "jsii-calc": /python/src/js class VirtualMethodPlayground( metaclass=jsii.JSIIMeta, -@@ -7738,38 +8444,53 @@ +@@ -7743,38 +8449,53 @@ @jsii.member(jsii_name="overrideMeAsync") def override_me_async(self, index: jsii.Number) -> jsii.Number: ''' @@ -18474,7 +18484,7 @@ exports[`Generated code for "jsii-calc": /python/src/js class VoidCallback( metaclass=jsii.JSIIAbstractClass, -@@ -7831,10 +8552,13 @@ +@@ -7836,10 +8557,13 @@ ''' return typing.cast(typing.Optional[builtins.str], jsii.get(self, "dontReadMe")) @@ -18488,7 +18498,7 @@ exports[`Generated code for "jsii-calc": /python/src/js class WithPrivatePropertyInConstructor( metaclass=jsii.JSIIMeta, -@@ -7844,10 +8568,13 @@ +@@ -7849,10 +8573,13 @@ def __init__(self, private_field: typing.Optional[builtins.str] = None) -> None: ''' @@ -18502,7 +18512,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @builtins.property @jsii.member(jsii_name="success") def success(self) -> builtins.bool: -@@ -7888,10 +8615,13 @@ +@@ -7893,10 +8620,13 @@ @jsii.member(jsii_name="abstractMethod") def abstract_method(self, name: builtins.str) -> builtins.str: ''' @@ -18516,7 +18526,7 @@ exports[`Generated code for "jsii-calc": /python/src/js # Adding a "__jsii_proxy_class__(): typing.Type" function to the abstract class typing.cast(typing.Any, AbstractClass).__jsii_proxy_class__ = lambda : _AbstractClassProxy -@@ -7907,10 +8637,14 @@ +@@ -7912,10 +8642,14 @@ '''Creates a BinaryOperation. :param lhs: Left-hand side operand. @@ -18531,7 +18541,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @jsii.member(jsii_name="toString") def to_string(self) -> builtins.str: '''String representation of the value.''' -@@ -7954,10 +8688,13 @@ +@@ -7959,10 +8693,13 @@ def rung(self) -> builtins.bool: return typing.cast(builtins.bool, jsii.get(self, "rung")) @@ -18545,7 +18555,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @jsii.data_type( jsii_type="jsii-calc.ChildStruct982", -@@ -7968,10 +8705,14 @@ +@@ -7973,10 +8710,14 @@ def __init__(self, *, foo: builtins.str, bar: jsii.Number) -> None: ''' :param foo: @@ -18560,7 +18570,7 @@ exports[`Generated code for "jsii-calc": /python/src/js "bar": bar, } -@@ -8012,37 +8753,49 @@ +@@ -8017,37 +8758,49 @@ def a(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "a")) @@ -18610,7 +18620,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @jsii.implements(INonInternalInterface) class ClassThatImplementsThePrivateInterface( -@@ -8057,37 +8810,49 @@ +@@ -8062,37 +8815,49 @@ def a(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "a")) @@ -18660,7 +18670,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @jsii.implements(IInterfaceWithProperties) class ClassWithPrivateConstructorAndAutomaticProperties( -@@ -8105,10 +8870,14 @@ +@@ -8110,10 +8875,14 @@ ) -> "ClassWithPrivateConstructorAndAutomaticProperties": ''' :param read_only_string: - @@ -18675,7 +18685,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @builtins.property @jsii.member(jsii_name="readOnlyString") def read_only_string(self) -> builtins.str: -@@ -8119,10 +8888,13 @@ +@@ -8124,10 +8893,13 @@ def read_write_string(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "readWriteString")) @@ -18689,7 +18699,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @jsii.implements(IIndirectlyImplemented) class FullCombo(BaseClass, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.FullCombo"): -@@ -8237,10 +9009,13 @@ +@@ -8242,10 +9014,13 @@ ): def __init__(self, property: builtins.str) -> None: ''' @@ -18703,7 +18713,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @jsii.member(jsii_name="bar") def bar(self) -> None: return typing.cast(None, jsii.invoke(self, "bar", [])) -@@ -8261,10 +9036,13 @@ +@@ -8266,10 +9041,13 @@ def __init__(self, operand: _scope_jsii_calc_lib_c61f082f.NumericValue) -> None: ''' @@ -18717,7 +18727,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @jsii.member(jsii_name="farewell") def farewell(self) -> builtins.str: '''Say farewell.''' -@@ -8324,10 +9102,16 @@ +@@ -8334,10 +9112,16 @@ :param id: some identifier. :param default_bar: the default value of \`\`bar\`\`. :param props: some props once can provide. @@ -18734,7 +18744,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @builtins.property @jsii.member(jsii_name="id") def id(self) -> jsii.Number: -@@ -8626,5 +9410,1544 @@ +@@ -8636,5 +9420,1544 @@ from . import nodirect from . import onlystatic from . import python_self diff --git a/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.js.snap b/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.js.snap index 55537e0506..eed058021d 100644 --- a/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.js.snap +++ b/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.js.snap @@ -2204,7 +2204,12 @@ exports[`jsii-tree --all 1`] = ` │ │ ├─┬ static method() method (stable) │ │ │ ├── static │ │ │ └── returns: void - │ │ └─┬ static property property (stable) + │ │ ├─┬ static property property (stable) + │ │ │ ├── immutable + │ │ │ ├── static + │ │ │ └── type: number + │ │ └─┬ static PROPERTY property (stable) + │ │ ├── const │ │ ├── immutable │ │ ├── static │ │ └── type: number @@ -2214,7 +2219,12 @@ exports[`jsii-tree --all 1`] = ` │ │ ├─┬ static method() method (stable) │ │ │ ├── static │ │ │ └── returns: void - │ │ └─┬ static property property (stable) + │ │ ├─┬ static property property (stable) + │ │ │ ├── immutable + │ │ │ ├── static + │ │ │ └── type: number + │ │ └─┬ static PROPERTY property (stable) + │ │ ├── const │ │ ├── immutable │ │ ├── static │ │ └── type: number @@ -5272,12 +5282,14 @@ exports[`jsii-tree --members 1`] = ` │ ├─┬ class StaticHelloChild │ │ └─┬ members │ │ ├── static method() method - │ │ └── static property property + │ │ ├── static property property + │ │ └── static PROPERTY property │ ├─┬ class StaticHelloParent │ │ └─┬ members │ │ ├── () initializer │ │ ├── static method() method - │ │ └── static property property + │ │ ├── static property property + │ │ └── static PROPERTY property │ ├─┬ class Statics │ │ └─┬ members │ │ ├── (value) initializer diff --git a/packages/jsii-reflect/test/__snapshots__/tree.test.js.snap b/packages/jsii-reflect/test/__snapshots__/tree.test.js.snap index 8d390c3709..ae7aa90d74 100644 --- a/packages/jsii-reflect/test/__snapshots__/tree.test.js.snap +++ b/packages/jsii-reflect/test/__snapshots__/tree.test.js.snap @@ -2381,7 +2381,12 @@ exports[`showAll 1`] = ` │ │ ├─┬ static method() method │ │ │ ├── static │ │ │ └── returns: void - │ │ └─┬ static property property + │ │ ├─┬ static property property + │ │ │ ├── immutable + │ │ │ ├── static + │ │ │ └── type: number + │ │ └─┬ static PROPERTY property + │ │ ├── const │ │ ├── immutable │ │ ├── static │ │ └── type: number @@ -2391,7 +2396,12 @@ exports[`showAll 1`] = ` │ │ ├─┬ static method() method │ │ │ ├── static │ │ │ └── returns: void - │ │ └─┬ static property property + │ │ ├─┬ static property property + │ │ │ ├── immutable + │ │ │ ├── static + │ │ │ └── type: number + │ │ └─┬ static PROPERTY property + │ │ ├── const │ │ ├── immutable │ │ ├── static │ │ └── type: number