From 6196292a8e21087247b6c1680780ef601689c795 Mon Sep 17 00:00:00 2001
From: Henrique Graca <999396+hjgraca@users.noreply.github.com>
Date: Sat, 17 Feb 2024 12:18:07 +0000
Subject: [PATCH 01/82] Update batch examples
Signed-off-by: Henrique Graca <999396+hjgraca@users.noreply.github.com>
---
examples/BatchProcessing/src/HelloWorld/HelloWorld.csproj | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/examples/BatchProcessing/src/HelloWorld/HelloWorld.csproj b/examples/BatchProcessing/src/HelloWorld/HelloWorld.csproj
index 0589010c..ddbd7f4e 100644
--- a/examples/BatchProcessing/src/HelloWorld/HelloWorld.csproj
+++ b/examples/BatchProcessing/src/HelloWorld/HelloWorld.csproj
@@ -7,8 +7,8 @@
-
-
+
+
From 21ea1f4357c1e4a0ce8a6e2dd92298e822eccce9 Mon Sep 17 00:00:00 2001
From: Henrique Graca <999396+hjgraca@users.noreply.github.com>
Date: Sat, 17 Feb 2024 12:19:55 +0000
Subject: [PATCH 02/82] Update idempotency
Signed-off-by: Henrique Graca <999396+hjgraca@users.noreply.github.com>
---
examples/Idempotency/src/HelloWorld/HelloWorld.csproj | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/examples/Idempotency/src/HelloWorld/HelloWorld.csproj b/examples/Idempotency/src/HelloWorld/HelloWorld.csproj
index 1b62c992..645f82af 100644
--- a/examples/Idempotency/src/HelloWorld/HelloWorld.csproj
+++ b/examples/Idempotency/src/HelloWorld/HelloWorld.csproj
@@ -8,7 +8,7 @@
-
-
+
+
From 7381be500da01e8c4c56e82c4a35cfb1704a7fef Mon Sep 17 00:00:00 2001
From: Henrique Graca <999396+hjgraca@users.noreply.github.com>
Date: Sat, 17 Feb 2024 12:20:22 +0000
Subject: [PATCH 03/82] Update Logging
Signed-off-by: Henrique Graca <999396+hjgraca@users.noreply.github.com>
---
examples/Logging/src/HelloWorld/HelloWorld.csproj | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/examples/Logging/src/HelloWorld/HelloWorld.csproj b/examples/Logging/src/HelloWorld/HelloWorld.csproj
index 53323ac8..57b2016b 100644
--- a/examples/Logging/src/HelloWorld/HelloWorld.csproj
+++ b/examples/Logging/src/HelloWorld/HelloWorld.csproj
@@ -8,7 +8,7 @@
-
+
From 2c18aec9168aaae8119d6bd7a8001e9563d9aab0 Mon Sep 17 00:00:00 2001
From: Henrique Graca <999396+hjgraca@users.noreply.github.com>
Date: Sat, 17 Feb 2024 12:20:48 +0000
Subject: [PATCH 04/82] Update Metrics
Signed-off-by: Henrique Graca <999396+hjgraca@users.noreply.github.com>
---
examples/Metrics/src/HelloWorld/HelloWorld.csproj | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/examples/Metrics/src/HelloWorld/HelloWorld.csproj b/examples/Metrics/src/HelloWorld/HelloWorld.csproj
index b3262af2..a3bd7722 100644
--- a/examples/Metrics/src/HelloWorld/HelloWorld.csproj
+++ b/examples/Metrics/src/HelloWorld/HelloWorld.csproj
@@ -8,8 +8,8 @@
-
-
+
+
From 726033d8df348420ade9254f46f908d76c39a22a Mon Sep 17 00:00:00 2001
From: Henrique Graca <999396+hjgraca@users.noreply.github.com>
Date: Sat, 17 Feb 2024 12:21:09 +0000
Subject: [PATCH 05/82] Update HelloWorld.csproj
Signed-off-by: Henrique Graca <999396+hjgraca@users.noreply.github.com>
---
examples/Parameters/src/HelloWorld/HelloWorld.csproj | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/examples/Parameters/src/HelloWorld/HelloWorld.csproj b/examples/Parameters/src/HelloWorld/HelloWorld.csproj
index d9709c68..8d258c52 100644
--- a/examples/Parameters/src/HelloWorld/HelloWorld.csproj
+++ b/examples/Parameters/src/HelloWorld/HelloWorld.csproj
@@ -8,6 +8,6 @@
-
+
From ba11561a3888e6ebac8774451196b6ca8df80616 Mon Sep 17 00:00:00 2001
From: Henrique Graca <999396+hjgraca@users.noreply.github.com>
Date: Sat, 17 Feb 2024 12:21:49 +0000
Subject: [PATCH 06/82] Update Api example
Signed-off-by: Henrique Graca <999396+hjgraca@users.noreply.github.com>
---
.../src/LambdaPowertoolsAPI/LambdaPowertoolsAPI.csproj | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/examples/ServerlessApi/src/LambdaPowertoolsAPI/LambdaPowertoolsAPI.csproj b/examples/ServerlessApi/src/LambdaPowertoolsAPI/LambdaPowertoolsAPI.csproj
index 3609e442..e3ad28df 100644
--- a/examples/ServerlessApi/src/LambdaPowertoolsAPI/LambdaPowertoolsAPI.csproj
+++ b/examples/ServerlessApi/src/LambdaPowertoolsAPI/LambdaPowertoolsAPI.csproj
@@ -13,8 +13,8 @@
-
-
-
+
+
+
From 3ffc13992998b7251ff69ca7e6c43b3afb0201bb Mon Sep 17 00:00:00 2001
From: Henrique Graca <999396+hjgraca@users.noreply.github.com>
Date: Sat, 17 Feb 2024 12:22:17 +0000
Subject: [PATCH 07/82] Update HelloWorld.csproj
Signed-off-by: Henrique Graca <999396+hjgraca@users.noreply.github.com>
---
examples/Tracing/src/HelloWorld/HelloWorld.csproj | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/examples/Tracing/src/HelloWorld/HelloWorld.csproj b/examples/Tracing/src/HelloWorld/HelloWorld.csproj
index 32beb88b..e7338a4a 100644
--- a/examples/Tracing/src/HelloWorld/HelloWorld.csproj
+++ b/examples/Tracing/src/HelloWorld/HelloWorld.csproj
@@ -8,8 +8,8 @@
-
-
+
+
From db8bac8ff924479fbf61c679bbc748d1923698d6 Mon Sep 17 00:00:00 2001
From: Henrique Graca <999396+hjgraca@users.noreply.github.com>
Date: Sat, 17 Feb 2024 20:05:26 +0000
Subject: [PATCH 08/82] first try to AOT for Logging
---
libraries/AWS.Lambda.Powertools.sln | 15 ++
...S.Lambda.Powertools.BatchProcessing.csproj | 1 +
.../AWS.Lambda.Powertools.Common.csproj | 1 +
.../Aspects/UniversalWrapperAspect.cs | 40 ++---
.../Core/PowertoolsSourceGenerationContext.cs | 43 +++++
.../AWS.Lambda.Powertools.Logging.csproj | 4 +
.../Internal/Converters/ExceptionConverter.cs | 6 +-
.../Internal/LoggingAspectHandler.cs | 27 +++-
.../Internal/PowertoolsLambdaContext.cs | 151 ++++++++++++++++++
.../Internal/PowertoolsLogger.cs | 86 +++++++---
.../LogEntryLambdaContext.cs | 22 ++-
.../AWS.Lambda.Powertools.Metrics.csproj | 2 +
.../Internal}/PowertoolsLambdaContext.cs | 112 +++++++------
.../AWS.Lambda.Powertools.Parameters.csproj | 1 +
.../AWS.Lambda.Powertools.Tracing.csproj | 1 +
libraries/src/Directory.Build.props | 2 +
libraries/src/Directory.Packages.props | 4 +-
....Lambda.Powertools.AotCompatibility.csproj | 43 +++++
.../GlobalUsings.cs | 1 +
.../Handlers/Handler.cs | 37 +++++
.../UnitTest1.cs | 28 ++++
...AWS.Lambda.Powertools.Logging.Tests.csproj | 1 +
.../Handlers/ExceptionFunctionHandler.cs | 2 +-
.../LogFormatterTest.cs | 1 +
.../PowertoolsLambdaContextTest.cs | 31 ++--
.../PowertoolsLoggerTest.cs | 3 +-
26 files changed, 549 insertions(+), 116 deletions(-)
create mode 100644 libraries/src/AWS.Lambda.Powertools.Common/Core/PowertoolsSourceGenerationContext.cs
create mode 100644 libraries/src/AWS.Lambda.Powertools.Logging/Internal/PowertoolsLambdaContext.cs
rename libraries/src/{AWS.Lambda.Powertools.Common/Core => AWS.Lambda.Powertools.Metrics/Internal}/PowertoolsLambdaContext.cs (50%)
create mode 100644 libraries/tests/AWS.Lambda.Powertools.AotCompatibility/AWS.Lambda.Powertools.AotCompatibility.csproj
create mode 100644 libraries/tests/AWS.Lambda.Powertools.AotCompatibility/GlobalUsings.cs
create mode 100644 libraries/tests/AWS.Lambda.Powertools.AotCompatibility/Handlers/Handler.cs
create mode 100644 libraries/tests/AWS.Lambda.Powertools.AotCompatibility/UnitTest1.cs
rename libraries/tests/{AWS.Lambda.Powertools.Common.Tests/Core => AWS.Lambda.Powertools.Logging.Tests}/PowertoolsLambdaContextTest.cs (78%)
diff --git a/libraries/AWS.Lambda.Powertools.sln b/libraries/AWS.Lambda.Powertools.sln
index 62c1cec1..d3ed829b 100644
--- a/libraries/AWS.Lambda.Powertools.sln
+++ b/libraries/AWS.Lambda.Powertools.sln
@@ -35,6 +35,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AWS.Lambda.Powertools.Param
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AWS.Lambda.Powertools.Parameters.Tests", "tests\AWS.Lambda.Powertools.Parameters.Tests\AWS.Lambda.Powertools.Parameters.Tests.csproj", "{386A9769-59BF-4BE3-99D4-A9603E300729}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AWS.Lambda.Powertools.AotCompatibility", "tests\AWS.Lambda.Powertools.AotCompatibility\AWS.Lambda.Powertools.AotCompatibility.csproj", "{2B782D22-675D-42D4-A041-90A27275A403}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -216,6 +218,18 @@ Global
{386A9769-59BF-4BE3-99D4-A9603E300729}.Release|x64.Build.0 = Release|Any CPU
{386A9769-59BF-4BE3-99D4-A9603E300729}.Release|x86.ActiveCfg = Release|Any CPU
{386A9769-59BF-4BE3-99D4-A9603E300729}.Release|x86.Build.0 = Release|Any CPU
+ {2B782D22-675D-42D4-A041-90A27275A403}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2B782D22-675D-42D4-A041-90A27275A403}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2B782D22-675D-42D4-A041-90A27275A403}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {2B782D22-675D-42D4-A041-90A27275A403}.Debug|x64.Build.0 = Debug|Any CPU
+ {2B782D22-675D-42D4-A041-90A27275A403}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {2B782D22-675D-42D4-A041-90A27275A403}.Debug|x86.Build.0 = Debug|Any CPU
+ {2B782D22-675D-42D4-A041-90A27275A403}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2B782D22-675D-42D4-A041-90A27275A403}.Release|Any CPU.Build.0 = Release|Any CPU
+ {2B782D22-675D-42D4-A041-90A27275A403}.Release|x64.ActiveCfg = Release|Any CPU
+ {2B782D22-675D-42D4-A041-90A27275A403}.Release|x64.Build.0 = Release|Any CPU
+ {2B782D22-675D-42D4-A041-90A27275A403}.Release|x86.ActiveCfg = Release|Any CPU
+ {2B782D22-675D-42D4-A041-90A27275A403}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
@@ -233,5 +247,6 @@ Global
{F8B4100F-4014-4A1E-8130-D281453B79ED} = {73C9B1E5-3893-47E8-B373-17E5F5D7E6F5}
{12B940EF-A5D3-459D-BD36-A603834D1F7D} = {1CFF5568-8486-475F-81F6-06105C437528}
{3E1D77BD-70AF-4767-B00A-4A321D5AB2C3} = {1CFF5568-8486-475F-81F6-06105C437528}
+ {2B782D22-675D-42D4-A041-90A27275A403} = {1CFF5568-8486-475F-81F6-06105C437528}
EndGlobalSection
EndGlobal
diff --git a/libraries/src/AWS.Lambda.Powertools.BatchProcessing/AWS.Lambda.Powertools.BatchProcessing.csproj b/libraries/src/AWS.Lambda.Powertools.BatchProcessing/AWS.Lambda.Powertools.BatchProcessing.csproj
index ed58f6f6..c766cac7 100644
--- a/libraries/src/AWS.Lambda.Powertools.BatchProcessing/AWS.Lambda.Powertools.BatchProcessing.csproj
+++ b/libraries/src/AWS.Lambda.Powertools.BatchProcessing/AWS.Lambda.Powertools.BatchProcessing.csproj
@@ -13,5 +13,6 @@
+
diff --git a/libraries/src/AWS.Lambda.Powertools.Common/AWS.Lambda.Powertools.Common.csproj b/libraries/src/AWS.Lambda.Powertools.Common/AWS.Lambda.Powertools.Common.csproj
index 9d3e6682..3084c61f 100644
--- a/libraries/src/AWS.Lambda.Powertools.Common/AWS.Lambda.Powertools.Common.csproj
+++ b/libraries/src/AWS.Lambda.Powertools.Common/AWS.Lambda.Powertools.Common.csproj
@@ -12,6 +12,7 @@
+
diff --git a/libraries/src/AWS.Lambda.Powertools.Common/Aspects/UniversalWrapperAspect.cs b/libraries/src/AWS.Lambda.Powertools.Common/Aspects/UniversalWrapperAspect.cs
index fedf4503..d076909f 100644
--- a/libraries/src/AWS.Lambda.Powertools.Common/Aspects/UniversalWrapperAspect.cs
+++ b/libraries/src/AWS.Lambda.Powertools.Common/Aspects/UniversalWrapperAspect.cs
@@ -1,12 +1,12 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
- *
+ *
* http://aws.amazon.com/apache2.0
- *
+ *
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
@@ -15,6 +15,7 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
@@ -32,19 +33,19 @@ public class UniversalWrapperAspect
///
/// The delegate cache
///
- private static readonly Dictionary _delegateCache = new();
+ private static readonly Dictionary DelegateCache = new();
///
/// The asynchronous generic handler
///
- private static readonly MethodInfo _asyncGenericHandler =
+ private static readonly MethodInfo AsyncGenericHandler =
typeof(UniversalWrapperAttribute).GetMethod(nameof(UniversalWrapperAttribute.WrapAsync),
BindingFlags.NonPublic | BindingFlags.Instance);
///
/// The synchronize generic handler
///
- private static readonly MethodInfo _syncGenericHandler =
+ private static readonly MethodInfo SyncGenericHandler =
typeof(UniversalWrapperAttribute).GetMethod(nameof(UniversalWrapperAttribute.WrapSync),
BindingFlags.NonPublic | BindingFlags.Instance);
@@ -93,6 +94,7 @@ public object Handle(
/// Type of the return.
/// The wrappers.
/// Handler.
+ [UnconditionalSuppressMessage("AOT", "IL3050:Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.", Justification = "")]
private static Handler CreateMethodHandler(Type returnType, IEnumerable wrappers)
{
var targetParam = Expression.Parameter(typeof(Func