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

feat(dotnet): introduce UnsafeCast<T>() method #2192

Merged
merged 5 commits into from
Oct 28, 2020

Conversation

RomainMuller
Copy link
Contributor

@RomainMuller RomainMuller commented Oct 27, 2020

In order to allow converting an opaque object instance to an arbitrary
(jsii-managed) interface type, the UnsafeCase operation may be used to
instantiate a proxy while bypassing all type consistency checks.

This is similar to using as any or as T in TypeScript, meaning that
if the user performs a cast to an incorrect/unsupported type, undefined
behavior follows.

This would unblock certain specific use-case scenarios that static
languages render difficult to enact, such as the one described in
aws/aws-cdk#3284.

In particular, this is the only way out until aws/aws-cdk-rfcs#193
is delivered, for dealing with instances of interfaces returned through
a type union API.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

In order to allow converting an opaque object instance to an arbitrary
(jsii-managed) interface type, the `UnsafeCase` operation may be used to
instantiate a proxy while bypassing all type consistency checks.

This is similar to using `as any` or `as T` in TypeScript, meaning that
if the user performs a cast to an incorrect/unsupported type, undefined
behavior follows.

This would unblock certain specific use-case scenarios that static
languages render difficult to enact, such as the one described in
aws/aws-cdk#3284.
@RomainMuller RomainMuller added language/dotnet Related to .NET bindings (C#, F#, ...) feature-request A feature should be added or improved. effort/small Small work item – less than a day of effort module/runtime Issues affecting the `jsii-runtime` labels Oct 27, 2020
@RomainMuller RomainMuller added this to the 🎃 October Release milestone Oct 27, 2020
@RomainMuller RomainMuller requested a review from a team October 27, 2020 15:07
@RomainMuller RomainMuller self-assigned this Oct 27, 2020
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Oct 27, 2020
Copy link
Contributor

@MrArnoldPalmer MrArnoldPalmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm into this. 👍

@mergify
Copy link
Contributor

mergify bot commented Oct 28, 2020

Thank you for contributing! ❤️ I will now look into making sure the PR is up-to-date, then proceed to try and merge it!

@mergify mergify bot added the pr/ready-to-merge This PR is ready to be merged. label Oct 28, 2020
@mergify
Copy link
Contributor

mergify bot commented Oct 28, 2020

Merging (with squash)...

@mergify
Copy link
Contributor

mergify bot commented Oct 28, 2020

Merging (with squash)...

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-Blkkw9bQFn8A
  • Commit ID: 152cfa8
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 5e22e81 into master Oct 28, 2020
@mergify mergify bot deleted the rmuller/dotnet-forced-down-cast branch October 28, 2020 10:41
@mergify
Copy link
Contributor

mergify bot commented Oct 28, 2020

Merging (with squash)...

@mergify mergify bot removed the pr/ready-to-merge This PR is ready to be merged. label Oct 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS. effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. language/dotnet Related to .NET bindings (C#, F#, ...) module/runtime Issues affecting the `jsii-runtime`
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants