aws-powertools / powertools-lambda-dotnet

Powertools is a developer toolkit to implement Serverless best practices and increase developer velocity.
https://docs.powertools.aws.dev/lambda/dotnet/
MIT No Attribution
152 stars 24 forks source link

fix: Error when decorating duplicate generic method - Tracing #572

Closed hjgraca closed 5 months ago

hjgraca commented 5 months ago

Please provide the issue number

Issue number: #571

Summary

Decorating a generic method with Tracing utility and calling that method more than once with different T would cause an exception, because the T that we cache would mismatch the new T resulting in System.InvalidCastException.

Changes

The fix is to change the cache key to use the full method name coming from the target method that was decorated, this will take into account the T, return T and T parameters making the key unique. Added tests to validate generic method decoration.

User experience

Please share what the user experience looks like before and after this change

Checklist

Please leave checklist items unchecked if they do not apply to your change.

Is this a breaking change? **RFC issue number**: Checklist: * [ ] Migration process documented * [ ] Implement warnings (if it can live side by side)

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

sonarcloud[bot] commented 5 months ago

Quality Gate Passed Quality Gate passed

Issues
1 New issue
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud