-
Notifications
You must be signed in to change notification settings - Fork 16
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: omitting optional property fails C# compilation #1448
Merged
aws-cdk-automation
merged 5 commits into
main
from
huijbers/missing-prop-on-abstract-class
Oct 30, 2024
Merged
fix: omitting optional property fails C# compilation #1448
aws-cdk-automation
merged 5 commits into
main
from
huijbers/missing-prop-on-abstract-class
Oct 30, 2024
Conversation
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
The following is a minimal reproducing example: ```ts export interface ISomeInterface { readonly xyz?: string; } export abstract class SomeClass implements ISomeInterface { } ``` This breaks code generation for C#, as the `SomeClass._Proxy` class we generate will try to generate an `override` for the `Xyz` property, which is missing from the `SomeClass` class itself. This issue is exhibited by a difference in logic between how we iterate the members of a class when we generate the class itself vs when we generate its proxy. However, after looking at the code I'm not convinced it's correct either way (nor for Java), so to be safe we picked the solution where we force the user to declare the property on the class. The correct declaration would be: ```ts export abstract class SomeClass implements ISomeInterface { public abstract readonly xyz?: string; } ```
Signed-off-by: github-actions <github-actions@github.com>
…aws/jsii-compiler into huijbers/missing-prop-on-abstract-class
mrgrain
requested changes
Oct 30, 2024
mrgrain
approved these changes
Oct 30, 2024
aws-cdk-automation
deleted the
huijbers/missing-prop-on-abstract-class
branch
October 30, 2024 18:15
aws-cdk-automation
pushed a commit
that referenced
this pull request
Oct 30, 2024
The following is a minimal reproducing example: ```ts export interface ISomeInterface { readonly xyz?: string; } export abstract class SomeClass implements ISomeInterface { } ``` This breaks code generation for C#, as the `SomeClass._Proxy` class we generate will try to generate an `override` for the `Xyz` property, which is missing from the `SomeClass` class itself. This issue is exhibited by a difference in logic between how we iterate the members of a class when we generate the class itself vs when we generate its proxy. However, after looking at the code I'm not convinced it's correct either way (nor for Java), so to be safe we picked the solution where we force the user to declare the property on the class. The correct declaration would be: ```ts export abstract class SomeClass implements ISomeInterface { public abstract readonly xyz?: string; } ``` Related: https://github.com/aws/aws-cdk/pull/31946/files --- By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license]. [Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0 --------- Signed-off-by: github-actions <github-actions@github.com> Co-authored-by: github-actions <github-actions@github.com> (cherry picked from commit 3322f9e)
aws-cdk-automation
pushed a commit
that referenced
this pull request
Oct 30, 2024
The following is a minimal reproducing example: ```ts export interface ISomeInterface { readonly xyz?: string; } export abstract class SomeClass implements ISomeInterface { } ``` This breaks code generation for C#, as the `SomeClass._Proxy` class we generate will try to generate an `override` for the `Xyz` property, which is missing from the `SomeClass` class itself. This issue is exhibited by a difference in logic between how we iterate the members of a class when we generate the class itself vs when we generate its proxy. However, after looking at the code I'm not convinced it's correct either way (nor for Java), so to be safe we picked the solution where we force the user to declare the property on the class. The correct declaration would be: ```ts export abstract class SomeClass implements ISomeInterface { public abstract readonly xyz?: string; } ``` Related: https://github.com/aws/aws-cdk/pull/31946/files --- By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license]. [Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0 --------- Signed-off-by: github-actions <github-actions@github.com> Co-authored-by: github-actions <github-actions@github.com> (cherry picked from commit 3322f9e)
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation and see the Github Action logs for details |
github-merge-queue bot
pushed a commit
that referenced
this pull request
Oct 30, 2024
…#1449) # Backport This will backport the following commits from `main` to `maintenance/v5.3`: - [fix: omitting optional property fails C# compilation (#1448)](#1448) <!--- Backport version: 9.5.1 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) Co-authored-by: Rico Hermans <rix0rrr@gmail.com>
github-merge-queue bot
pushed a commit
that referenced
this pull request
Oct 30, 2024
…#1450) # Backport This will backport the following commits from `main` to `maintenance/v5.4`: - [fix: omitting optional property fails C# compilation (#1448)](#1448) <!--- Backport version: 9.5.1 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) Co-authored-by: Rico Hermans <rix0rrr@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The following is a minimal reproducing example:
This breaks code generation for C#, as the
SomeClass._Proxy
class we generate will try to generate anoverride
for theXyz
property, which is missing from theSomeClass
class itself.This issue is exhibited by a difference in logic between how we iterate the members of a class when we generate the class itself vs when we generate its proxy.
However, after looking at the code I'm not convinced it's correct either way (nor for Java), so to be safe we picked the solution where we force the user to declare the property on the class.
The correct declaration would be:
Related: https://github.com/aws/aws-cdk/pull/31946/files
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.