-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: omitting optional property fails C# compilation (#1448)
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 <[email protected]> Co-authored-by: github-actions <[email protected]>
- Loading branch information
Showing
4 changed files
with
120 additions
and
15 deletions.
There are no files selected for viewing
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export interface ISomeInterface { | ||
readonly xyz?: string; | ||
} | ||
|
||
export abstract class SomeClass implements ISomeInterface { | ||
} |