File tree Expand file tree Collapse file tree 3 files changed +62
-2
lines changed
src/AWS.Lambda.Powertools.Common/Aspects
tests/AWS.Lambda.Powertools.Tracing.Tests/Handlers Expand file tree Collapse file tree 3 files changed +62
-2
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 44
55namespace 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}
You can’t perform that action at this time.
0 commit comments