Remove PostSharp reference after build?
Asked Answered
H

1

7

Is is possible to get postsharp to remove references to the postsharp assemblies during a build?

I have an exe i needs to have a very small footprint. I want to use some of the compile time weaving of postsharp but dont want to have to deploy PostSharp.dll with the exe.

I am using PostSharp 2 (2.0.4.1074 specifically)

Hypozeuxis answered 22/4, 2010 at 7:34 Comment(5)
What version of PostSharp do you use?Pazice
@Alex updated question to include the infoHypozeuxis
Are you still in need of a solution the does not have a runtime dependency?Sandler
@Jamie. no. instead I implement all the features I wanted with cecil and use the following approach to avoid a reference code.google.com/p/notifypropertyweaver/wiki/…Hypozeuxis
Cool. I recently released Afterthought as an open source alternative to PostSharp (leveraging the Microsoft CCI libraries instead of Cecil). One of the design goals was providing a simple API (aka, not Cecil or CCI or even PostSharp) while also ensuring that the modified assemblies would not have references to any of the libraries used to enable the weaving. Sounds like you went down the somewhat hard yet beneficial path that I did. Thanks for the update!Sandler
P
2

As far as I know, this is impossible. References are necessary, since base classes of your aspects are located in public PostSharp assembly.

Pazice answered 22/4, 2010 at 8:32 Comment(3)
but if postsharp does compile time waving to modify the assembly cant it modify the assembly to remove the references?Hypozeuxis
Alex is right. Note that aspects are executed at runtime, they are not inlined in your code. But you can use ILMerge to merge PostSharp.dll into one of your libraries.Surbased
Clear. References can't be removed, because to execute the aspects code, framework will need (in particular) all its base classes. These classes are in PostSharp.dll, so an attempt to remove the reference would lead to TypeLoadException (or similar) in runtime.Pazice

© 2022 - 2024 — McMap. All rights reserved.