[C#] Possibility to add custom Attributes on argument event

Hi,

Currently in C# when we want to retreive something we have to get the argument & call a function. This lead to code duplication.

For instance, if I want to retreive a User (from my database) into a server side delegate I’d have to do this :

    [EventHandler("OnGetUser")]
    private void OnGetUser([FromSource] Player player, NetworkCallbackDelegate networkCB)
    {
        User user = Database.GetMyUser(player.Identifiers);
       
        networkCB.Invoke(user); 
    }

This is fine, but there is a cleaner way to do it. An implementation could be :

    [EventHandler("OnGetUser")]
    private void OnGetUser([GetMyUserCustomAttribute] User user, NetworkCallbackDelegate networkCB)
    {
        networkCB.Invoke(user); 
    }

Then, in my GetMyUserCustomAttribute I’d retreive the sourceString & current arg to retreive my User from my database & set it.

The implement would go here :

This could help C# devs to avoid code duplication in events as well as implementing args convertion or logic onto args or methods since this logic could be extended to attribute method such as EventHandler.

Maybe leaving a way to implement a logic inside the Invoke here :

Thank you for reading & I hope it makes sense to you.