Skip to content

Commit df82bdd

Browse files
RomainMullermergify[bot]
authored andcommitted
chore: clean up C# example (#143)
- Added the dependency on the JSII Roslyn analyzers package. - Removed now-unnecessary `null` arguments for "default props". - Upgraded Lambda's runtime to Node-10.x (Node-8.x being deprecated)
1 parent 2f44560 commit df82bdd

File tree

4 files changed

+24
-23
lines changed

4 files changed

+24
-23
lines changed

csharp/my-widget-service/cdk.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"app": "dotnet src/MyWidgetService/bin/Debug/netcoreapp2.1/MyWidgetService.dll"
2+
"app": "dotnet src/MyWidgetService/bin/Debug/netcoreapp3.0/MyWidgetService.dll"
33
}

csharp/my-widget-service/src/MyWidgetService/MyWidgetService.csproj

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp2.1</TargetFramework>
5+
<TargetFramework>netcoreapp3.0</TargetFramework>
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Amazon.CDK" Version="1.2.0-devpreview" />
10-
<PackageReference Include="Amazon.CDK.AWS.ApiGateway" Version="1.2.0-devpreview" />
11-
<PackageReference Include="Amazon.CDK.AWS.Lambda" Version="1.2.0-devpreview" />
12-
<PackageReference Include="Amazon.CDK.AWS.S3" Version="1.2.0-devpreview" />
9+
<PackageReference Include="Amazon.CDK" Version="1.14.0-devpreview" />
10+
<PackageReference Include="Amazon.CDK.AWS.ApiGateway" Version="1.14.0-devpreview" />
11+
<PackageReference Include="Amazon.CDK.AWS.Lambda" Version="1.14.0-devpreview" />
12+
<PackageReference Include="Amazon.CDK.AWS.S3" Version="1.14.0-devpreview" />
13+
<PackageReference Include="Amazon.JSII.Analyzers" Version="0.19.0" PrivateAssets="all" />
1314
</ItemGroup>
1415

1516
</Project>

csharp/my-widget-service/src/MyWidgetService/MyWidgetServiceStack.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@
66

77
namespace MyWidgetService
88
{
9-
public class MyWidgetServiceStack : Stack
9+
internal sealed class MyWidgetServiceStack : Stack
1010
{
1111
public MyWidgetServiceStack(Construct parent, string id, IStackProps props) : base(parent, id, props)
1212
{
13-
var bucket = new Bucket(this, "WidgetStore", null);
13+
var bucket = new Bucket(this, "WidgetStore");
1414

1515
var handler = new Function(this, "WidgetHandler", new FunctionProps {
16-
Runtime = Runtime.NODEJS_8_10,
17-
Code = AssetCode.Asset("src/MyWidgetService/resources"),
16+
Runtime = Runtime.NODEJS_10_X,
17+
Code = Code.FromAsset("src/MyWidgetService/resources"),
1818
Handler = "widgets.main",
19-
Environment = new Dictionary<string, object>{
19+
Environment = new Dictionary<string, string>{
2020
{ "BUCKET", bucket.BucketName }
2121
}
2222
});
2323

24-
bucket.GrantReadWrite(handler, null);
24+
bucket.GrantReadWrite(handler);
2525

2626
var api = new RestApi(this, "widgets-api", new RestApiProps {
2727
RestApiName = "Widget Service",
@@ -34,17 +34,17 @@ public MyWidgetServiceStack(Construct parent, string id, IStackProps props) : ba
3434
},
3535
});
3636

37-
api.Root.AddMethod("GET", getWidgetsIntegration, null);
37+
api.Root.AddMethod("GET", getWidgetsIntegration);
3838

39-
var widget = api.Root.AddResource("{id}", null);
39+
var widget = api.Root.AddResource("{id}");
4040

41-
var postWidgetIntegration = new LambdaIntegration(handler, null);
42-
var getWidgetIntegration = new LambdaIntegration(handler, null);
43-
var deleteWidgetIntegration = new LambdaIntegration(handler, null);
41+
var postWidgetIntegration = new LambdaIntegration(handler);
42+
var getWidgetIntegration = new LambdaIntegration(handler);
43+
var deleteWidgetIntegration = new LambdaIntegration(handler);
4444

45-
widget.AddMethod("POST", postWidgetIntegration, null);
46-
widget.AddMethod("GET", getWidgetIntegration, null);
47-
widget.AddMethod("DELETE", deleteWidgetIntegration, null);
45+
widget.AddMethod("POST", postWidgetIntegration);
46+
widget.AddMethod("GET", getWidgetIntegration);
47+
widget.AddMethod("DELETE", deleteWidgetIntegration);
4848
}
4949
}
5050
}

csharp/my-widget-service/src/MyWidgetService/Program.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55

66
namespace MyWidgetService
77
{
8-
class Program
8+
public sealed class Program
99
{
10-
static void Main(string[] args)
10+
public static void Main(string[] args)
1111
{
12-
var app = new App(null);
12+
var app = new App();
1313
new MyWidgetServiceStack(app, "MyWidgetServiceStack", new StackProps());
1414
app.Synth();
1515
}

0 commit comments

Comments
 (0)