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: Missing types in JSII assembly, invalid Java code, confusing docs #208

Merged
merged 10 commits into from
Sep 5, 2018
Prev Previous commit
Next Next commit
Add coverage for interface in namespace
And fix a bug which failed complication if
a namespace contained /only/ an interface.
Elad Ben-Israel committed Sep 5, 2018
commit 1175bffbcae8be578ca2a4eeb6ccbaec11bfcd98
24 changes: 24 additions & 0 deletions packages/jsii-calc/lib/compliance.ts
Original file line number Diff line number Diff line change
@@ -782,3 +782,27 @@ export class ReferenceEnumFromScopedPackage {
this.foo = value;
}
}

/**
* awslabs/jsii#208
* Interface within a namespace
*/
export namespace InterfaceInNamespaceOnlyInterface {

// it's a special case when only an interface is exported from a namespace
export interface Hello {
foo: number
}

}

export namespace InterfaceInNamespaceIncludesClasses {

export class Foo {
public bar?: string;
}

export interface Hello {
foo: number
}
}
Original file line number Diff line number Diff line change
@@ -1244,6 +1244,57 @@
}
]
},
"jsii-calc.InterfaceInNamespaceIncludesClasses.Foo": {
"assembly": "jsii-calc",
"fqn": "jsii-calc.InterfaceInNamespaceIncludesClasses.Foo",
"initializer": {
"initializer": true
},
"kind": "class",
"name": "Foo",
"namespace": "InterfaceInNamespaceIncludesClasses",
"properties": [
{
"name": "bar",
"type": {
"optional": true,
"primitive": "string"
}
}
]
},
"jsii-calc.InterfaceInNamespaceIncludesClasses.Hello": {
"assembly": "jsii-calc",
"datatype": true,
"fqn": "jsii-calc.InterfaceInNamespaceIncludesClasses.Hello",
"kind": "interface",
"name": "Hello",
"namespace": "InterfaceInNamespaceIncludesClasses",
"properties": [
{
"name": "foo",
"type": {
"primitive": "number"
}
}
]
},
"jsii-calc.InterfaceInNamespaceOnlyInterface.Hello": {
"assembly": "jsii-calc",
"datatype": true,
"fqn": "jsii-calc.InterfaceInNamespaceOnlyInterface.Hello",
"kind": "interface",
"name": "Hello",
"namespace": "InterfaceInNamespaceOnlyInterface",
"properties": [
{
"name": "foo",
"type": {
"primitive": "number"
}
}
]
},
"jsii-calc.JSObjectLiteralForInterface": {
"assembly": "jsii-calc",
"fqn": "jsii-calc.JSObjectLiteralForInterface",
@@ -2844,5 +2895,5 @@
}
},
"version": "0.7.1",
"fingerprint": "xRKsZzmRl0yM7EYcHnUbf691eFzAupWFIvCbEqWcUuA="
"fingerprint": "kLi/5UqkB6zGOVxj7UcMCVnDhIx51fN9Fo9aNKDHqPY="
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Amazon.JSII.Runtime.Deputy;

