"Caller Info Attributes"

static void Log(string message, [CallerMemberName] string callerMemberName = null, [CallerFilePath] string callerFilePath = null, [CallerLineNumber] int callerLineNumber) {
	Console.WriteLine($"{message} (called from {callerMemberName} on line {callerLineNumber} in file {callerFilePath})");

static void Test() {
	Log("My message"); // Will print something like "My message (called from Test() on line 15 in file C:\...\Example.cs)"

Code snippet taken from "Two Decades of C#: A Reference - C# 5 and C# 6".