C
C#fenixblades

✅ Any modern approach to getting the calling class typename aside from using the stack frame?

10 years ago I used to use the stack frame to go backwards and get what class is calling my current method. I know there's attributes as well, but they are more physical file based. Is there a modern approach in current .NET to getting this information at runtime? Such as for a logger method that's trying to find out what called it?
S
Sossenbinder511d ago
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/attributes/caller-information These are what you are looking for I think CallerMemberName mostly
A
Accord509d ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.