namespace Amazon.JSII.Tests.CalculatorNamespace.InterfaceInNamespaceIncludesClasses
{
[JsiiClass(typeof(Foo), "jsii-calc.InterfaceInNamespaceIncludesClasses.Foo", "[]")]
public class Foo : DeputyBase
{
public Foo(): base(new DeputyProps(new object[]{}))
{
}

protected Foo(ByRefValue reference): base(reference)
{
}

protected Foo(DeputyProps props): base(props)
{
}

[JsiiProperty("bar", "{\"primitive\":\"string\",\"optional\":true}")]
public virtual string Bar
{
get => GetInstanceProperty<string>();
set => SetInstanceProperty(value);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Amazon.JSII.Runtime.Deputy;

namespace Amazon.JSII.Tests.CalculatorNamespace.InterfaceInNamespaceIncludesClasses
{
public class Hello : DeputyBase, Amazon.JSII.Tests.CalculatorNamespace.InterfaceInNamespaceIncludesClasses.IHello
{
[JsiiProperty("foo", "{\"primitive\":\"number\"}", true)]
public double Foo
{
get;
set;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Amazon.JSII.Runtime.Deputy;

namespace Amazon.JSII.Tests.CalculatorNamespace.InterfaceInNamespaceIncludesClasses
{
[JsiiInterfaceProxy(typeof(IHello), "jsii-calc.InterfaceInNamespaceIncludesClasses.Hello")]
internal class HelloProxy : DeputyBase, Amazon.JSII.Tests.CalculatorNamespace.InterfaceInNamespaceIncludesClasses.IHello
{
private HelloProxy(ByRefValue reference): base(reference)
{
}

[JsiiProperty("foo", "{\"primitive\":\"number\"}")]
public virtual double Foo
{
get => GetInstanceProperty<double>();
set => SetInstanceProperty(value);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Amazon.JSII.Runtime.Deputy;

namespace Amazon.JSII.Tests.CalculatorNamespace.InterfaceInNamespaceIncludesClasses
{
[JsiiInterface(typeof(IHello), "jsii-calc.InterfaceInNamespaceIncludesClasses.Hello")]
public interface IHello
{
[JsiiProperty("foo", "{\"primitive\":\"number\"}")]
double Foo
{
get;
set;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Amazon.JSII.Runtime.Deputy;

namespace Amazon.JSII.Tests.CalculatorNamespace.InterfaceInNamespaceOnlyInterface
{
public class Hello : DeputyBase, Amazon.JSII.Tests.CalculatorNamespace.InterfaceInNamespaceOnlyInterface.IHello
{
[JsiiProperty("foo", "{\"primitive\":\"number\"}", true)]
public double Foo
{
get;
set;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Amazon.JSII.Runtime.Deputy;

namespace Amazon.JSII.Tests.CalculatorNamespace.InterfaceInNamespaceOnlyInterface
{
[JsiiInterfaceProxy(typeof(IHello), "jsii-calc.InterfaceInNamespaceOnlyInterface.Hello")]
internal class HelloProxy : DeputyBase, Amazon.JSII.Tests.CalculatorNamespace.InterfaceInNamespaceOnlyInterface.IHello
{
private HelloProxy(ByRefValue reference): base(reference)
{
}

[JsiiProperty("foo", "{\"primitive\":\"number\"}")]
public virtual double Foo
{
get => GetInstanceProperty<double>();
set => SetInstanceProperty(value);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Amazon.JSII.Runtime.Deputy;

namespace Amazon.JSII.Tests.CalculatorNamespace.InterfaceInNamespaceOnlyInterface
{
[JsiiInterface(typeof(IHello), "jsii-calc.InterfaceInNamespaceOnlyInterface.Hello")]
public interface IHello
{
[JsiiProperty("foo", "{\"primitive\":\"number\"}")]
double Foo
{
get;
set;
}
}
}
Original file line number Diff line number Diff line change
@@ -37,6 +37,9 @@ protected Class<?> resolveClass(final String fqn) throws ClassNotFoundException
case "jsii-calc.IInterfaceWithPropertiesExtension": return software.amazon.jsii.tests.calculator.IInterfaceWithPropertiesExtension.class;
case "jsii-calc.IRandomNumberGenerator": return software.amazon.jsii.tests.calculator.IRandomNumberGenerator.class;
case "jsii-calc.ImplictBaseOfBase": return software.amazon.jsii.tests.calculator.ImplictBaseOfBase.class;
case "jsii-calc.InterfaceInNamespaceIncludesClasses.Foo": return software.amazon.jsii.tests.calculator.InterfaceInNamespaceIncludesClasses.Foo.class;
case "jsii-calc.InterfaceInNamespaceIncludesClasses.Hello": return software.amazon.jsii.tests.calculator.InterfaceInNamespaceIncludesClasses.Hello.class;
case "jsii-calc.InterfaceInNamespaceOnlyInterface.Hello": return software.amazon.jsii.tests.calculator.InterfaceInNamespaceOnlyInterface.Hello.class;
case "jsii-calc.JSObjectLiteralForInterface": return software.amazon.jsii.tests.calculator.JSObjectLiteralForInterface.class;
case "jsii-calc.JSObjectLiteralToNative": return software.amazon.jsii.tests.calculator.JSObjectLiteralToNative.class;
case "jsii-calc.JSObjectLiteralToNativeClass": return software.amazon.jsii.tests.calculator.JSObjectLiteralToNativeClass.class;
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package software.amazon.jsii.tests.calculator.InterfaceInNamespaceIncludesClasses;

@javax.annotation.Generated(value = "jsii-pacmak")
@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.InterfaceInNamespaceIncludesClasses.Foo")
public class Foo extends software.amazon.jsii.JsiiObject {
protected Foo(final software.amazon.jsii.JsiiObject.InitializationMode mode) {
super(mode);
}
public Foo() {
super(software.amazon.jsii.JsiiObject.InitializationMode.Jsii);
software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this);
}

@javax.annotation.Nullable
public java.lang.String getBar() {
return this.jsiiGet("bar", java.lang.String.class);
}

public void setBar(@javax.annotation.Nullable final java.lang.String value) {
this.jsiiSet("bar", value);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package software.amazon.jsii.tests.calculator.InterfaceInNamespaceIncludesClasses;

@javax.annotation.Generated(value = "jsii-pacmak")
public interface Hello extends software.amazon.jsii.JsiiSerializable {
java.lang.Number getFoo();
void setFoo(final java.lang.Number value);

/**
* @return a {@link Builder} of {@link Hello}
*/
static Builder builder() {
return new Builder();
}

/**
* A builder for {@link Hello}
*/
final class Builder {
private java.lang.Number _foo;

/**
* Sets the value of Foo
* @param value the value to be set
* @return {@code this}
*/
public Builder withFoo(final java.lang.Number value) {
this._foo = java.util.Objects.requireNonNull(value, "foo is required");
return this;
}

/**
* Builds the configured instance.
* @return a new instance of {@link Hello}
* @throws NullPointerException if any required attribute was not provided
*/
public Hello build() {
return new Hello() {
private java.lang.Number $foo = java.util.Objects.requireNonNull(_foo, "foo is required");

@Override
public java.lang.Number getFoo() {
return this.$foo;
}

@Override
public void setFoo(final java.lang.Number value) {
this.$foo = java.util.Objects.requireNonNull(value, "foo is required");
}

};
}
}

/**
* A proxy class which for javascript object literal which adhere to this interface.
*/
final class Jsii$Proxy extends software.amazon.jsii.JsiiObject implements software.amazon.jsii.tests.calculator.InterfaceInNamespaceIncludesClasses.Hello {
protected Jsii$Proxy(final software.amazon.jsii.JsiiObject.InitializationMode mode) {
super(mode);
}

@Override
public java.lang.Number getFoo() {
return this.jsiiGet("foo", java.lang.Number.class);
}

@Override
public void setFoo(final java.lang.Number value) {
this.jsiiSet("foo", java.util.Objects.requireNonNull(value, "foo is required"));
}
}
}
Loading