Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(jsii): use base interfaces for 'datatype' property #265

Merged
merged 3 commits into from
Oct 16, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions packages/jsii-calc/lib/compliance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -922,3 +922,16 @@ export class ClassWithPrivateConstructorAndAutomaticProperties implements IInter
private constructor(public readonly readOnlyString: string, public readWriteString: string) {
}
}

export interface IInterfaceWithMethods {
readonly value: string;
doThings(): void;
}

/**
* Even though this interface has only properties, it is disqualified from being a datatype
* because it inherits from an interface that is not a datatype.
*/
export interface IInterfaceThatShouldNotBeADataType extends IInterfaceWithMethods {
readonly otherValue: string;
}
48 changes: 47 additions & 1 deletion packages/jsii-calc/test/assembly.jsii
Original file line number Diff line number Diff line change
Expand Up @@ -1429,6 +1429,52 @@
"kind": "interface",
"name": "IFriendlyRandomGenerator"
},
"jsii-calc.IInterfaceThatShouldNotBeADataType": {
"assembly": "jsii-calc",
"docs": {
"comment": "Even though this interface has only properties, it is disqualified from being a datatype\nbecause it inherits from an interface that is not a datatype."
},
"fqn": "jsii-calc.IInterfaceThatShouldNotBeADataType",
"interfaces": [
{
"fqn": "jsii-calc.IInterfaceWithMethods"
}
],
"kind": "interface",
"name": "IInterfaceThatShouldNotBeADataType",
"properties": [
{
"abstract": true,
"immutable": true,
"name": "otherValue",
"type": {
"primitive": "string"
}
}
]
},
"jsii-calc.IInterfaceWithMethods": {
"assembly": "jsii-calc",
"fqn": "jsii-calc.IInterfaceWithMethods",
"kind": "interface",
"methods": [
{
"abstract": true,
"name": "doThings"
}
],
"name": "IInterfaceWithMethods",
"properties": [
{
"abstract": true,
"immutable": true,
"name": "value",
"type": {
"primitive": "string"
}
}
]
},
"jsii-calc.IInterfaceWithProperties": {
"assembly": "jsii-calc",
"datatype": true,
Expand Down Expand Up @@ -3332,5 +3378,5 @@
}
},
"version": "0.7.7",
"fingerprint": "SMX3FQtN8x0lUjxLt3hL50eC+4BhUchNcGPOAxkO9Xw="
"fingerprint": "bxhDOTLZBrkP11/RKcB3NDECWyzz3uPDRFgQXpHtrc0="
}
Original file line number Diff line number Diff line change
Expand Up @@ -1429,6 +1429,52 @@
"kind": "interface",
"name": "IFriendlyRandomGenerator"
},
"jsii-calc.IInterfaceThatShouldNotBeADataType": {
"assembly": "jsii-calc",
"docs": {
"comment": "Even though this interface has only properties, it is disqualified from being a datatype\nbecause it inherits from an interface that is not a datatype."
},
"fqn": "jsii-calc.IInterfaceThatShouldNotBeADataType",
"interfaces": [
{
"fqn": "jsii-calc.IInterfaceWithMethods"
}
],
"kind": "interface",
"name": "IInterfaceThatShouldNotBeADataType",
"properties": [
{
"abstract": true,
"immutable": true,
"name": "otherValue",
"type": {
"primitive": "string"
}
}
]
},
"jsii-calc.IInterfaceWithMethods": {
"assembly": "jsii-calc",
"fqn": "jsii-calc.IInterfaceWithMethods",
"kind": "interface",
"methods": [
{
"abstract": true,
"name": "doThings"
}
],
"name": "IInterfaceWithMethods",
"properties": [
{
"abstract": true,
"immutable": true,
"name": "value",
"type": {
"primitive": "string"
}
}
]
},
"jsii-calc.IInterfaceWithProperties": {
"assembly": "jsii-calc",
"datatype": true,
Expand Down Expand Up @@ -3332,5 +3378,5 @@
}
},
"version": "0.7.7",
"fingerprint": "SMX3FQtN8x0lUjxLt3hL50eC+4BhUchNcGPOAxkO9Xw="
"fingerprint": "bxhDOTLZBrkP11/RKcB3NDECWyzz3uPDRFgQXpHtrc0="
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Amazon.JSII.Runtime.Deputy;

