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)

Simon
  • 33,714
  • 21
  • 133
  • 202
  • 1
    What version of PostSharp do you use? – Alex Yakunin Apr 22 '10 at 08:32
  • @Alex updated question to include the info – Simon Apr 22 '10 at 08:56
  • Are you still in need of a solution the does not have a runtime dependency? – Jamie Thomas May 30 '11 at 21:18
  • @Jamie. no. instead I implement all the features I wanted with cecil and use the following approach to avoid a reference http://code.google.com/p/notifypropertyweaver/wiki/WeavingWithoutAddingAReference – Simon May 30 '11 at 23:13
  • Cool. I recently released [Afterthought](https://github.com/vc3/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! – Jamie Thomas May 31 '11 at 02:00

1 Answers1

2

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

Alex Yakunin
  • 6,330
  • 3
  • 33
  • 52
  • but if postsharp does compile time waving to modify the assembly cant it modify the assembly to remove the references? – Simon Apr 22 '10 at 08:51
  • 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. – Gael Fraiteur Apr 22 '10 at 11:23
  • 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. – Alex Yakunin Apr 23 '10 at 06:41