-
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(.net): occasional incorrect param type cast
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
a2116e9
commit dfdddd6
Showing
16 changed files
with
408 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
17 changes: 17 additions & 0 deletions
17
packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Amazon.JSII.Runtime.sln
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,17 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Amazon.JSII.Runtime", "Amazon.JSII.Runtime.csproj", "{A31525BC-0422-446E-B7DE-92769D96302B}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{A31525BC-0422-446E-B7DE-92769D96302B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{A31525BC-0422-446E-B7DE-92769D96302B}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{A31525BC-0422-446E-B7DE-92769D96302B}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{A31525BC-0422-446E-B7DE-92769D96302B}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
EndGlobal |
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.