SharpCrafters Forum – Adding a low level aspect into a CompoundAspect

SharpCrafters Support Forum

        


Adding a low level aspect into a... Expand / Collapse
Author
Message
Posted 11/26/2009 1:12:36 PM


Pierre-Emmanuel Dautreppe

Community Member
Hello all,

as described here http://www.pedautreppe.com/post/Generating-fields-in-an-existing-class---Using-PostSharp-15.aspx, I have created a low level aspect that is generating a public field into a class.
To do that, I declare a MulticastAttribute with a plugin, task, and an advice to do that.

And this is working fine.

To go a bit further, I would like to add this low-level aspect to an existing CompoundAspect. But to do that I need a ILaosAspect.

So I change the inheritance of my attribute : from MulticastAttribute to LaosTypeLevelAspect.
But after I have a compilation error :
"PostSharp: Cannot find a weaver for the aspect type LowLevelAspect.InjectCodeAttribute. Are you sure it implements one of the supported interfaces?"

Do you have any clue about this ?

Many thanks !
Post #644
Posted 11/26/2009 8:35:50 PM


Gael Fraiteur

SharpCrafters
You have to create a class, even empty, that implements ILaosAspect. The assembly declaring this class should not have references to PostSharp.Core.dll and PostSharp.Laos.Weaver.dll.

Then you should create the implementation of this aspect in an assembly referencing PostSharp.Laos.Weaver.dll. This assembly should contain a class derived from Task and implementing ILaosAspectWeaverFactory, and this interface is responsible for providing the weaver (LaosAspectWeaver) for the aspect (ILaosAspect).

This is illustrated in the sample PostSharp.Samples.Librarian (see Weaver).

-gael
Post #645
Posted 11/27/2009 8:22:37 AM


Pierre-Emmanuel Dautreppe

Community Member
Thanks Gaël !

That's a way I had not seen before for low level aspects ! Interesting.
I should dig further into weaver definition.

I have now something working fine !
Post #646
« Prev Topic | Next Topic »


All times are GMT +1:00, Time now is 11:34am

Powered By InstantForum.NET v4.1.4 © 2010
Execution: 0.103. 7 queries. Compression Disabled.