-
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
fix(pacmak): .NET bindings fail to compile with error CS8120 #3760
Conversation
If a type union includes several candidates that are related to each other (A extends B or A implements B), `jsii-pacmak` may generate type checking clauses in a pattern matching `switch` statement in an order such that the compiler identifies dead clauses, which is an error in C#. This adds a provision to NOT emit such a clause so as to not cause the error. It is worth mentioning that the error cannot be "opted out" of via a `#pragma` directive like a warning would be, which is unfortunate. Fixes #3759
@@ -21,5 +21,6 @@ | |||
"composite": true, /* Ensure TypeScript can determine where to find the outputs of the referenced project to compile project. */ | |||
"incremental": true, /* Enable incremental compilation by reading/writing information from prior compilations to a file on disk. */ | |||
"useDefineForClassFields": false, /* Use Object.defineProperty for introducing class fields. */ | |||
"skipLibCheck": true, /* Skip type checking of declaration files. */ |
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.
This seems unrelated, was this an error?
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.
Yeah this is unrelated but does not hurt :) It's a recommended setting in TypeScript and could make builds somewhat faster.
@@ -172,6 +172,26 @@ abstract class Validation { | |||
code.openBlock(`switch (${expression})`); | |||
for (const type of types) { | |||
validTypes.push(resolver.toDotNetTypeName(type.spec!)); | |||
|
|||
/** |
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.
Great explanation 👍
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)... |
1 similar comment
Merging (with squash)... |
Merging (with squash)... |
@Mergifyio update |
✅ Branch has been successfully updated |
Merging (with squash)... |
If a type union includes several candidates that are related to each other (A extends B or A implements B),
jsii-pacmak
may generate type checking clauses in a pattern matchingswitch
statement in an order such that the compiler identifies dead clauses, which is an error in C#.This adds a provision to NOT emit such a clause so as to not cause the error. It is worth mentioning that the error cannot be "opted out" of via a
#pragma
directive like a warning would be, which is unfortunate.Fixes #3759
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.