-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(.net): occasional incorrect param type cast (#568)
When structures (as literal JSON blocks) get passed through a "map" argument, a `JObject` would be passed to the method despite the declared type on the .NET code is `IDictionary`, resulting in a crash. This code forcefully converts `JObject` to `IDictionary<string, objetc>` in such code paths. Fixes aws/aws-cdk#3093
- Loading branch information
1 parent
a4de2d8
commit c89d0fa
Showing
17 changed files
with
415 additions
and
4 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
39 changes: 39 additions & 0 deletions
39
...azon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/DataRenderer.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,39 @@ | ||
using Amazon.JSII.Runtime.Deputy; | ||
using Amazon.JSII.Tests.CalculatorNamespace.LibNamespace; | ||
using System.Collections.Generic; | ||
|
||
namespace Amazon.JSII.Tests.CalculatorNamespace | ||
{ | ||
/// <summary>Verifies proper type handling through dynamic overrides.</summary> | ||
/// <remarks>stability: Experimental</remarks> | ||
[JsiiClass(nativeType: typeof(DataRenderer), fullyQualifiedName: "jsii-calc.DataRenderer")] | ||
public class DataRenderer : DeputyBase | ||
{ | ||
/// <remarks>stability: Experimental</remarks> | ||
public DataRenderer(): base(new DeputyProps(new object[]{})) | ||
{ | ||
} | ||
|
||
protected DataRenderer(ByRefValue reference): base(reference) | ||
{ | ||
} | ||
|
||
protected DataRenderer(DeputyProps props): base(props) | ||
{ | ||
} | ||
|
||
/// <remarks>stability: Experimental</remarks> | ||
[JsiiMethod(name: "render", returnsJson: "{\"type\":{\"primitive\":\"string\"}}", parametersJson: "[{\"name\":\"data\",\"type\":{\"fqn\":\"@scope/jsii-calc-lib.MyFirstStruct\"},\"optional\":true}]")] | ||
public virtual string Render(IMyFirstStruct data) | ||
{ | ||
return InvokeInstanceMethod<string>(new object[]{data}); | ||
} | ||
|
||
/// <remarks>stability: Experimental</remarks> | ||
[JsiiMethod(name: "renderMap", returnsJson: "{\"type\":{\"primitive\":\"string\"}}", parametersJson: "[{\"name\":\"map\",\"type\":{\"collection\":{\"kind\":\"map\",\"elementtype\":{\"primitive\":\"any\"}}}}]")] | ||
public virtual string RenderMap(IDictionary<string, object> map) | ||
{ | ||
return InvokeInstanceMethod<string>(new object[]{map}); | ||
} | ||
} | ||
} |
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
47 changes: 47 additions & 0 deletions
47
...cted.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/DataRenderer.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,47 @@ | ||
package software.amazon.jsii.tests.calculator; | ||
|
||
/** | ||
* Verifies proper type handling through dynamic overrides. | ||
* | ||
* EXPERIMENTAL | ||
*/ | ||
@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.DataRenderer") | ||
public class DataRenderer extends software.amazon.jsii.JsiiObject { | ||
protected DataRenderer(final software.amazon.jsii.JsiiObject.InitializationMode mode) { | ||
super(mode); | ||
} | ||
/** | ||
* EXPERIMENTAL | ||
*/ | ||
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) | ||
public DataRenderer() { | ||
super(software.amazon.jsii.JsiiObject.InitializationMode.Jsii); | ||
software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this); | ||
} | ||
|
||
/** | ||
* EXPERIMENTAL | ||
*/ | ||
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) | ||
public java.lang.String render(@javax.annotation.Nullable final software.amazon.jsii.tests.calculator.lib.MyFirstStruct data) { | ||
return this.jsiiCall("render", java.lang.String.class, new Object[] { data }); | ||
} | ||
|
||
/** | ||
* EXPERIMENTAL | ||
*/ | ||
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) | ||
public java.lang.String render() { | ||
return this.jsiiCall("render", java.lang.String.class); | ||
} | ||
|
||
/** | ||
* EXPERIMENTAL | ||
*/ | ||
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) | ||
public java.lang.String renderMap(final java.util.Map<java.lang.String, java.lang.Object> map) { | ||
return this.jsiiCall("renderMap", java.lang.String.class, new Object[] { java.util.Objects.requireNonNull(map, "map is required") }); | ||
} | ||
} |
Oops, something went wrong.