I’m thinking you can’t but is there a way to reference a method as a parameter on an attribute? I.e. something like below? I can fall back to use strings, but prefer to use compiler time to verify the types are correct.
[LinkToAction(Something)]
public void SomethingElse()
{
}
public static void Something()
{
}
public class LinkToActionAttribute : Attribute
{
public LinkToActionAttribute(MethodInfo info)
{
}
}
Sorry, but you can’t. Just these can be passed as arguments for attributes:
This question is similar to yours: Is it possible to have a delegate as attribute parameter?. There, a workaround is available which can be useful to you.