From 37ddfd5fde1399274ca1541542c7268b75e026c2 Mon Sep 17 00:00:00 2001 From: Romain Marcadier-Muller Date: Tue, 29 Oct 2019 09:29:05 +0100 Subject: [PATCH] fix(java,dotnet): emit default implementations for optional properties (#906) For optional properties on interfaces, emit default implementations (for .NET, this required upgrading the target to `netcoreapp3.0`) so that adding a new optional property on an interface does not break existing code that implements the interface. In it's current form, the getters always return `null`, while the setters throw an exception unless overridden. Fixes #543 --- .../Amazon.JSII.Analyzers.UnitTests.csproj | 2 +- .../Amazon.JSII.Analyzers.csproj | 2 +- .../Amazon.JSII.JsonModel.UnitTests.csproj | 2 +- .../Amazon.JSII.JsonModel.csproj | 2 +- ...mazon.JSII.Runtime.IntegrationTests.csproj | 2 +- .../ComplianceTests.cs | 2 +- .../Amazon.JSII.Runtime.UnitTests.csproj | 2 +- .../Amazon.JSII.Runtime.csproj | 2 +- .../Deputy/JsiiOptionalAttribute.cs | 10 +++++-- .../java/software/amazon/jsii/Optional.java | 15 ++++++++++ packages/jsii-pacmak/lib/targets/dotnet.ts | 2 +- .../lib/targets/dotnet/dotnetgenerator.ts | 22 ++++++++++++-- .../lib/targets/dotnet/filegenerator.ts | 2 +- packages/jsii-pacmak/lib/targets/java.ts | 17 +++++++++-- packages/jsii-pacmak/test/diff-test.sh | 6 +++- ...s.CalculatorPackageId.BasePackageId.csproj | 2 +- ...ts.CalculatorPackageId.LibPackageId.csproj | 2 +- .../LibNamespace/IMyFirstStruct.cs | 6 +++- .../LibNamespace/IStructWithOnlyOptionals.cs | 18 +++++++++-- .../tests/calculator/lib/MyFirstStruct.java | 4 ++- .../lib/StructWithOnlyOptionals.java | 12 ++++++-- ...azon.JSII.Tests.CalculatorPackageId.csproj | 2 +- .../CalculatorNamespace/ICalculatorProps.cs | 12 ++++++-- .../IDeprecatedInterface.cs | 11 +++++-- .../CalculatorNamespace/IDerivedStruct.cs | 18 +++++++++-- .../IEraseUndefinedHashValuesOptions.cs | 12 ++++++-- .../IExperimentalInterface.cs | 11 +++++-- .../Tests/CalculatorNamespace/IGreetee.cs | 6 +++- .../ILoadBalancedFargateServiceProps.cs | 30 +++++++++++++++---- .../INullShouldBeTreatedAsUndefinedData.cs | 6 +++- .../CalculatorNamespace/IOptionalStruct.cs | 6 +++- .../CalculatorNamespace/ISecondLevelStruct.cs | 6 +++- .../CalculatorNamespace/IStableInterface.cs | 11 +++++-- .../IStructWithJavaReservedWords.cs | 18 +++++++++-- .../CalculatorNamespace/ITopLevelStruct.cs | 6 +++- .../CalculatorNamespace/IUnionProperties.cs | 6 +++- .../tests/calculator/CalculatorProps.java | 8 +++-- .../jsii/tests/calculator/DerivedStruct.java | 12 ++++++-- .../EraseUndefinedHashValuesOptions.java | 8 +++-- .../amazon/jsii/tests/calculator/Greetee.java | 4 ++- .../calculator/IDeprecatedInterface.java | 9 ++++-- .../calculator/IExperimentalInterface.java | 9 ++++-- .../tests/calculator/IStableInterface.java | 9 ++++-- .../LoadBalancedFargateServiceProps.java | 20 +++++++++---- .../NullShouldBeTreatedAsUndefinedData.java | 4 ++- .../jsii/tests/calculator/OptionalStruct.java | 4 ++- .../tests/calculator/SecondLevelStruct.java | 4 ++- .../StructWithJavaReservedWords.java | 12 ++++++-- .../jsii/tests/calculator/TopLevelStruct.java | 4 ++- .../tests/calculator/UnionProperties.java | 4 ++- 50 files changed, 323 insertions(+), 83 deletions(-) create mode 100644 packages/jsii-java-runtime/project/src/main/java/software/amazon/jsii/Optional.java diff --git a/packages/jsii-dotnet-analyzers/src/Amazon.JSII.Analyzers.UnitTests/Amazon.JSII.Analyzers.UnitTests.csproj b/packages/jsii-dotnet-analyzers/src/Amazon.JSII.Analyzers.UnitTests/Amazon.JSII.Analyzers.UnitTests.csproj index 00730a3323..b800fbe261 100755 --- a/packages/jsii-dotnet-analyzers/src/Amazon.JSII.Analyzers.UnitTests/Amazon.JSII.Analyzers.UnitTests.csproj +++ b/packages/jsii-dotnet-analyzers/src/Amazon.JSII.Analyzers.UnitTests/Amazon.JSII.Analyzers.UnitTests.csproj @@ -1,7 +1,7 @@  - netcoreapp2.1 + netcoreapp3.0 false Amazon.JSII.Analyzers.UnitTests diff --git a/packages/jsii-dotnet-analyzers/src/Amazon.JSII.Analyzers/Amazon.JSII.Analyzers.csproj b/packages/jsii-dotnet-analyzers/src/Amazon.JSII.Analyzers/Amazon.JSII.Analyzers.csproj index ad3b270ef4..e51c3eb96a 100644 --- a/packages/jsii-dotnet-analyzers/src/Amazon.JSII.Analyzers/Amazon.JSII.Analyzers.csproj +++ b/packages/jsii-dotnet-analyzers/src/Amazon.JSII.Analyzers/Amazon.JSII.Analyzers.csproj @@ -4,7 +4,7 @@ Amazon.JSII.Analyzers .NET Roslyn Analyzers for JSII - netcoreapp2.1 + netcoreapp3.0 true icon.png diff --git a/packages/jsii-dotnet-jsonmodel/src/Amazon.JSII.JsonModel.UnitTests/Amazon.JSII.JsonModel.UnitTests.csproj b/packages/jsii-dotnet-jsonmodel/src/Amazon.JSII.JsonModel.UnitTests/Amazon.JSII.JsonModel.UnitTests.csproj index feb55eee58..80e18ae770 100644 --- a/packages/jsii-dotnet-jsonmodel/src/Amazon.JSII.JsonModel.UnitTests/Amazon.JSII.JsonModel.UnitTests.csproj +++ b/packages/jsii-dotnet-jsonmodel/src/Amazon.JSII.JsonModel.UnitTests/Amazon.JSII.JsonModel.UnitTests.csproj @@ -1,7 +1,7 @@  - netcoreapp2.1 + netcoreapp3.0 false Amazon.JSII.JsonModel.UnitTests Amazon.JSII.JsonModel.UnitTests diff --git a/packages/jsii-dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Amazon.JSII.JsonModel.csproj b/packages/jsii-dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Amazon.JSII.JsonModel.csproj index a91e6cd4c7..1d85da564d 100644 --- a/packages/jsii-dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Amazon.JSII.JsonModel.csproj +++ b/packages/jsii-dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Amazon.JSII.JsonModel.csproj @@ -2,7 +2,7 @@ - netcoreapp2.1 + netcoreapp3.0 Amazon.JSII.JsonModel .NET JsonModel for JSII icon.png diff --git a/packages/jsii-dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/Amazon.JSII.Runtime.IntegrationTests.csproj b/packages/jsii-dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/Amazon.JSII.Runtime.IntegrationTests.csproj index 4ab2dd0061..8dd1adf65a 100644 --- a/packages/jsii-dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/Amazon.JSII.Runtime.IntegrationTests.csproj +++ b/packages/jsii-dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/Amazon.JSII.Runtime.IntegrationTests.csproj @@ -1,7 +1,7 @@  - netcoreapp2.1 + netcoreapp3.0 false diff --git a/packages/jsii-dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/ComplianceTests.cs b/packages/jsii-dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/ComplianceTests.cs index ef29d60206..43b28496e1 100644 --- a/packages/jsii-dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/ComplianceTests.cs +++ b/packages/jsii-dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/ComplianceTests.cs @@ -928,7 +928,7 @@ public void OptionalAndVariadicArgumentsTest() [Fact(DisplayName = Prefix + nameof(JsiiAgent))] public void JsiiAgent() { - Assert.Equal("DotNet/" + Environment.Version.ToString() + "/.NETCoreApp,Version=v2.1/1.0.0.0", JsiiAgent_.JsiiAgent); + Assert.Equal("DotNet/" + Environment.Version.ToString() + "/.NETCoreApp,Version=v3.0/1.0.0.0", JsiiAgent_.JsiiAgent); } [Fact(DisplayName = Prefix + nameof(ReceiveInstanceOfPrivateClass))] diff --git a/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime.UnitTests/Amazon.JSII.Runtime.UnitTests.csproj b/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime.UnitTests/Amazon.JSII.Runtime.UnitTests.csproj index 8bc086169c..4339b99677 100644 --- a/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime.UnitTests/Amazon.JSII.Runtime.UnitTests.csproj +++ b/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime.UnitTests/Amazon.JSII.Runtime.UnitTests.csproj @@ -1,7 +1,7 @@  - netcoreapp2.1 + netcoreapp3.0 false diff --git a/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Amazon.JSII.Runtime.csproj b/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Amazon.JSII.Runtime.csproj index 2dd9b98ae3..a3048b7b90 100644 --- a/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Amazon.JSII.Runtime.csproj +++ b/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Amazon.JSII.Runtime.csproj @@ -2,7 +2,7 @@ - netcoreapp2.1 + netcoreapp3.0 Amazon.JSII.Runtime .NET Runtime for JSII icon.png diff --git a/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Deputy/JsiiOptionalAttribute.cs b/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Deputy/JsiiOptionalAttribute.cs index 1102879073..81ae1f590c 100644 --- a/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Deputy/JsiiOptionalAttribute.cs +++ b/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Deputy/JsiiOptionalAttribute.cs @@ -4,9 +4,15 @@ namespace Amazon.JSII.Runtime.Deputy { /// /// Flags a property as optional. - /// This is used by the jsii-dotnet-analyzers package to emit errors - /// on required properties that are missing. + /// + /// This is used by the jsii-dotnet-analyzers package to emit errors on required properties that are missing. /// + /// + /// Annotated properties have a setter with a default implementation that throws + /// System.NotSupportedException when invoked. In a similar way that they have to in TypeScript, + /// implementors need to actively opt into supporting the functionality by providing a custom implementation + /// for the member. + /// [AttributeUsage(AttributeTargets.Property)] public class JsiiOptionalAttribute : Attribute { diff --git a/packages/jsii-java-runtime/project/src/main/java/software/amazon/jsii/Optional.java b/packages/jsii-java-runtime/project/src/main/java/software/amazon/jsii/Optional.java new file mode 100644 index 0000000000..b85634eb83 --- /dev/null +++ b/packages/jsii-java-runtime/project/src/main/java/software/amazon/jsii/Optional.java @@ -0,0 +1,15 @@ +package software.amazon.jsii; + +import java.lang.annotation.*; + +/** + * Denotes an optional member from the TypeScript model for the API. + * + * Annotated methods have a default implementation that throws {@link UnsupportedOperationException} when invoked. + * In a similar way that they have to in TypeScript, implementors need to actively opt into supporting the + * functionality by providing a custom implementation for the member. + */ +@Documented +@Target({ElementType.METHOD}) +@Retention(RetentionPolicy.SOURCE) +public @interface Optional {} diff --git a/packages/jsii-pacmak/lib/targets/dotnet.ts b/packages/jsii-pacmak/lib/targets/dotnet.ts index 54729e328e..176e157c1a 100644 --- a/packages/jsii-pacmak/lib/targets/dotnet.ts +++ b/packages/jsii-pacmak/lib/targets/dotnet.ts @@ -55,7 +55,7 @@ export default class Dotnet extends Target { await this.copyFiles( path.join(sourceDir, packageId, 'bin', 'Release'), outDir); - await fs.remove(path.join(outDir, 'netcoreapp2.1')); + await fs.remove(path.join(outDir, 'netcoreapp3.0')); } private async generateNuGetConfigForLocalDeps(sourceDirectory: string, currentOutputDirectory: string): Promise { diff --git a/packages/jsii-pacmak/lib/targets/dotnet/dotnetgenerator.ts b/packages/jsii-pacmak/lib/targets/dotnet/dotnetgenerator.ts index 4721db20b3..b851965b1e 100644 --- a/packages/jsii-pacmak/lib/targets/dotnet/dotnetgenerator.ts +++ b/packages/jsii-pacmak/lib/targets/dotnet/dotnetgenerator.ts @@ -179,14 +179,30 @@ export class DotNetGenerator extends Generator { const propType = this.typeresolver.toDotNetType(prop.type); const propName = this.nameutils.convertPropertyName(prop.name); + if (prop.optional) { + this.code.line('[Amazon.JSII.Runtime.Deputy.JsiiOptional]'); + } + // Specifying that a type is nullable is only required for primitive value types const isOptionalPrimitive = this.isOptionalPrimitive(prop) ? '?' : ''; this.code.openBlock(`${propType}${isOptionalPrimitive} ${propName}`); - this.code.line('get;'); - if (!prop.immutable) { - this.code.line('set;'); + if (prop.optional) { + this.code.openBlock('get'); + this.code.line('return null;'); + this.code.closeBlock(); + if (!prop.immutable) { + this.code.openBlock('set'); + this.code.line(`throw new System.NotSupportedException("'set' for '${propName}' is not implemented");`); + this.code.closeBlock(); + } + } else { + this.code.line('get;'); + if (!prop.immutable) { + this.code.line('set;'); + } } + this.code.closeBlock(); this.flagFirstMemberWritten(true); } diff --git a/packages/jsii-pacmak/lib/targets/dotnet/filegenerator.ts b/packages/jsii-pacmak/lib/targets/dotnet/filegenerator.ts index 1d30359fee..f8ab3a413d 100644 --- a/packages/jsii-pacmak/lib/targets/dotnet/filegenerator.ts +++ b/packages/jsii-pacmak/lib/targets/dotnet/filegenerator.ts @@ -50,7 +50,7 @@ export class FileGenerator { const rootNode = xmlbuilder.create('Project', { encoding: 'UTF-8', headless: true }); rootNode.att('Sdk', 'Microsoft.NET.Sdk'); const propertyGroup = rootNode.ele('PropertyGroup'); - propertyGroup.ele('TargetFramework', 'netcoreapp2.1'); + propertyGroup.ele('TargetFramework', 'netcoreapp3.0'); propertyGroup.ele('GeneratePackageOnBuild', 'true'); propertyGroup.ele('GenerateDocumentationFile', 'true'); propertyGroup.ele('IncludeSymbols', 'true'); diff --git a/packages/jsii-pacmak/lib/targets/java.ts b/packages/jsii-pacmak/lib/targets/java.ts index 5fd838b167..8c5a2ca0a8 100644 --- a/packages/jsii-pacmak/lib/targets/java.ts +++ b/packages/jsii-pacmak/lib/targets/java.ts @@ -538,13 +538,26 @@ class JavaGenerator extends Generator { this.code.line(); this.addJavaDocs(prop); this.emitStabilityAnnotations(prop); - this.code.line(`${getterType} get${propName}();`); + if (prop.optional) { + this.code.openBlock(`default ${getterType} get${propName}()`); + this.code.line('return null;'); + this.code.closeBlock(); + } else { + this.code.line(`${getterType} get${propName}();`); + } if (!prop.immutable) { for (const type of setterTypes) { this.code.line(); this.addJavaDocs(prop); - this.code.line(`void set${propName}(final ${type} value);`); + if (prop.optional) { + this.code.line('@software.amazon.jsii.Optional'); + this.code.openBlock(`default void set${propName}(final ${type} value)`); + this.code.line(`throw new UnsupportedOperationException("'void " + getClass().getCanonicalName() + "#set${propName}(${type})' is not implemented!");`); + this.code.closeBlock(); + } else { + this.code.line(`void set${propName}(final ${type} value);`); + } } } } diff --git a/packages/jsii-pacmak/test/diff-test.sh b/packages/jsii-pacmak/test/diff-test.sh index 39d7efc78f..8889c113d3 100755 --- a/packages/jsii-pacmak/test/diff-test.sh +++ b/packages/jsii-pacmak/test/diff-test.sh @@ -30,7 +30,11 @@ function assert-generator() { fi if [[ -d ${original_expected}/java/target ]]; then - echo "An IDE plugin seems to have eagerly tried to compile ${original_expected}/java. Please remove." >&2 + # When IDEs automaticallu compile the java target, the diff-test may fail later on with a cryptic error message + # due to the existence of .settings / .projects / ... directories that aren't part of the expected outcome. This + # check is here to avoid the confusion. + echo "An IDE plugin seems to have eagerly tried to compile ${original_expected}/java. Please remove:" + echo " rm -rf ${original_expected}/java/target" exit 1 fi diff --git a/packages/jsii-pacmak/test/expected.jsii-calc-base/dotnet/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId.csproj b/packages/jsii-pacmak/test/expected.jsii-calc-base/dotnet/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId.csproj index dde4b3b9ff..0735208f5b 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc-base/dotnet/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId.csproj +++ b/packages/jsii-pacmak/test/expected.jsii-calc-base/dotnet/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId.csproj @@ -1,6 +1,6 @@ - netcoreapp2.1 + netcoreapp3.0 true true true diff --git a/packages/jsii-pacmak/test/expected.jsii-calc-lib/dotnet/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId.csproj b/packages/jsii-pacmak/test/expected.jsii-calc-lib/dotnet/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId.csproj index 148b43a8b0..622664209e 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc-lib/dotnet/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId.csproj +++ b/packages/jsii-pacmak/test/expected.jsii-calc-lib/dotnet/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId.csproj @@ -1,6 +1,6 @@ - netcoreapp2.1 + netcoreapp3.0 true true true diff --git a/packages/jsii-pacmak/test/expected.jsii-calc-lib/dotnet/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId/Amazon/JSII/Tests/CalculatorNamespace/LibNamespace/IMyFirstStruct.cs b/packages/jsii-pacmak/test/expected.jsii-calc-lib/dotnet/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId/Amazon/JSII/Tests/CalculatorNamespace/LibNamespace/IMyFirstStruct.cs index f5681f0998..cd9b7dad3a 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc-lib/dotnet/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId/Amazon/JSII/Tests/CalculatorNamespace/LibNamespace/IMyFirstStruct.cs +++ b/packages/jsii-pacmak/test/expected.jsii-calc-lib/dotnet/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId/Amazon/JSII/Tests/CalculatorNamespace/LibNamespace/IMyFirstStruct.cs @@ -37,9 +37,13 @@ string Astring /// [JsiiProperty(name: "firstOptional", typeJson: "{\"collection\":{\"elementtype\":{\"primitive\":\"string\"},\"kind\":\"array\"}}", isOptional: true)] [System.Obsolete()] + [Amazon.JSII.Runtime.Deputy.JsiiOptional] string[] FirstOptional { - get; + get + { + return null; + } } } } diff --git a/packages/jsii-pacmak/test/expected.jsii-calc-lib/dotnet/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId/Amazon/JSII/Tests/CalculatorNamespace/LibNamespace/IStructWithOnlyOptionals.cs b/packages/jsii-pacmak/test/expected.jsii-calc-lib/dotnet/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId/Amazon/JSII/Tests/CalculatorNamespace/LibNamespace/IStructWithOnlyOptionals.cs index 23413fa7ef..bb4471ede9 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc-lib/dotnet/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId/Amazon/JSII/Tests/CalculatorNamespace/LibNamespace/IStructWithOnlyOptionals.cs +++ b/packages/jsii-pacmak/test/expected.jsii-calc-lib/dotnet/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId/Amazon/JSII/Tests/CalculatorNamespace/LibNamespace/IStructWithOnlyOptionals.cs @@ -16,9 +16,13 @@ public interface IStructWithOnlyOptionals /// [JsiiProperty(name: "optional1", typeJson: "{\"primitive\":\"string\"}", isOptional: true)] [System.Obsolete()] + [Amazon.JSII.Runtime.Deputy.JsiiOptional] string Optional1 { - get; + get + { + return null; + } } /// @@ -26,9 +30,13 @@ string Optional1 /// [JsiiProperty(name: "optional2", typeJson: "{\"primitive\":\"number\"}", isOptional: true)] [System.Obsolete()] + [Amazon.JSII.Runtime.Deputy.JsiiOptional] double? Optional2 { - get; + get + { + return null; + } } /// @@ -36,9 +44,13 @@ string Optional1 /// [JsiiProperty(name: "optional3", typeJson: "{\"primitive\":\"boolean\"}", isOptional: true)] [System.Obsolete()] + [Amazon.JSII.Runtime.Deputy.JsiiOptional] bool? Optional3 { - get; + get + { + return null; + } } } } diff --git a/packages/jsii-pacmak/test/expected.jsii-calc-lib/java/src/main/java/software/amazon/jsii/tests/calculator/lib/MyFirstStruct.java b/packages/jsii-pacmak/test/expected.jsii-calc-lib/java/src/main/java/software/amazon/jsii/tests/calculator/lib/MyFirstStruct.java index 48581d9b99..f3f0414138 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc-lib/java/src/main/java/software/amazon/jsii/tests/calculator/lib/MyFirstStruct.java +++ b/packages/jsii-pacmak/test/expected.jsii-calc-lib/java/src/main/java/software/amazon/jsii/tests/calculator/lib/MyFirstStruct.java @@ -26,7 +26,9 @@ public interface MyFirstStruct extends software.amazon.jsii.JsiiSerializable { */ @Deprecated @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Deprecated) - java.util.List getFirstOptional(); + default java.util.List getFirstOptional() { + return null; + } /** * @return a {@link Builder} of {@link MyFirstStruct} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc-lib/java/src/main/java/software/amazon/jsii/tests/calculator/lib/StructWithOnlyOptionals.java b/packages/jsii-pacmak/test/expected.jsii-calc-lib/java/src/main/java/software/amazon/jsii/tests/calculator/lib/StructWithOnlyOptionals.java index e850573ede..78949c2d0e 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc-lib/java/src/main/java/software/amazon/jsii/tests/calculator/lib/StructWithOnlyOptionals.java +++ b/packages/jsii-pacmak/test/expected.jsii-calc-lib/java/src/main/java/software/amazon/jsii/tests/calculator/lib/StructWithOnlyOptionals.java @@ -13,19 +13,25 @@ public interface StructWithOnlyOptionals extends software.amazon.jsii.JsiiSerial */ @Deprecated @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Deprecated) - java.lang.String getOptional1(); + default java.lang.String getOptional1() { + return null; + } /** */ @Deprecated @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Deprecated) - java.lang.Number getOptional2(); + default java.lang.Number getOptional2() { + return null; + } /** */ @Deprecated @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Deprecated) - java.lang.Boolean getOptional3(); + default java.lang.Boolean getOptional3() { + return null; + } /** * @return a {@link Builder} of {@link StructWithOnlyOptionals} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon.JSII.Tests.CalculatorPackageId.csproj b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon.JSII.Tests.CalculatorPackageId.csproj index 4a859586a5..1890516e1e 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon.JSII.Tests.CalculatorPackageId.csproj +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon.JSII.Tests.CalculatorPackageId.csproj @@ -1,6 +1,6 @@ - netcoreapp2.1 + netcoreapp3.0 true true true diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/ICalculatorProps.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/ICalculatorProps.cs index 5c7915c541..dce6c31947 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/ICalculatorProps.cs +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/ICalculatorProps.cs @@ -13,18 +13,26 @@ public interface ICalculatorProps /// stability: Experimental /// [JsiiProperty(name: "initialValue", typeJson: "{\"primitive\":\"number\"}", isOptional: true)] + [Amazon.JSII.Runtime.Deputy.JsiiOptional] double? InitialValue { - get; + get + { + return null; + } } /// /// stability: Experimental /// [JsiiProperty(name: "maximumValue", typeJson: "{\"primitive\":\"number\"}", isOptional: true)] + [Amazon.JSII.Runtime.Deputy.JsiiOptional] double? MaximumValue { - get; + get + { + return null; + } } } } diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IDeprecatedInterface.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IDeprecatedInterface.cs index 548b659527..f9c3993e3f 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IDeprecatedInterface.cs +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IDeprecatedInterface.cs @@ -14,10 +14,17 @@ public interface IDeprecatedInterface /// [JsiiProperty(name: "mutableProperty", typeJson: "{\"primitive\":\"number\"}", isOptional: true)] [System.Obsolete("could be better")] + [Amazon.JSII.Runtime.Deputy.JsiiOptional] double? MutableProperty { - get; - set; + get + { + return null; + } + set + { + throw new System.NotSupportedException("'set' for 'MutableProperty' is not implemented"); + } } /// /// stability: Deprecated diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IDerivedStruct.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IDerivedStruct.cs index c757d31530..52e933c746 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IDerivedStruct.cs +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IDerivedStruct.cs @@ -42,27 +42,39 @@ Amazon.JSII.Tests.CalculatorNamespace.DoubleTrouble NonPrimitive /// stability: Experimental /// [JsiiProperty(name: "anotherOptional", typeJson: "{\"collection\":{\"elementtype\":{\"fqn\":\"@scope/jsii-calc-lib.Value\"},\"kind\":\"map\"}}", isOptional: true)] + [Amazon.JSII.Runtime.Deputy.JsiiOptional] System.Collections.Generic.IDictionary AnotherOptional { - get; + get + { + return null; + } } /// /// stability: Experimental /// [JsiiProperty(name: "optionalAny", typeJson: "{\"primitive\":\"any\"}", isOptional: true)] + [Amazon.JSII.Runtime.Deputy.JsiiOptional] object OptionalAny { - get; + get + { + return null; + } } /// /// stability: Experimental /// [JsiiProperty(name: "optionalArray", typeJson: "{\"collection\":{\"elementtype\":{\"primitive\":\"string\"},\"kind\":\"array\"}}", isOptional: true)] + [Amazon.JSII.Runtime.Deputy.JsiiOptional] string[] OptionalArray { - get; + get + { + return null; + } } } } diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IEraseUndefinedHashValuesOptions.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IEraseUndefinedHashValuesOptions.cs index 979958786b..610a03e3f9 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IEraseUndefinedHashValuesOptions.cs +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IEraseUndefinedHashValuesOptions.cs @@ -12,18 +12,26 @@ public interface IEraseUndefinedHashValuesOptions /// stability: Experimental /// [JsiiProperty(name: "option1", typeJson: "{\"primitive\":\"string\"}", isOptional: true)] + [Amazon.JSII.Runtime.Deputy.JsiiOptional] string Option1 { - get; + get + { + return null; + } } /// /// stability: Experimental /// [JsiiProperty(name: "option2", typeJson: "{\"primitive\":\"string\"}", isOptional: true)] + [Amazon.JSII.Runtime.Deputy.JsiiOptional] string Option2 { - get; + get + { + return null; + } } } } diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IExperimentalInterface.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IExperimentalInterface.cs index b1a6cf5cc9..80152a2151 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IExperimentalInterface.cs +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IExperimentalInterface.cs @@ -12,10 +12,17 @@ public interface IExperimentalInterface /// stability: Experimental /// [JsiiProperty(name: "mutableProperty", typeJson: "{\"primitive\":\"number\"}", isOptional: true)] + [Amazon.JSII.Runtime.Deputy.JsiiOptional] double? MutableProperty { - get; - set; + get + { + return null; + } + set + { + throw new System.NotSupportedException("'set' for 'MutableProperty' is not implemented"); + } } /// /// stability: Experimental diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IGreetee.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IGreetee.cs index c82087b6db..13edf40384 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IGreetee.cs +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IGreetee.cs @@ -16,9 +16,13 @@ public interface IGreetee /// stability: Experimental /// [JsiiProperty(name: "name", typeJson: "{\"primitive\":\"string\"}", isOptional: true)] + [Amazon.JSII.Runtime.Deputy.JsiiOptional] string Name { - get; + get + { + return null; + } } } } diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/ILoadBalancedFargateServiceProps.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/ILoadBalancedFargateServiceProps.cs index d0452eb2df..138e634419 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/ILoadBalancedFargateServiceProps.cs +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/ILoadBalancedFargateServiceProps.cs @@ -17,9 +17,13 @@ public interface ILoadBalancedFargateServiceProps /// stability: Experimental /// [JsiiProperty(name: "containerPort", typeJson: "{\"primitive\":\"number\"}", isOptional: true)] + [Amazon.JSII.Runtime.Deputy.JsiiOptional] double? ContainerPort { - get; + get + { + return null; + } } /// The number of cpu units used by the task. Valid values, which determines your range of valid values for the memory parameter: 256 (.25 vCPU) - Available memory values: 0.5GB, 1GB, 2GB 512 (.5 vCPU) - Available memory values: 1GB, 2GB, 3GB, 4GB 1024 (1 vCPU) - Available memory values: 2GB, 3GB, 4GB, 5GB, 6GB, 7GB, 8GB 2048 (2 vCPU) - Available memory values: Between 4GB and 16GB in 1GB increments 4096 (4 vCPU) - Available memory values: Between 8GB and 30GB in 1GB increments. @@ -30,9 +34,13 @@ public interface ILoadBalancedFargateServiceProps /// stability: Experimental /// [JsiiProperty(name: "cpu", typeJson: "{\"primitive\":\"string\"}", isOptional: true)] + [Amazon.JSII.Runtime.Deputy.JsiiOptional] string Cpu { - get; + get + { + return null; + } } /// The amount (in MiB) of memory used by the task. @@ -56,9 +64,13 @@ string Cpu /// stability: Experimental /// [JsiiProperty(name: "memoryMiB", typeJson: "{\"primitive\":\"string\"}", isOptional: true)] + [Amazon.JSII.Runtime.Deputy.JsiiOptional] string MemoryMiB { - get; + get + { + return null; + } } /// Determines whether the Application Load Balancer will be internet-facing. @@ -68,9 +80,13 @@ string MemoryMiB /// stability: Experimental /// [JsiiProperty(name: "publicLoadBalancer", typeJson: "{\"primitive\":\"boolean\"}", isOptional: true)] + [Amazon.JSII.Runtime.Deputy.JsiiOptional] bool? PublicLoadBalancer { - get; + get + { + return null; + } } /// Determines whether your Fargate Service will be assigned a public IP address. @@ -80,9 +96,13 @@ string MemoryMiB /// stability: Experimental /// [JsiiProperty(name: "publicTasks", typeJson: "{\"primitive\":\"boolean\"}", isOptional: true)] + [Amazon.JSII.Runtime.Deputy.JsiiOptional] bool? PublicTasks { - get; + get + { + return null; + } } } } diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/INullShouldBeTreatedAsUndefinedData.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/INullShouldBeTreatedAsUndefinedData.cs index f2cda4473b..aa8dad47cf 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/INullShouldBeTreatedAsUndefinedData.cs +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/INullShouldBeTreatedAsUndefinedData.cs @@ -21,9 +21,13 @@ object[] ArrayWithThreeElementsAndUndefinedAsSecondArgument /// stability: Experimental /// [JsiiProperty(name: "thisShouldBeUndefined", typeJson: "{\"primitive\":\"any\"}", isOptional: true)] + [Amazon.JSII.Runtime.Deputy.JsiiOptional] object ThisShouldBeUndefined { - get; + get + { + return null; + } } } } diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IOptionalStruct.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IOptionalStruct.cs index 6fed1c1d17..d668496af9 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IOptionalStruct.cs +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IOptionalStruct.cs @@ -12,9 +12,13 @@ public interface IOptionalStruct /// stability: Experimental /// [JsiiProperty(name: "field", typeJson: "{\"primitive\":\"string\"}", isOptional: true)] + [Amazon.JSII.Runtime.Deputy.JsiiOptional] string Field { - get; + get + { + return null; + } } } } diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/ISecondLevelStruct.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/ISecondLevelStruct.cs index cbf60a85ee..7dfe871498 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/ISecondLevelStruct.cs +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/ISecondLevelStruct.cs @@ -23,9 +23,13 @@ string DeeperRequiredProp /// stability: Experimental /// [JsiiProperty(name: "deeperOptionalProp", typeJson: "{\"primitive\":\"string\"}", isOptional: true)] + [Amazon.JSII.Runtime.Deputy.JsiiOptional] string DeeperOptionalProp { - get; + get + { + return null; + } } } } diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IStableInterface.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IStableInterface.cs index c28a6624ad..bfd4c5301b 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IStableInterface.cs +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IStableInterface.cs @@ -12,10 +12,17 @@ public interface IStableInterface /// stability: Stable /// [JsiiProperty(name: "mutableProperty", typeJson: "{\"primitive\":\"number\"}", isOptional: true)] + [Amazon.JSII.Runtime.Deputy.JsiiOptional] double? MutableProperty { - get; - set; + get + { + return null; + } + set + { + throw new System.NotSupportedException("'set' for 'MutableProperty' is not implemented"); + } } /// /// stability: Stable diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IStructWithJavaReservedWords.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IStructWithJavaReservedWords.cs index 82b77c4bb3..323fd86218 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IStructWithJavaReservedWords.cs +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IStructWithJavaReservedWords.cs @@ -21,27 +21,39 @@ string Default /// stability: Experimental /// [JsiiProperty(name: "assert", typeJson: "{\"primitive\":\"string\"}", isOptional: true)] + [Amazon.JSII.Runtime.Deputy.JsiiOptional] string Assert { - get; + get + { + return null; + } } /// /// stability: Experimental /// [JsiiProperty(name: "result", typeJson: "{\"primitive\":\"string\"}", isOptional: true)] + [Amazon.JSII.Runtime.Deputy.JsiiOptional] string Result { - get; + get + { + return null; + } } /// /// stability: Experimental /// [JsiiProperty(name: "that", typeJson: "{\"primitive\":\"string\"}", isOptional: true)] + [Amazon.JSII.Runtime.Deputy.JsiiOptional] string That { - get; + get + { + return null; + } } } } diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/ITopLevelStruct.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/ITopLevelStruct.cs index cacaf15a97..0cb00703cd 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/ITopLevelStruct.cs +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/ITopLevelStruct.cs @@ -33,9 +33,13 @@ object SecondLevel /// stability: Experimental /// [JsiiProperty(name: "optional", typeJson: "{\"primitive\":\"string\"}", isOptional: true)] + [Amazon.JSII.Runtime.Deputy.JsiiOptional] string Optional { - get; + get + { + return null; + } } } } diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IUnionProperties.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IUnionProperties.cs index ffed2786ba..2791a24f35 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IUnionProperties.cs +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IUnionProperties.cs @@ -21,9 +21,13 @@ object Bar /// stability: Experimental /// [JsiiProperty(name: "foo", typeJson: "{\"union\":{\"types\":[{\"primitive\":\"string\"},{\"primitive\":\"number\"}]}}", isOptional: true)] + [Amazon.JSII.Runtime.Deputy.JsiiOptional] object Foo { - get; + get + { + return null; + } } } } diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/CalculatorProps.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/CalculatorProps.java index 56b53e27f5..edec2a00f8 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/CalculatorProps.java +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/CalculatorProps.java @@ -13,13 +13,17 @@ public interface CalculatorProps extends software.amazon.jsii.JsiiSerializable { * EXPERIMENTAL */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) - java.lang.Number getInitialValue(); + default java.lang.Number getInitialValue() { + return null; + } /** * EXPERIMENTAL */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) - java.lang.Number getMaximumValue(); + default java.lang.Number getMaximumValue() { + return null; + } /** * @return a {@link Builder} of {@link CalculatorProps} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/DerivedStruct.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/DerivedStruct.java index 9ef12b74a6..478af8702e 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/DerivedStruct.java +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/DerivedStruct.java @@ -35,19 +35,25 @@ public interface DerivedStruct extends software.amazon.jsii.JsiiSerializable, so * EXPERIMENTAL */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) - java.util.Map getAnotherOptional(); + default java.util.Map getAnotherOptional() { + return null; + } /** * EXPERIMENTAL */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) - java.lang.Object getOptionalAny(); + default java.lang.Object getOptionalAny() { + return null; + } /** * EXPERIMENTAL */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) - java.util.List getOptionalArray(); + default java.util.List getOptionalArray() { + return null; + } /** * @return a {@link Builder} of {@link DerivedStruct} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/EraseUndefinedHashValuesOptions.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/EraseUndefinedHashValuesOptions.java index ebc4b4549a..67422c0aa8 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/EraseUndefinedHashValuesOptions.java +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/EraseUndefinedHashValuesOptions.java @@ -11,13 +11,17 @@ public interface EraseUndefinedHashValuesOptions extends software.amazon.jsii.Js * EXPERIMENTAL */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) - java.lang.String getOption1(); + default java.lang.String getOption1() { + return null; + } /** * EXPERIMENTAL */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) - java.lang.String getOption2(); + default java.lang.String getOption2() { + return null; + } /** * @return a {@link Builder} of {@link EraseUndefinedHashValuesOptions} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/Greetee.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/Greetee.java index 2f1cd911f2..31080ca6ee 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/Greetee.java +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/Greetee.java @@ -17,7 +17,9 @@ public interface Greetee extends software.amazon.jsii.JsiiSerializable { * EXPERIMENTAL */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) - java.lang.String getName(); + default java.lang.String getName() { + return null; + } /** * @return a {@link Builder} of {@link Greetee} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/IDeprecatedInterface.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/IDeprecatedInterface.java index f98a494aa7..d0150fc5b0 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/IDeprecatedInterface.java +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/IDeprecatedInterface.java @@ -13,12 +13,17 @@ public interface IDeprecatedInterface extends software.amazon.jsii.JsiiSerializa */ @Deprecated @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Deprecated) - java.lang.Number getMutableProperty(); + default java.lang.Number getMutableProperty() { + return null; + } /** * @deprecated could be better */ - void setMutableProperty(final java.lang.Number value); + @software.amazon.jsii.Optional + default void setMutableProperty(final java.lang.Number value) { + throw new UnsupportedOperationException("'void " + getClass().getCanonicalName() + "#setMutableProperty(java.lang.Number)' is not implemented!"); + } /** * @deprecated services no purpose diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/IExperimentalInterface.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/IExperimentalInterface.java index 28a772b678..ff5048a591 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/IExperimentalInterface.java +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/IExperimentalInterface.java @@ -11,12 +11,17 @@ public interface IExperimentalInterface extends software.amazon.jsii.JsiiSeriali * EXPERIMENTAL */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) - java.lang.Number getMutableProperty(); + default java.lang.Number getMutableProperty() { + return null; + } /** * EXPERIMENTAL */ - void setMutableProperty(final java.lang.Number value); + @software.amazon.jsii.Optional + default void setMutableProperty(final java.lang.Number value) { + throw new UnsupportedOperationException("'void " + getClass().getCanonicalName() + "#setMutableProperty(java.lang.Number)' is not implemented!"); + } /** * EXPERIMENTAL diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/IStableInterface.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/IStableInterface.java index f068c80dc9..4e6dcc87e4 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/IStableInterface.java +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/IStableInterface.java @@ -9,11 +9,16 @@ public interface IStableInterface extends software.amazon.jsii.JsiiSerializable /** */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) - java.lang.Number getMutableProperty(); + default java.lang.Number getMutableProperty() { + return null; + } /** */ - void setMutableProperty(final java.lang.Number value); + @software.amazon.jsii.Optional + default void setMutableProperty(final java.lang.Number value) { + throw new UnsupportedOperationException("'void " + getClass().getCanonicalName() + "#setMutableProperty(java.lang.Number)' is not implemented!"); + } /** */ diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/LoadBalancedFargateServiceProps.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/LoadBalancedFargateServiceProps.java index bbd612596d..1f4fe750ac 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/LoadBalancedFargateServiceProps.java +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/LoadBalancedFargateServiceProps.java @@ -19,7 +19,9 @@ public interface LoadBalancedFargateServiceProps extends software.amazon.jsii.Js * EXPERIMENTAL */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) - java.lang.Number getContainerPort(); + default java.lang.Number getContainerPort() { + return null; + } /** * The number of cpu units used by the task. Valid values, which determines your range of valid values for the memory parameter: 256 (.25 vCPU) - Available memory values: 0.5GB, 1GB, 2GB 512 (.5 vCPU) - Available memory values: 1GB, 2GB, 3GB, 4GB 1024 (1 vCPU) - Available memory values: 2GB, 3GB, 4GB, 5GB, 6GB, 7GB, 8GB 2048 (2 vCPU) - Available memory values: Between 4GB and 16GB in 1GB increments 4096 (4 vCPU) - Available memory values: Between 8GB and 30GB in 1GB increments. @@ -31,7 +33,9 @@ public interface LoadBalancedFargateServiceProps extends software.amazon.jsii.Js * EXPERIMENTAL */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) - java.lang.String getCpu(); + default java.lang.String getCpu() { + return null; + } /** * The amount (in MiB) of memory used by the task. @@ -56,7 +60,9 @@ public interface LoadBalancedFargateServiceProps extends software.amazon.jsii.Js * EXPERIMENTAL */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) - java.lang.String getMemoryMiB(); + default java.lang.String getMemoryMiB() { + return null; + } /** * Determines whether the Application Load Balancer will be internet-facing. @@ -66,7 +72,9 @@ public interface LoadBalancedFargateServiceProps extends software.amazon.jsii.Js * EXPERIMENTAL */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) - java.lang.Boolean getPublicLoadBalancer(); + default java.lang.Boolean getPublicLoadBalancer() { + return null; + } /** * Determines whether your Fargate Service will be assigned a public IP address. @@ -76,7 +84,9 @@ public interface LoadBalancedFargateServiceProps extends software.amazon.jsii.Js * EXPERIMENTAL */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) - java.lang.Boolean getPublicTasks(); + default java.lang.Boolean getPublicTasks() { + return null; + } /** * @return a {@link Builder} of {@link LoadBalancedFargateServiceProps} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/NullShouldBeTreatedAsUndefinedData.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/NullShouldBeTreatedAsUndefinedData.java index 0cc86a97de..d4abffa9b3 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/NullShouldBeTreatedAsUndefinedData.java +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/NullShouldBeTreatedAsUndefinedData.java @@ -17,7 +17,9 @@ public interface NullShouldBeTreatedAsUndefinedData extends software.amazon.jsii * EXPERIMENTAL */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) - java.lang.Object getThisShouldBeUndefined(); + default java.lang.Object getThisShouldBeUndefined() { + return null; + } /** * @return a {@link Builder} of {@link NullShouldBeTreatedAsUndefinedData} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/OptionalStruct.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/OptionalStruct.java index 08f72989ff..4ecf71d049 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/OptionalStruct.java +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/OptionalStruct.java @@ -11,7 +11,9 @@ public interface OptionalStruct extends software.amazon.jsii.JsiiSerializable { * EXPERIMENTAL */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) - java.lang.String getField(); + default java.lang.String getField() { + return null; + } /** * @return a {@link Builder} of {@link OptionalStruct} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/SecondLevelStruct.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/SecondLevelStruct.java index b8608b560a..0b65b9dfbd 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/SecondLevelStruct.java +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/SecondLevelStruct.java @@ -21,7 +21,9 @@ public interface SecondLevelStruct extends software.amazon.jsii.JsiiSerializable * EXPERIMENTAL */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) - java.lang.String getDeeperOptionalProp(); + default java.lang.String getDeeperOptionalProp() { + return null; + } /** * @return a {@link Builder} of {@link SecondLevelStruct} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/StructWithJavaReservedWords.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/StructWithJavaReservedWords.java index 4ec8701f2c..ba8ebc1d61 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/StructWithJavaReservedWords.java +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/StructWithJavaReservedWords.java @@ -17,19 +17,25 @@ public interface StructWithJavaReservedWords extends software.amazon.jsii.JsiiSe * EXPERIMENTAL */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) - java.lang.String getAssertValue(); + default java.lang.String getAssertValue() { + return null; + } /** * EXPERIMENTAL */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) - java.lang.String getResult(); + default java.lang.String getResult() { + return null; + } /** * EXPERIMENTAL */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) - java.lang.String getThat(); + default java.lang.String getThat() { + return null; + } /** * @return a {@link Builder} of {@link StructWithJavaReservedWords} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/TopLevelStruct.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/TopLevelStruct.java index d697f1e156..11fc51a439 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/TopLevelStruct.java +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/TopLevelStruct.java @@ -29,7 +29,9 @@ public interface TopLevelStruct extends software.amazon.jsii.JsiiSerializable { * EXPERIMENTAL */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) - java.lang.String getOptional(); + default java.lang.String getOptional() { + return null; + } /** * @return a {@link Builder} of {@link TopLevelStruct} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/UnionProperties.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/UnionProperties.java index 3e0bb49b73..9af45426cb 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/UnionProperties.java +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/UnionProperties.java @@ -17,7 +17,9 @@ public interface UnionProperties extends software.amazon.jsii.JsiiSerializable { * EXPERIMENTAL */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) - java.lang.Object getFoo(); + default java.lang.Object getFoo() { + return null; + } /** * @return a {@link Builder} of {@link UnionProperties}