-
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.
fix(kernel): cannot pass decorated structs as "any"
When a struct is serialized with a $jsii.struct decoration from a jsii host language and passed into a value typed `any`, the kernel ignored the decoration. This resulted in a malformed object passed to the javascript code. This fix undecorates the object and continues to deserialize it as `any`. Fixes aws/aws-cdk#5066
- Loading branch information
Elad Ben-Israel
committed
Nov 18, 2019
1 parent
08c4294
commit 684a368
Showing
16 changed files
with
256 additions
and
7 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
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
31 changes: 31 additions & 0 deletions
31
...zon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/JsonFormatter.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,31 @@ | ||
using Amazon.JSII.Runtime.Deputy; | ||
|
||
namespace Amazon.JSII.Tests.CalculatorNamespace | ||
{ | ||
/// <summary>Make sure structs are un-decorated on the way in.</summary> | ||
/// <remarks> | ||
/// stability: Experimental | ||
/// see: | ||
/// https://github.com/aws/aws-cdk/issues/5066 | ||
/// </remarks> | ||
[JsiiClass(nativeType: typeof(Amazon.JSII.Tests.CalculatorNamespace.JsonFormatter), fullyQualifiedName: "jsii-calc.JsonFormatter")] | ||
public class JsonFormatter : DeputyBase | ||
{ | ||
protected JsonFormatter(ByRefValue reference): base(reference) | ||
{ | ||
} | ||
|
||
protected JsonFormatter(DeputyProps props): base(props) | ||
{ | ||
} | ||
|
||
/// <remarks> | ||
/// stability: Experimental | ||
/// </remarks> | ||
[JsiiMethod(name: "stringify", returnsJson: "{\"type\":{\"primitive\":\"string\"}}", parametersJson: "[{\"name\":\"value\",\"type\":{\"primitive\":\"any\"}}]")] | ||
public static string Stringify(object @value) | ||
{ | ||
return InvokeStaticMethod<string>(typeof(Amazon.JSII.Tests.CalculatorNamespace.JsonFormatter), new System.Type[]{typeof(object)}, new object[]{@value}); | ||
} | ||
} | ||
} |
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
32 changes: 32 additions & 0 deletions
32
...ted.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/JsonFormatter.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,32 @@ | ||
package software.amazon.jsii.tests.calculator; | ||
|
||
/** | ||
* Make sure structs are un-decorated on the way in. | ||
* | ||
* EXPERIMENTAL | ||
* | ||
* @see https://github.com/aws/aws-cdk/issues/5066 | ||
*/ | ||
@javax.annotation.Generated(value = "jsii-pacmak") | ||
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) | ||
@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.JsonFormatter") | ||
public class JsonFormatter extends software.amazon.jsii.JsiiObject { | ||
|
||
protected JsonFormatter(final software.amazon.jsii.JsiiObjectRef objRef) { | ||
super(objRef); | ||
} | ||
|
||
protected JsonFormatter(final software.amazon.jsii.JsiiObject.InitializationMode initializationMode) { | ||
super(initializationMode); | ||
} | ||
|
||
/** | ||
* EXPERIMENTAL | ||
* | ||
* @param value This parameter is required. | ||
*/ | ||
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) | ||
public static java.lang.String stringify(final java.lang.Object value) { | ||
return software.amazon.jsii.JsiiObject.jsiiStaticCall(software.amazon.jsii.tests.calculator.JsonFormatter.class, "stringify", java.lang.String.class, new Object[] { value }); | ||
} | ||
} |
Oops, something went wrong.