The caller information attributes cause the C# compiler to supply the caller’s name at the callsite. This happens at compile-time, there is no reflection involved.
public void DoProcessing()
{
LogCall();
}
public void LogCall([CallerMemberName] string memberName = "")
{
Console.WriteLine(memberName + " was called.");
}
Will be compiled to:
public void DoProcessing()
{
LogCall("DoProcessing");
}
public void LogCall(string memberName)
{
Console.WriteLine(memberName + " was called.");
}