using System.Runtime.CompilerServices;
public static void Main()
var mi = typeof(MyEnum).GetMember("Value1");
var attr = mi[0].GetCustomAttribute<FooAttribute>();
mi = typeof(Bar).GetMember("SomeProp");
attr = mi[0].GetCustomAttribute<FooAttribute>();
public string SomeProp { get; set; }
public class FooAttribute : Attribute
public FooAttribute([CallerMemberName]string propName = null)
Console.WriteLine("Propname = " + propName);