Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NETCore31] Add support for using System.Text.Json as the serialization parser #568

Merged
merged 13 commits into from
Mar 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
604 changes: 312 additions & 292 deletions Libraries/Libraries.sln

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@ public class APIGatewayCustomAuthorizerPolicy
/// <summary>
/// Gets or sets the IAM API version.
/// </summary>
#if NETCOREAPP_3_1
[System.Text.Json.Serialization.JsonPropertyName("Version")]
#endif
public string Version { get; set; } = "2012-10-17";

/// <summary>
/// Gets or sets a list of IAM policy statements to apply.
/// </summary>
#if NETCOREAPP_3_1
[System.Text.Json.Serialization.JsonPropertyName("Statement")]
#endif
public List<IAMPolicyStatement> Statement { get; set; } = new List<IAMPolicyStatement>();

/// <summary>
Expand All @@ -25,16 +31,25 @@ public class IAMPolicyStatement
/// <summary>
/// Gets or sets the effect the statement has.
/// </summary>
#if NETCOREAPP_3_1
[System.Text.Json.Serialization.JsonPropertyName("Effect")]
#endif
public string Effect { get; set; } = "Allow";

/// <summary>
/// Gets or sets the action/s the statement has.
/// </summary>
#if NETCOREAPP_3_1
[System.Text.Json.Serialization.JsonPropertyName("Action")]
#endif
public HashSet<string> Action { get; set; }

/// <summary>
/// Gets or sets the resources the statement applies to.
/// </summary>
#if NETCOREAPP_3_1
[System.Text.Json.Serialization.JsonPropertyName("Resource")]
#endif
public HashSet<string> Resource { get; set; }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,36 @@ public class APIGatewayCustomAuthorizerResponse
/// Gets or sets the ID of the principal.
/// </summary>
[DataMember(Name = "principalId")]
#if NETCOREAPP_3_1
[System.Text.Json.Serialization.JsonPropertyName("principalId")]
#endif
public string PrincipalID { get; set; }

/// <summary>
/// Gets or sets the <see cref="APIGatewayCustomAuthorizerPolicy"/> policy document.
/// </summary>
[DataMember(Name = "policyDocument")]
#if NETCOREAPP_3_1
[System.Text.Json.Serialization.JsonPropertyName("policyDocument")]
#endif
public APIGatewayCustomAuthorizerPolicy PolicyDocument { get; set; } = new APIGatewayCustomAuthorizerPolicy();

/// <summary>
/// Gets or sets the <see cref="APIGatewayCustomAuthorizerContext"/> property.
/// </summary>
[DataMember(Name = "context")]
#if NETCOREAPP_3_1
[System.Text.Json.Serialization.JsonPropertyName("context")]
#endif
public APIGatewayCustomAuthorizerContextOutput Context { get; set; }

