-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(jsii): Defaulted parameters were not rendered as optional (#234)
Parameters with a default value were not represented as optional in the assembly documents due to an oversight when re-writing `jsii`. There was also no coverage in the test corpus for this use-case, so I've added some. Fixes #233
- Loading branch information
1 parent
b664805
commit 578bf9c
Showing
12 changed files
with
551 additions
and
4 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
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
39 changes: 39 additions & 0 deletions
39
...CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/DefaultedConstructorArgument.cs
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,39 @@ | ||
using Amazon.JSII.Runtime.Deputy; | ||
using System; | ||
|
||
namespace Amazon.JSII.Tests.CalculatorNamespace | ||
{ | ||
[JsiiClass(typeof(DefaultedConstructorArgument), "jsii-calc.DefaultedConstructorArgument", "[{\"name\":\"arg1\",\"type\":{\"primitive\":\"number\",\"optional\":true}},{\"name\":\"arg2\",\"type\":{\"primitive\":\"string\"}},{\"name\":\"arg3\",\"type\":{\"primitive\":\"date\",\"optional\":true}}]")] | ||
public class DefaultedConstructorArgument : DeputyBase | ||
{ | ||
public DefaultedConstructorArgument(double? arg1, string arg2, DateTime? arg3): base(new DeputyProps(new object[]{arg1, arg2, arg3})) | ||
{ | ||
} | ||
|
||
protected DefaultedConstructorArgument(ByRefValue reference): base(reference) | ||
{ | ||
} | ||
|
||
protected DefaultedConstructorArgument(DeputyProps props): base(props) | ||
{ | ||
} | ||
|
||
[JsiiProperty("arg1", "{\"primitive\":\"number\"}")] | ||
public virtual double Arg1 | ||
{ | ||
get => GetInstanceProperty<double>(); | ||
} | ||
|
||
[JsiiProperty("arg2", "{\"primitive\":\"string\"}")] | ||
public virtual string Arg2 | ||
{ | ||
get => GetInstanceProperty<string>(); | ||
} | ||
|
||
[JsiiProperty("arg3", "{\"primitive\":\"date\"}")] | ||
public virtual DateTime Arg3 | ||
{ | ||
get => GetInstanceProperty<DateTime>(); | ||
} | ||
} | ||
} |
Oops, something went wrong.