tags:

views:

343

answers:

2

I am considering PostSharp (www.postsharp.org) at this time to write my own custom logging system (sitting on top of log4net) as part of my application. Do you think PostSharp qualifies in all these requirements?

This are my requirements:

  1. I want to be able to write custom "Aspects" that work on methods, properties, fields, class and at assembly levels.

  2. I want to be able to use the tool for .NET 2.0 projects as well as 3.5, specifically in WinForms and ASP.NET (MVC included) and WCF projects

  3. I don't want to be running a separate tool (exe) apart from my own software at client machines / deployment points.

Preferable: It is preferable that i would want to avoid even having to redistribute any of the tool's dlls. But the requirement to not re-distribute run-time dlls with apps may be a pushing requirements - so skip it.

  1. I want to extend this to mainly write my custom logging aspects for my applications.

  2. I will be redistributing my web applications and the windows forms apps. So i want to ensure the tool i am going to use is free of any kind of royalty payments or license fees, and also that it does not restrict me into one particular type of license. I am selling commercial licenses of my applications.

A: 
  1. Yes.

  2. Yes. If you want to compile aspected code from ASP.NET, you will need to deploy PostSharp build-time components on the ASP.NET server. Not sure it's what you want given (3).

  3. If you develop your own custom aspect using PostSharp.Core, you do not need any dependency. If you use PostSharp Laos, you will need to redistribute PostSharp.Public.dll and PostSharp.Laod.dll.

  4. No problem.

  5. If you distribute compiled webs, there is no problem. If you distribute source code that needs to be enhanced by the weaver, you need to redistribute the whole PostSharp stuff. Possible, but not very sexy.

Gael Fraiteur
Thanks Gael.As for 2: Do you mean that i should have those postsharp build components in build server that builds my app dlls, or you mean the final deployment web server / application server?As for 3: what i mean is that i will be writing my own custom aspects that will do some custom logic for writing the log (maybe finally using log4net for that purpose). Do you think i will be using the PostSharp.Core for that. I read in teh website that if i use that dll, i will have to pay for license fees.For 5: The websites will be deployed as dll files that run as apps.Then?
@2: On the server that builds the app. But with ASP.NET, you can put on the server source code that will be compiled by ASP.NET. I stronly recommend that you use no aspect in this source code. All aspected code should be compiled. So you don't have to deploy PostSharp on the final deployment server of the web site.So if you deploy only dlls + code that does not use PostSharp (like *.aspx typically), no problem.
Gael Fraiteur
Thnx. Sure, i don't intend to "deploy" any source code files, it will only be compiled dlls + aspx + scripts etc.OK that means i don't ahve to re-distribute postshartp core dll. Thanks Gael.
@Gael: But would GPL not say that you need to publish your work under GPL if you link a GPL protected DLL (e.g. PostSharp.Laos.dll)?
Stefan Egli
Oh goodness, Really, Stefan? Gael can you confirm this please. I will have to recommend my customers to come-off postsharp then!!! I was the one who got them into this stuff since it was cool. I better tell them soon before they build their applications using it heavily. The people i know are selling their software (procesed using PostSharp) commercially, and they cannot publish their applications under GPL.I am now panicking!!!!!!
If what Stefan has said is true, i would stay away from all these open source kind of projects since it will be very difficult to change things later if we end up in license mis-understanding. This reminds me of what my friend always used to say - go by the route of commercial licenses, not htese GPL, etc, so that one can stay peaceful with their license terms in regard to deployment etc.
I am linking the Postsharp dll in my project too. But that is what postsharp website asks you to do for the tool to be able to produce the modified dll. If that linkage to the dll in project will need me to publish my application under BSD, then i ts not for me. I am building a commercial application, and i cannot put it under BSD license terms. Thanks for pointing this important info Stefan. I guess next time i will have a lawyer assist me when i am picking tools (especially the free ones) for my projects :-)
Sorry for delay (wth dont they have mail notfication on comments). PostSharp.Laos.dll is not GPLed. Only PostSharp.Core.dll and PostSharp.Laos.Weaver.dll are. So no worry.
Gael Fraiteur
I see :-) So if i wanted to either:1. Use the Laos.dll and write my own aspects, and get my dll processed by your dll, and deploy my app without any dlls, i am safe? or2. If i was using Log4Netpostsharp (that uses postsharp in some form) to use thrie existing logging aspects, and get my dlls processed, and deploy my app without any postshar or log4netpostsharp dll, then also i am safe.By Safe - i mean i don;t have to offer my application under BSD, and i can sell my apps commercially.Please confirm.
Exactly. You are safe unless the code references, directly or indirectly, PostSharp.Core.dll. To be sure, check with Reflector. But I'm sure it does not.
Gael Fraiteur
OK, i checked it, the log4postsharp weaver.dll refers to postsharp.core.dll. If i use log4postsharp.weaver.dll (which i think anybody will have to) this can be a problem then? since we will be inddirectly referencing postsharp.core.dll.
It does not matter since your code does not refer to log4postsharp.weaver.dll. It's used at built-time only.
Gael Fraiteur
+2  A: 

Have a look at Log4PostSharp before you start coding a custom aspect yourself using PostSharp.Core.

Gael Fraiteur
Yep i did that a while back, but the impression i got from the web site (first page) was that it only has only one custom aspect, and that too only for methods.May be i will need to read more there. Do you think that project will be quite comprehensive for logging purposes.Of course it is tightly coupled to log4net too.
Only for methods? But what else than methods need to be logged? Property and event accessors are methods also. And logging field access if the way to performance hell...
Gael Fraiteur
Yes agreed, but on the property bit, i thought since it is not a method at the time of writing the code (not by the complier) i thought maybe that tool won't support logging on properties.
I tried to checkout (readonly) from the svn location, but it is returning some error saysing "could not connect to server.Maybe this is not the place to ask this, but since its a post about getting log4postsharp, i thought i will post it anyway.
http://postsharp-user-plugins.googlecode.com/svn/trunk/ works for me.
Gael Fraiteur
OK i took a look at the log4postsharp, but the main important attribute the LogAttribute class is sealed, and i cannot extend the capabilities of that unless i get the source code and write some CIL / IL code myself. It is not extendable at all. But i f we had the time to write code ourselves, not C#, but CIL (i don't claim to be an expert there!), then we can extend it in that sense.But for my work, i need something that is extendable easily and not having to write CIL etc. No extra time available in teh project for those things.
Added on top of that, i am now concerned using postshart itself in the first place, having read Stefen's coments about the license terms that i have to publish my application under BSD license if i use postsharp for processing my application code.I have a commerical application, and i cannot put it under BSD license.So postsharp is out of equation now :-(... it was a good tool i thought, but the license terms scares me.Is there a commercial alternative to postsharp where i don;t hav to be converned about publishig as a commercial licensed product. Please let me know.