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(
83
83
} ;
84
84
85
85
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 ) ;
87
88
return handler ( target , args , eventArgs ) ;
88
89
}
89
90
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 4
4
5
5
namespace AWS . Lambda . Powertools . Tracing . Tests . Handlers ;
6
6
7
- public sealed class ExceptionFunctionHandlerTests
7
+ public sealed class HandlerTests
8
8
{
9
9
[ Fact ]
10
10
public async Task Stack_Trace_Included_When_Decorator_Present ( )
@@ -20,4 +20,17 @@ public async Task Stack_Trace_Included_When_Decorator_Present()
20
20
Assert . StartsWith ( "at AWS.Lambda.Powertools.Tracing.Tests.Handlers.ExceptionFunctionHandler.ThisThrows()" , tracedException . StackTrace ? . TrimStart ( ) ) ;
21
21
22
22
}
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
+ }
23
36
}
You can’t perform that action at this time.
0 commit comments