The method is probably being called from a lambda expression. The C# compiler actually converts lambdas to hidden methods inside your class. These methods have special compiler-generated names, like the <Frequency>b__46
you're seeing. I think you'll find if you look at GetFrame(2)
you'll see the name you expect. Your function could ignore lambdas by looping up the stack until it finds a valid method name (you can check the method descriptor's IsSpecialName property for that).
The compiler also generates hidden methods with special names for auto property getters and setters, event add/remove handlers, and some other cases (you won't encounter these since these auto-generated methods can't call your GetCurrentMethod()
). But note also that manual property getters and setters have "special" names like get_PropertyName()
, and you may see those if you have a property whose code calls GetCurrentMethod()
.