I'm trying to figure out of there is a somewhat straight forward way to get the reflected properties of the currently executing async method. I'm looking for the same properties that wuld be available if I were to just do something like this in a regular non-async method:
var method = (MethodInfo)MethodBase.GetCurrentMethod();
But if I'm in an async method, I am getting a MoveNext() method back from reflection, when using the above reflective code.
Would I just have to step up the call stack using StackTrace or StackFrame?
The only problem that I have with that is that it's somewhat manual. This code needs to by dynamic, as my implementation is going to be used in logging, and needs to be reliable and accurate across many applications. It needs to work with both async and synchronous methods / functions.
All that I can find out there currently is people using the baked in .net CallermemberName
attribute, which gets the correct name of the currently executing method, but obviously I need more than that.
Any help would be greatly appreciated. Thanks!
Aucun commentaire:
Enregistrer un commentaire