Giving Aspects Metadata ?

I've only just started messing with MetaLama and going thru the documentation and videos but I was wondering if its possible to give an attribute extra metadata to send based on the place its invoked for example
public class HookFunctionAndPrint : OverrideMethodAspect
{
    public override dynamic? OverrideMethod()
    {
        //hooks on method start
        var functionName = meta.Target.Method.Name;
        Console.WriteLine($"Hooked on {functionName} method start");
        try
        {
            // Let the method do its own thing.
            return meta.Proceed();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            Console.WriteLine(ex.StackTrace);
            return null;
        }
        finally
        {
            Console.WriteLine($"Hooked on {functionName} method end");
        }
    }
}

but what if I wanted extra metadata such as stuff you get along with MEF plugins if you are familiar with that but something lets say a string to set a logging verbosity.
public class HookFunctionAndPrint : OverrideMethodAspect
{
    public override dynamic? OverrideMethod()
    {
        //hooks on method start
        var functionName = meta.Target.Method.Name;
        Console.WriteLine($"Hooked on {functionName} method start");
        try
        {
            // logging level here would be a defined name when the attribute is set
            if(meta.Metadata.loggingLevel == "Verbose")
            {
              Console.WriteLine($"verbose logging enabled for {functionName}");
            }
            else if(meta.Metadata.loggingLevel == "info")
            {
              Console.WriteLine($"info only logging enabled for {functionName}");
            }
            // Let the method do its own thing.
            return meta.Proceed();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            Console.WriteLine(ex.StackTrace);
            return null;
        }
        finally
        {
            Console.WriteLine($"Hooked on {functionName} method end");
        }
    }
}

then when you give the attribute to the function you do something like
[HookFunctionAndPrint]
[MetaLamaMetadata("Logging", "Verbose")]
static void Main(string[] args)
{
}

I dont know if something like this alrady exists and I just missed it in the docs or if this would be a feature request. Also currently on the free license if this is a premium feature 🙂
Was this page helpful?