Skip to content

Commit 0022859

Browse files
authored
Add trimming support for RuntimeSupport, SystemTextJson serializer and Lambda event packages (#1596)
Add trimming support for RuntimeSupport, SystemTextJson serializer and Lambda event packages when targeting .NET 8
1 parent 68396f5 commit 0022859

File tree

100 files changed

+553
-348
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+553
-348
lines changed

.github/workflows/source-generator-ci.yml

+8
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ jobs:
2222
uses: actions/setup-dotnet@v1
2323
with:
2424
dotnet-version: 6.0.x
25+
- name: Setup .NET 8.0
26+
uses: actions/setup-dotnet@v1
27+
with:
28+
dotnet-version: 8.0.100-rc.2.23502.2
2529
- name: Configure AWS Credentials
2630
uses: aws-actions/configure-aws-credentials@v1
2731
with:
@@ -73,6 +77,10 @@ jobs:
7377
uses: actions/setup-dotnet@v1
7478
with:
7579
dotnet-version: 6.0.x
80+
- name: Setup .NET 8.0
81+
uses: actions/setup-dotnet@v1
82+
with:
83+
dotnet-version: 8.0.100-rc.2.23502.2
7684
- name: Restore dependencies
7785
run: dotnet restore Libraries/test/TestServerlessApp/TestServerlessApp.csproj
7886
- name: Build

Libraries/src/Amazon.Lambda.APIGatewayEvents/APIGatewayCustomAuthorizerPolicy.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ public class APIGatewayCustomAuthorizerPolicy
1010
/// <summary>
1111
/// Gets or sets the IAM API version.
1212
/// </summary>
13-
#if NETCOREAPP_3_1
13+
#if NETCOREAPP3_1_OR_GREATER
1414
[System.Text.Json.Serialization.JsonPropertyName("Version")]
1515
#endif
1616
public string Version { get; set; } = "2012-10-17";
1717

1818
/// <summary>
1919
/// Gets or sets a list of IAM policy statements to apply.
2020
/// </summary>
21-
#if NETCOREAPP_3_1
21+
#if NETCOREAPP3_1_OR_GREATER
2222
[System.Text.Json.Serialization.JsonPropertyName("Statement")]
2323
#endif
2424
public List<IAMPolicyStatement> Statement { get; set; } = new List<IAMPolicyStatement>();
@@ -31,23 +31,23 @@ public class IAMPolicyStatement
3131
/// <summary>
3232
/// Gets or sets the effect the statement has.
3333
/// </summary>
34-
#if NETCOREAPP_3_1
34+
#if NETCOREAPP3_1_OR_GREATER
3535
[System.Text.Json.Serialization.JsonPropertyName("Effect")]
3636
#endif
3737
public string Effect { get; set; } = "Allow";
3838

3939
/// <summary>
4040
/// Gets or sets the action/s the statement has.
4141
/// </summary>
42-
#if NETCOREAPP_3_1
42+
#if NETCOREAPP3_1_OR_GREATER
4343
[System.Text.Json.Serialization.JsonPropertyName("Action")]
4444
#endif
4545
public HashSet<string> Action { get; set; }
4646

4747
/// <summary>
4848
/// Gets or sets the resources the statement applies to.
4949
/// </summary>
50-
#if NETCOREAPP_3_1
50+
#if NETCOREAPP3_1_OR_GREATER
5151
[System.Text.Json.Serialization.JsonPropertyName("Resource")]
5252
#endif
5353
public HashSet<string> Resource { get; set; }

Libraries/src/Amazon.Lambda.APIGatewayEvents/APIGatewayCustomAuthorizerResponse.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class APIGatewayCustomAuthorizerResponse
1212
/// Gets or sets the ID of the principal.
1313
/// </summary>
1414
[DataMember(Name = "principalId")]
15-
#if NETCOREAPP_3_1
15+
#if NETCOREAPP3_1_OR_GREATER
1616
[System.Text.Json.Serialization.JsonPropertyName("principalId")]
1717
#endif
1818
public string PrincipalID { get; set; }
@@ -21,7 +21,7 @@ public class APIGatewayCustomAuthorizerResponse
2121
/// Gets or sets the <see cref="APIGatewayCustomAuthorizerPolicy"/> policy document.
2222
/// </summary>
2323
[DataMember(Name = "policyDocument")]
24-
#if NETCOREAPP_3_1
24+
#if NETCOREAPP3_1_OR_GREATER
2525
[System.Text.Json.Serialization.JsonPropertyName("policyDocument")]
2626
#endif
2727
public APIGatewayCustomAuthorizerPolicy PolicyDocument { get; set; } = new APIGatewayCustomAuthorizerPolicy();
@@ -30,7 +30,7 @@ public class APIGatewayCustomAuthorizerResponse
3030
/// Gets or sets the <see cref="APIGatewayCustomAuthorizerContext"/> property.
3131
/// </summary>
3232
[DataMember(Name = "context")]
33-
#if NETCOREAPP_3_1
33+
#if NETCOREAPP3_1_OR_GREATER
3434
[System.Text.Json.Serialization.JsonPropertyName("context")]
3535
#endif
3636
public APIGatewayCustomAuthorizerContextOutput Context { get; set; }
@@ -39,7 +39,7 @@ public class APIGatewayCustomAuthorizerResponse
3939
/// Gets or sets the usageIdentifierKey.
4040
/// </summary>
4141
[DataMember(Name = "usageIdentifierKey")]
42-
#if NETCOREAPP_3_1
42+
#if NETCOREAPP3_1_OR_GREATER
4343
[System.Text.Json.Serialization.JsonPropertyName("usageIdentifierKey")]
4444
#endif
4545
public string UsageIdentifierKey { get; set; }

Libraries/src/Amazon.Lambda.APIGatewayEvents/APIGatewayCustomAuthorizerV2IamResponse.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class APIGatewayCustomAuthorizerV2IamResponse
1414
/// Gets or sets the ID of the principal.
1515
/// </summary>
1616
[DataMember(Name = "principalId")]
17-
#if NETCOREAPP_3_1
17+
#if NETCOREAPP3_1_OR_GREATER
1818
[System.Text.Json.Serialization.JsonPropertyName("principalId")]
1919
#endif
2020
public string PrincipalID { get; set; }
@@ -23,7 +23,7 @@ public class APIGatewayCustomAuthorizerV2IamResponse
2323
/// Gets or sets the <see cref="APIGatewayCustomAuthorizerPolicy"/> policy document.
2424
/// </summary>
2525
[DataMember(Name = "policyDocument")]
26-
#if NETCOREAPP_3_1
26+
#if NETCOREAPP3_1_OR_GREATER
2727
[System.Text.Json.Serialization.JsonPropertyName("policyDocument")]
2828
#endif
2929
public APIGatewayCustomAuthorizerPolicy PolicyDocument { get; set; } = new APIGatewayCustomAuthorizerPolicy();
@@ -32,7 +32,7 @@ public class APIGatewayCustomAuthorizerV2IamResponse
3232
/// Gets or sets the <see cref="APIGatewayCustomAuthorizerContext"/> property.
3333
/// </summary>
3434
[DataMember(Name = "context")]
35-
#if NETCOREAPP_3_1
35+
#if NETCOREAPP3_1_OR_GREATER
3636
[System.Text.Json.Serialization.JsonPropertyName("context")]
3737
#endif
3838
public Dictionary<string, object> Context { get; set; }

Libraries/src/Amazon.Lambda.APIGatewayEvents/APIGatewayCustomAuthorizerV2SimpleResponse.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class APIGatewayCustomAuthorizerV2SimpleResponse
1414
/// Gets or sets authorization result.
1515
/// </summary>
1616
[DataMember(Name = "isAuthorized")]
17-
#if NETCOREAPP_3_1
17+
#if NETCOREAPP3_1_OR_GREATER
1818
[System.Text.Json.Serialization.JsonPropertyName("isAuthorized")]
1919
#endif
2020
public bool IsAuthorized { get; set; }
@@ -23,7 +23,7 @@ public class APIGatewayCustomAuthorizerV2SimpleResponse
2323
/// Gets or sets the <see cref="APIGatewayCustomAuthorizerContext"/> property.
2424
/// </summary>
2525
[DataMember(Name = "context")]
26-
#if NETCOREAPP_3_1
26+
#if NETCOREAPP3_1_OR_GREATER
2727
[System.Text.Json.Serialization.JsonPropertyName("context")]
2828
#endif
2929
public Dictionary<string, object> Context { get; set; }

Libraries/src/Amazon.Lambda.APIGatewayEvents/APIGatewayHttpApiV2ProxyResponse.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class APIGatewayHttpApiV2ProxyResponse
1717
/// The HTTP status code for the request
1818
/// </summary>
1919
[DataMember(Name = "statusCode")]
20-
#if NETCOREAPP_3_1
20+
#if NETCOREAPP3_1_OR_GREATER
2121
[System.Text.Json.Serialization.JsonPropertyName("statusCode")]
2222
#endif
2323
public int StatusCode { get; set; }
@@ -26,7 +26,7 @@ public class APIGatewayHttpApiV2ProxyResponse
2626
/// The Http headers returned in the response. Multiple header values set for the the same header should be separate by a comma.
2727
/// </summary>
2828
[DataMember(Name = "headers")]
29-
#if NETCOREAPP_3_1
29+
#if NETCOREAPP3_1_OR_GREATER
3030
[System.Text.Json.Serialization.JsonPropertyName("headers")]
3131
#endif
3232
public IDictionary<string, string> Headers { get; set; }
@@ -67,7 +67,7 @@ public void SetHeaderValues(string headerName, IEnumerable<string> values, bool
6767
/// The cookies returned in the response.
6868
/// </summary>
6969
[DataMember(Name = "cookies")]
70-
#if NETCOREAPP_3_1
70+
#if NETCOREAPP3_1_OR_GREATER
7171
[System.Text.Json.Serialization.JsonPropertyName("cookies")]
7272
#endif
7373
public string[] Cookies { get; set; }
@@ -76,7 +76,7 @@ public void SetHeaderValues(string headerName, IEnumerable<string> values, bool
7676
/// The response body
7777
/// </summary>
7878
[DataMember(Name = "body")]
79-
#if NETCOREAPP_3_1
79+
#if NETCOREAPP3_1_OR_GREATER
8080
[System.Text.Json.Serialization.JsonPropertyName("body")]
8181
#endif
8282
public string Body { get; set; }
@@ -85,7 +85,7 @@ public void SetHeaderValues(string headerName, IEnumerable<string> values, bool
8585
/// Flag indicating whether the body should be treated as a base64-encoded string
8686
/// </summary>
8787
[DataMember(Name = "isBase64Encoded")]
88-
#if NETCOREAPP_3_1
88+
#if NETCOREAPP3_1_OR_GREATER
8989
[System.Text.Json.Serialization.JsonPropertyName("isBase64Encoded")]
9090
#endif
9191
public bool IsBase64Encoded { get; set; }

Libraries/src/Amazon.Lambda.APIGatewayEvents/APIGatewayProxyResponse.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class APIGatewayProxyResponse
1414
/// The HTTP status code for the request
1515
/// </summary>
1616
[DataMember(Name = "statusCode")]
17-
#if NETCOREAPP_3_1
17+
#if NETCOREAPP3_1_OR_GREATER
1818
[System.Text.Json.Serialization.JsonPropertyName("statusCode")]
1919
#endif
2020
public int StatusCode { get; set; }
@@ -25,7 +25,7 @@ public class APIGatewayProxyResponse
2525
/// before returning back the headers to the caller.
2626
/// </summary>
2727
[DataMember(Name = "headers")]
28-
#if NETCOREAPP_3_1
28+
#if NETCOREAPP3_1_OR_GREATER
2929
[System.Text.Json.Serialization.JsonPropertyName("headers")]
3030
#endif
3131
public IDictionary<string, string> Headers { get; set; }
@@ -36,7 +36,7 @@ public class APIGatewayProxyResponse
3636
/// before returning back the headers to the caller.
3737
/// </summary>
3838
[DataMember(Name = "multiValueHeaders")]
39-
#if NETCOREAPP_3_1
39+
#if NETCOREAPP3_1_OR_GREATER
4040
[System.Text.Json.Serialization.JsonPropertyName("multiValueHeaders")]
4141
#endif
4242
public IDictionary<string, IList<string>> MultiValueHeaders { get; set; }
@@ -45,7 +45,7 @@ public class APIGatewayProxyResponse
4545
/// The response body
4646
/// </summary>
4747
[DataMember(Name = "body")]
48-
#if NETCOREAPP_3_1
48+
#if NETCOREAPP3_1_OR_GREATER
4949
[System.Text.Json.Serialization.JsonPropertyName("body")]
5050
#endif
5151
public string Body { get; set; }
@@ -54,7 +54,7 @@ public class APIGatewayProxyResponse
5454
/// Flag indicating whether the body should be treated as a base64-encoded string
5555
/// </summary>
5656
[DataMember(Name = "isBase64Encoded")]
57-
#if NETCOREAPP_3_1
57+
#if NETCOREAPP3_1_OR_GREATER
5858
[System.Text.Json.Serialization.JsonPropertyName("isBase64Encoded")]
5959
#endif
6060
public bool IsBase64Encoded { get; set; }

Libraries/src/Amazon.Lambda.APIGatewayEvents/Amazon.Lambda.APIGatewayEvents.csproj

+7-5
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
<Import Project="..\..\..\buildtools\common.props" />
44

55
<PropertyGroup>
6-
<TargetFrameworks>netstandard2.0;netcoreapp3.1</TargetFrameworks>
6+
<TargetFrameworks>netstandard2.0;netcoreapp3.1;net8.0</TargetFrameworks>
77
<Description>Amazon Lambda .NET Core support - API Gateway package.</Description>
88
<AssemblyTitle>Amazon.Lambda.APIGatewayEvents</AssemblyTitle>
9-
<VersionPrefix>2.6.0</VersionPrefix>
9+
<VersionPrefix>2.7.0</VersionPrefix>
1010
<AssemblyName>Amazon.Lambda.APIGatewayEvents</AssemblyName>
1111
<PackageId>Amazon.Lambda.APIGatewayEvents</PackageId>
1212
<PackageTags>AWS;Amazon;Lambda</PackageTags>
@@ -17,9 +17,6 @@
1717
<DefineConstants>NETSTANDARD_2_0</DefineConstants>
1818
</PropertyGroup>
1919

20-
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
21-
<DefineConstants>NETCOREAPP_3_1</DefineConstants>
22-
</PropertyGroup>
2320
<ItemGroup>
2421
<None Include="README.md" Pack="true" PackagePath="\"/>
2522
</ItemGroup>
@@ -28,4 +25,9 @@
2825
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
2926
</ItemGroup>
3027

28+
<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0'">
29+
<WarningsAsErrors>IL2026,IL2067,IL2075</WarningsAsErrors>
30+
<IsTrimmable>true</IsTrimmable>
31+
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
32+
</PropertyGroup>
3133
</Project>

Libraries/src/Amazon.Lambda.ApplicationLoadBalancerEvents/Amazon.Lambda.ApplicationLoadBalancerEvents.csproj

+8-3
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,18 @@
33
<Import Project="..\..\..\buildtools\common.props" />
44

55
<PropertyGroup>
6-
<TargetFrameworks>netstandard2.0;netcoreapp3.1</TargetFrameworks>
6+
<TargetFrameworks>netstandard2.0;netcoreapp3.1;net8.0</TargetFrameworks>
77
<Description>Amazon Lambda .NET Core support - Application Load Balancer package.</Description>
88
<AssemblyTitle>Amazon.Lambda.ApplicationLoadBalancerEvents</AssemblyTitle>
9-
<VersionPrefix>2.1.0</VersionPrefix>
9+
<VersionPrefix>2.2.0</VersionPrefix>
1010
<AssemblyName>Amazon.Lambda.ApplicationLoadBalancerEvents</AssemblyName>
1111
<PackageId>Amazon.Lambda.ApplicationLoadBalancerEvents</PackageId>
1212
<PackageTags>AWS;Amazon;Lambda</PackageTags>
1313
</PropertyGroup>
14-
14+
15+
<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0'">
16+
<WarningsAsErrors>IL2026,IL2067,IL2075</WarningsAsErrors>
17+
<IsTrimmable>true</IsTrimmable>
18+
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
19+
</PropertyGroup>
1520
</Project>

Libraries/src/Amazon.Lambda.ApplicationLoadBalancerEvents/ApplicationLoadBalancerResponse.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class ApplicationLoadBalancerResponse
1414
/// The HTTP status code for the request
1515
/// </summary>
1616
[DataMember(Name = "statusCode")]
17-
#if NETCOREAPP3_1
17+
#if NETCOREAPP3_1_OR_GREATER
1818
[System.Text.Json.Serialization.JsonPropertyName("statusCode")]
1919
#endif
2020
public int StatusCode { get; set; }
@@ -23,7 +23,7 @@ public class ApplicationLoadBalancerResponse
2323
/// The HTTP status description for the request
2424
/// </summary>
2525
[DataMember(Name = "statusDescription")]
26-
#if NETCOREAPP3_1
26+
#if NETCOREAPP3_1_OR_GREATER
2727
[System.Text.Json.Serialization.JsonPropertyName("statusDescription")]
2828
#endif
2929
public string StatusDescription { get; set; }
@@ -33,7 +33,7 @@ public class ApplicationLoadBalancerResponse
3333
/// Note: Use this property when "Multi value headers" is disabled on ELB Target Group.
3434
/// </summary>
3535
[DataMember(Name = "headers")]
36-
#if NETCOREAPP3_1
36+
#if NETCOREAPP3_1_OR_GREATER
3737
[System.Text.Json.Serialization.JsonPropertyName("headers")]
3838
#endif
3939
public IDictionary<string, string> Headers { get; set; }
@@ -43,7 +43,7 @@ public class ApplicationLoadBalancerResponse
4343
/// Note: Use this property when "Multi value headers" is enabled on ELB Target Group.
4444
/// </summary>
4545
[DataMember(Name = "multiValueHeaders")]
46-
#if NETCOREAPP3_1
46+
#if NETCOREAPP3_1_OR_GREATER
4747
[System.Text.Json.Serialization.JsonPropertyName("multiValueHeaders")]
4848
#endif
4949
public IDictionary<string, IList<string>> MultiValueHeaders { get; set; }
@@ -52,7 +52,7 @@ public class ApplicationLoadBalancerResponse
5252
/// The response body
5353
/// </summary>
5454
[DataMember(Name = "body")]
55-
#if NETCOREAPP3_1
55+
#if NETCOREAPP3_1_OR_GREATER
5656
[System.Text.Json.Serialization.JsonPropertyName("body")]
5757
#endif
5858
public string Body { get; set; }
@@ -61,7 +61,7 @@ public class ApplicationLoadBalancerResponse
6161
/// Flag indicating whether the body should be treated as a base64-encoded string
6262
/// </summary>
6363
[DataMember(Name = "isBase64Encoded")]
64-
#if NETCOREAPP3_1
64+
#if NETCOREAPP3_1_OR_GREATER
6565
[System.Text.Json.Serialization.JsonPropertyName("isBase64Encoded")]
6666
#endif
6767
public bool IsBase64Encoded { get; set; }

Libraries/src/Amazon.Lambda.CloudWatchEvents/Amazon.Lambda.CloudWatchEvents.csproj

+7-6
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@
33
<Import Project="..\..\..\buildtools\common.props" />
44

55
<PropertyGroup>
6-
<TargetFrameworks>netstandard2.0;netcoreapp3.1</TargetFrameworks>
6+
<TargetFrameworks>netstandard2.0;netcoreapp3.1;net8.0</TargetFrameworks>
77
<Description>Amazon Lambda .NET Core support - CloudWatchEvents package.</Description>
88
<AssemblyTitle>Amazon.Lambda.CloudWatchEvents</AssemblyTitle>
9-
<VersionPrefix>4.3.0</VersionPrefix>
9+
<VersionPrefix>4.4.0</VersionPrefix>
1010
<AssemblyName>Amazon.Lambda.CloudWatchEvents</AssemblyName>
1111
<PackageId>Amazon.Lambda.CloudWatchEvents</PackageId>
1212
<PackageTags>AWS;Amazon;Lambda</PackageTags>
1313
</PropertyGroup>
1414

15-
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
16-
<DefineConstants>NETCOREAPP_3_1</DefineConstants>
17-
</PropertyGroup>
18-
15+
<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0'">
16+
<WarningsAsErrors>IL2026,IL2067,IL2075</WarningsAsErrors>
17+
<IsTrimmable>true</IsTrimmable>
18+
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
19+
</PropertyGroup>
1920
</Project>

Libraries/src/Amazon.Lambda.CloudWatchEvents/CloudWatchEvent.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ public class CloudWatchEvent<T>
4040
/// For example, ScheduledEvent will be null
4141
/// For example, ECSEvent could be "ECS Container Instance State Change" or "ECS Task State Change"
4242
/// </summary>
43-
#if NETCOREAPP_3_1
44-
[System.Text.Json.Serialization.JsonPropertyName("detail-type")]
43+
#if NETCOREAPP3_1_OR_GREATER
44+
[System.Text.Json.Serialization.JsonPropertyName("detail-type")]
4545
#endif
4646
public string DetailType { get; set; }
4747

Libraries/src/Amazon.Lambda.CloudWatchEvents/S3Events/S3Object.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class S3Object
3030
/// The version ID of the object.
3131
/// </summary>
3232
[DataMember(Name = "version-id")]
33-
#if NETCOREAPP_3_1
33+
#if NETCOREAPP3_1_OR_GREATER
3434
[System.Text.Json.Serialization.JsonPropertyName("version-id")]
3535
#endif
3636
public string VersionId { get; set; }

0 commit comments

Comments
 (0)