diff --git a/packages/jsii-calc/lib/compliance.ts b/packages/jsii-calc/lib/compliance.ts index 65aad2efd9..4bac3db39f 100644 --- a/packages/jsii-calc/lib/compliance.ts +++ b/packages/jsii-calc/lib/compliance.ts @@ -1335,3 +1335,92 @@ export class Constructors { return new PrivateClass(); } } + +// internal can be used to represent members that can only be accessed from the current module +export class StripInternal { + public youSeeMe = 'hello'; + + /** + * This is an internal thing + * @internal + */ + public _youDontSeeMeAlthoughIamPublic = 'world' +} + +/** + * @internal + */ +export class InternalClass { + public iAmNotHere = 'yes'; +} + +/** + * @internal + */ +export interface IInternalInterface { + prop: string; +} + +/** + * @internal + */ +export enum InternalEnum { + Member1 = 12, + Member2 = 23 +} + +export interface IInterfaceWithInternal { + visible(): void; + + /** @internal */ + _hidden(): void; +} + +export class ImplementsInterfaceWithInternal implements IInterfaceWithInternal { + visible() { } + + /** @internal */ + _hidden() { } + + /** @internal */ + _alsoHidden() { } + + /** @internal */ + _propertiesToo?: string; +} + +export class ImplementsInterfaceWithInternalSubclass extends ImplementsInterfaceWithInternal { + /** @internal */ + _alsoHidden() { } + + /** + * @internal + */ + public _propertiesToo?: string; +} + +// +// hidden interface erasure +// if a class/interface uses a hidden (private/internal) interface as base, the base will +// be erased from the API +// + +interface IPrivateInterface { + private: string; +} + +export interface ExtendsInternalInterface extends IInternalInterface { + boom: boolean +} + +export class ImplementInternalInterface implements IInternalInterface { + prop = 'implement me' +} + +export class ImplementsPrivateInterface implements IPrivateInterface { + public private = 'i came from private into the light' +} + +export interface ExtendsPrivateInterface extends IPrivateInterface { + moreThings: string[]; +} diff --git a/packages/jsii-calc/test/assembly.jsii b/packages/jsii-calc/test/assembly.jsii index 1911171cc8..f8fb036c02 100644 --- a/packages/jsii-calc/test/assembly.jsii +++ b/packages/jsii-calc/test/assembly.jsii @@ -1478,6 +1478,43 @@ } ] }, + "jsii-calc.ExtendsInternalInterface": { + "assembly": "jsii-calc", + "datatype": true, + "fqn": "jsii-calc.ExtendsInternalInterface", + "kind": "interface", + "name": "ExtendsInternalInterface", + "properties": [ + { + "abstract": true, + "name": "boom", + "type": { + "primitive": "boolean" + } + } + ] + }, + "jsii-calc.ExtendsPrivateInterface": { + "assembly": "jsii-calc", + "datatype": true, + "fqn": "jsii-calc.ExtendsPrivateInterface", + "kind": "interface", + "name": "ExtendsPrivateInterface", + "properties": [ + { + "abstract": true, + "name": "moreThings", + "type": { + "collection": { + "elementtype": { + "primitive": "string" + }, + "kind": "array" + } + } + } + ] + }, "jsii-calc.GiveMeStructs": { "assembly": "jsii-calc", "fqn": "jsii-calc.GiveMeStructs", @@ -1649,6 +1686,18 @@ } ] }, + "jsii-calc.IInterfaceWithInternal": { + "assembly": "jsii-calc", + "fqn": "jsii-calc.IInterfaceWithInternal", + "kind": "interface", + "methods": [ + { + "abstract": true, + "name": "visible" + } + ], + "name": "IInterfaceWithInternal" + }, "jsii-calc.IInterfaceWithMethods": { "assembly": "jsii-calc", "fqn": "jsii-calc.IInterfaceWithMethods", @@ -1776,6 +1825,74 @@ } ] }, + "jsii-calc.ImplementInternalInterface": { + "assembly": "jsii-calc", + "fqn": "jsii-calc.ImplementInternalInterface", + "initializer": { + "initializer": true + }, + "kind": "class", + "name": "ImplementInternalInterface", + "properties": [ + { + "name": "prop", + "type": { + "primitive": "string" + } + } + ] + }, + "jsii-calc.ImplementsInterfaceWithInternal": { + "assembly": "jsii-calc", + "fqn": "jsii-calc.ImplementsInterfaceWithInternal", + "initializer": { + "initializer": true + }, + "interfaces": [ + { + "fqn": "jsii-calc.IInterfaceWithInternal" + } + ], + "kind": "class", + "methods": [ + { + "name": "visible", + "overrides": { + "fqn": "jsii-calc.IInterfaceWithInternal" + } + } + ], + "name": "ImplementsInterfaceWithInternal" + }, + "jsii-calc.ImplementsInterfaceWithInternalSubclass": { + "assembly": "jsii-calc", + "base": { + "fqn": "jsii-calc.ImplementsInterfaceWithInternal" + }, + "fqn": "jsii-calc.ImplementsInterfaceWithInternalSubclass", + "initializer": { + "initializer": true + }, + "kind": "class", + "name": "ImplementsInterfaceWithInternalSubclass" + }, + "jsii-calc.ImplementsPrivateInterface": { + "assembly": "jsii-calc", + "fqn": "jsii-calc.ImplementsPrivateInterface", + "initializer": { + "initializer": true + }, + "kind": "class", + "name": "ImplementsPrivateInterface", + "properties": [ + { + "name": "private", + "type": { + "primitive": "string" + } + } + ] + }, "jsii-calc.ImplictBaseOfBase": { "assembly": "jsii-calc", "datatype": true, @@ -3318,6 +3435,23 @@ ], "name": "StringEnum" }, + "jsii-calc.StripInternal": { + "assembly": "jsii-calc", + "fqn": "jsii-calc.StripInternal", + "initializer": { + "initializer": true + }, + "kind": "class", + "name": "StripInternal", + "properties": [ + { + "name": "youSeeMe", + "type": { + "primitive": "string" + } + } + ] + }, "jsii-calc.Sum": { "assembly": "jsii-calc", "base": { @@ -3949,5 +4083,5 @@ } }, "version": "0.7.15", - "fingerprint": "IWSOEhdZzuvrss5K2WBjZCawXayV13yCAKTj/kJ9+mo=" + "fingerprint": "iMxRj3lsHKNzSiBrjCyBH6Pp7Uvo+1Sxh/jN3hW+3nA=" } 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 1911171cc8..f8fb036c02 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 @@ -1478,6 +1478,43 @@ } ] }, + "jsii-calc.ExtendsInternalInterface": { + "assembly": "jsii-calc", + "datatype": true, + "fqn": "jsii-calc.ExtendsInternalInterface", + "kind": "interface", + "name": "ExtendsInternalInterface", + "properties": [ + { + "abstract": true, + "name": "boom", + "type": { + "primitive": "boolean" + } + } + ] + }, + "jsii-calc.ExtendsPrivateInterface": { + "assembly": "jsii-calc", + "datatype": true, + "fqn": "jsii-calc.ExtendsPrivateInterface", + "kind": "interface", + "name": "ExtendsPrivateInterface", + "properties": [ + { + "abstract": true, + "name": "moreThings", + "type": { + "collection": { + "elementtype": { + "primitive": "string" + }, + "kind": "array" + } + } + } + ] + }, "jsii-calc.GiveMeStructs": { "assembly": "jsii-calc", "fqn": "jsii-calc.GiveMeStructs", @@ -1649,6 +1686,18 @@ } ] }, + "jsii-calc.IInterfaceWithInternal": { + "assembly": "jsii-calc", + "fqn": "jsii-calc.IInterfaceWithInternal", + "kind": "interface", + "methods": [ + { + "abstract": true, + "name": "visible" + } + ], + "name": "IInterfaceWithInternal" + }, "jsii-calc.IInterfaceWithMethods": { "assembly": "jsii-calc", "fqn": "jsii-calc.IInterfaceWithMethods", @@ -1776,6 +1825,74 @@ } ] }, + "jsii-calc.ImplementInternalInterface": { + "assembly": "jsii-calc", + "fqn": "jsii-calc.ImplementInternalInterface", + "initializer": { + "initializer": true + }, + "kind": "class", + "name": "ImplementInternalInterface", + "properties": [ + { + "name": "prop", + "type": { + "primitive": "string" + } + } + ] + }, + "jsii-calc.ImplementsInterfaceWithInternal": { + "assembly": "jsii-calc", + "fqn": "jsii-calc.ImplementsInterfaceWithInternal", + "initializer": { + "initializer": true + }, + "interfaces": [ + { + "fqn": "jsii-calc.IInterfaceWithInternal" + } + ], + "kind": "class", + "methods": [ + { + "name": "visible", + "overrides": { + "fqn": "jsii-calc.IInterfaceWithInternal" + } + } + ], + "name": "ImplementsInterfaceWithInternal" + }, + "jsii-calc.ImplementsInterfaceWithInternalSubclass": { + "assembly": "jsii-calc", + "base": { + "fqn": "jsii-calc.ImplementsInterfaceWithInternal" + }, + "fqn": "jsii-calc.ImplementsInterfaceWithInternalSubclass", + "initializer": { + "initializer": true + }, + "kind": "class", + "name": "ImplementsInterfaceWithInternalSubclass" + }, + "jsii-calc.ImplementsPrivateInterface": { + "assembly": "jsii-calc", + "fqn": "jsii-calc.ImplementsPrivateInterface", + "initializer": { + "initializer": true + }, + "kind": "class", + "name": "ImplementsPrivateInterface", + "properties": [ + { + "name": "private", + "type": { + "primitive": "string" + } + } + ] + }, "jsii-calc.ImplictBaseOfBase": { "assembly": "jsii-calc", "datatype": true, @@ -3318,6 +3435,23 @@ ], "name": "StringEnum" }, + "jsii-calc.StripInternal": { + "assembly": "jsii-calc", + "fqn": "jsii-calc.StripInternal", + "initializer": { + "initializer": true + }, + "kind": "class", + "name": "StripInternal", + "properties": [ + { + "name": "youSeeMe", + "type": { + "primitive": "string" + } + } + ] + }, "jsii-calc.Sum": { "assembly": "jsii-calc", "base": { @@ -3949,5 +4083,5 @@ } }, "version": "0.7.15", - "fingerprint": "IWSOEhdZzuvrss5K2WBjZCawXayV13yCAKTj/kJ9+mo=" + "fingerprint": "iMxRj3lsHKNzSiBrjCyBH6Pp7Uvo+1Sxh/jN3hW+3nA=" } diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/ExtendsInternalInterface.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/ExtendsInternalInterface.cs new file mode 100644 index 0000000000..74f3685952 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/ExtendsInternalInterface.cs @@ -0,0 +1,14 @@ +using Amazon.JSII.Runtime.Deputy; + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + public class ExtendsInternalInterface : DeputyBase, IExtendsInternalInterface + { + [JsiiProperty("boom", "{\"primitive\":\"boolean\"}", true)] + public bool Boom + { + 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/ExtendsInternalInterfaceProxy.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/ExtendsInternalInterfaceProxy.cs new file mode 100644 index 0000000000..6d71d9c080 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/ExtendsInternalInterfaceProxy.cs @@ -0,0 +1,19 @@ +using Amazon.JSII.Runtime.Deputy; + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + [JsiiTypeProxy(typeof(IExtendsInternalInterface), "jsii-calc.ExtendsInternalInterface")] + internal sealed class ExtendsInternalInterfaceProxy : DeputyBase, IExtendsInternalInterface + { + private ExtendsInternalInterfaceProxy(ByRefValue reference): base(reference) + { + } + + [JsiiProperty("boom", "{\"primitive\":\"boolean\"}")] + public bool Boom + { + get => GetInstanceProperty(); + set => SetInstanceProperty(value); + } + } +} \ 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/ExtendsPrivateInterface.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/ExtendsPrivateInterface.cs new file mode 100644 index 0000000000..c8d579d155 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/ExtendsPrivateInterface.cs @@ -0,0 +1,14 @@ +using Amazon.JSII.Runtime.Deputy; + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + public class ExtendsPrivateInterface : DeputyBase, IExtendsPrivateInterface + { + [JsiiProperty("moreThings", "{\"collection\":{\"kind\":\"array\",\"elementtype\":{\"primitive\":\"string\"}}}", true)] + public string[] MoreThings + { + 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/ExtendsPrivateInterfaceProxy.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/ExtendsPrivateInterfaceProxy.cs new file mode 100644 index 0000000000..880c3d032f --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/ExtendsPrivateInterfaceProxy.cs @@ -0,0 +1,19 @@ +using Amazon.JSII.Runtime.Deputy; + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + [JsiiTypeProxy(typeof(IExtendsPrivateInterface), "jsii-calc.ExtendsPrivateInterface")] + internal sealed class ExtendsPrivateInterfaceProxy : DeputyBase, IExtendsPrivateInterface + { + private ExtendsPrivateInterfaceProxy(ByRefValue reference): base(reference) + { + } + + [JsiiProperty("moreThings", "{\"collection\":{\"kind\":\"array\",\"elementtype\":{\"primitive\":\"string\"}}}")] + public string[] MoreThings + { + get => GetInstanceProperty(); + set => SetInstanceProperty(value); + } + } +} \ 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/IExtendsInternalInterface.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IExtendsInternalInterface.cs new file mode 100644 index 0000000000..bb0f93d2e7 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IExtendsInternalInterface.cs @@ -0,0 +1,15 @@ +using Amazon.JSII.Runtime.Deputy; + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + [JsiiInterface(typeof(IExtendsInternalInterface), "jsii-calc.ExtendsInternalInterface")] + public interface IExtendsInternalInterface + { + [JsiiProperty("boom", "{\"primitive\":\"boolean\"}")] + bool Boom + { + 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/IExtendsPrivateInterface.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IExtendsPrivateInterface.cs new file mode 100644 index 0000000000..1916e235ab --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IExtendsPrivateInterface.cs @@ -0,0 +1,15 @@ +using Amazon.JSII.Runtime.Deputy; + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + [JsiiInterface(typeof(IExtendsPrivateInterface), "jsii-calc.ExtendsPrivateInterface")] + public interface IExtendsPrivateInterface + { + [JsiiProperty("moreThings", "{\"collection\":{\"kind\":\"array\",\"elementtype\":{\"primitive\":\"string\"}}}")] + string[] MoreThings + { + 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/IIInterfaceWithInternal.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IIInterfaceWithInternal.cs new file mode 100644 index 0000000000..88502b3fa0 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IIInterfaceWithInternal.cs @@ -0,0 +1,11 @@ +using Amazon.JSII.Runtime.Deputy; + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + [JsiiInterface(typeof(IIInterfaceWithInternal), "jsii-calc.IInterfaceWithInternal")] + public interface IIInterfaceWithInternal + { + [JsiiMethod("visible", null, "[]")] + void Visible(); + } +} \ 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/IInterfaceWithInternalProxy.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IInterfaceWithInternalProxy.cs new file mode 100644 index 0000000000..4284951359 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IInterfaceWithInternalProxy.cs @@ -0,0 +1,18 @@ +using Amazon.JSII.Runtime.Deputy; + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + [JsiiTypeProxy(typeof(IIInterfaceWithInternal), "jsii-calc.IInterfaceWithInternal")] + internal sealed class IInterfaceWithInternalProxy : DeputyBase, IIInterfaceWithInternal + { + private IInterfaceWithInternalProxy(ByRefValue reference): base(reference) + { + } + + [JsiiMethod("visible", null, "[]")] + public void Visible() + { + 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/ImplementInternalInterface.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/ImplementInternalInterface.cs new file mode 100644 index 0000000000..342e6c4f9a --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/ImplementInternalInterface.cs @@ -0,0 +1,27 @@ +using Amazon.JSII.Runtime.Deputy; + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + [JsiiClass(typeof(ImplementInternalInterface), "jsii-calc.ImplementInternalInterface", "[]")] + public class ImplementInternalInterface : DeputyBase + { + public ImplementInternalInterface(): base(new DeputyProps(new object[]{})) + { + } + + protected ImplementInternalInterface(ByRefValue reference): base(reference) + { + } + + protected ImplementInternalInterface(DeputyProps props): base(props) + { + } + + [JsiiProperty("prop", "{\"primitive\":\"string\"}")] + public virtual string Prop + { + get => GetInstanceProperty(); + set => SetInstanceProperty(value); + } + } +} \ 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/ImplementsInterfaceWithInternal.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/ImplementsInterfaceWithInternal.cs new file mode 100644 index 0000000000..1b783a8748 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/ImplementsInterfaceWithInternal.cs @@ -0,0 +1,26 @@ +using Amazon.JSII.Runtime.Deputy; + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + [JsiiClass(typeof(ImplementsInterfaceWithInternal), "jsii-calc.ImplementsInterfaceWithInternal", "[]")] + public class ImplementsInterfaceWithInternal : DeputyBase, IIInterfaceWithInternal + { + public ImplementsInterfaceWithInternal(): base(new DeputyProps(new object[]{})) + { + } + + protected ImplementsInterfaceWithInternal(ByRefValue reference): base(reference) + { + } + + protected ImplementsInterfaceWithInternal(DeputyProps props): base(props) + { + } + + [JsiiMethod("visible", null, "[]")] + public virtual void Visible() + { + 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/ImplementsInterfaceWithInternalSubclass.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/ImplementsInterfaceWithInternalSubclass.cs new file mode 100644 index 0000000000..9a86613908 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/ImplementsInterfaceWithInternalSubclass.cs @@ -0,0 +1,20 @@ +using Amazon.JSII.Runtime.Deputy; + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + [JsiiClass(typeof(ImplementsInterfaceWithInternalSubclass), "jsii-calc.ImplementsInterfaceWithInternalSubclass", "[]")] + public class ImplementsInterfaceWithInternalSubclass : ImplementsInterfaceWithInternal + { + public ImplementsInterfaceWithInternalSubclass(): base(new DeputyProps(new object[]{})) + { + } + + protected ImplementsInterfaceWithInternalSubclass(ByRefValue reference): base(reference) + { + } + + protected ImplementsInterfaceWithInternalSubclass(DeputyProps props): base(props) + { + } + } +} \ 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/ImplementsPrivateInterface.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/ImplementsPrivateInterface.cs new file mode 100644 index 0000000000..892ffa7339 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/ImplementsPrivateInterface.cs @@ -0,0 +1,27 @@ +using Amazon.JSII.Runtime.Deputy; + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + [JsiiClass(typeof(ImplementsPrivateInterface), "jsii-calc.ImplementsPrivateInterface", "[]")] + public class ImplementsPrivateInterface : DeputyBase + { + public ImplementsPrivateInterface(): base(new DeputyProps(new object[]{})) + { + } + + protected ImplementsPrivateInterface(ByRefValue reference): base(reference) + { + } + + protected ImplementsPrivateInterface(DeputyProps props): base(props) + { + } + + [JsiiProperty("private", "{\"primitive\":\"string\"}")] + public virtual string Private + { + get => GetInstanceProperty(); + set => SetInstanceProperty(value); + } + } +} \ 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/StripInternal.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/StripInternal.cs new file mode 100644 index 0000000000..3344d1dbb4 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/StripInternal.cs @@ -0,0 +1,27 @@ +using Amazon.JSII.Runtime.Deputy; + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + [JsiiClass(typeof(StripInternal), "jsii-calc.StripInternal", "[]")] + public class StripInternal : DeputyBase + { + public StripInternal(): base(new DeputyProps(new object[]{})) + { + } + + protected StripInternal(ByRefValue reference): base(reference) + { + } + + protected StripInternal(DeputyProps props): base(props) + { + } + + [JsiiProperty("youSeeMe", "{\"primitive\":\"string\"}")] + public virtual string YouSeeMe + { + get => GetInstanceProperty(); + set => SetInstanceProperty(value); + } + } +} \ No newline at end of file diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/jsii-calc-0.7.15.tgz b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/jsii-calc-0.7.15.tgz index ed86b811e5..eef7587bf2 100644 Binary files a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/jsii-calc-0.7.15.tgz and b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/jsii-calc-0.7.15.tgz differ 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 09aa4177c1..9ce60725e4 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 @@ -42,17 +42,24 @@ protected Class resolveClass(final String fqn) throws ClassNotFoundException case "jsii-calc.DontComplainAboutVariadicAfterOptional": return software.amazon.jsii.tests.calculator.DontComplainAboutVariadicAfterOptional.class; case "jsii-calc.DoubleTrouble": return software.amazon.jsii.tests.calculator.DoubleTrouble.class; case "jsii-calc.ExportedBaseClass": return software.amazon.jsii.tests.calculator.ExportedBaseClass.class; + case "jsii-calc.ExtendsInternalInterface": return software.amazon.jsii.tests.calculator.ExtendsInternalInterface.class; + case "jsii-calc.ExtendsPrivateInterface": return software.amazon.jsii.tests.calculator.ExtendsPrivateInterface.class; case "jsii-calc.GiveMeStructs": return software.amazon.jsii.tests.calculator.GiveMeStructs.class; case "jsii-calc.GreetingAugmenter": return software.amazon.jsii.tests.calculator.GreetingAugmenter.class; case "jsii-calc.IFriendlier": return software.amazon.jsii.tests.calculator.IFriendlier.class; case "jsii-calc.IFriendlyRandomGenerator": return software.amazon.jsii.tests.calculator.IFriendlyRandomGenerator.class; case "jsii-calc.IInterfaceThatShouldNotBeADataType": return software.amazon.jsii.tests.calculator.IInterfaceThatShouldNotBeADataType.class; + case "jsii-calc.IInterfaceWithInternal": return software.amazon.jsii.tests.calculator.IInterfaceWithInternal.class; case "jsii-calc.IInterfaceWithMethods": return software.amazon.jsii.tests.calculator.IInterfaceWithMethods.class; case "jsii-calc.IInterfaceWithOptionalMethodArguments": return software.amazon.jsii.tests.calculator.IInterfaceWithOptionalMethodArguments.class; case "jsii-calc.IPrivatelyImplemented": return software.amazon.jsii.tests.calculator.IPrivatelyImplemented.class; case "jsii-calc.IPublicInterface": return software.amazon.jsii.tests.calculator.IPublicInterface.class; case "jsii-calc.IRandomNumberGenerator": return software.amazon.jsii.tests.calculator.IRandomNumberGenerator.class; case "jsii-calc.IReturnsNumber": return software.amazon.jsii.tests.calculator.IReturnsNumber.class; + case "jsii-calc.ImplementInternalInterface": return software.amazon.jsii.tests.calculator.ImplementInternalInterface.class; + case "jsii-calc.ImplementsInterfaceWithInternal": return software.amazon.jsii.tests.calculator.ImplementsInterfaceWithInternal.class; + case "jsii-calc.ImplementsInterfaceWithInternalSubclass": return software.amazon.jsii.tests.calculator.ImplementsInterfaceWithInternalSubclass.class; + case "jsii-calc.ImplementsPrivateInterface": return software.amazon.jsii.tests.calculator.ImplementsPrivateInterface.class; case "jsii-calc.ImplictBaseOfBase": return software.amazon.jsii.tests.calculator.ImplictBaseOfBase.class; case "jsii-calc.InbetweenClass": return software.amazon.jsii.tests.calculator.InbetweenClass.class; case "jsii-calc.InterfaceImplementedByAbstractClass": return software.amazon.jsii.tests.calculator.InterfaceImplementedByAbstractClass.class; @@ -86,6 +93,7 @@ protected Class resolveClass(final String fqn) throws ClassNotFoundException case "jsii-calc.RuntimeTypeChecking": return software.amazon.jsii.tests.calculator.RuntimeTypeChecking.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; case "jsii-calc.Sum": return software.amazon.jsii.tests.calculator.Sum.class; case "jsii-calc.SyncVirtualMethods": return software.amazon.jsii.tests.calculator.SyncVirtualMethods.class; case "jsii-calc.Thrower": return software.amazon.jsii.tests.calculator.Thrower.class; diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/ExtendsInternalInterface.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/ExtendsInternalInterface.java new file mode 100644 index 0000000000..d93a72c5cd --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/ExtendsInternalInterface.java @@ -0,0 +1,72 @@ +package software.amazon.jsii.tests.calculator; + +@javax.annotation.Generated(value = "jsii-pacmak") +public interface ExtendsInternalInterface extends software.amazon.jsii.JsiiSerializable { + java.lang.Boolean getBoom(); + void setBoom(final java.lang.Boolean value); + + /** + * @return a {@link Builder} of {@link ExtendsInternalInterface} + */ + static Builder builder() { + return new Builder(); + } + + /** + * A builder for {@link ExtendsInternalInterface} + */ + final class Builder { + private java.lang.Boolean _boom; + + /** + * Sets the value of Boom + * @param value the value to be set + * @return {@code this} + */ + public Builder withBoom(final java.lang.Boolean value) { + this._boom = java.util.Objects.requireNonNull(value, "boom is required"); + return this; + } + + /** + * Builds the configured instance. + * @return a new instance of {@link ExtendsInternalInterface} + * @throws NullPointerException if any required attribute was not provided + */ + public ExtendsInternalInterface build() { + return new ExtendsInternalInterface() { + private java.lang.Boolean $boom = java.util.Objects.requireNonNull(_boom, "boom is required"); + + @Override + public java.lang.Boolean getBoom() { + return this.$boom; + } + + @Override + public void setBoom(final java.lang.Boolean value) { + this.$boom = java.util.Objects.requireNonNull(value, "boom is required"); + } + + }; + } + } + + /** + * 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.ExtendsInternalInterface { + protected Jsii$Proxy(final software.amazon.jsii.JsiiObject.InitializationMode mode) { + super(mode); + } + + @Override + public java.lang.Boolean getBoom() { + return this.jsiiGet("boom", java.lang.Boolean.class); + } + + @Override + public void setBoom(final java.lang.Boolean value) { + this.jsiiSet("boom", java.util.Objects.requireNonNull(value, "boom is required")); + } + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/ExtendsPrivateInterface.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/ExtendsPrivateInterface.java new file mode 100644 index 0000000000..2da0756139 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/ExtendsPrivateInterface.java @@ -0,0 +1,72 @@ +package software.amazon.jsii.tests.calculator; + +@javax.annotation.Generated(value = "jsii-pacmak") +public interface ExtendsPrivateInterface extends software.amazon.jsii.JsiiSerializable { + java.util.List getMoreThings(); + void setMoreThings(final java.util.List value); + + /** + * @return a {@link Builder} of {@link ExtendsPrivateInterface} + */ + static Builder builder() { + return new Builder(); + } + + /** + * A builder for {@link ExtendsPrivateInterface} + */ + final class Builder { + private java.util.List _moreThings; + + /** + * Sets the value of MoreThings + * @param value the value to be set + * @return {@code this} + */ + public Builder withMoreThings(final java.util.List value) { + this._moreThings = java.util.Objects.requireNonNull(value, "moreThings is required"); + return this; + } + + /** + * Builds the configured instance. + * @return a new instance of {@link ExtendsPrivateInterface} + * @throws NullPointerException if any required attribute was not provided + */ + public ExtendsPrivateInterface build() { + return new ExtendsPrivateInterface() { + private java.util.List $moreThings = java.util.Objects.requireNonNull(_moreThings, "moreThings is required"); + + @Override + public java.util.List getMoreThings() { + return this.$moreThings; + } + + @Override + public void setMoreThings(final java.util.List value) { + this.$moreThings = java.util.Objects.requireNonNull(value, "moreThings is required"); + } + + }; + } + } + + /** + * 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.ExtendsPrivateInterface { + protected Jsii$Proxy(final software.amazon.jsii.JsiiObject.InitializationMode mode) { + super(mode); + } + + @Override + public java.util.List getMoreThings() { + return this.jsiiGet("moreThings", java.util.List.class); + } + + @Override + public void setMoreThings(final java.util.List value) { + this.jsiiSet("moreThings", java.util.Objects.requireNonNull(value, "moreThings is required")); + } + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/IInterfaceWithInternal.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/IInterfaceWithInternal.java new file mode 100644 index 0000000000..dff686d28a --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/IInterfaceWithInternal.java @@ -0,0 +1,20 @@ +package software.amazon.jsii.tests.calculator; + +@javax.annotation.Generated(value = "jsii-pacmak") +public interface IInterfaceWithInternal extends software.amazon.jsii.JsiiSerializable { + void visible(); + + /** + * 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.IInterfaceWithInternal { + protected Jsii$Proxy(final software.amazon.jsii.JsiiObject.InitializationMode mode) { + super(mode); + } + + @Override + public void visible() { + this.jsiiCall("visible", Void.class); + } + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/ImplementInternalInterface.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/ImplementInternalInterface.java new file mode 100644 index 0000000000..fe714d34c3 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/ImplementInternalInterface.java @@ -0,0 +1,21 @@ +package software.amazon.jsii.tests.calculator; + +@javax.annotation.Generated(value = "jsii-pacmak") +@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.ImplementInternalInterface") +public class ImplementInternalInterface extends software.amazon.jsii.JsiiObject { + protected ImplementInternalInterface(final software.amazon.jsii.JsiiObject.InitializationMode mode) { + super(mode); + } + public ImplementInternalInterface() { + super(software.amazon.jsii.JsiiObject.InitializationMode.Jsii); + software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this); + } + + public java.lang.String getProp() { + return this.jsiiGet("prop", java.lang.String.class); + } + + public void setProp(final java.lang.String value) { + this.jsiiSet("prop", java.util.Objects.requireNonNull(value, "prop is required")); + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/ImplementsInterfaceWithInternal.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/ImplementsInterfaceWithInternal.java new file mode 100644 index 0000000000..118c2d2a28 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/ImplementsInterfaceWithInternal.java @@ -0,0 +1,18 @@ +package software.amazon.jsii.tests.calculator; + +@javax.annotation.Generated(value = "jsii-pacmak") +@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.ImplementsInterfaceWithInternal") +public class ImplementsInterfaceWithInternal extends software.amazon.jsii.JsiiObject implements software.amazon.jsii.tests.calculator.IInterfaceWithInternal { + protected ImplementsInterfaceWithInternal(final software.amazon.jsii.JsiiObject.InitializationMode mode) { + super(mode); + } + public ImplementsInterfaceWithInternal() { + super(software.amazon.jsii.JsiiObject.InitializationMode.Jsii); + software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this); + } + + @Override + public void visible() { + this.jsiiCall("visible", Void.class); + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/ImplementsInterfaceWithInternalSubclass.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/ImplementsInterfaceWithInternalSubclass.java new file mode 100644 index 0000000000..692993f251 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/ImplementsInterfaceWithInternalSubclass.java @@ -0,0 +1,13 @@ +package software.amazon.jsii.tests.calculator; + +@javax.annotation.Generated(value = "jsii-pacmak") +@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.ImplementsInterfaceWithInternalSubclass") +public class ImplementsInterfaceWithInternalSubclass extends software.amazon.jsii.tests.calculator.ImplementsInterfaceWithInternal { + protected ImplementsInterfaceWithInternalSubclass(final software.amazon.jsii.JsiiObject.InitializationMode mode) { + super(mode); + } + public ImplementsInterfaceWithInternalSubclass() { + super(software.amazon.jsii.JsiiObject.InitializationMode.Jsii); + software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this); + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/ImplementsPrivateInterface.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/ImplementsPrivateInterface.java new file mode 100644 index 0000000000..c8f13c3480 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/ImplementsPrivateInterface.java @@ -0,0 +1,21 @@ +package software.amazon.jsii.tests.calculator; + +@javax.annotation.Generated(value = "jsii-pacmak") +@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.ImplementsPrivateInterface") +public class ImplementsPrivateInterface extends software.amazon.jsii.JsiiObject { + protected ImplementsPrivateInterface(final software.amazon.jsii.JsiiObject.InitializationMode mode) { + super(mode); + } + public ImplementsPrivateInterface() { + super(software.amazon.jsii.JsiiObject.InitializationMode.Jsii); + software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this); + } + + public java.lang.String getPrivate() { + return this.jsiiGet("private", java.lang.String.class); + } + + public void setPrivate(final java.lang.String value) { + this.jsiiSet("private", java.util.Objects.requireNonNull(value, "private is required")); + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/StripInternal.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/StripInternal.java new file mode 100644 index 0000000000..c58cffea3b --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/StripInternal.java @@ -0,0 +1,21 @@ +package software.amazon.jsii.tests.calculator; + +@javax.annotation.Generated(value = "jsii-pacmak") +@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.StripInternal") +public class StripInternal extends software.amazon.jsii.JsiiObject { + protected StripInternal(final software.amazon.jsii.JsiiObject.InitializationMode mode) { + super(mode); + } + public StripInternal() { + super(software.amazon.jsii.JsiiObject.InitializationMode.Jsii); + software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this); + } + + public java.lang.String getYouSeeMe() { + return this.jsiiGet("youSeeMe", java.lang.String.class); + } + + public void setYouSeeMe(final java.lang.String value) { + this.jsiiSet("youSeeMe", java.util.Objects.requireNonNull(value, "youSeeMe is required")); + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/resources/software/amazon/jsii/tests/calculator/jsii-calc@0.7.15.jsii.tgz b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/resources/software/amazon/jsii/tests/calculator/jsii-calc@0.7.15.jsii.tgz index ed86b811e5..eef7587bf2 100644 Binary files a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/resources/software/amazon/jsii/tests/calculator/jsii-calc@0.7.15.jsii.tgz and b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/resources/software/amazon/jsii/tests/calculator/jsii-calc@0.7.15.jsii.tgz differ diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/js/jsii-calc@0.7.15.jsii.tgz b/packages/jsii-pacmak/test/expected.jsii-calc/js/jsii-calc@0.7.15.jsii.tgz index ed86b811e5..eef7587bf2 100644 Binary files a/packages/jsii-pacmak/test/expected.jsii-calc/js/jsii-calc@0.7.15.jsii.tgz and b/packages/jsii-pacmak/test/expected.jsii-calc/js/jsii-calc@0.7.15.jsii.tgz differ 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 79ad16e900..966a35d5cf 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 @@ -1615,6 +1615,74 @@ ExportedBaseClass :type: boolean *(readonly)* +ExtendsInternalInterface (interface) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. py:class:: ExtendsInternalInterface + + **Language-specific names:** + + .. tabs:: + + .. code-tab:: c# + + using Amazon.JSII.Tests.CalculatorNamespace; + + .. code-tab:: java + + import software.amazon.jsii.tests.calculator.ExtendsInternalInterface; + + .. code-tab:: javascript + + // ExtendsInternalInterface is an interface + + .. code-tab:: typescript + + import { ExtendsInternalInterface } from 'jsii-calc'; + + + + + + .. py:attribute:: boom + + :type: boolean + + +ExtendsPrivateInterface (interface) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. py:class:: ExtendsPrivateInterface + + **Language-specific names:** + + .. tabs:: + + .. code-tab:: c# + + using Amazon.JSII.Tests.CalculatorNamespace; + + .. code-tab:: java + + import software.amazon.jsii.tests.calculator.ExtendsPrivateInterface; + + .. code-tab:: javascript + + // ExtendsPrivateInterface is an interface + + .. code-tab:: typescript + + import { ExtendsPrivateInterface } from 'jsii-calc'; + + + + + + .. py:attribute:: moreThings + + :type: string[] + + GiveMeStructs ^^^^^^^^^^^^^ @@ -1894,6 +1962,40 @@ IInterfaceThatShouldNotBeADataType (interface) :type: string *(readonly)* +IInterfaceWithInternal (interface) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. py:class:: IInterfaceWithInternal + + **Language-specific names:** + + .. tabs:: + + .. code-tab:: c# + + using Amazon.JSII.Tests.CalculatorNamespace; + + .. code-tab:: java + + import software.amazon.jsii.tests.calculator.IInterfaceWithInternal; + + .. code-tab:: javascript + + // IInterfaceWithInternal is an interface + + .. code-tab:: typescript + + import { IInterfaceWithInternal } from 'jsii-calc'; + + + + + + .. py:method:: visible() + + :abstract: Yes + + IInterfaceWithMethods (interface) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -2129,6 +2231,142 @@ IReturnsNumber (interface) :abstract: Yes +ImplementInternalInterface +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. py:class:: ImplementInternalInterface() + + **Language-specific names:** + + .. tabs:: + + .. code-tab:: c# + + using Amazon.JSII.Tests.CalculatorNamespace; + + .. code-tab:: java + + import software.amazon.jsii.tests.calculator.ImplementInternalInterface; + + .. code-tab:: javascript + + const { ImplementInternalInterface } = require('jsii-calc'); + + .. code-tab:: typescript + + import { ImplementInternalInterface } from 'jsii-calc'; + + + + + .. py:attribute:: prop + + :type: string + + +ImplementsInterfaceWithInternal +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. py:class:: ImplementsInterfaceWithInternal() + + **Language-specific names:** + + .. tabs:: + + .. code-tab:: c# + + using Amazon.JSII.Tests.CalculatorNamespace; + + .. code-tab:: java + + import software.amazon.jsii.tests.calculator.ImplementsInterfaceWithInternal; + + .. code-tab:: javascript + + const { ImplementsInterfaceWithInternal } = require('jsii-calc'); + + .. code-tab:: typescript + + import { ImplementsInterfaceWithInternal } from 'jsii-calc'; + + + + :implements: :py:class:`~jsii-calc.IInterfaceWithInternal`\ + + .. py:method:: visible() + + *Implements* :py:meth:`jsii-calc.IInterfaceWithInternal.visible` + + + +ImplementsInterfaceWithInternalSubclass +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. py:class:: ImplementsInterfaceWithInternalSubclass() + + **Language-specific names:** + + .. tabs:: + + .. code-tab:: c# + + using Amazon.JSII.Tests.CalculatorNamespace; + + .. code-tab:: java + + import software.amazon.jsii.tests.calculator.ImplementsInterfaceWithInternalSubclass; + + .. code-tab:: javascript + + const { ImplementsInterfaceWithInternalSubclass } = require('jsii-calc'); + + .. code-tab:: typescript + + import { ImplementsInterfaceWithInternalSubclass } from 'jsii-calc'; + + + + :extends: :py:class:`~jsii-calc.ImplementsInterfaceWithInternal`\ + + .. py:method:: visible() + + *Inherited from* :py:meth:`jsii-calc.ImplementsInterfaceWithInternal ` + + + +ImplementsPrivateInterface +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. py:class:: ImplementsPrivateInterface() + + **Language-specific names:** + + .. tabs:: + + .. code-tab:: c# + + using Amazon.JSII.Tests.CalculatorNamespace; + + .. code-tab:: java + + import software.amazon.jsii.tests.calculator.ImplementsPrivateInterface; + + .. code-tab:: javascript + + const { ImplementsPrivateInterface } = require('jsii-calc'); + + .. code-tab:: typescript + + import { ImplementsPrivateInterface } from 'jsii-calc'; + + + + + .. py:attribute:: private + + :type: string + + ImplictBaseOfBase (interface) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -4243,6 +4481,39 @@ StringEnum (enum) .. py:data:: C +StripInternal +^^^^^^^^^^^^^ + +.. py:class:: StripInternal() + + **Language-specific names:** + + .. tabs:: + + .. code-tab:: c# + + using Amazon.JSII.Tests.CalculatorNamespace; + + .. code-tab:: java + + import software.amazon.jsii.tests.calculator.StripInternal; + + .. code-tab:: javascript + + const { StripInternal } = require('jsii-calc'); + + .. code-tab:: typescript + + import { StripInternal } from 'jsii-calc'; + + + + + .. py:attribute:: youSeeMe + + :type: string + + Sum ^^^ diff --git a/packages/jsii-reflect/test/classes.expected.txt b/packages/jsii-reflect/test/classes.expected.txt index 4723146f5c..d6388b6515 100644 --- a/packages/jsii-reflect/test/classes.expected.txt +++ b/packages/jsii-reflect/test/classes.expected.txt @@ -24,6 +24,10 @@ ExportedBaseClass Foo GiveMeStructs GreetingAugmenter +ImplementInternalInterface +ImplementsInterfaceWithInternal +ImplementsInterfaceWithInternalSubclass +ImplementsPrivateInterface InbetweenClass JSObjectLiteralForInterface JSObjectLiteralToNative @@ -48,6 +52,7 @@ ReferenceEnumFromScopedPackage ReturnsPrivateImplementationOfInterface RuntimeTypeChecking Statics +StripInternal Sum SyncVirtualMethods Thrower 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 51c230e60e..493633803f 100644 --- a/packages/jsii-reflect/test/jsii-tree.test.all.expected.txt +++ b/packages/jsii-reflect/test/jsii-tree.test.all.expected.txt @@ -375,6 +375,30 @@ assemblies │ │ │ └─┬ friendly │ │ │ └── type: interface:@scope/jsii-calc-lib.IFriendly │ │ └── returns: primitive:string + │ ├─┬ class ImplementInternalInterface + │ │ └─┬ members + │ │ ├─┬ () method + │ │ │ └── returns: void + │ │ └─┬ prop property + │ │ └── type: primitive:string + │ ├─┬ class ImplementsInterfaceWithInternal + │ │ ├── interfaces: IInterfaceWithInternal + │ │ └─┬ members + │ │ ├─┬ () method + │ │ │ └── returns: void + │ │ └─┬ visible() method + │ │ └── returns: void + │ ├─┬ class ImplementsInterfaceWithInternalSubclass + │ │ ├── base: ImplementsInterfaceWithInternal + │ │ └─┬ members + │ │ └─┬ () method + │ │ └── returns: void + │ ├─┬ class ImplementsPrivateInterface + │ │ └─┬ members + │ │ ├─┬ () method + │ │ │ └── returns: void + │ │ └─┬ private property + │ │ └── type: primitive:string │ ├─┬ class InbetweenClass │ │ ├── base: PublicClass │ │ └─┬ members @@ -856,6 +880,12 @@ assemblies │ │ └─┬ value property │ │ ├── immutable │ │ └── type: primitive:string + │ ├─┬ class StripInternal + │ │ └─┬ members + │ │ ├─┬ () method + │ │ │ └── returns: void + │ │ └─┬ youSeeMe property + │ │ └── type: primitive:string │ ├─┬ class Sum │ │ ├── base: CompositeOperation │ │ └─┬ members @@ -1063,6 +1093,16 @@ assemblies │ │ └─┬ optionalArray property │ │ ├── abstract │ │ └── type: Array + │ ├─┬ interface ExtendsInternalInterface + │ │ └─┬ members + │ │ └─┬ boom property + │ │ ├── abstract + │ │ └── type: primitive:boolean + │ ├─┬ interface ExtendsPrivateInterface + │ │ └─┬ members + │ │ └─┬ moreThings property + │ │ ├── abstract + │ │ └── type: Array │ ├─┬ interface IFriendlier │ │ ├─┬ interfaces │ │ │ └── IFriendly @@ -1086,6 +1126,11 @@ assemblies │ │ ├── abstract │ │ ├── immutable │ │ └── type: primitive:string + │ ├─┬ interface IInterfaceWithInternal + │ │ └─┬ members + │ │ └─┬ visible() method + │ │ ├── abstract + │ │ └── returns: void │ ├─┬ interface IInterfaceWithMethods │ │ └─┬ members │ │ ├─┬ doThings() method 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 f65536e262..5ed60d75ad 100644 --- a/packages/jsii-reflect/test/jsii-tree.test.inheritance.expected.txt +++ b/packages/jsii-reflect/test/jsii-tree.test.inheritance.expected.txt @@ -33,6 +33,12 @@ assemblies │ ├── class ExportedBaseClass │ ├── class GiveMeStructs │ ├── class GreetingAugmenter + │ ├── class ImplementInternalInterface + │ ├─┬ class ImplementsInterfaceWithInternal + │ │ └── interfaces: IInterfaceWithInternal + │ ├─┬ class ImplementsInterfaceWithInternalSubclass + │ │ └── base: ImplementsInterfaceWithInternal + │ ├── class ImplementsPrivateInterface │ ├─┬ class InbetweenClass │ │ └── base: PublicClass │ ├── class Foo @@ -62,6 +68,7 @@ assemblies │ ├── class ReturnsPrivateImplementationOfInterface │ ├── class RuntimeTypeChecking │ ├── class Statics + │ ├── class StripInternal │ ├─┬ class Sum │ │ └── base: CompositeOperation │ ├── class SyncVirtualMethods @@ -79,6 +86,8 @@ assemblies │ ├─┬ interface DerivedStruct │ │ └─┬ interfaces │ │ └── MyFirstStruct + │ ├── interface ExtendsInternalInterface + │ ├── interface ExtendsPrivateInterface │ ├─┬ interface IFriendlier │ │ └─┬ interfaces │ │ └── IFriendly @@ -89,6 +98,7 @@ assemblies │ ├─┬ interface IInterfaceThatShouldNotBeADataType │ │ └─┬ interfaces │ │ └── IInterfaceWithMethods + │ ├── interface IInterfaceWithInternal │ ├── interface IInterfaceWithMethods │ ├── interface IInterfaceWithOptionalMethodArguments │ ├── interface IPrivatelyImplemented 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 2dc70c18fc..4b12ae297a 100644 --- a/packages/jsii-reflect/test/jsii-tree.test.members.expected.txt +++ b/packages/jsii-reflect/test/jsii-tree.test.members.expected.txt @@ -147,6 +147,21 @@ assemblies │ │ └─┬ members │ │ ├── () method │ │ └── betterGreeting(friendly) method + │ ├─┬ class ImplementInternalInterface + │ │ └─┬ members + │ │ ├── () method + │ │ └── prop property + │ ├─┬ class ImplementsInterfaceWithInternal + │ │ └─┬ members + │ │ ├── () method + │ │ └── visible() method + │ ├─┬ class ImplementsInterfaceWithInternalSubclass + │ │ └─┬ members + │ │ └── () method + │ ├─┬ class ImplementsPrivateInterface + │ │ └─┬ members + │ │ ├── () method + │ │ └── private property │ ├─┬ class InbetweenClass │ │ └─┬ members │ │ └── () method @@ -356,6 +371,10 @@ assemblies │ │ ├── instance property │ │ ├── nonConstStatic property │ │ └── value property + │ ├─┬ class StripInternal + │ │ └─┬ members + │ │ ├── () method + │ │ └── youSeeMe property │ ├─┬ class Sum │ │ └─┬ members │ │ ├── () method @@ -436,6 +455,12 @@ assemblies │ │ ├── anotherOptional property │ │ ├── optionalAny property │ │ └── optionalArray property + │ ├─┬ interface ExtendsInternalInterface + │ │ └─┬ members + │ │ └── boom property + │ ├─┬ interface ExtendsPrivateInterface + │ │ └─┬ members + │ │ └── moreThings property │ ├─┬ interface IFriendlier │ │ └─┬ members │ │ ├── farewell() method @@ -445,6 +470,9 @@ assemblies │ ├─┬ interface IInterfaceThatShouldNotBeADataType │ │ └─┬ members │ │ └── otherValue property + │ ├─┬ interface IInterfaceWithInternal + │ │ └─┬ members + │ │ └── visible() method │ ├─┬ interface IInterfaceWithMethods │ │ └─┬ members │ │ ├── doThings() method 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 674648f02a..3caad51496 100644 --- a/packages/jsii-reflect/test/jsii-tree.test.types.expected.txt +++ b/packages/jsii-reflect/test/jsii-tree.test.types.expected.txt @@ -24,6 +24,10 @@ assemblies │ ├── class ExportedBaseClass │ ├── class GiveMeStructs │ ├── class GreetingAugmenter + │ ├── class ImplementInternalInterface + │ ├── class ImplementsInterfaceWithInternal + │ ├── class ImplementsInterfaceWithInternalSubclass + │ ├── class ImplementsPrivateInterface │ ├── class InbetweenClass │ ├── class Foo │ ├── class JSObjectLiteralForInterface @@ -47,6 +51,7 @@ assemblies │ ├── class ReturnsPrivateImplementationOfInterface │ ├── class RuntimeTypeChecking │ ├── class Statics + │ ├── class StripInternal │ ├── class Sum │ ├── class SyncVirtualMethods │ ├── class Thrower @@ -59,9 +64,12 @@ assemblies │ ├── class CompositeOperation │ ├── interface CalculatorProps │ ├── interface DerivedStruct + │ ├── interface ExtendsInternalInterface + │ ├── interface ExtendsPrivateInterface │ ├── interface IFriendlier │ ├── interface IFriendlyRandomGenerator │ ├── interface IInterfaceThatShouldNotBeADataType + │ ├── interface IInterfaceWithInternal │ ├── interface IInterfaceWithMethods │ ├── interface IInterfaceWithOptionalMethodArguments │ ├── interface IPrivatelyImplemented diff --git a/packages/jsii/lib/assembler.ts b/packages/jsii/lib/assembler.ts index 860df41f21..7bceb52b66 100644 --- a/packages/jsii/lib/assembler.ts +++ b/packages/jsii/lib/assembler.ts @@ -11,7 +11,7 @@ import { Diagnostic, Emitter } from './emitter'; import literate = require('./literate'); import { ProjectInfo } from './project-info'; import utils = require('./utils'); -import { Validator } from './validator'; +import { Validator } from './validator'; // tslint:disable:no-var-requires Modules without TypeScript definitions const sortJson = require('sort-json'); @@ -337,11 +337,15 @@ export class Assembler implements Emitter { return [jsiiType]; } - private async _visitClass(type: ts.Type, namespace: string[]): Promise { + private async _visitClass(type: ts.Type, namespace: string[]): Promise { if (LOG.isTraceEnabled()) { LOG.trace(`Processing class: ${colors.gray(namespace.join('.'))}.${colors.cyan(type.symbol.name)}`); } + if (_hasInternalJsDocTag(type.symbol)) { + return undefined; + } + const fqn = `${[this.projectInfo.name, ...namespace].join('.')}.${type.symbol.name}`; const jsiiType: spec.ClassType = { @@ -360,7 +364,9 @@ export class Assembler implements Emitter { this._diagnostic(base.symbol.valueDeclaration, ts.DiagnosticCategory.Error, `Found multiple base types for ${jsiiType.fqn}`); continue; } + const ref = await this._typeReference(base, type.symbol.valueDeclaration); + if (!spec.isNamedTypeReference(ref)) { this._diagnostic(base.symbol.valueDeclaration, ts.DiagnosticCategory.Error, @@ -384,15 +390,25 @@ export class Assembler implements Emitter { this._diagnostic(clause, ts.DiagnosticCategory.Error, `Ignoring ${ts.SyntaxKind[clause.token]} heritage clause`); continue; } + for (const expression of clause.types) { const iface = this._typeChecker.getTypeFromTypeNode(expression); + + // if this interface is internal/private, we erase it from the API definition + if (this._isPrivateOrInternal(iface.symbol)) { + LOG.trace(`erasing hidden interface ${iface.symbol.name}`); + continue; + } + const typeRef = await this._typeReference(iface, iface.symbol.valueDeclaration); + if (!spec.isNamedTypeReference(typeRef)) { this._diagnostic(expression, ts.DiagnosticCategory.Error, `Interface of ${jsiiType.fqn} is not a named type (${spec.describeTypeReference(typeRef)})`); continue; } + this._deferUntilTypesAvailable(fqn, [typeRef], expression, (deref) => { if (!spec.isInterfaceType(deref)) { this._diagnostic(expression, @@ -400,11 +416,9 @@ export class Assembler implements Emitter { `Implements clause of ${jsiiType.fqn} uses ${spec.describeTypeReference(typeRef)} as an interface`); } }); - if (jsiiType.interfaces) { - jsiiType.interfaces.push(typeRef); - } else { - jsiiType.interfaces = [typeRef]; - } + + jsiiType.interfaces = jsiiType.interfaces || []; + jsiiType.interfaces.push(typeRef); } } @@ -418,8 +432,20 @@ export class Assembler implements Emitter { for (const memberDecl of classDecl.members) { const member: ts.Symbol = (memberDecl as any).symbol; - if (!(type.symbol.getDeclarations() || []).find(d => d === memberDecl.parent)) { continue; } - if (_isHidden(member)) { continue; } + + if (!(type.symbol.getDeclarations() || []).find(d => d === memberDecl.parent)) { + continue; + } + + if (this._isPrivateOrInternal(member, memberDecl)) { + continue; + } + + // constructors are handled later + if (ts.isConstructorDeclaration(memberDecl)) { + continue; + } + if (ts.isMethodDeclaration(memberDecl) || ts.isMethodSignature(memberDecl)) { await this._visitMethod(member, jsiiType); } else if (ts.isPropertyDeclaration(memberDecl) @@ -479,11 +505,47 @@ export class Assembler implements Emitter { return _sortMembers(this._visitDocumentation(type.symbol, jsiiType)); } - private async _visitEnum(type: ts.Type, namespace: string[]): Promise { + /** + * @returns true if this member is internal and should be omitted from the type manifest + */ + private _isPrivateOrInternal(symbol: ts.Symbol, validateDeclaration?: ts.Declaration): boolean { + const hasInternalJsDocTag = _hasInternalJsDocTag(symbol); + const hasUnderscorePrefix = symbol.name !== '__constructor' && symbol.name.startsWith('_'); + + if (_isPrivate(symbol)) { + LOG.trace(`skipping ${symbol.name} because it is marked "private"`); + return true; + } + + if (!hasInternalJsDocTag && !hasUnderscorePrefix) { + return false; + } + + // we only validate if we have a declaration + if (validateDeclaration) { + if (!hasUnderscorePrefix) { + this._diagnostic(validateDeclaration, ts.DiagnosticCategory.Error, + `${symbol.name}: the name of members marked as @internal must begin with an underscore`); + } + + if (!hasInternalJsDocTag) { + this._diagnostic(validateDeclaration, ts.DiagnosticCategory.Error, + `${symbol.name}: members with names that begin with an underscore must be marked as @internal via a JSDoc tag`); + } + } + + return true; + } + + private async _visitEnum(type: ts.Type, namespace: string[]): Promise { if (LOG.isTraceEnabled()) { LOG.trace(`Processing enum: ${colors.gray(namespace.join('.'))}.${colors.cyan(type.symbol.name)}`); } + if (_hasInternalJsDocTag(type.symbol)) { + return undefined; + } + const decl = type.symbol.valueDeclaration; const flags = ts.getCombinedModifierFlags(decl); // tslint:disable-next-line:no-bitwise @@ -553,11 +615,15 @@ export class Assembler implements Emitter { } } - private async _visitInterface(type: ts.Type, namespace: string[]): Promise { + private async _visitInterface(type: ts.Type, namespace: string[]): Promise { if (LOG.isTraceEnabled()) { LOG.trace(`Processing interface: ${colors.gray(namespace.join('.'))}.${colors.cyan(type.symbol.name)}`); } + if (_hasInternalJsDocTag(type.symbol)) { + return undefined; + } + const fqn = `${[this.projectInfo.name, ...namespace].join('.')}.${type.symbol.name}`; const jsiiType: spec.InterfaceType = { @@ -569,13 +635,21 @@ export class Assembler implements Emitter { }; for (const base of (type.getBaseTypes() || [])) { + // if this interface is internal/private, we erase it from the API definition + if (this._isPrivateOrInternal(base.symbol)) { + LOG.trace(`erasing hidden interface ${base.symbol.name}`); + continue; + } + const ref = await this._typeReference(base, type.symbol.valueDeclaration); + if (!spec.isNamedTypeReference(ref)) { this._diagnostic(base.symbol.valueDeclaration, ts.DiagnosticCategory.Error, `Base type of ${jsiiType.fqn} is not a named type (${spec.describeTypeReference(ref)})`); continue; } + this._deferUntilTypesAvailable(fqn, [ref], base.symbol.valueDeclaration, (baseType) => { if (!spec.isInterfaceType(baseType)) { // tslint:disable:max-line-length @@ -585,15 +659,17 @@ export class Assembler implements Emitter { // tslint:enable:max-line-length } }); - if (jsiiType.interfaces) { - jsiiType.interfaces.push(ref); - } else { - jsiiType.interfaces = [ref]; - } + + jsiiType.interfaces = jsiiType.interfaces || []; + jsiiType.interfaces.push(ref); } for (const member of type.getProperties()) { if (!(type.symbol.getDeclarations() || []).find(decl => decl === member.valueDeclaration.parent)) { continue; } - if (_isHidden(member)) { continue; } + + if (this._isPrivateOrInternal(member, member.valueDeclaration)) { + continue; + } + if (ts.isMethodDeclaration(member.valueDeclaration) || ts.isMethodSignature(member.valueDeclaration)) { await this._visitMethod(member, jsiiType); } else if (ts.isPropertyDeclaration(member.valueDeclaration) @@ -723,6 +799,7 @@ export class Assembler implements Emitter { */ return; } + if (LOG.isTraceEnabled()) { LOG.trace(`Processing property: ${colors.green(type.fqn)}#${colors.cyan(symbol.name)}`); } @@ -1051,17 +1128,34 @@ function _isExported(node: ts.Declaration): boolean { } /** - * Members with names starting with ``_`` and members that are private are hidden. + * Members with names starting with `_` (and marked as @internal) and members + * that are private are hidden. * * @param symbol the symbol which should be assessed * - * @return ``true`` if the symbol should be hidden + * @return `true` if the symbol should be hidden */ -function _isHidden(symbol: ts.Symbol): boolean { - return !symbol.valueDeclaration - || symbol.name.startsWith('_') - // tslint:disable-next-line:no-bitwise - || (ts.getCombinedModifierFlags(symbol.valueDeclaration) & ts.ModifierFlags.Private) !== 0; +function _isPrivate(symbol: ts.Symbol): boolean { + + // if the symbol doesn't have a value declaration, we are assuming it's a type (enum/interface/class) + // and check that it has an "export" modifier + if (!symbol.valueDeclaration) { + let hasExport = false; + for (const decl of symbol.declarations) { + // tslint:disable-next-line:no-bitwise + if (ts.getCombinedModifierFlags(decl) & ts.ModifierFlags.Export) { + hasExport = true; + } + } + return !hasExport; + } + + // tslint:disable-next-line:no-bitwise + return symbol.valueDeclaration && (ts.getCombinedModifierFlags(symbol.valueDeclaration) & ts.ModifierFlags.Private) !== 0; +} + +function _hasInternalJsDocTag(symbol: ts.Symbol) { + return symbol.getJsDocTags().some((t: any) => t.name === 'internal'); } function _isProtected(symbol: ts.Symbol): boolean { diff --git a/packages/jsii/lib/compiler.ts b/packages/jsii/lib/compiler.ts index ce0a409115..83e8cfa2ca 100644 --- a/packages/jsii/lib/compiler.ts +++ b/packages/jsii/lib/compiler.ts @@ -29,6 +29,7 @@ const COMPILER_OPTIONS: ts.CompilerOptions = { strict: true, strictNullChecks: true, strictPropertyInitialization: false, + stripInternal: true, target: ts.ScriptTarget.ES2018 }; diff --git a/packages/jsii/test/negatives/neg.internal-underscore-class.5.ts b/packages/jsii/test/negatives/neg.internal-underscore-class.5.ts new file mode 100644 index 0000000000..f6e220556c --- /dev/null +++ b/packages/jsii/test/negatives/neg.internal-underscore-class.5.ts @@ -0,0 +1,6 @@ +///!MATCH_ERROR: the name of members marked as @internal must begin with an underscore + +export class MyClass { + /** @internal */ + public propertyWithInternalButNotUnderscorePrefix?: string; +} diff --git a/packages/jsii/test/negatives/neg.internal-underscore-class.6.ts b/packages/jsii/test/negatives/neg.internal-underscore-class.6.ts new file mode 100644 index 0000000000..0f96a89f5e --- /dev/null +++ b/packages/jsii/test/negatives/neg.internal-underscore-class.6.ts @@ -0,0 +1,5 @@ +///!MATCH_ERROR: members with names that begin with an underscore must be marked as @internal via a JSDoc tag + +export class MyClass { + public _propertyWithUnderscoreButNoInternal?: string; +} diff --git a/packages/jsii/test/negatives/neg.internal-underscore-class.7.ts b/packages/jsii/test/negatives/neg.internal-underscore-class.7.ts new file mode 100644 index 0000000000..43f4ecb8eb --- /dev/null +++ b/packages/jsii/test/negatives/neg.internal-underscore-class.7.ts @@ -0,0 +1,6 @@ +///!MATCH_ERROR: the name of members marked as @internal must begin with an underscore + +export class MyClass { + /** @internal */ + public methodWithInternalButNoUnderscore(): string { return 'hi'; } +} diff --git a/packages/jsii/test/negatives/neg.internal-underscore-class.8.ts b/packages/jsii/test/negatives/neg.internal-underscore-class.8.ts new file mode 100644 index 0000000000..e7b5afd433 --- /dev/null +++ b/packages/jsii/test/negatives/neg.internal-underscore-class.8.ts @@ -0,0 +1,5 @@ +///!MATCH_ERROR: members with names that begin with an underscore must be marked as @internal via a JSDoc tag + +export interface IMyInterface { + _methodWithUnderscoreButNoInternal(); +} diff --git a/packages/jsii/test/negatives/neg.internal-underscore-interface.1.ts b/packages/jsii/test/negatives/neg.internal-underscore-interface.1.ts new file mode 100644 index 0000000000..9edd58ae90 --- /dev/null +++ b/packages/jsii/test/negatives/neg.internal-underscore-interface.1.ts @@ -0,0 +1,6 @@ +///!MATCH_ERROR: the name of members marked as @internal must begin with an underscore + +export interface IMyInterface { + /** @internal */ + propertyWithInternalButNotUnderscorePrefix: string; +} diff --git a/packages/jsii/test/negatives/neg.internal-underscore-interface.2.ts b/packages/jsii/test/negatives/neg.internal-underscore-interface.2.ts new file mode 100644 index 0000000000..f025d1d9b1 --- /dev/null +++ b/packages/jsii/test/negatives/neg.internal-underscore-interface.2.ts @@ -0,0 +1,5 @@ +///!MATCH_ERROR: members with names that begin with an underscore must be marked as @internal via a JSDoc tag + +export interface IMyInterface { + _propertyWithUnderscoreButNoInternal: string; +} diff --git a/packages/jsii/test/negatives/neg.internal-underscore-interface.3.ts b/packages/jsii/test/negatives/neg.internal-underscore-interface.3.ts new file mode 100644 index 0000000000..62a744501c --- /dev/null +++ b/packages/jsii/test/negatives/neg.internal-underscore-interface.3.ts @@ -0,0 +1,6 @@ +///!MATCH_ERROR: the name of members marked as @internal must begin with an underscore + +export interface IMyInterface { + /** @internal */ + methodWithInternalButNoUnderscore(): string; +} diff --git a/packages/jsii/test/negatives/neg.internal-underscore-interface.4.ts b/packages/jsii/test/negatives/neg.internal-underscore-interface.4.ts new file mode 100644 index 0000000000..8d33518242 --- /dev/null +++ b/packages/jsii/test/negatives/neg.internal-underscore-interface.4.ts @@ -0,0 +1,7 @@ +///!MATCH_ERROR: members with names that begin with an underscore must be marked as @internal via a JSDoc tag + +export class MyClass { + public _methodWithUnderscoreButNoInternal() { + return; + } +}