-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When generating java proxy classes for interfaces, make sure to create an overload for methods that include optional arguments.
- Loading branch information
Elad Ben-Israel
committed
Sep 5, 2018
1 parent
b3c05f5
commit 7125e67
Showing
9 changed files
with
160 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...rPackageId/Amazon/JSII/Tests/CalculatorNamespace/IInterfaceWithOptionalMethodArguments.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using Amazon.JSII.Runtime.Deputy; | ||
|
||
namespace Amazon.JSII.Tests.CalculatorNamespace | ||
{ | ||
/// <summary> | ||
/// awslabs/jsii#175 | ||
/// Interface proxies (and builders) do not respect optional arguments in methods | ||
/// </summary> | ||
[JsiiInterface(typeof(IInterfaceWithOptionalMethodArguments), "jsii-calc.InterfaceWithOptionalMethodArguments")] | ||
public interface IInterfaceWithOptionalMethodArguments | ||
{ | ||
[JsiiMethod("hello", null, "[{\"name\":\"arg1\",\"type\":{\"primitive\":\"string\"}},{\"name\":\"arg2\",\"type\":{\"primitive\":\"number\",\"optional\":true}}]")] | ||
void Hello(string arg1, double? arg2); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...kageId/Amazon/JSII/Tests/CalculatorNamespace/InterfaceWithOptionalMethodArgumentsProxy.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Amazon.JSII.Runtime.Deputy; | ||
|
||
namespace Amazon.JSII.Tests.CalculatorNamespace | ||
{ | ||
/// <summary> | ||
/// awslabs/jsii#175 | ||
/// Interface proxies (and builders) do not respect optional arguments in methods | ||
/// </summary> | ||
[JsiiInterfaceProxy(typeof(IInterfaceWithOptionalMethodArguments), "jsii-calc.InterfaceWithOptionalMethodArguments")] | ||
internal class InterfaceWithOptionalMethodArgumentsProxy : DeputyBase, IInterfaceWithOptionalMethodArguments | ||
{ | ||
private InterfaceWithOptionalMethodArgumentsProxy(ByRefValue reference): base(reference) | ||
{ | ||
} | ||
|
||
[JsiiMethod("hello", null, "[{\"name\":\"arg1\",\"type\":{\"primitive\":\"string\"}},{\"name\":\"arg2\",\"type\":{\"primitive\":\"number\",\"optional\":true}}]")] | ||
public virtual void Hello(string arg1, double? arg2) | ||
{ | ||
InvokeInstanceVoidMethod(new object[]{arg1, arg2}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...main/java/software/amazon/jsii/tests/calculator/InterfaceWithOptionalMethodArguments.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package software.amazon.jsii.tests.calculator; | ||
|
||
/** | ||
* awslabs/jsii#175 | ||
* Interface proxies (and builders) do not respect optional arguments in methods | ||
*/ | ||
@javax.annotation.Generated(value = "jsii-pacmak") | ||
public interface InterfaceWithOptionalMethodArguments extends software.amazon.jsii.JsiiSerializable { | ||
void hello(final java.lang.String arg1, @javax.annotation.Nullable final java.lang.Number arg2); | ||
void hello(final java.lang.String arg1); | ||
|
||
/** | ||
* 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.InterfaceWithOptionalMethodArguments { | ||
protected Jsii$Proxy(final software.amazon.jsii.JsiiObject.InitializationMode mode) { | ||
super(mode); | ||
} | ||
|
||
@Override | ||
public void hello(final java.lang.String arg1, @javax.annotation.Nullable final java.lang.Number arg2) { | ||
this.jsiiCall("hello", Void.class, java.util.stream.Stream.concat(java.util.stream.Stream.of(java.util.Objects.requireNonNull(arg1, "arg1 is required")), java.util.stream.Stream.of(arg2)).toArray()); | ||
} | ||
|
||
@Override | ||
public void hello(final java.lang.String arg1) { | ||
this.jsiiCall("hello", Void.class, java.util.stream.Stream.of(java.util.Objects.requireNonNull(arg1, "arg1 is required")).toArray()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters