I need to do some stuff with parameteres passed into my method. How can I play with them (modify) using PostSharp ?
Using methodinterception, you can use the Args.Arguments object to change the values via the SetArgument method.
[Serializable]
public class MyAspect : MethodInterceptionAspect
{
    public override void OnInvoke(MethodInterceptionArgs args)
    {
        string input = (string)args.Arguments[0];
        if (input.Equals("123"))
        {
            args.Arguments.SetArgument(0, " 456");
        }
        args.Proceed();
    }       
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With