/// <summary>
/// Gets or sets the usageIdentifierKey.
/// </summary>
[DataMember(Name = "usageIdentifierKey")]
#if NETCOREAPP_3_1
[System.Text.Json.Serialization.JsonPropertyName("usageIdentifierKey")]
#endif
public string UsageIdentifierKey { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public class APIGatewayProxyResponse
/// The HTTP status code for the request
/// </summary>
[DataMember(Name = "statusCode")]
#if NETCOREAPP_3_1
[System.Text.Json.Serialization.JsonPropertyName("statusCode")]
#endif
public int StatusCode { get; set; }

/// <summary>
Expand All @@ -22,6 +25,9 @@ public class APIGatewayProxyResponse
/// before returning back the headers to the caller.
/// </summary>
[DataMember(Name = "headers")]
#if NETCOREAPP_3_1
[System.Text.Json.Serialization.JsonPropertyName("headers")]
#endif
public IDictionary<string, string> Headers { get; set; }

/// <summary>
Expand All @@ -30,18 +36,27 @@ public class APIGatewayProxyResponse
/// before returning back the headers to the caller.
/// </summary>
[DataMember(Name = "multiValueHeaders")]
#if NETCOREAPP_3_1
[System.Text.Json.Serialization.JsonPropertyName("multiValueHeaders")]
#endif
public IDictionary<string, IList<string>> MultiValueHeaders { get; set; }

/// <summary>
/// The response body
/// </summary>
[DataMember(Name = "body")]
#if NETCOREAPP_3_1
[System.Text.Json.Serialization.JsonPropertyName("body")]
#endif
public string Body { get; set; }

/// <summary>
/// Flag indicating whether the body should be treated as a base64-encoded string
/// </summary>
[DataMember(Name = "isBase64Encoded")]
#if NETCOREAPP_3_1
[System.Text.Json.Serialization.JsonPropertyName("isBase64Encoded")]
#endif
public bool IsBase64Encoded { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@
<Import Project="..\..\..\buildtools\common.props" />

<PropertyGroup>
<TargetFrameworks>netstandard1.3;netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netcoreapp3.1</TargetFrameworks>
<Description>Amazon Lambda .NET Core support - API Gateway package.</Description>
<AssemblyTitle>Amazon.Lambda.APIGatewayEvents</AssemblyTitle>
<VersionPrefix>1.3.0</VersionPrefix>
<VersionPrefix>2.0.0-preview1</VersionPrefix>
<AssemblyName>Amazon.Lambda.APIGatewayEvents</AssemblyName>
<PackageId>Amazon.Lambda.APIGatewayEvents</PackageId>
<PackageTags>AWS;Amazon;Lambda</PackageTags>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<DefineConstants>NETCOREAPP_3_1</DefineConstants>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http.Features.Authentication;
#if NETCOREAPP_3_0
#if NETCOREAPP_3_1
using Microsoft.Extensions.Hosting;
#endif

Expand Down Expand Up @@ -341,7 +341,11 @@ protected string ErrorReport(Exception e)
/// <param name="request"></param>
/// <param name="lambdaContext"></param>
/// <returns></returns>
#if NETCOREAPP_2_1
[LambdaSerializer(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))]
#elif NETCOREAPP_3_1
[LambdaSerializer(typeof(Amazon.Lambda.Serialization.SystemTextJson.LambdaJsonSerializer))]
#endif
public virtual async Task<TRESPONSE> FunctionHandlerAsync(TREQUEST request, ILambdaContext lambdaContext)
{
if (!IsStarted)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

<PropertyGroup>
<Description>Amazon.Lambda.AspNetCoreServer makes it easy to run ASP.NET Core Web API applications as AWS Lambda functions.</Description>
<TargetFrameworks>netstandard2.0;netcoreapp3.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netcoreapp3.1</TargetFrameworks>
<AssemblyTitle>Amazon.Lambda.AspNetCoreServer</AssemblyTitle>
<VersionPrefix>4.1.0</VersionPrefix>
<VersionPrefix>5.0.0-preview1</VersionPrefix>
<AssemblyName>Amazon.Lambda.AspNetCoreServer</AssemblyName>
<PackageId>Amazon.Lambda.AspNetCoreServer</PackageId>
<PackageTags>AWS;Amazon;Lambda;aspnetcore</PackageTags>
Expand All @@ -17,25 +17,26 @@
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<DefineConstants>NETSTANDARD_2_0,NETCOREAPP_2_1</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
<DefineConstants>NETCOREAPP_3_0</DefineConstants>
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<DefineConstants>NETCOREAPP_3_1</DefineConstants>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Amazon.Lambda.ApplicationLoadBalancerEvents\Amazon.Lambda.ApplicationLoadBalancerEvents.csproj" />
<ProjectReference Include="..\Amazon.Lambda.Core\Amazon.Lambda.Core.csproj" />
<ProjectReference Include="..\Amazon.Lambda.Logging.AspNetCore\Amazon.Lambda.Logging.AspNetCore.csproj" />
<ProjectReference Include="..\Amazon.Lambda.Serialization.Json\Amazon.Lambda.Serialization.Json.csproj" />
<ProjectReference Include="..\Amazon.Lambda.APIGatewayEvents\Amazon.Lambda.APIGatewayEvents.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.AspNetCore" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.1" />
<ProjectReference Include="..\Amazon.Lambda.Serialization.Json\Amazon.Lambda.Serialization.Json.csproj" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<ProjectReference Include="..\Amazon.Lambda.Serialization.SystemTextJson\Amazon.Lambda.Serialization.SystemTextJson.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
<Import Project="..\..\..\buildtools\common.props" />

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>netstandard2.0;netcoreapp3.1</TargetFrameworks>
<Description>Amazon Lambda .NET Core support - CloudWatchEvents package.</Description>
<AssemblyTitle>Amazon.Lambda.CloudWatchEvents</AssemblyTitle>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionPrefix>2.0.0-preview1</VersionPrefix>
<AssemblyName>Amazon.Lambda.CloudWatchEvents</AssemblyName>
<PackageId>Amazon.Lambda.CloudWatchEvents</PackageId>
<PackageTags>AWS;Amazon;Lambda</PackageTags>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<DefineConstants>NETCOREAPP_3_1</DefineConstants>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public class CloudWatchEvent<T>
/// For example, ScheduledEvent will be null
/// For example, ECSEvent could be "ECS Container Instance State Change" or "ECS Task State Change"
/// </summary>
#if NETCOREAPP_3_1
[System.Text.Json.Serialization.JsonPropertyName("detail-type")]
#endif
public string DetailType { get; set; }

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
<Import Project="..\..\..\buildtools\common.props" />
<PropertyGroup>
<Description>Amazon Lambda .NET Core support - CloudWatchLogsEvents package.</Description>
<TargetFrameworks>netstandard1.3;netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netcoreapp3.1</TargetFrameworks>
<AssemblyTitle>Amazon.Lambda.CloudWatchLogsEvents</AssemblyTitle>
<VersionPrefix>1.1.0</VersionPrefix>
<VersionPrefix>2.0.0-preview1</VersionPrefix>
<AssemblyName>Amazon.Lambda.CloudWatchLogsEvents</AssemblyName>
<PackageId>Amazon.Lambda.CloudWatchLogsEvents</PackageId>
<PackageTags>AWS;Amazon;Lambda</PackageTags>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<DefineConstants>NETCOREAPP_3_1</DefineConstants>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.3'">
<PackageReference Include="System.Runtime.Serialization.Primitives" Version="4.1.1" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ public class Log
/// The data that are base64 encoded and gziped messages in LogStreams.
/// </summary>
[DataMember(Name = "data", IsRequired = false)]
#if NETCOREAPP_3_1
[System.Text.Json.Serialization.JsonPropertyName("data")]
#endif
public string EncodedData { get; set; }

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@
<Import Project="..\..\..\buildtools\common.props" />

<PropertyGroup>
<TargetFrameworks>netstandard1.3;netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netcoreapp3.1</TargetFrameworks>
<Description>Amazon Lambda .NET Core support - Amazon Kinesis Analytics package.</Description>
<AssemblyTitle>Amazon.Lambda.KinesisAnalyticsEvents</AssemblyTitle>
<VersionPrefix>1.1.0</VersionPrefix>
<VersionPrefix>2.0.0-preview1</VersionPrefix>
<AssemblyName>Amazon.Lambda.KinesisAnalyticsEvents</AssemblyName>
<PackageId>Amazon.Lambda.KinesisAnalyticsEvents</PackageId>
<PackageTags>AWS;Amazon;Lambda;KinesisAnalytics</PackageTags>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<DefineConstants>NETCOREAPP_3_1</DefineConstants>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.3'">
<PackageReference Include="System.Runtime.Serialization.Primitives" Version="4.1.1" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public class KinesisAnalyticsInputPreprocessingResponse
/// The records.
/// </value>
[DataMember(Name = "records")]
#if NETCOREAPP_3_1
[System.Text.Json.Serialization.JsonPropertyName("records")]
#endif
public IList<Record> Records { get; set; }

/// <summary>
Expand All @@ -48,6 +51,9 @@ public class Record
/// The record identifier.
/// </value>
[DataMember(Name = "recordId")]
#if NETCOREAPP_3_1
[System.Text.Json.Serialization.JsonPropertyName("recordId")]
#endif
public string RecordId { get; set; }

/// <summary>
Expand All @@ -57,6 +63,9 @@ public class Record
/// The result.
/// </value>
[DataMember(Name = "result")]
#if NETCOREAPP_3_1
[System.Text.Json.Serialization.JsonPropertyName("result")]
#endif
public string Result { get; set; }

/// <summary>
Expand All @@ -66,7 +75,11 @@ public class Record
/// The base64 encoded data.
/// </value>
[DataMember(Name = "data")]
#if NETCOREAPP_3_1
[System.Text.Json.Serialization.JsonPropertyName("data")]
#endif
public string Base64EncodedData { get; set; }

/// <summary>
/// Encodes the data.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ public class LambdaDeliveryRecordMetadata
/// The base64 encoded data.
/// </value>
[DataMember(Name = "data")]
#if NETCOREAPP_3_1
[System.Text.Json.Serialization.JsonPropertyName("data")]
#endif
public string Base64EncodedData { get; set; }

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ public DateTime ApproximateArrivalTimestamp
/// The base64 encoded data.
/// </value>
[DataMember(Name = "data")]
#if NETCOREAPP_3_1
[System.Text.Json.Serialization.JsonPropertyName("data")]
#endif
public string Base64EncodedData { get; set; }

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@
<Import Project="..\..\..\buildtools\common.props" />

<PropertyGroup>
<TargetFrameworks>netstandard1.3;netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netcoreapp3.1</TargetFrameworks>
<Description>Amazon Lambda .NET Core support - Amazon Kinesis Firehose package.</Description>
<AssemblyTitle>Amazon.Lambda.KinesisFirehoseEvents</AssemblyTitle>
<VersionPrefix>1.1.0</VersionPrefix>
<VersionPrefix>2.0.0-preview1</VersionPrefix>
<AssemblyName>Amazon.Lambda.KinesisFirehoseEvents</AssemblyName>
<PackageId>Amazon.Lambda.KinesisFirehoseEvents</PackageId>
<PackageTags>AWS;Amazon;Lambda;KinesisFirehose</PackageTags>
</PropertyGroup>


<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<DefineConstants>NETCOREAPP_3_1</DefineConstants>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.3'">
<PackageReference Include="System.Runtime.Serialization.Primitives" Version="4.1.1" />
</ItemGroup>
Expand Down