-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(kernel): Return object literals as references (#249)
Use the javascript `Proxy` class to coalesce object literals to an interface type, allowing them to be returned by reference instead of by value. Introduces a test in the `jsii-kernel` to demonstrate the feature works as intended. Fixes #248 Fixes aws/aws-cdk#774
- Loading branch information
1 parent
96ac5d6
commit 61cb3a4
Showing
17 changed files
with
517 additions
and
11 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
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
27 changes: 27 additions & 0 deletions
27
...rPackageId/Amazon/JSII/Tests/CalculatorNamespace/ClassWithMutableObjectLiteralProperty.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,27 @@ | ||
using Amazon.JSII.Runtime.Deputy; | ||
|
||
namespace Amazon.JSII.Tests.CalculatorNamespace | ||
{ | ||
[JsiiClass(typeof(ClassWithMutableObjectLiteralProperty), "jsii-calc.ClassWithMutableObjectLiteralProperty", "[]")] | ||
public class ClassWithMutableObjectLiteralProperty : DeputyBase | ||
{ | ||
public ClassWithMutableObjectLiteralProperty(): base(new DeputyProps(new object[]{})) | ||
{ | ||
} | ||
|
||
protected ClassWithMutableObjectLiteralProperty(ByRefValue reference): base(reference) | ||
{ | ||
} | ||
|
||
protected ClassWithMutableObjectLiteralProperty(DeputyProps props): base(props) | ||
{ | ||
} | ||
|
||
[JsiiProperty("mutableObject", "{\"fqn\":\"jsii-calc.MutableObjectLiteral\"}")] | ||
public virtual IMutableObjectLiteral MutableObject | ||
{ | ||
get => GetInstanceProperty<IMutableObjectLiteral>(); | ||
set => SetInstanceProperty(value); | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
....Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IMutableObjectLiteral.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 | ||
{ | ||
[JsiiInterface(typeof(IMutableObjectLiteral), "jsii-calc.MutableObjectLiteral")] | ||
public interface IMutableObjectLiteral | ||
{ | ||
[JsiiProperty("value", "{\"primitive\":\"string\"}")] | ||
string Value | ||
{ | ||
get; | ||
set; | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...I.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/MutableObjectLiteral.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,14 @@ | ||
using Amazon.JSII.Runtime.Deputy; | ||
|
||
namespace Amazon.JSII.Tests.CalculatorNamespace | ||
{ | ||
public class MutableObjectLiteral : DeputyBase, IMutableObjectLiteral | ||
{ | ||
[JsiiProperty("value", "{\"primitive\":\"string\"}", true)] | ||
public string Value | ||
{ | ||
get; | ||
set; | ||
} | ||
} | ||
} |
Oops, something went wrong.