-
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(dotnet): "Could not infer JSII type for .NET type 'AnonymousObject'"
When obtained through an untyped way (e.g: as part of an opaque object for example), instances of `AnonymousObject` could not be cast back to their Kernel form, because the converter lacked a code path to handle this type. Instead, it insisted on trying to infer a "better" run-time type for it. This adds the necessary code path to handle this condition and properly return the reverse conversion. Fixes aws/aws-cdk#7977
- Loading branch information
1 parent
61f8883
commit 3567bab
Showing
12 changed files
with
394 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
51 changes: 51 additions & 0 deletions
51
...Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/BurriedAnonymousObject.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,51 @@ | ||
using Amazon.JSII.Runtime.Deputy; | ||
|
||
#pragma warning disable CS0672,CS0809,CS1591 | ||
|
||
namespace Amazon.JSII.Tests.CalculatorNamespace | ||
{ | ||
/// <summary>See https://github.com/aws/aws-cdk/issues/7977.</summary> | ||
/// <remarks> | ||
/// <strong>Stability</strong>: Experimental | ||
/// </remarks> | ||
[JsiiClass(nativeType: typeof(Amazon.JSII.Tests.CalculatorNamespace.BurriedAnonymousObject), fullyQualifiedName: "jsii-calc.BurriedAnonymousObject")] | ||
public abstract class BurriedAnonymousObject : DeputyBase | ||
{ | ||
protected BurriedAnonymousObject(): base(new DeputyProps(new object[]{})) | ||
{ | ||
} | ||
|
||
/// <summary>Used by jsii to construct an instance of this class from a Javascript-owned object reference</summary> | ||
/// <param name="reference">The Javascript-owned object reference</param> | ||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] | ||
protected BurriedAnonymousObject(ByRefValue reference): base(reference) | ||
{ | ||
} | ||
|
||
/// <summary>Used by jsii to construct an instance of this class from DeputyProps</summary> | ||
/// <param name="props">The deputy props</param> | ||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] | ||
protected BurriedAnonymousObject(DeputyProps props): base(props) | ||
{ | ||
} | ||
|
||
/// <remarks> | ||
/// <strong>Stability</strong>: Experimental | ||
/// </remarks> | ||
[JsiiMethod(name: "check", returnsJson: "{\"type\":{\"primitive\":\"boolean\"}}")] | ||
public virtual bool Check() | ||
{ | ||
return InvokeInstanceMethod<bool>(new System.Type[]{}, new object[]{}); | ||
} | ||
|
||
/// <summary>Implement this method and have it return it's parameter.</summary> | ||
/// <param name="value">the value that should be returned.</param> | ||
/// <returns>`value`</returns> | ||
/// <remarks> | ||
/// <strong>Stability</strong>: Experimental | ||
/// </remarks> | ||
[JsiiMethod(name: "giveItBack", returnsJson: "{\"type\":{\"primitive\":\"any\"}}", parametersJson: "[{\"docs\":{\"summary\":\"the value that should be returned.\"},\"name\":\"value\",\"type\":{\"primitive\":\"any\"}}]")] | ||
public abstract object GiveItBack(object @value); | ||
|
||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
....CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/BurriedAnonymousObjectProxy.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,30 @@ | ||
using Amazon.JSII.Runtime.Deputy; | ||
|
||
#pragma warning disable CS0672,CS0809,CS1591 | ||
|
||
namespace Amazon.JSII.Tests.CalculatorNamespace | ||
{ | ||
/// <summary>See https://github.com/aws/aws-cdk/issues/7977.</summary> | ||
/// <remarks> | ||
/// <strong>Stability</strong>: Experimental | ||
/// </remarks> | ||
[JsiiTypeProxy(nativeType: typeof(Amazon.JSII.Tests.CalculatorNamespace.BurriedAnonymousObject), fullyQualifiedName: "jsii-calc.BurriedAnonymousObject")] | ||
internal sealed class BurriedAnonymousObjectProxy : Amazon.JSII.Tests.CalculatorNamespace.BurriedAnonymousObject | ||
{ | ||
private BurriedAnonymousObjectProxy(ByRefValue reference): base(reference) | ||
{ | ||
} | ||
|
||
/// <summary>Implement this method and have it return it's parameter.</summary> | ||
/// <param name="value">the value that should be returned.</param> | ||
/// <returns>`value`</returns> | ||
/// <remarks> | ||
/// <strong>Stability</strong>: Experimental | ||
/// </remarks> | ||
[JsiiMethod(name: "giveItBack", returnsJson: "{\"type\":{\"primitive\":\"any\"}}", parametersJson: "[{\"docs\":{\"summary\":\"the value that should be returned.\"},\"name\":\"value\",\"type\":{\"primitive\":\"any\"}}]")] | ||
public override object GiveItBack(object @value) | ||
{ | ||
return InvokeInstanceMethod<object>(new System.Type[]{typeof(object)}, new object[]{@value}); | ||
} | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
...calc/java/src/main/java/software/amazon/jsii/tests/calculator/BurriedAnonymousObject.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,67 @@ | ||
package software.amazon.jsii.tests.calculator; | ||
|
||
/** | ||
* See https://github.com/aws/aws-cdk/issues/7977. | ||
* <p> | ||
* 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.BurriedAnonymousObject") | ||
public abstract class BurriedAnonymousObject extends software.amazon.jsii.JsiiObject { | ||
|
||
protected BurriedAnonymousObject(final software.amazon.jsii.JsiiObjectRef objRef) { | ||
super(objRef); | ||
} | ||
|
||
protected BurriedAnonymousObject(final software.amazon.jsii.JsiiObject.InitializationMode initializationMode) { | ||
super(initializationMode); | ||
} | ||
|
||
protected BurriedAnonymousObject() { | ||
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 @org.jetbrains.annotations.NotNull java.lang.Boolean check() { | ||
return this.jsiiCall("check", java.lang.Boolean.class); | ||
} | ||
|
||
/** | ||
* Implement this method and have it return it's parameter. | ||
* <p> | ||
* EXPERIMENTAL | ||
* <p> | ||
* @return `value` | ||
* @param value the value that should be returned. This parameter is required. | ||
*/ | ||
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) | ||
public abstract @org.jetbrains.annotations.NotNull java.lang.Object giveItBack(final @org.jetbrains.annotations.NotNull java.lang.Object value); | ||
|
||
/** | ||
* A proxy class which represents a concrete javascript instance of this type. | ||
*/ | ||
final static class Jsii$Proxy extends software.amazon.jsii.tests.calculator.BurriedAnonymousObject { | ||
protected Jsii$Proxy(final software.amazon.jsii.JsiiObjectRef objRef) { | ||
super(objRef); | ||
} | ||
|
||
/** | ||
* Implement this method and have it return it's parameter. | ||
* <p> | ||
* EXPERIMENTAL | ||
* <p> | ||
* @return `value` | ||
* @param value the value that should be returned. This parameter is required. | ||
*/ | ||
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) | ||
@Override | ||
public @org.jetbrains.annotations.NotNull java.lang.Object giveItBack(final @org.jetbrains.annotations.NotNull java.lang.Object value) { | ||
return this.jsiiCall("giveItBack", java.lang.Object.class, 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
Oops, something went wrong.