Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.NET fails mapping objects to interface types when returned from callbacks #290

Closed
RomainMuller opened this issue Nov 2, 2018 · 0 comments · Fixed by #291
Closed

.NET fails mapping objects to interface types when returned from callbacks #290

RomainMuller opened this issue Nov 2, 2018 · 0 comments · Fixed by #291
Assignees
Labels
bug This issue is a bug. language/dotnet Related to .NET bindings (C#, F#, ...)

Comments

@RomainMuller
Copy link
Contributor

RomainMuller commented Nov 2, 2018

When a method that is modeled to return an interface type is overridden in .NET, the callback handler fails to map the object to the JSII type, producing the Could not infer JSII type for .NET type error.

This is because the callback code attempts to map the type using the PrimitiveType.Any reference type instead of what is modeled on the overridden function.

This was identified as the root cause of aws/aws-cdk#1027.

@RomainMuller RomainMuller added bug This issue is a bug. language/dotnet Related to .NET bindings (C#, F#, ...) labels Nov 2, 2018
@RomainMuller RomainMuller self-assigned this Nov 2, 2018
RomainMuller added a commit that referenced this issue Nov 2, 2018
Use the type data available on the deputy object to determine the
relevant JSII type for the result of callbacks, instead of trying to map
into `PrimitiveType.Any`.

Fixes #290
Fixes aws/aws-cdk#1027
RomainMuller added a commit that referenced this issue Nov 2, 2018
The `jsii` compiler incorrectly mapped types homonym with a standard
type (`String`, `Number`, ...) to the primitive type on usage sites.
This commit corrects this behavior and adjusts the C# tests accordingly.

Additionally, when the return type of a callback was an interface, the
C# runtime was unable to determine the correct JSII type to use, despite
it has the information on the type of the callback method available. The
resolution behavior has also been fixes, as well as a couple of other
glitches that became apparent as a result of the `Number` type starting
to be correctly represented as the `@scope/jsii-calc-lib.Number` type.

Fixes #290
Fixes aws/aws-cdk#1027
RomainMuller added a commit that referenced this issue Nov 5, 2018
The `jsii` compiler incorrectly mapped types homonym with a standard
type (`String`, `Number`, ...) to the primitive type on usage sites.
This commit corrects this behavior and adjusts the C# tests accordingly.

Additionally, when the return type of a callback was an interface, the
C# runtime was unable to determine the correct JSII type to use, despite
it has the information on the type of the callback method available. The
resolution behavior has also been fixes, as well as a couple of other
glitches that became apparent as a result of the `Number` type starting
to be correctly represented as the `@scope/jsii-calc-lib.Number` type.

Fixes #290
Fixes aws/aws-cdk#1027
RomainMuller added a commit that referenced this issue Nov 6, 2018
The `jsii` compiler incorrectly mapped types homonym with a standard
type (`String`, `Number`, ...) to the primitive type on usage sites.
This commit corrects this behavior and adjusts the C# tests accordingly.

Additionally, when the return type of a callback was an interface, the
C# runtime was unable to determine the correct JSII type to use, despite
it has the information on the type of the callback method available. The
resolution behavior has also been fixes, as well as a couple of other
glitches that became apparent as a result of the `Number` type starting
to be correctly represented as the `@scope/jsii-calc-lib.Number` type.

Fixes #290
Fixes aws/aws-cdk#1027
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. language/dotnet Related to .NET bindings (C#, F#, ...)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant