Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to apply a Postsharp aspect solution wide (all classes in namespace)

Tags:

aop

postsharp

I am trying to modify the sample trace app that ships with Postsharp so that the trace is applied to all classes in my namespace without explicitly putting the [QuickTrace] on top of each class. I have attached a screenshot. What am I doing wrong ? Right click open/view image for bigger picture. thank you

enter image description here

like image 916
Gullu Avatar asked Oct 10 '22 03:10

Gullu


1 Answers

You're doing it incorrectly. You're trying to assign the aspects to the mscorelib which will wrap calls to any methods that reside in the mscorelib (not your current app) but you're negating that with the fact tyhat you're telling it to apply to methods only in the Trace namespace.

Just use

[assembly: QuickTrace()]

Done. On your aspect, add the following

[QuickTrace(AttributeExclude=True)]
[Serializable]
public QuickTrace : OnMethodBoundaryAspect
{
  //..Aspect code here
}
like image 96
Dustin Davis Avatar answered Oct 14 '22 05:10

Dustin Davis