0

I have a custom attribute that can be applied to methods. How would I go about getting a callback when a tagged function is called?

class RPC : Attribute
{
    private string RPCName;

    public RPC (string RPCName)
    {

        this.RPCName = RPCName;
    }
}

How would I go about knowing when such a function is called:

[RPC("shoot")]
    public static void shoot(int testParameter)
    {
        Console.WriteLine("Shoot was called.");

    }
volairs22
  • 83
  • 6
  • at runtime? you obviously can't ... the only way is to use some weaver (which will recompile your assembly) which would add such event based on this attribute – Selvin Mar 02 '20 at 10:21
  • Does this answer your question? [C#: How to create an attribute on a method triggering an event when it is invoked?](https://stackoverflow.com/questions/226420/c-how-to-create-an-attribute-on-a-method-triggering-an-event-when-it-is-invoke) – Kilazur Mar 02 '20 at 10:22

0 Answers0