Skip to content

Commit d3396b0

Browse files
authored
Merge pull request #574 from aws-powertools/develop
chore: Sync main and develop release 1.9.1
2 parents e48cecd + 15efb4c commit d3396b0

File tree

5 files changed

+70
-7
lines changed

5 files changed

+70
-7
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
![aws provider](https://img.shields.io/badge/provider-AWS-orange?logo=amazon-aws&color=ff9900)
44
[![Build](https://github.com/aws-powertools/powertools-lambda-dotnet/actions/workflows/build.yml/badge.svg?branch=develop)](https://github.com/aws-powertools/powertools-lambda-dotnet/actions/workflows/build.yml)
55
[![codecov.io](https://codecov.io/github/aws-powertools/powertools-lambda-dotnet/branch/develop/graphs/badge.svg)](https://app.codecov.io/gh/aws-powertools/powertools-lambda-dotnet)
6-
[![dotnet support](https://img.shields.io/static/v1?label=dotnet&message=%20NET6.0&color=blue?style=flat-square&logo=dotnet)](https://dotnet.microsoft.com/en-us/download/dotnet/6.0)
6+
[![dotnet support](https://img.shields.io/static/v1?label=dotnet&message=%20NET6.0|NET8.0&color=blue?style=flat-square&logo=dotnet)](https://dotnet.microsoft.com/en-us/download/dotnet/6.0)
77
[![NuGet Downloads](https://img.shields.io/nuget/dt/AWS.Lambda.Powertools.Logging.svg)](https://www.nuget.org/packages?q=AWS.Lambda.Powertools)
8-
[![Join our Discord](https://dcbadge.vercel.app/api/server/B8zZKbbyET)](https://discord.gg/B8zZKbbyET)
8+
[![Join our Discord](https://dcbadge.vercel.app/api/server/B8zZKbbyET?style=flat-square)](https://discord.gg/B8zZKbbyET)
99

1010
Powertools for AWS Lambda (.NET) is a developer toolkit to implement Serverless [best practices and increase developer velocity](https://docs.powertools.aws.dev/lambda-dotnet/#features).
1111

@@ -33,7 +33,7 @@ Powertools for AWS Lambda (.NET) provides three core utilities:
3333

3434
### Installation
3535

36-
The Powertools for AWS Lambda (.NET) utilities (.NET 6) are available as NuGet packages. You can install the packages from [NuGet Gallery](https://www.nuget.org/packages?q=AWS+Lambda+Powertools*) or from Visual Studio editor by searching `AWS.Lambda.Powertools*` to see various utilities available.
36+
The Powertools for AWS Lambda (.NET) utilities (.NET 6 and .NET 8) are available as NuGet packages. You can install the packages from [NuGet Gallery](https://www.nuget.org/packages?q=AWS+Lambda+Powertools*) or from Visual Studio editor by searching `AWS.Lambda.Powertools*` to see various utilities available.
3737

3838
* [AWS.Lambda.Powertools.Logging](https://www.nuget.org/packages?q=AWS.Lambda.Powertools.Logging):
3939

@@ -61,7 +61,7 @@ The Powertools for AWS Lambda (.NET) utilities (.NET 6) are available as NuGet p
6161

6262
## Examples
6363

64-
We have provided examples focused specifically on each of the utilities. Each solution comes with an AWS Serverless Application Model (AWS SAM) templates to run your functions as a Zip package using the AWS Lambda .NET 6 managed runtime; or as a container package using the AWS base images for .NET.
64+
We have provided examples focused specifically on each of the utilities. Each solution comes with an AWS Serverless Application Model (AWS SAM) templates to run your functions as a Zip package using the AWS Lambda .NET 6 or .NET 8 managed runtime; or as a container package using the AWS base images for .NET.
6565

6666
* **[Logging example](examples/Logging/)**
6767
* **[Metrics example](examples/Metrics/)**

docs/index.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ description: Powertools for AWS Lambda (.NET)
77

88
# Powertools for AWS Lambda (.NET)
99

10-
Powertools for AWS Lambda (.NET) (which from here will be referred as Powertools) is a suite of utilities for [AWS Lambda](https://aws.amazon.com/lambda/) functions to ease adopting best practices such as tracing, structured logging, custom metrics, and more. Please note, **Powertools for AWS Lambda (.NET) is optimized for .NET 6+**.
10+
Powertools for AWS Lambda (.NET) (which from here will be referred as Powertools) is a suite of utilities for [AWS Lambda](https://aws.amazon.com/lambda/) functions to ease adopting best practices such as tracing, structured logging, custom metrics, and more.
11+
12+
!!! info
13+
**Supports .NET 6 and .NET 8 runtimes**
1114

1215
???+ tip
1316
Powertools is also available for [Python](https://docs.powertools.aws.dev/lambda/python/){target="_blank"}, [Java](https://docs.powertools.aws.dev/lambda/java/){target="_blank"}, and [TypeScript](https://docs.powertools.aws.dev/lambda/typescript/latest/){target="_blank"}.

libraries/src/AWS.Lambda.Powertools.Common/Aspects/UniversalWrapperAspect.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ public object Handle(
8383
};
8484

8585
var wrappers = triggers.OfType<UniversalWrapperAttribute>().ToArray();
86-
var handler = GetMethodHandler(method, returnType, wrappers);
86+
// Target.Method is more precise for cases when decorating generic methods
87+
var handler = GetMethodHandler(target.Method, returnType, wrappers);
8788
return handler(target, args, eventArgs);
8889
}
8990

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using System.Globalization;
2+
using System.Threading.Tasks;
3+
4+
namespace AWS.Lambda.Powertools.Tracing.Tests.Handlers;
5+
6+
public class FunctionHandlerForGeneric
7+
{
8+
[Tracing(CaptureMode = TracingCaptureMode.ResponseAndError)]
9+
public async Task<string> Handle(string input)
10+
{
11+
GenericMethod<int>(1);
12+
GenericMethod<double>(2);
13+
14+
GenericMethod<int>(1);
15+
16+
GenericMethod<int>();
17+
GenericMethod<double>();
18+
19+
GenericMethod2<int>(1);
20+
GenericMethod2<double>(2);
21+
22+
GenericMethod<int>();
23+
GenericMethod<double>();
24+
25+
await Task.Delay(1);
26+
27+
return input.ToUpper(CultureInfo.InvariantCulture);
28+
}
29+
30+
[Tracing]
31+
private T GenericMethod<T>(T x)
32+
{
33+
return default;
34+
}
35+
36+
[Tracing]
37+
private T GenericMethod<T>()
38+
{
39+
return default;
40+
}
41+
42+
[Tracing]
43+
private void GenericMethod2<T>(T x)
44+
{
45+
}
46+
}
Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace AWS.Lambda.Powertools.Tracing.Tests.Handlers;
66

7-
public sealed class ExceptionFunctionHandlerTests
7+
public sealed class HandlerTests
88
{
99
[Fact]
1010
public async Task Stack_Trace_Included_When_Decorator_Present()
@@ -20,4 +20,17 @@ public async Task Stack_Trace_Included_When_Decorator_Present()
2020
Assert.StartsWith("at AWS.Lambda.Powertools.Tracing.Tests.Handlers.ExceptionFunctionHandler.ThisThrows()", tracedException.StackTrace?.TrimStart());
2121

2222
}
23+
24+
[Fact]
25+
public async Task When_Decorator_Present_In_Generic_Method_Should_Not_Throw_When_Type_Changes()
26+
{
27+
// Arrange
28+
var handler = new FunctionHandlerForGeneric();
29+
30+
// Act
31+
await handler.Handle("whatever");
32+
33+
// Assert
34+
35+
}
2336
}

0 commit comments

Comments
 (0)