-
Notifications
You must be signed in to change notification settings - Fork 245
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
Conversation
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.
There was a problem hiding this 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. 👍
Thank you for contributing! ❤️ I will now look into making sure the PR is up-to-date, then proceed to try and merge it! |
Merging (with squash)... |
Merging (with squash)... |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Merging (with squash)... |
In order to allow converting an opaque object instance to an arbitrary
(jsii-managed) interface type, the
UnsafeCase
operation may be used toinstantiate a proxy while bypassing all type consistency checks.
This is similar to using
as any
oras T
in TypeScript, meaning thatif 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.