PostSharp OnMethodBoundaryAspect - access parameters types from constructor

240 views Asked by At

I have an OnMethodBoundaryAspect attribute (PostSharp), I want to be able to use expression from attribute constructor that gets uses the methods parameters

Lets say something like this :

[MyAttribute(p => p.SomeProperty)]
public void DoSomething(Parameter parameter)
{
    ....
}

p is type Parameter

Is it possible?

Thanks

1

There are 1 answers

0
Daniel Balas On

Using expression trees in attribute constructors is not possible.

Depending on the problem you are trying to solve there may be ways that would achieve what you are trying to solve - e.g. you can use PostSharp to analyze the method body and apply aspects dynamically based on that information.