namespace Amazon.JSII.Tests.CalculatorNamespace
{
/// <summary>
/// Even though this interface has only properties, it is disqualified from being a datatype
/// because it inherits from an interface that is not a datatype.
/// </summary>
[JsiiInterface(typeof(IIInterfaceThatShouldNotBeADataType), "jsii-calc.IInterfaceThatShouldNotBeADataType")]
public interface IIInterfaceThatShouldNotBeADataType : IIInterfaceWithMethods
{
[JsiiProperty("otherValue", "{\"primitive\":\"string\"}")]
string OtherValue
{
get;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Amazon.JSII.Runtime.Deputy;

namespace Amazon.JSII.Tests.CalculatorNamespace
{
[JsiiInterface(typeof(IIInterfaceWithMethods), "jsii-calc.IInterfaceWithMethods")]
public interface IIInterfaceWithMethods
{
[JsiiProperty("value", "{\"primitive\":\"string\"}")]
string Value
{
get;
}

[JsiiMethod("doThings", null, "[]")]
void DoThings();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Amazon.JSII.Runtime.Deputy;

namespace Amazon.JSII.Tests.CalculatorNamespace
{
/// <summary>
/// Even though this interface has only properties, it is disqualified from being a datatype
/// because it inherits from an interface that is not a datatype.
/// </summary>
[JsiiTypeProxy(typeof(IIInterfaceThatShouldNotBeADataType), "jsii-calc.IInterfaceThatShouldNotBeADataType")]
internal sealed class IInterfaceThatShouldNotBeADataTypeProxy : DeputyBase, IIInterfaceThatShouldNotBeADataType
{
private IInterfaceThatShouldNotBeADataTypeProxy(ByRefValue reference): base(reference)
{
}

[JsiiProperty("otherValue", "{\"primitive\":\"string\"}")]
public string OtherValue
{
get => GetInstanceProperty<string>();
}

[JsiiProperty("value", "{\"primitive\":\"string\"}")]
public string Value
{
get => GetInstanceProperty<string>();
}

[JsiiMethod("doThings", null, "[]")]
public void DoThings()
{
InvokeInstanceVoidMethod(new object[]{});
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Amazon.JSII.Runtime.Deputy;

namespace Amazon.JSII.Tests.CalculatorNamespace
{
[JsiiTypeProxy(typeof(IIInterfaceWithMethods), "jsii-calc.IInterfaceWithMethods")]
internal sealed class IInterfaceWithMethodsProxy : DeputyBase, IIInterfaceWithMethods
{
private IInterfaceWithMethodsProxy(ByRefValue reference): base(reference)
{
}

[JsiiProperty("value", "{\"primitive\":\"string\"}")]
public string Value
{
get => GetInstanceProperty<string>();
}

[JsiiMethod("doThings", null, "[]")]
public void DoThings()
{
InvokeInstanceVoidMethod(new object[]{});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ protected Class<?> resolveClass(final String fqn) throws ClassNotFoundException
case "jsii-calc.GiveMeStructs": return software.amazon.jsii.tests.calculator.GiveMeStructs.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.IInterfaceWithMethods": return software.amazon.jsii.tests.calculator.IInterfaceWithMethods.class;
case "jsii-calc.IInterfaceWithProperties": return software.amazon.jsii.tests.calculator.IInterfaceWithProperties.class;
case "jsii-calc.IInterfaceWithPropertiesExtension": return software.amazon.jsii.tests.calculator.IInterfaceWithPropertiesExtension.class;
case "jsii-calc.IRandomNumberGenerator": return software.amazon.jsii.tests.calculator.IRandomNumberGenerator.class;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package software.amazon.jsii.tests.calculator;

/**
* Even though this interface has only properties, it is disqualified from being a datatype
* because it inherits from an interface that is not a datatype.
*/
@javax.annotation.Generated(value = "jsii-pacmak")
public interface IInterfaceThatShouldNotBeADataType extends software.amazon.jsii.JsiiSerializable, software.amazon.jsii.tests.calculator.IInterfaceWithMethods {
java.lang.String getOtherValue();

/**
* 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.IInterfaceThatShouldNotBeADataType {
protected Jsii$Proxy(final software.amazon.jsii.JsiiObject.InitializationMode mode) {
super(mode);
}

@Override
public java.lang.String getOtherValue() {
return this.jsiiGet("otherValue", java.lang.String.class);
}

@Override
public java.lang.String getValue() {
return this.jsiiGet("value", java.lang.String.class);
}

@Override
public void doThings() {
this.jsiiCall("doThings", Void.class);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package software.amazon.jsii.tests.calculator;

@javax.annotation.Generated(value = "jsii-pacmak")
public interface IInterfaceWithMethods extends software.amazon.jsii.JsiiSerializable {
java.lang.String getValue();
void doThings();

/**
* 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.IInterfaceWithMethods {
protected Jsii$Proxy(final software.amazon.jsii.JsiiObject.InitializationMode mode) {
super(mode);
}

@Override
public java.lang.String getValue() {
return this.jsiiGet("value", java.lang.String.class);
}

@Override
public void doThings() {
this.jsiiCall("doThings", Void.class);
}
}
}
Loading